【问题标题】:While I try to add second id to channel.id the command does not send on it当我尝试将第二个 id 添加到 channel.id 时,命令不会发送
【发布时间】:2023-01-05 22:54:10
【问题描述】:

就像标题中一样。当我向 channel.id 添加第二个 id 时,命令不会发送它。

@client.command()
async def test(ctx):
  if ctx.channel.id == 1234567890:
    await ctx.send('testing')

  else:
    await ctx.send('wrong channel')

现在,当我尝试将另一个 id 添加到:

  if ctx.channel.id == 1234567890, 0987654321:

这是行不通的。

我尝试将 [] 和 "" 添加到 ids 但它不起作用。

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您可以使用列表和 in 运算符来检查多个频道 ID。

    if ctx.channel.id in [1234567890, 0987654321]:
        await ctx.send('testing')
    

    【讨论】:

      猜你喜欢
      • 2013-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-17
      • 1970-01-01
      • 2012-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多