我在制作机器人时出错

时间:2021-02-19 17:38:33

标签: python discord discord.py bots

所以呃我有这个 python 代码,它“生成”一个输出。 (在 if 之后) 我试图通过机器人或网络钩子将其重定向到不和谐频道,但我尝试的一切都还没有奏效。你知道怎么做吗?

import threading
import time
import random
 
# How many threads the program is gonna run | The more threads the more internet and pc resources are needed.
threads = 50
# Determines the ID range that will be scanned - Default is 6000000 - 7800000
minrange = 6000000
maxrange = 7800000
# -----------------------
group_ids = [*range(minrange, maxrange)]
 
random.shuffle(group_ids)
popped_groups = group_ids
 
results = open('results.txt', 'w')
results.close()
 
i = 0
 
 
def groupthingy():
    current_group = popped_groups.pop()
 
    try:
        group = requests.get(
            f'https://groups.roblox.com/v1/groups/{current_group}')
        json = group.json()
        if '"isLocked":true' not in group.text:
            if json['owner'] == None:
                if json['publicEntryAllowed'] == True:
                    results = open('results.txt', 'a')
                    results.write(f"Group: {current_group} is claimable!\n")
                    results.close()
 
    except Exception:
        pass
 
 
groupthreads = []
for gk in range(threads):
    lt = threading.Thread(target=groupthingy)
    groupthreads.append(lt)
    lt.start()
    time.sleep(0.00000000001)```

1 个答案:

答案 0 :(得分:0)

您应该通过 Official discord py documentation 了解机器人的工作原理。您需要下载一些库,创建一个 discord app,然后创建一个机器人。然后,您将收到一个令牌,用于识别您的机器人不和谐,您还可以生成一个链接以邀请您的机器人访问您拥有的服务器或您可以邀请机器人的服务器。

首先,您需要通过 get 获取频道以从您硬编码的 guild_id 中获取 Guild 对象,然后通过您硬编码的 channel_id 获取该公会中的 channels。找到您想要的频道后,您可以在您想要的频道上调用协程 send,参数 content= 后跟要发送到不和谐服务器的字符串