Пример #1
0
def discord_bot(commands: List[Command]) -> None:
    """Launch the Discord bot"""
    with open("discord.token", "rt", encoding="utf-8") as token_handle:
        token = token_handle.read().strip()

    if not token:
        raise Exception("Unable to load token from token file")

    instance = DiscordBot(commands)
    instance.run(token)
Пример #2
0
def run(config_path, no_chdir=False):
    if not no_chdir:
        os.chdir(os.path.dirname(os.path.abspath(__file__)))
    bot = DiscordBot(config_path)
    bot.run()
Пример #3
0
import settings
from loguru import logger
import discord
import discord.ext.commands
from bot import DiscordBot

logger.configure(**settings.LOGGING)

bot = DiscordBot('>')

for module_name in settings.MODULES:
    bot.load_extension('modules.' + module_name)

if __name__ == "__main__":
    bot.run(settings.TOKEN)
Пример #4
0
from bot import DiscordBot
from utils import Utils, ErrorMessages
from validation import Validation

validation = Validation()
utils = Utils()
error_message = ErrorMessages()
bot_token = utils.BOT_TOKEN

while not validation.validate_token(bot_token):
    print(error_message.VALDIDATION_ERROR_MESSAGE)
    userInput = input(utils.USER_TOKEN_QUESTION)

bot = DiscordBot()

##bot.loop.create_task(bot.backgoundTask())
bot.run(bot_token)
Пример #5
0
app = web.app

if __name__ == '__main__':
    kwargs = {}
    try:
        port_index = sys.argv[1:].index('--port')
        kwargs['port'] = sys.argv[1:][port_index + 1]
    except ValueError:
        pass
    try:
        port_index = sys.argv[1:].index('--host')
        kwargs['host'] = sys.argv[1:][port_index + 1]
    except ValueError:
        pass
    t = threading.Thread(target=web.run, kwargs=kwargs)
    t.daemon = True
    t.start()
    bot.run(global_settings['TOKEN'])

else:
    import asyncio

    def run_bot():
        bot.bot.loop = asyncio.new_event_loop()
        bot.run(global_settings['TOKEN'])

    t = threading.Thread(target=run_bot)
    t.daemon = True
    t.start()