所以,我有一个可以运行的命令,除了需要获取用户ID的部分,这里是代码:
from discord import abc
from discord.ext import commands
import asyncio
class DMCog:
def __init__(self, bot):
self.bot = bot
async def on_message(self, message):
if message.guild is None:`
if message.content.startswith("!report"):
await message.channel.send("Who are you reporting? Input the ID only please.")
def is_correct(m):
return m.author == message.author and m.content.isdigit()
victim_ID = await self.bot.wait_for('message', check = is_correct)
victim = await self.bot.get_user_info(victim_ID)
if victim == None:
await message.channel.send("Can't find user, please try again")
return
else:
success = (f"Found user: {victim.username} \n Is this correct? reply with Y or N. ")
await message.channel.send(success)
它输出的错误:
"discord.errors.HTTPException: BAD REQUEST (status code: 400): Invalid Form Body
In user_id: Value "<Message id=542780755034767380 pinned=False author=<User id=197054540015599616 name='TheFutureKnight' discriminator='7664' bot=False>>" is not snowflake."
答案 0 :(得分:0)
victim_ID
是Message
对象,代表用户发送的消息。您需要以int
的形式提取该邮件的内容:
msg = await self.bot.wait_for('message', check = is_correct)
victim_ID = int(msg.content)