【问题标题】:Specific channel message without ID in discord pydiscord py中没有ID的特定频道消息
【发布时间】:2021-09-27 00:50:01
【问题描述】:

我正在使用我的机器人创建一个命令,该命令使机器人创建一个频道,我希望它在新创建的频道上发送消息,但我还没有找到任何方法让它在没有频道的情况下发送消息身份证。

假设我第一条消息应该在命令开始的通道上,但第二条消息应该在机器人创建的通道上,这不会发生,我不能给它一个 id 因为它创建通道。提前致谢。

我从命令中得到的是这样的:

async def avengers(ctx):
    guild = ctx.message.guild
    embed = discord.Embed(title='¿Listos?',  color=discord.Color.purple())
    await ctx.send(embed=embed)
    await guild.create_text_channel('『????』chat-anticristiano')
    for channel in ctx.guild.channels:
    if str(channel) == '『????』chat-anticristiano':
        channel = '『????』chat-anticristiano'
        for channel in ctx.guild.channels:
            await ctx.channel.send('Ready!')

【问题讨论】:

    标签: python visual-studio-code discord discord.py


    【解决方案1】:

    您可以像这样在创建时指定频道:

    new_channel = await ctx.guild.create_text_channel('『?』chat-anticristiano')
    await new_channel.send("Ready!")
    

    【讨论】:

      猜你喜欢
      • 2020-10-01
      • 2021-07-06
      • 2020-04-07
      • 2020-10-01
      • 2023-03-27
      • 2021-10-28
      • 2020-07-06
      • 2021-11-11
      • 2020-05-18
      相关资源
      最近更新 更多