【问题标题】:Im having errors while making a bot我在制作机器人时遇到错误
【发布时间】:2021-05-22 17:31:03
【问题描述】:

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

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)```

【问题讨论】:

    标签: python discord discord.py bots


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-09-14
      • 2023-01-05
      • 2019-10-25
      • 2021-11-03
      • 2021-12-14
      • 2022-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多