You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord.py获取社区服务器规则与版主更新频道方法咨询

获取Discord社区服务器的规则频道与版主更新频道(discord.py)
  • 规则频道:使用Guild.rules_channel属性,返回对应规则频道的TextChannel实例,服务器未配置时返回None。
  • 版主更新频道:使用Guild.moderation_log_channel属性,返回对应版主日志(更新)频道的TextChannel实例,未配置时返回None。

代码示例

# 示例:通过命令获取当前服务器的目标频道
@bot.command()
async def fetch_community_channels(ctx):
    rules_channel = ctx.guild.rules_channel
    mod_updates_channel = ctx.guild.moderation_log_channel

    msg_parts = []
    if rules_channel:
        msg_parts.append(f"规则频道:{rules_channel.name}(ID: {rules_channel.id})")
    else:
        msg_parts.append("该服务器未设置规则频道")
    
    if mod_updates_channel:
        msg_parts.append(f"版主更新频道:{mod_updates_channel.name}(ID: {mod_updates_channel.id})")
    else:
        msg_parts.append("该服务器未设置版主更新频道")
    
    await ctx.send("\n".join(msg_parts))

内容的提问来源于stack exchange,提问作者Master Oogway

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 20:15:55