【发布时间】:2021-07-28 23:37:20
【问题描述】:
这是一个不和谐的自我机器人 mudae 狙击手
我不久前(比如 2 个月前)做了它然后停止使用它我决定再次使用它但它不起作用
它会登录,但没有做出应有的反应或打印消息 它的行为就像它甚至没有看到消息一样
没有任何错误信息
老实说,我不知道我错过了什么
导入是:from discord.ext import commands import discord, json, asyncio, re, os
代码:
from imports import *
try:
with open("config.json", "x"): pass
config = {"token": input("Enter discord token: "), "min": int(input("Enter minimum amount of kakera: "))}
with open("config.json", "w") as configFile:
configFile.write(json.dumps(config))
except:
with open("config.json", "r") as configFile:
config = json.loads(configFile.read())
bot = commands.Bot(">", self_bot=True)
@bot.event
async def on_connect():
os.system("cls")
print(f"Logged in as: {bot.user}\n")
@bot.event
async def on_message(message):
if message.author.id == 488711695640821760 and message.embeds:
if "wished" in message.content.lower():
try:
kakera = int(re.findall(r"\*\*([0-9]+)\*\*", message.embeds[0].description)[0])
if kakera < config["min"]:
print(kakera, "is less than", config["min"])
return
except Exception as e:
return
fails = 0
print(f"Claiming {message.embeds[0].title} in {message.channel.guild.name}")
while True:
try:
await message.add_reaction(message.reactions[0])
return
except Exception as e:
print(e)
if fails > 3:
break
await asyncio.sleep(0.1)
fails += 1
print("Failed to claim")
bot.run(config["token"], bot=False)
【问题讨论】:
-
使用 Self-bot 是违反 Discord's TOS 的,因此是不合适的。另外,也曾出现过类似的问题,如:Discord API “soft-ban” for Selfbot? It can only read its own messages