如何解决'TextChannel'对象不可迭代|频道检查不起作用
您好,我正在尝试查看某个频道是否已经存在,而不是每次成员发送modmail请求时都创建一个新频道。我得到的错误是
EnvironmentPlugin
不确定为什么或方法不正确的一些方法。创建的通道名称是用户名和标识符。我要实现的目标是,如果该频道已经存在,不要在同一频道中创建另一个频道/帖子。
有帮助的人
这是我正在使用的代码:
File "C:\Users\User\Desktop\Build 1.0.2\cogs\modmail.py",line 145,in on_message
if get(modmailchannel,name=f"{message.author.name.lower()}{message.author.discriminator}"):
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\utils.py",line 271,in get
for elem in iterable:
TypeError: 'TextChannel' object is not iterable
enter code here
解决方法
代替get(modmailchannel,name=f"{message.author.name.lower()}{message.author.discriminator}"):
使用:
if modmailchannel.name == f"{message.author.name.lower()}{message.author.discriminator}":
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。