如何将一个类别中的每个频道添加到嵌入频道?不和谐

2024-04-26 21:50:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我的计划是将特定类别中的每个频道添加到一个嵌入式系统中。每个月carlbot都会发布一个包含所有当前频道的嵌入,每个领域所有者都必须通过对他们的领域表情做出反应来进行登录。这就是一个例子:

领域类别:

#realm1-🐢

#realm2-🌞

#realm3-🟢


然后在我说>;签到

bot发送一个包含所有通道的嵌入

例: 使用你所在领域的表情符号进行反应以进行登录

realm1-(表情符号)

realm2-(表情符号)

realm3-(表情符号)


到目前为止,我唯一遇到的问题是收集该类别中的所有频道,并用它创建一个列表或其他东西。我对创建嵌入和所有东西都很在行,只需要将其提取并形成一个列表

我尝试了一下,得到了这个,但我不确定这是否正确

category = client.get_channel(id_here)

for channel in category.voice_channels:
    #something here> await channel.???

任何提示都会大有帮助


Tags: 列表here系统channel频道类别表情领域
1条回答
网友
1楼 · 发布于 2024-04-26 21:50:50
@client.command()
async def checkin(ctx):
    category = discord.utils.get(ctx.guild.categories, id=your_id_here)
    embed = discord.Embed(title='Realms channels')
    
    for channel in category.channels: # or text_channels or voice_channels
        realm, emoji = channel.name.split('-')
        embed.add_field(name=realm, value=emoji)

    await ctx.send(embed=embed)

如果我正确理解了你的问题,应该是这样的

相关问题 更多 >