Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord as ds
- from discord.ext import commands
- from utils.data import check_file
- TOKEN = "(the token, I removed it to avoid it generating a new one)"
- PREFIX = "e!"
- DESCRIPTION = "EchoBot is here for all your wishing needs."
- extensions = ['general', 'fun', 'economy']
- # client = ds.Client()
- bot = commands.Bot(command_prefix=PREFIX, description=DESCRIPTION)
- # Check if files exist, and create if required
- check_file('users.json', 'json')
- check_file('assets/arrays/future.json', 'json')
- check_file('assets/arrays/poke.json', 'json')
- check_file('assets/arrays/roasts.json', 'json')
- check_file('assets/arrays/wish.json', 'json')
- # Load cogs (temporarily removed try clause to properly log exceptions)
- bot.remove_command('help') # Remove default 'help' command to replace with custom
- for extension in extensions:
- # noinspection PyBroadException
- # try:
- bot.load_extension(extension)
- # except ModuleNotFoundError:
- # print("Failed to load cog '{}': extension not found.".format(extension))
- # except Exception:
- # print("Failed to load cog '{}': unknown cause.".format(extension))
- # Notify when bot is ready.
- @bot.event
- async def on_ready():
- print('Logged in as')
- print(f'Bot-Name: {bot.user.name}')
- print(f'Bot-ID: {bot.user.id}')
- await bot.change_presence(status=ds.Status.online, activity=ds.Game(name="e!help"))
- # Handle errors on command.
- @bot.event
- async def on_command_error(ctx, error):
- if isinstance(error, commands.CommandNotFound):
- await ctx.send("Unknown command '{}'. Use ``e!help`` for a list of commands.".format(ctx.invoked_with))
- return
- if isinstance(error, commands.MissingPermissions):
- await ctx.send(ctx.message.author.mention + " You do not have permission to use this command.")
- return
- # if isinstance(error, BaseException):
- # await ctx.send("An unexpected error occurred while trying to execute '{}'.".format(ctx.invoked_with))
- # TODO print error message
- # return
- bot.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment