Add fun extension with autoload
This commit is contained in:
parent
2cf43e938f
commit
0f94b0ff40
60
extensions/fun.py
Normal file
60
extensions/fun.py
Normal 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))
|
@ -7,6 +7,7 @@
|
|||||||
"admins": [],
|
"admins": [],
|
||||||
"mods": [],
|
"mods": [],
|
||||||
"extensions": [
|
"extensions": [
|
||||||
|
"fun"
|
||||||
],
|
],
|
||||||
"joinMessage": "",
|
"joinMessage": "",
|
||||||
"suggestionChannel": 0
|
"suggestionChannel": 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user