Greenadine

EchoBot main.py

Nov 12th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.03 KB | None | 0 0
  1. import discord as ds
  2. from discord.ext import commands
  3. from utils.data import check_file
  4.  
  5. TOKEN = "(the token, I removed it to avoid it generating a new one)"
  6. PREFIX = "e!"
  7. DESCRIPTION = "EchoBot is here for all your wishing needs."
  8.  
  9. extensions = ['general', 'fun', 'economy']
  10.  
  11. # client = ds.Client()
  12. bot = commands.Bot(command_prefix=PREFIX, description=DESCRIPTION)
  13.  
  14. # Check if files exist, and create if required
  15. check_file('users.json', 'json')
  16. check_file('assets/arrays/future.json', 'json')
  17. check_file('assets/arrays/poke.json', 'json')
  18. check_file('assets/arrays/roasts.json', 'json')
  19. check_file('assets/arrays/wish.json', 'json')
  20.  
  21.  
  22. # Load cogs (temporarily removed try clause to properly log exceptions)
  23. bot.remove_command('help')  # Remove default 'help' command to replace with custom
  24. for extension in extensions:
  25.     # noinspection PyBroadException
  26.     # try:
  27.     bot.load_extension(extension)
  28.     # except ModuleNotFoundError:
  29.     #    print("Failed to load cog '{}': extension not found.".format(extension))
  30.     # except Exception:
  31.     #    print("Failed to load cog '{}': unknown cause.".format(extension))
  32.  
  33. # Notify when bot is ready.
  34. @bot.event
  35. async def on_ready():
  36.     print('Logged in as')
  37.     print(f'Bot-Name: {bot.user.name}')
  38.     print(f'Bot-ID: {bot.user.id}')
  39.     await bot.change_presence(status=ds.Status.online, activity=ds.Game(name="e!help"))
  40.  
  41. # Handle errors on command.
  42. @bot.event
  43. async def on_command_error(ctx, error):
  44.     if isinstance(error, commands.CommandNotFound):
  45.         await ctx.send("Unknown command '{}'. Use ``e!help`` for a list of commands.".format(ctx.invoked_with))
  46.         return
  47.     if isinstance(error, commands.MissingPermissions):
  48.         await ctx.send(ctx.message.author.mention + " You do not have permission to use this command.")
  49.         return
  50.     # if isinstance(error, BaseException):
  51.     #    await ctx.send("An unexpected error occurred while trying to execute '{}'.".format(ctx.invoked_with))
  52.     #    TODO print error message
  53.     #    return
  54.  
  55.  
  56. bot.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment