Python discord 模块,LoginFailure() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用discord.LoginFailure()

项目:Turbo    作者:jaydenkieran    | 项目源码 | 文件源码
def run(self, token):
        """
        Override's discord.py's function for running the bot
        """
        try:
            super().run(token, bot=(not self.config.selfbot))
        except discord.LoginFailure:
            log.critical("Incorrect login token")
            if not self.config.selfbot:
                log.critical(
                    "Using your own token? Change 'selfbot' to 'True' in the config")
            else:
                log.critical(
                    "Using an OAuth account? Change 'selfbot' to 'False' in the config")
        except discord.HTTPException as e:
            log.critical(e)
项目:Dwarf    作者:Dwarf-Community    | 项目源码 | 文件源码
def main(loop=None):
    if loop is None:
        loop = asyncio.get_event_loop()

    bot = Bot(loop=loop, command_prefix=core.get_prefixes(), description=__doc__, pm_help=core.is_help_private())

    if not is_configured():
        initial_config()

    error = False
    error_message = ""
    try:
        loop.run_until_complete(run(bot))
    except discord.LoginFailure:
        error = True
        error_message = 'Invalid credentials'
        choice = input(strings.invalid_credentials)
        if choice.strip() == 'reset':
            base.delete_token()
        else:
            base.disable_restarting()
    except KeyboardInterrupt:
        base.disable_restarting()
        loop.run_until_complete(bot.logout())
    except Exception as e:
        error = True
        print(e)
        error_message = traceback.format_exc()
        base.disable_restarting()
        loop.run_until_complete(bot.logout())
    finally:
        if error:
            print(error_message)
        return bot
项目:apex-sigma-core    作者:lu-ci    | 项目源码 | 文件源码
def run(self):
        try:
            self.log.info('Connecting to Discord Gateway...')
            super().run(self.cfg.dsc.token, bot=self.cfg.dsc.bot)
        except discord.LoginFailure:
            self.log.error('Invalid Token!')
            exit(errno.EPERM)
项目:Pesterchum-Discord    作者:henry232323    | 项目源码 | 文件源码
def runbot(self):
        try:
            if (self.user and self.passwd) and not self.token:
                await self.client.start(self.user, self.passwd, bot=False)
            elif self.token and not (self.user or self.passwd):
                await self.client.start(self.token, bot=self.botAccount)
        except discord.LoginFailure:
            self.openAuth(f=True)
            save_auth((self.user, self.passwd, self.token, self.botAccount,))
        finally:
            await self.runbot()