尝试删除频道时,Discord.py重写,“。delete()”命令给出错误

时间:2018-12-21 17:51:56

标签: python python-3.x discord.py discord.py-rewrite

我一直在研究一款Discord机器人,但遇到了一个问题。 创建频道(票证)就可以了,但是当我要删除某个频道时,即使我做了一个if语句,它仍然关闭了所有频道:

if message.content.lower().startswith('!close'):
    close = message.channel.id
    if close == '521992786187255818' or close == '525730667607228426' or close ==... (etc):
        await message.channel.send("This command is only allowed in a ticket channel!")
    elif close != '521992786187255818' or close != '525730667607228426' or close !=...(etc):
        await message.channel.delete(reason='Ticket Closed')

我已经尝试了所有可以想到的方法:制作不希望其显示在列表中的频道。

所以问题是:我希望!close命令仅关闭我未列出的通道。但是,当我在列出的通道(在if语句中输入的通道)中尝试时,它仍然关闭。

希望我能得到答案! 在此先感谢:)

1 个答案:

答案 0 :(得分:0)

在重写分支中,all ids are integers, not strings。将您的代码更改为

non_ticket_channels = [521992786187255818, 525730667607228426, ...]

if close in non_ticket_channels:
    ...
else:
    ...