Ejemplo n.º 1
0
 def _add_check(self,
                bot: commands.Bot,
                name: str,
                call_once: bool = False):
     try:
         check = getattr(self, f'_{self.__class__.__name__}__{name}')
     except AttributeError:
         pass
     else:
         bot.add_check(check, call_once=call_once)
Ejemplo n.º 2
0
import logging
from discord.ext import commands
from discord.ext.commands import Bot
from os import environ
from discord import Game


def isprivate(ctx):
    return ctx.guild is not None


logging.basicConfig(level=logging.INFO)
description = '''Stonks'''
client = Bot(description="A Discord bot to manage your stocks in Codeforces", command_prefix="+")
client.add_check(isprivate)


@client.event
async def on_command_error(ctx: commands.Context, error: Exception):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send_help(ctx.command)
    else:
        logging.info(str(error))


@client.event
async def on_ready():
    await client.change_presence(activity=Game(name="with stocks"))
    logging.info('Logged in as')
    logging.info(client.user.name)
    logging.info(client.user.id)
Ejemplo n.º 3
0
def setup(bot: Bot) -> None:
    checks = [is_not_bot]
    for check in checks:
        bot.add_check(check)