Python3 discord selfbot NameError:未定义名称“令牌" [英] Python3 discord selfbot NameError: name 'tokens' is not defined

查看:57
本文介绍了Python3 discord selfbot NameError:未定义名称“令牌"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我为我的 discord selfbot 运行我的文件时,它给了我错误 NameError: name 'tokens' is not defined.我对编程很陌生,我不知道为什么.如果你知道我该如何解决这个问题,请在评论中告诉我.

When I run my file for my discord selfbot, it gives me the error NameError: name 'tokens' is not defined. I am quite new to programming and I don't know why. If you know how I can fix this, please let me know in a comment.

这是不工作的部分:

loop = asyncio.get_event_loop()
def Selfbottokens():
    with open("tokens.txt", "r") as f:
        tokens = [token.strip("\n") for token in f.readlines()]
for i in range(len(tokens)):
    client.add_cog(client)
    loop.create_task(client.start(tokens[i], bot=False))

推荐答案

你的代码没有很好的缩进

your code is not well indented

应该是这样的:

loop = asyncio.get_event_loop()
def Selfbottokens():
    with open("tokens.txt", "r") as f:
        tokens = [token.strip("\n") for token in f.readlines()]
        for i in range(len(tokens)):
            client.add_cog(client)
            loop.create_task(client.start(tokens[i], bot=False))

这篇关于Python3 discord selfbot NameError:未定义名称“令牌"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆