Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- from datetime import datetime
- from os import path, listdir
- from discord.ext.commands import Bot, when_mentioned_or
- from discord import DMChannel
- from aiohttp import ClientSession
- from orchidbot.cogs import linkblock
- class Orchid(Bot):
- def __init__(self, *args, **options):
- super().__init__(*args, **options)
- self.session = None
- with open('../config.json') as configfile:
- self.config = json.load(configfile)
- self.last_errors = []
- async def start(self, *args, **kwargs):
- self.session = ClientSession()
- await super().start(self.config["bot_key"], *args, **kwargs)
- async def close(self):
- await self.session.close()
- await super().close()
- def user_is_admin(self, user):
- try:
- user_roles = [role.id for role in user.roles]
- except AttributeError:
- return False
- permitted_roles = self.config['admin_roles']
- return any(role in permitted_roles for role in user_roles)
- def user_is_superuser(self, user):
- superusers = self.config['superusers']
- return user.id in superusers
- def user_is_ignored(self, user):
- user_roles = [role.id for role in user.roles]
- if self.config['ignore_role'] in user_roles:
- return True
- return False
- client = Orchid(
- command_prefix=when_mentioned_or('orchid ', 'Orchid '),
- description='Hi I\'m Orchid!',
- max_messages=15000
- )
- @client.event
- async def on_ready():
- main_id = client.config['main_guild']
- client.main_guild = client.get_guild(main_id) or client.guilds[0]
- print('\nActive in these guilds/servers:')
- [print(g.name) for g in client.guilds]
- print('\nMain guild:', client.main_guild.name)
- print('\nOrchid started successfully')
- return True
- @client.event
- async def on_message(message):
- if isinstance(message.channel, DMChannel):
- return
- if client.user_is_ignored(message.author):
- return
- await client.process_commands(message)
- client.run()
- print('Orchid has exited')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement