Ejemplo n.º 1
0
"""
    comandos da aplicação de gif
"""
from discord.ext import commands
from DiscordBot.Bot import Bot
from DiscordBot.utils import command_error
from .modules.giphy import GiphyAPI

bot = Bot()
gif_api = GiphyAPI()


@bot.command(name='gif', help='the bot create send a gif')
async def rand_gif(ctx: commands.Context, message=None):
    """ comando para gerar uma gif aleatória """
    try:
        async with ctx.typing():
            img = await gif_api.rand_gif(tag=message)

        await ctx.send(img)
    except Exception as e:
        await command_error(ctx, e)
Ejemplo n.º 2
0
"""
    inicializador do discord python
"""
import logging

from DiscordBot.Bot import Bot

# configurando logger
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log',
                              encoding='utf-8',
                              mode='w')
handler.setFormatter(
    logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)

# Get the API token from the .env file.

if __name__ == "__main__":
    Bot().run()
Ejemplo n.º 3
0
import argparse
import logging
from DiscordBot.Bot import Bot

if __name__ == '__main__':
    # command line handling
    cli = argparse.ArgumentParser(description='Run Discord Bot')
    cli.add_argument('token', help='Bot token')
    cli.add_argument('-chromium_args',
                     action='extend',
                     nargs='*',
                     default=[],
                     help='Chromium extra arguments')
    cli.add_argument('-isthereanydeal_token', help='IsThereAnyDeal API token')
    cli = cli.parse_args()

    # logging handling
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s:%(levelname)s:%(name)s: %(message)s')
    logger = logging.getLogger('DiscordBot.main')

    # run bot
    logger.info('Starting bot')
    Bot(prefix='!',
        intents=None,
        chromium_args=cli.chromium_args,
        isthereanydeal_token=cli.isthereanydeal_token).run(cli.token)
    logger.info('Shutting down bot complete')