Add fun extension with autoload

This commit is contained in:
Akumatic 2018-06-20 02:31:49 +02:00
parent 2cf43e938f
commit 0f94b0ff40
2 changed files with 61 additions and 0 deletions

60
extensions/fun.py Normal file
View File

@ -0,0 +1,60 @@
import discord, random
from discord.ext import commands
class Fun():
def __init__(self, bot):
self.bot = bot
@commands.command()
async def ping(self, ctx):
"""Ping, Pong"""
await ctx.send("Pong!")
@commands.command()
async def dice(self, ctx):
"""Throws a six-sided dice."""
await ctx.send(random.randint(1,6))
@commands.command()
async def coin(self, ctx):
"""Throws a coin."""
await ctx.send("Heads" if (random.random() < 0.5) else "Tails")
@commands.command()
async def rps(self, ctx, userChoice : str):
"""Play Rock, Paper, Scissors with the Bot
Input \"r\" for Rock, \"p\" for Paper and \"s\" for Scissors"""
vals = ["r", "p", "s"]
userChoice = str.lower(userChoice)
if userChoice not in vals:
await ctx.send(ctx.autor.mention + " Invalid input. Please enter \"r\", \"p\", or \"s\"")
else:
botChoice = vals[random.randint(0,2)]
if(userChoice == "r" and botChoice == "p"):
await ctx.send(ctx.author.mention + " You lose")
elif(userChoice == "r" and botChoice == "s"):
await ctx.send(ctx.author.mention + " You win")
elif(userChoice == "p" and botChoice == "r"):
await ctx.send(ctx.author.mention + " You win")
elif(userChoice == "p" and botChoice == "s"):
await ctx.send(ctx.author.mention + " You lose")
elif(userChoice == "s" and botChoice == "r"):
await ctx.send(ctx.author.mention + " You lose")
elif(userChoice == "s" and botChoice == "p"):
await ctx.send(ctx.author.mention + " You win")
else:
await ctx.send(ctx.author.mention + " It's a tie")
@commands.command()
async def roll(self, ctx, a : int = 0, b : int= 100):
"""Rolls a random number between min and max.
Default values are 0 and 100"""
if(a > b):
temp = a
a = b
b = temp
await ctx.send("Random roll between " + str(a) + " and " + str(b) + ": " + str(random.randint(a,b)))
#Setup
def setup(bot):
bot.add_cog(Fun(bot))

View File

@ -7,6 +7,7 @@
"admins": [],
"mods": [],
"extensions": [
"fun"
],
"joinMessage": "",
"suggestionChannel": 0