python - 我在制作机器人时遇到错误
问题描述
所以,我有这个 python 代码,它“生成”一个输出。(在 if 之后)我试图通过 bot 或 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)```
解决方案
您应该通过官方 discord py 文档了解机器人是如何工作的。您将需要下载一些库,创建一个不和谐的应用程序,然后创建一个机器人。然后,您将收到一个令牌来识别您的机器人不和谐,您还可以生成一个链接以邀请您的机器人到您拥有的服务器或您可以邀请机器人的服务器。
首先,您需要通过get从硬编码的 guild_id 中获取 Guild 对象来获取频道,然后通过硬编码的 channel_id 获取该公会中的频道。找到所需频道后,您可以在所需频道上调用协程发送,参数content=
后跟要发送到不和谐服务器的字符串
推荐阅读
- ansible - Ansible 不使用 -u root 运行剧本
- c# - 注释斜线 // 缩进太左 (Rider)
- mysql - 使用 sql 中的 case 语句填充的三列的总和
- sql-server - 计算匹配值并以矩阵形式显示
- python - GCloud 命令行正在从不同的帐户错误执行
- java - Selenium - Java:如何获取文件的绝对路径
- python - 将包含时区的字符串秒转换为格式化的字符串日期
- java - 同一 PDF 中不同部分之间的链接
- django - 如何解决Django中的返回外部函数
- python - 使用base64发送大图到nginx+uwsig+django服务器