gpt4 book ai didi

Python-将 channel 添加到类别

转载 作者:太空宇宙 更新时间:2023-11-03 20:47:13 25 4
gpt4 key购买 nike

我正在尝试创建一个将在类别中创建的 channel ,但我尝试过的方法没有奏效

代码相当大,所以我不会展示所有内容,只是添加 channel

@client.command()
@has_permissions(kick_members=True)
async def warn(ctx, member:discord.Member, *, reason=None):
arg=reason
author=ctx.author
guild=ctx.message.guild
overwritee = discord.PermissionOverwrite()
overwrite = discord.PermissionOverwrite()
channel = get(guild.text_channels, name='warn-logs')
category = get(guild.category_channels, name='Multi-Logs')
mrole = get(ctx.guild.roles, name="Multi-Galaxy")

if category is None:
category = await guild.create_category_channel("Multi-Logs")
overwritee.read_messages = False
overwritee.read_message_history = False
overwritee.send_messages = False
overwrite.read_messages = True
overwrite.read_message_history = True
overwrite.send_messages = True
await channel.set_permissions(guild.default_role, overwrite=overwritee)
await channel.set_permissions(mrole, overwrite=overwrite)
if channel is None:
channel = await guild.create_text_channel('warn-logs')
overwritee.read_messages = False
overwritee.read_message_history = False
overwritee.send_messages = False
overwrite.read_messages = True
overwrite.read_message_history = True
overwrite.send_messages = True
await channel.set_permissions(guild.default_role, overwrite=overwritee)
await channel.set_permissions(mrole, overwrite=overwrite)

它只是创建彼此分开的类别和 channel ,因此该 channel 不在该类别中

最佳答案

只需在create_text_channel中传入一个类别即可:

if channel is None:
channel = await guild.create_text_channel('warn-logs', category=category)
# ^^^^^^^^^^^^^^^^^
# keyword-argument––––^^^^^^^^
# your-variable––––––––––^^^^^^^^

关于Python-将 channel 添加到类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56508041/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com