示例#1
0
def main():
    """Main function"""
    intents = discord.Intents.default()
    intents.members = True
    bot = Client(intents=intents)
    if bot.error_code == 0:
        bot.run(constants.BOT_TOKEN)
    return bot.error_code
示例#2
0
def main():
    client = Client()

    file_handler = logging.FileHandler(filename="output.log",
                                       encoding="utf-8",
                                       mode="w")

    if "--no-log-discord" in sys.argv:
        handlers = [file_handler, logging.StreamHandler()]
    else:
        handlers = [
            DiscordLogHandler(client), file_handler,
            logging.StreamHandler()
        ]

    logging.basicConfig(
        format="%(asctime)s | %(name)10s | %(levelname)8s | %(message)s",
        level=logging.DEBUG if "--debug" in sys.argv else logging.INFO,
        handlers=handlers)

    logging.getLogger("discord").setLevel(logging.WARNING)
    logging.getLogger("websockets.protocol").setLevel(logging.INFO)

    client.run(client.get_token(), bot=True)
示例#3
0
def main():
    """Main function"""
    bot = Client()
    if bot.error_code == 0:
        bot.run(constants.BOT_TOKEN)
    return bot.error_code
示例#4
0
import asyncio
import os
from bot.client import Client

discord_token = os.environ['DISCORD_TOKEN']

# Create our eventloop and put it into discord client
# and the Client class will put it into the aioredis client
loop = asyncio.get_event_loop()

discord = Client(loop=loop)
discord.run(discord_token)