【问题标题】:How can I run multiple discord tokens one by one until it sends X messages in discord.py?在discord.py中发送X消息之前,如何一个接一个地运行多个discord令牌?
【发布时间】:2021-12-11 14:12:15
【问题描述】:

我正在编写一些代码,使用令牌向 X 人发送消息,然后更改为列表中的另一个。例如:

tokens = [token1, token2, token3 ... token100]
for token in tokens:
    client.run(token)

我的疑问基本上是:当 X 消息已发送后,我如何才能完成运行功能,然后转到下一个令牌

【问题讨论】:

  • 这听起来像是垃圾邮件帐户或一般垃圾邮件,已经违反了 Discord 的 ToS。我想没有人会帮助你。

标签: python discord discord.py python-asyncio


【解决方案1】:

我已经解决了这个问题,希望对大家有帮助=] 我不关心 TOS,所以这里是:

import discord
import asyncio

conta = 0

tokens = list(map(lambda t : t.split(':')[2], open('tokens.txt', 'r', encoding='utf-8').readlines()))

async def main():
    while True:
        for token in tokens:
            client = discord.Client()

            @client.event
            async def on_ready():
                print(f'Logged on as {client.user.name}')
                await asyncio.sleep(5)
                await client.close()

            try:
                client.loop.run_until_complete(await client.start(token))
            except Exception as e:
                continue

asyncio.run(main())

【讨论】:

    猜你喜欢
    • 2020-04-21
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多