[英]Make a category on a server with a BOT inside the discord.py API
I am new to Python (and, of course to discord.py), and I didn't really find any documentation on websites or on the official Discord for this question. 我是Python的新手(当然是discord.py的新手),在这个问题上,我在网站或官方Discord上都没有真正找到任何文档。
I was wondering if there is any function inside discord.py that would create a category on a server ( client.get_server('295959610043531264')
) 我想知道client.get_server('295959610043531264')
内部是否有任何函数可以在服务器上创建类别( client.get_server('295959610043531264')
)
Thanks a lot ;) 非常感谢 ;)
You can create categories and channel simple with this code. 您可以使用此代码创建类别和渠道。
the command: !new category admin-chat 命令:!new category admin-chat
@client.command()
async def new(ctx, arg1, arg2):
guild = ctx.message.guild
if arg1 == "channel":
await guild.create_text_channel(arg2)
elif arg1 == "category":
await ctx.guild.create_category(arg2)
You can only create categories with the rewrite version of discord.py ( 1.0.0a ) 您只能使用重写版本discord.py ( 1.0.0a )创建类别。
Here is the documentation for it. 这是它的文档。
This would be an example of how I would do it with the commands extension: 这将是我如何使用命令扩展名执行此操作的示例:
@bot.command()
async def create_category(ctx, *, name):
await ctx.guild.create_category(name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.