如何仅使discord.py cog管理员?

时间:2020-07-24 21:22:19

标签: python python-3.x discord.py-rewrite

我为我的discord.py机器人制作了齿轮。但是,该类中有一些特定的命令我只想让管理员(经许可)。有没有办法让整个班级只成为管理员?代码:

const RenderIt = () => {
    let found = results.find(element => element.EMPLID === '345397')
    if (!found) return '';
    return (<div> {found.first_name} </div>)
}

谢谢

1 个答案:

答案 0 :(得分:2)

您可以覆盖现有的cog_check方法:

library(dplyr)
dat %>% 
    group_by(date) %>% 
    filter(!(n_distinct(group) > 1 & group == 1))
# A tibble: 5 x 4
# Groups:   date [4]
#  date       name     group total
#  <chr>      <chr>    <chr> <dbl>
#1 2020-07-21 ramsay   0       112
#2 2020-07-22 walton   0        56
#3 2020-07-23 franklin 0       215
#4 2020-07-24 allen    0       283
#5 2020-07-24 wilson   0        18

当调用命令时,它将触发此检查,然后根据是否返回 bottomNavigationBar: ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(40), topRight: Radius.circular(40)), child: Container( child: BottomAppBar( shape: CircularNotchedRectangle(), color: Colors.blue, child: SizedBox( height: height * 0.12, width: width, ), ), ), ), floatingActionButton: Container( margin: EdgeInsets.all(8), width: 80.0, height: 80.0, child: FloatingActionButton( onPressed: () {}, child: Icon( Icons.add, size: 25.0, ), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, from discord.ext import commands from discord.utils import get import bot class Member(commands.Cog): def __init__(self, client): self.client = client @commands.Cog.listener() async def on_ready(self): print(bot.online) async def cog_check(self, ctx): #Check if user has admin role admin = get(ctx.guild.roles, name="Admin") return admin in ctx.author.roles #Check if user has manage messages perm return ctx.author.guild_permissions.manage_messages @commands.command(aliases=['te']) async def test(self, ctx): await ctx.send("Test!") def setup(client): client.add_cog(Member(client)) ,它是否执行代码。如果返回True,您将在控制台中看到一条消息。

如果要检查特定的权限,可以使用Member.guild_permissionsFalse返回FalseMember.guild_permissions.(permission name)