UnhandledPromiseRejectionWarning:DiscordAPIError:无法在RequestHandler.execute上发送空消息

时间:2020-07-18 15:35:05

标签: javascript arrays discord discord.js logical-operators

因此,我正在制作一个使用户静音的机器人,然后在达到静音人员提供的冷却时间时将其取消静音。这行代码不断给我错误:-

if (!args[1].endsWith('s') && !args[1].endsWith('m')) 
  return message.channel.send('Please specify seconds or minutes!');

该行用于检查时间是否以s(秒)和m(分钟)结尾,如果不是,则返回消息。但是,当我键入静音命令!mute @user 1s几秒钟时,它可以工作,但是在几分钟!mute @user 1m中却不起作用,它返回此错误:

UnhandledPromiseRejection警告:DiscordAPIError:无法发送 空消息

在RequestHandler.execute

1 个答案:

答案 0 :(得分:0)

您的线路对我有用,也许您的class C: counter = 0 # static variable def __init__(self): C.counter += 1 print(self.counter) 定义不明确? 这是我使用的代码:

c1 = C()
c1 = C()
c1 = C()