Discord.py get用户返回无

2024-06-25 07:18:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我想禁止任何成员的信息与此代码

elif "$ban" in message.content:
    msg = message.content
    msgsplit = msg.split() #banid[-1] gets last index of message array
    banidstr = msgsplit[-1]
    banid = int(banidstr)
    member = bot.get_user(int(banid))
    print(member)

它看起来像意大利面条,但用于测试。“打印(成员)”行不返回任何内容,但“打印(banid)”返回用户ID。我能做什么


Tags: 代码in信息message成员msgcontentint
2条回答

我想this帖子可能会有帮助

我还建议您使用^{},在这里生成命令要容易得多:

from discord.ext import commands

bot = commands.Bot(command_prefix='?')

@bot.command()
async def echo(ctx, *, message):
    await ctx.send(message)

# Command will be invoked by user like '?echo this is the bot speaking'
# And the bot will then send 'this is the bot speaking'

是的,伙计们,成功了

async def ceza(ctx, *, message):
    cezaname=bot.get_user(int(message))
    print(cezaname)

这需要正确地按id打印用户名

相关问题 更多 >