Advertisement
12944qwerty

Discord.py Ratchet Code

Mar 10th, 2019
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.17 KB | None | 0 0
  1. import discord as d
  2. import sys, traceback
  3. from discord.ext.commands import Bot
  4. from discord.ext.commands import bot_has_permissions
  5. from discord.ext.commands import has_permissions
  6. from discord.ext import commands as c
  7. import os
  8. from random import randint
  9.  
  10. client = Bot(command_prefix='?R ')
  11.  
  12.  
  13. class BotCogs:
  14.     @client.command()
  15.     @c.is_owner()
  16.     async def stop(ctx):
  17.         """Stop the bot. ONLY OWNER CAN DO SO"""
  18.         try:
  19.             await ctx.send('Stopping.......')
  20.             client.loop.run_until_complete(client.logout())
  21.         except Exception as e:
  22.             print(e)
  23.            
  24.     @client.command()
  25.     async def desc(ctx):
  26.         """Sends desc of bot"""
  27.         try:   
  28.             await ctx.send('I am Ratchet. A fun bot. To see a list of commands, type in \'?R helps\'.\n To report a bug, DM the owner. @12944qwerty#9317')
  29.         except Exception as e:
  30.             print(e)
  31.  
  32.     @client.command()
  33.     async def ping(ctx):
  34.         """Tests for reply speed"""
  35.         try:
  36.             msg = await ctx.send('Pong!:ping_pong: {}ms '.format(round(client.latency * 1000,1)))
  37.             msg2 = str(msg.content) + '\nEdit: {}ms'.format(round(client.latency * 1000,1))
  38.             await msg.edit(content=msg2)
  39.         except Exception as e:
  40.             print(e)
  41.  
  42.     @client.command()
  43.     async def hi(ctx):
  44.         """Test if bot is working"""
  45.  
  46.         try:
  47.             await ctx.send('Hello {}!'.format(ctx.author.display_name))
  48.         except Exception as e:
  49.             print(e)
  50.  
  51. class ModsCogs:
  52.     @client.command()
  53.     async def ban(ctx, *, user : d.Member):
  54.         """votetoban someone"""
  55.         try:
  56.             await ctx.send('@Moderators, {} has requested for {} to be banned'.format(ctx.author, user.mention))
  57.  
  58.             #await ctx.send('Please specify a user you want to ban.')
  59.         except Exception as e:
  60.             print(e)
  61.  
  62. initial_extensions = [
  63.     'cogs.Mods',
  64.     'cogs.Bot',
  65. ]
  66.  
  67. if __name__ == '__main__':
  68.     for extension in initial_extensions:
  69.         try:
  70.             client.load_extension(extension)
  71.         except Exception as e:
  72.             print(f'Failed to load extension {extension}.', file=sys.stderr)
  73.             traceback.print_exc()
  74.  
  75.  
  76. token = os.environ.get('TOKEN')
  77. try:
  78.     client.loop.run_until_complete(client.start(token))
  79. except KeyboardInterrupt:
  80.     client.loop.run_until_complete(client.logout())
  81. finally:
  82.     client.loop.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement