60 lines
2.4 KiB
Python
Raw Normal View History

2018-06-20 02:31:49 +02:00
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"""
2019-01-22 01:07:52 +01:00
await ctx.send(ctx.author.mention + "Pong!")
2018-06-20 02:31:49 +02:00
@commands.command()
async def dice(self, ctx):
"""Throws a six-sided dice."""
2019-01-22 01:07:52 +01:00
await ctx.send(ctx.author.mention + " You rolled a D6: " + random.randint(1,6))
2018-06-20 02:31:49 +02:00
@commands.command()
async def coin(self, ctx):
"""Throws a coin."""
2019-01-22 01:07:52 +01:00
await ctx.send(ctx.author.mention + " Your coin flip is " + "Heads" if (random.random() < 0.5) else "Tails")
2018-06-20 02:31:49 +02:00
@commands.command()
2019-01-22 01:07:52 +01:00
async def rps(self, ctx, userChoice : str=""):
2018-06-20 02:31:49 +02:00
"""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)
2019-01-22 01:07:52 +01:00
if userChoice == "" or userChoice not in vals:
await ctx.send(ctx.author.mention + " Invalid input. Please enter \"r\", \"p\", or \"s\"")
2018-06-20 02:31:49 +02:00
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
2019-01-22 01:07:52 +01:00
await ctx.send(ctx.author.mention + " Random roll between " + str(a) + " and " + str(b) + ": " + str(random.randint(a,b)))
2018-06-20 02:31:49 +02:00
#Setup
def setup(bot):
bot.add_cog(Fun(bot))