【发布时间】:2021-02-20 16:02:14
【问题描述】:
我对 python 和 discord 非常陌生。下面的代码用于在用户键入 $create 时创建一个新频道。我只需要以某种方式获取新创建的频道的频道 ID 并将其打印在我的终端上。请帮忙....
@bot.command(name='create')
async def create_channel(ctx, channel_name='New-temporary'):
name = 'ideas' # this name is for which channel to put it in
category = discord.utils.get(ctx.guild.categories, name=name)
guild = ctx.guild
print(guild)
print(f'Creating a new channel: {channel_name}')
await asyncio.sleep(1)
await guild.create_text_channel(channel_name, category=category)
bot.run(TOKEN)
【问题讨论】: