基本上就是标题中所说的。我想获得一个频道对象,并且我有频道 ID,以数字和 <# 和 > 的形式。我如何从 discord.py 中的任何一个获取频道对象?
答案 0 :(得分:1)
通过将其存储在 this_channel 变量中,您可以获得可以在 on_message 或任务循环或命令中使用的通道 ID,然后通过该命令,它可以检索该变量和消息,无论您想要什么从那里到频道。
this_channel = ctx.channel.id
channel = client.get_channel(int(this_channel))
await channel.send('Heres the message')
答案 1 :(得分:0)
如果您想提及或获取其名称或 ID,您不会在如何使用频道对象中包含太多其他内容:
@client.command()
async def channel(ctx):
channel_name = ctx.channel.mention
channel_id = ctx.channel.id
await ctx.send("""
Channel name: {channel_name}
Channel ID: {channel_id}
""")