我正在用python创建一个自定义的discord机器人。我正在尝试添加!report命令。我很困惑,无法在任何地方找到答案。谁能帮助我做到这一点?
我希望任何用户都可以执行!report @example reason.
并将其保存在excel或sql3之类的数据库中,或者最好保存在人员频道中。我该怎么办?
我尝试使用on_message()
您可以使用on_message()
命令:
@client.event
async def on_message(message):
if message.startswith("!report"):
report_channel = client.get_channel(channel id)
member = text.split(" ")[1]
reason = ' '.join(text.split(" ")[1:])
await report_channel.send(f"Member: {member}, Reason: {reason}")
因此,第一件事是查看该人员是否使用带有if语句的“!report”命令。
接下来,您通过输入消息的第二个单词来找到成员。
之后,您将消息中的其余单词用于查找原因。
然后您将其发送到不一致的预定义报告频道。