如何检查所有者是否在discord.py中 [英] How to check if owner in discord.py

查看:0
本文介绍了如何检查所有者是否在discord.py中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在只有所有者可以运行的情况下执行此命令。是否要检查服务器的最高角色或创建者?

我尝试了"@Commands.is_Owner()",但这只检查某人是否为机器人的所有者。

推荐答案

您可以使用装饰符:

@commands.has_role("RoleName")

示例:

import discord
from discord.ext import commands
from discord.ext.commands.core import command

@bot.command
@commands.has_role("RoleName")
async def ...(ctx)
    await ctx.send("your message")

如果有效,请让我知道!

编辑:您还可以导入所有内容:

import discord
from discord import user
from discord.ext import commands
from discord.ext.commands.core import command
from discord.member import Member
from discord.message import Message
from discord.user import User

这篇关于如何检查所有者是否在discord.py中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆