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-03 18:38:49 +02:00
async def dice ( self , ctx , * , countstr : str = " 4 " ) :
2019-06-21 23:39:54 +02:00
""" Throws a four-sided dice. """
2019-10-03 18:38:49 +02:00
try :
count = int ( countstr )
except :
await ctx . send ( embed = discord . Embed ( color = discord . Color . red ( ) , description = " Please enter a valid number for ``dice`` " ) )
return
2019-06-21 23:39:54 +02:00
2019-10-03 18:38:49 +02:00
limit = 1000 # The limit for the amount of sides of the dice can be set here
if count > limit :
await ctx . send ( embed = discord . Embed ( color = discord . Color . red ( ) , description = f " The limit for the number of sides of the dice is { limit } . Please use a smaller number next time. " ) )
count = limit
2019-06-21 23:39:54 +02:00
2019-10-03 18:38:49 +02:00
await ctx . send ( embed = discord . Embed ( title = f " << Dice { count } >> " , description = f " { random . randint ( 1 , int ( count ) ) } " , color = 0x53ff28 ) )
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 ) :
2019-10-03 18:38:49 +02:00
bot . add_cog ( Fun ( bot ) )