Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Discord.py检查频道是否在类别中_Python_Discord_Discord.py - Fatal编程技术网

Python Discord.py检查频道是否在类别中

Python Discord.py检查频道是否在类别中,python,discord,discord.py,Python,Discord,Discord.py,因此,我正在创建一个命令,其中bot将检查该命令是否在特定类别中运行。如果是,则bot将继续执行该命令。如果不是,bot会说“不允许”。我该怎么做?text频道有 属性,使用它获取频道当前所在类别的id,然后您可以使用它获取类别频道,然后您可以匹配discord.CategoryChannel.name,它用您的字符串表示类别名称。reddy上的discord.py from discord.ext import commands cl = commands.Bot(command_prefix

因此,我正在创建一个命令,其中bot将检查该命令是否在特定类别中运行。如果是,则bot将继续执行该命令。如果不是,bot会说“不允许”。我该怎么做?

text频道有 属性,使用它获取频道当前所在类别的id,然后您可以使用它获取类别频道,然后您可以匹配discord.CategoryChannel.name,它用您的字符串表示类别名称。

reddy上的discord.py

from discord.ext import commands
cl = commands.Bot(command_prefix = ':')
tk = <token>

@cl.event
async def on_ready():
  print('Logged in as Bot#1234')
// Runs when bot is online 


cl.run(tk)
请试试这个 欲了解更多解释,请访问


告诉我它是否适合你

你能详细说明你想做什么吗?我想检查一下该频道是否属于特定类别。嗯。。。这与我的问题无关。这并不能回答这个问题。若要评论或要求作者澄清,请在其帖子下方留下评论-
bot.event
async def on_ready():
  await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=""))