如何使用get_user_info为Discord.py重写

问题描述 投票:0回答:1

所以,我有除非它需要在这里得到的用户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."
python discord discord.py discord.py-rewrite
1个回答
0
投票

victim_ID是表示用户发送消息的Message对象。你需要提取的消息作为int的内容:

msg = await self.bot.wait_for('message', check = is_correct)
victim_ID = int(msg.content)
© www.soinside.com 2019 - 2024. All rights reserved.