Advertisement
BlueBoy728

bot2.py

Dec 16th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. import discord
  2. import asyncio
  3. import random
  4. from discord.ext import commands
  5. import sys, traceback
  6.  
  7. game = discord.Game(name='in the blue waters')
  8. bot = commands.Bot(command_prefix='>', description='--- List of Aqua\'s commands ---')
  9. extensions = ['cogs.cog']
  10.  
  11. @bot.event
  12. async def on_ready():
  13. await bot.change_presence(status=None, game=game)
  14. print('---------- AquaBot ----------')
  15. print('Logged in as %s\n(client ID: %s)' % (bot.user.name, bot.user.id))
  16. print('-----------------------------')
  17. if __name__ == '__main__':
  18. for ext in extensions:
  19. try:
  20. bot.load_extension(ext)
  21. except Exception as e:
  22. print(f'Failure while loading extension {ext}!', file = sys.stderr)
  23. traceback.print_exc()
  24. print('Aqua has loaded succesfully.')
  25.  
  26. @bot.command(help='Pong!', aliases={'pong'})
  27. async def ping(ctx):
  28. await ctx.send('Pong!')
  29.  
  30. @bot.command(help='Hello world!', aliases={'helloworld'})
  31. async def hello(ctx):
  32. await ctx.send('Hello, world!')
  33.  
  34. @bot.command(help='Aaaaaaaaaa!', brief='AAAAA', aliases={'scream','A'})
  35. async def a(ctx):
  36. a= random.randint(1,100)
  37. A = random.randint(1,2)
  38. if A == 1:
  39. await ctx.send('a' * a)
  40. else:
  41. await ctx.send('A' * a)
  42. @bot.command(help='Displays a list of all commands.', brief='Shows Aqua\'s commands.', aliases={'commands'})
  43. async def cmds(ctx):
  44. cmds = discord.Embed(title=':information_source: Aqua\'s commands', description='```a, dice, ping, 8ball, hello```', colour = discord.Colour.from_rgb(10,240,250))
  45. cmds.add_field(name='Bot Owner Only commands', value='```stop```')
  46. await ctx.send(embed = cmds)
  47.  
  48. @bot.command(help='Rolls a 6-sided dice.', brief='Rolls a dice.', aliases={'roll'})
  49. async def dice(ctx):
  50. await ctx.send('You rolled a %s!' % random.randint(1,6))
  51.  
  52. @bot.command(help='Test.')
  53. async def test(ctx):
  54. await ctx.send(':white_check_mark: Test complete.')
  55.  
  56. @bot.command(name='8ball', brief='Ask the mighty 8Ball!', help='Ask the 8Ball a yes/no question and let the stars do the magic!', aliases={'ask','eightball'}, usage='<question...>')
  57. async def _ball(ctx, *args):
  58. r = random.choice(['Yes','No','Maybe','I don\'t know','The outlooks are good','Ask again please','Of course','Of course not'])
  59. ball = discord.Embed(title=':8ball: The Mighty 8Ball', colour = discord.Colour.darker_grey())
  60. ball.add_field(name='Your question:', value='```%s```' % ' '.join(args), inline=False)
  61. ball.add_field(name='The 8Ball says:', value='```%s```' % r, inline=False)
  62. await ctx.send(embed = ball)
  63.  
  64. @bot.command(help='Displays when a member joined the server.', brief='Shows a member\'s join date.', aliases={'info'})
  65. async def joindate(ctx, *, member: discord.Member):
  66. fmt = '```{0} joined on {0.joined_at}.```'
  67. await ctx.send(fmt.format(member))
  68.  
  69. @bot.command(help='Stops the bot. Only the bot owner can execute this command.', brief='[BOT OWNER ONLY] Stops the bot.', aliases = {'quit', 'exit'})
  70. @commands.is_owner()
  71. async def stop(ctx):
  72. await ctx.send(':ballot_box_with_check: `The bot has been stopped.`')
  73. print('The bot owner issued the >stop command.')
  74. exit()
  75.  
  76. @joindate.error
  77. async def joindate_error(ctx, error):
  78. if isinstance(error, commands.BadArgument):
  79. await ctx.send(':warning: **Failed to find member!**')
  80.  
  81. @stop.error
  82. async def stop_error(ctx, error):
  83. if isinstance(error, commands.CheckFailure):
  84. await ctx.send(':warning: **Only the bot owner can use `>stop`:!**')
  85.  
  86. bot.run('TOKEN')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement