我正试图在我的discord机器人上建立一个“窃窃私语”系统,为频道上的一些成员提供一条耳聋和解除耳聋的捷径
现在,这是我的代码:
from typing import Optional
from discord import Member
from discord.ext.commands import Cog, Greedy
from discord.ext.commands import CheckFailure
from discord.ext.commands import command, has_permissions, bot_has_permissions, MissingPermissions
from ..db import db
class Mod(Cog):
def __init__(self, bot):
self.bot = bot
@command(description = 'I will deafen the person mentioned, Restriction to GM role', name = 'deaf')
@bot_has_permissions(administrator = True, manage_roles=True, deafen_members = True)
async def deaf_members(self, ctx, targets: Greedy[Member], *, reason: Optional[str] = 'The master is whispering!'):
if targets (deafen = False):
await targets.edit(deafen = True)
await ctx.send(f"{targets.mention} can't hear anymore")
@Cog.listener()
async def on_ready(self):
if not self.bot.ready:
self.bot.cogs_ready.ready_up('mod')
def setup(bot):
bot.add_cog(Mod(bot))
我遇到的问题是,每次我尝试运行该命令时,它都会说我缺少deafen_members
权限。但是我已经在代码和bot-dev页面中授予了它管理员权限。
我希望你能帮助我,如果可能的话,有人能向我解释,除了我想传达信息的人之外,我怎样才能让每个人都耳聋,从而通过这个命令提高生活质量
目前没有回答
相关问题 更多 >
编程相关推荐