【问题标题】:Discord.py How do I make my bot not ping everyone when it repeats a users argumentDiscord.py 如何让我的机器人在重复用户参数时无法 ping 所有人
【发布时间】:2021-04-22 04:34:31
【问题描述】:

我正在尝试创建一个重复用户所说内容的命令,但是当人们在他们的消息中添加 @everyone ping 时,机器人会 ping 所有人。 我的代码:

@bot.command()
async def say(ctx, *, arg):
  everyone = ctx.message.guild.default_role
  if arg == everyone:
    await ctx.send(arg.replace('@every-no'))
  await ctx.send(arg)

【问题讨论】:

  • discord.utils.escape_mentions
  • 哦,可能Duplicate?

标签: python discord.py


【解决方案1】:

Discord 有一个实用功能可以避免提及! discord.utils.escape_mentions(text) 看看吧!

您也可以在发送消息时使用AllowedMentions 对象。

allowed = discord.AllowedMentions.all() # Make all mentions escaped. You can always change.
await ctx.send(arg, allowed_mentions=allowed)

【讨论】:

    猜你喜欢
    • 2022-10-13
    • 2021-10-02
    • 2019-04-24
    • 2020-12-10
    • 2021-01-26
    • 2018-05-10
    • 2021-06-13
    • 2020-07-29
    • 1970-01-01
    相关资源
    最近更新 更多