2018-06-20 02:31:49 +02:00
|
|
|
import discord, random
|
|
|
|
from discord.ext import commands
|
|
|
|
|
2019-06-21 23:39:54 +02:00
|
|
|
class Fun(commands.Cog):
|
2018-06-20 02:31:49 +02:00
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
|
|
|
|
@commands.command()
|
|
|
|
async def ping(self, ctx):
|
|
|
|
"""Ping, Pong"""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} Pong!".format(ctx.author.mention))
|
2018-06-20 02:31:49 +02:00
|
|
|
|
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def d4(self, ctx, *, msg : str = None):
|
2019-06-21 23:39:54 +02:00
|
|
|
"""Throws a four-sided dice."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} You rolled a D4{}: {}".format(ctx.author.mention,
|
|
|
|
"" if msg is None else " for \"{}\"".format(msg), random.randint(1, 4)))
|
2019-06-21 23:39:54 +02:00
|
|
|
|
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def d6(self, ctx, *, msg : str = None):
|
2018-06-20 02:31:49 +02:00
|
|
|
"""Throws a six-sided dice."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} You rolled a D6{}: {}".format(ctx.author.mention,
|
|
|
|
"" if msg is None else " for \"{}\"".format(msg), random.randint(1, 6)))
|
2018-06-20 02:31:49 +02:00
|
|
|
|
2019-06-21 23:39:54 +02:00
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def d8(self, ctx, *, msg : str = None):
|
2019-06-21 23:39:54 +02:00
|
|
|
"""Throws a eight-sided dice."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} You rolled a D8{}: {}".format(ctx.author.mention,
|
|
|
|
"" if msg is None else " for \"{}\"".format(msg), random.randint(1, 8)))
|
2019-06-21 23:39:54 +02:00
|
|
|
|
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def d10(self, ctx, *, msg : str = None):
|
2019-06-21 23:39:54 +02:00
|
|
|
"""Throws a eight-sided dice."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} You rolled a D10{}: {}".format(ctx.author.mention,
|
|
|
|
"" if msg is None else " for \"{}\"".format(msg), random.randint(1, 10)))
|
2019-06-21 23:39:54 +02:00
|
|
|
|
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def d12(self, ctx, *, msg : str = None):
|
2019-06-21 23:39:54 +02:00
|
|
|
"""Throws a twelve-sided dice."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} You rolled a D12{}: {}".format(ctx.author.mention,
|
|
|
|
"" if msg is None else " for \"{}\"".format(msg), random.randint(1, 12)))
|
2019-06-21 23:39:54 +02:00
|
|
|
|
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def d20(self, ctx, *, msg : str = None):
|
2019-06-21 23:39:54 +02:00
|
|
|
"""Throws a twenty-sided dice."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} You rolled a D20{}: {}".format(ctx.author.mention,
|
|
|
|
"" if msg is None else " for \"{}\"".format(msg), random.randint(1, 20)))
|
2019-06-21 23:39:54 +02:00
|
|
|
|
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def d100(self, ctx, *, msg : str = None):
|
2019-06-21 23:39:54 +02:00
|
|
|
"""Throws a hundred-sided dice."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} You rolled a D100{}: {}".format(ctx.author.mention,
|
|
|
|
"" if msg is None else " for \"{}\"".format(msg), random.randint(1, 100)))
|
2019-06-21 23:39:54 +02:00
|
|
|
|
2019-10-01 01:08:38 +02:00
|
|
|
@commands.command(name="8ball")
|
2019-06-21 23:39:54 +02:00
|
|
|
async def magic8ball(self,ctx, *, msg : str = None):
|
|
|
|
if msg is None:
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send(":8ball: You need to specify a question.")
|
2019-06-21 23:39:54 +02:00
|
|
|
else:
|
|
|
|
e = discord.Embed(color=0x3296ff)
|
|
|
|
e.set_author(name = str(ctx.author), icon_url=ctx.author.avatar_url)
|
|
|
|
e.add_field(name=":grey_question: Question", value=msg, inline=False)
|
2019-10-01 01:08:38 +02:00
|
|
|
e.add_field(name=":8ball: Answer", value=random.choice(
|
|
|
|
["Yes.", "As I see it, yes.", "Outlook good.", "For sure", "Without a doubt.", "It is decidedly so.",
|
|
|
|
"Without a doubt.", "Maybe", "Perhaps","It is uncertain", "Dont even think about it.", "Nope.", "Don't "
|
|
|
|
"count on it.", "My sources say no.", "Outlook not so good.", "Very doubtful.", "Definitely no."]
|
|
|
|
), inline=False)
|
2019-06-21 23:39:54 +02:00
|
|
|
await ctx.send(embed=e)
|
|
|
|
|
2018-06-20 02:31:49 +02:00
|
|
|
@commands.command()
|
|
|
|
async def coin(self, ctx):
|
|
|
|
"""Throws a coin."""
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} Your coin flip is {}".format(ctx.author.mention, random.choice(["Head", "Tail"])))
|
2018-06-20 02:31:49 +02:00
|
|
|
|
|
|
|
@commands.command()
|
2019-10-01 01:08:38 +02:00
|
|
|
async def rps(self, ctx, userChoice : str = None):
|
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"""
|
2019-10-01 01:08:38 +02:00
|
|
|
if userChoice == None or str.lower(userChoice) not in ["r", "p", "s"]:
|
|
|
|
return await ctx.send("{} Invalid input. Please enter \"r\", \"p\" or \"s\"".format(ctx.author.mention))
|
|
|
|
|
|
|
|
botChoice = ["r", "p", "s"][random.randint(0,2)]
|
|
|
|
if userChoice == "r" and botChoice == "p":
|
|
|
|
await ctx.send("{} You lose".format(ctx.author.mention))
|
|
|
|
elif userChoice == "p" and botChoice == "s":
|
|
|
|
await ctx.send("{} You lose".format(ctx.author.mention))
|
|
|
|
elif userChoice == "s" and botChoice == "r":
|
|
|
|
await ctx.send("{} You lose".format(ctx.author.mention))
|
|
|
|
elif userChoice == "r" and botChoice == "s":
|
|
|
|
await ctx.send("{} You win".format(ctx.author.mention))
|
|
|
|
elif userChoice == "p" and botChoice == "r":
|
|
|
|
await ctx.send("{} You win".format(ctx.author.mention))
|
|
|
|
elif userChoice == "s" and botChoice == "p":
|
|
|
|
await ctx.send("{} You win".format(ctx.author.mention))
|
2018-06-20 02:31:49 +02:00
|
|
|
else:
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} It's a tie".format(ctx.author.mention))
|
2018-06-20 02:31:49 +02:00
|
|
|
|
|
|
|
@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"""
|
2019-10-01 01:08:38 +02:00
|
|
|
if a > b:
|
2018-06-20 02:31:49 +02:00
|
|
|
temp = a
|
|
|
|
a = b
|
|
|
|
b = temp
|
2019-10-01 01:08:38 +02:00
|
|
|
await ctx.send("{} Random roll between {} and {}: {}".format(ctx.author.mention, a, b, random.randint(a, b)))
|
2018-06-20 02:31:49 +02:00
|
|
|
|
|
|
|
#Setup
|
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(Fun(bot))
|