【问题标题】:How to make my discord.py bot only allow @everyone and @here from only admins and mods and not from normal members如何让我的 discord.py 机器人只允许来自管理员和模组的 @everyone 和 @here,而不是来自普通成员的
【发布时间】:2021-10-15 19:46:24
【问题描述】:
import discord
from discord.ext import commands 

bot = discord.Bot(command_prefix='!')

@bot.event
@commands.has_permissions(administrator=False)
async def delmessage(message):
 await message.delete()

【问题讨论】:

  • 在服务器频道的设置中禁用@所有人和@这里权限,并且只为管理员和模组启用它

标签: discord.py


【解决方案1】:

正如stijndcl 在评论中解释的那样,最好的解决方案是直接进入您的服务器设置,只允许管理员和版主使用@everyone@here

如果您仍想使用机器人,可以使用on_message 处理程序轻松完成某些操作,然后检查消息作者的角色以删除或保留消息。

这种方法的问题是过滤过程是在消息发布之后完成的,因此删除未经授权的 ping 会创建ghost pings,因此会给您的服务器成员带来糟糕的体验(以及为什么当存在用于此确切目的的设置时会打扰)。

【讨论】:

    猜你喜欢
    • 2020-12-10
    • 1970-01-01
    • 2020-04-15
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多