如何打印新创建的不和谐文本频道的 ID?
How can I print the id of the newly created discord text channel?
我是 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)
create_text_channel
将 return 刚刚创建的频道。您可以通过以下方式获取id:
channel = await guild.create_text_channel(channel_name, category=category)
print(channel.id)
我是 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)
create_text_channel
将 return 刚刚创建的频道。您可以通过以下方式获取id:
channel = await guild.create_text_channel(channel_name, category=category)
print(channel.id)