Discord.js博特赠品命令:UnhandledPromiseRejectionWarning

时间:2021-01-06 18:56:43

标签: javascript node.js discord.js

我想代码赠品命令,但这个问题上弹出我的脸

<块引用>

(节点:2052)UnhandledPromiseRejectionWarning:类型错误: ARGS [1] .endswith不是函数(节点:2052) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。这 错误源于抛出异步函数内部 没有 catch 块,或者通过拒绝未处理的承诺 用 .catch()。在未处理的承诺上终止节点进程 排斥反应,使用CLI标志--unhandled-rejections=strict(见 https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)。 (拒收ID:1)(节点:2052)[DEP0018] DeprecationWarning:未处理 不推荐使用承诺拒绝。在未来,承诺拒绝 未办理将终止与Node.js的过程 非零退出代码。

client.on('message', async message => {
  let args = message.content.substring(prefix.length).split(" ")
  if(message.content.startsWith(`${prefix}giveaway`)) {
    let time = args[1]
    if(!time) return message.channel.send('**You did not specify your time!**');
    if(
    !args[1].endsWith('d') &&
    !args[1].endsWith('h') &&
    !args[1].endsWith('m') &&
    !args[1].endsWith('s')
   )
    return message.channel.send('**You need to use d (days), h (hours), m (minutes), s (seconds)**')

let gchannel = message.mentions.channels.first();
if(!gchannel) return message.channel.send('**I can not find this channel!**')

let prize = args.slice(3).join(" ")
if(!prize) return message.channel.send('**What is the prize?**')

message.delete();
gchannel.send(":tada: **NEW GIVEAWAY** :tada:")
let gembed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle('New GIVEAWAY!')
.setDescription(`react with :tada: to enter the giveaway! \nHosted by **${message.author}**\nTime: **${time}**`)
.setTimestamp(Date.now + ms(args[1]))
.setFooter('Will end at:')
let m = await gchannel.send(gembed)
m.react("?")
setTimeout(() => {
  if(m.reactions.cache.get("?").count <= 1) {
    return message.channel.send('**No enough people reacted for mr to draw a winner!**')
  }

let winner = m.reactions.cache.get("?").users.cache.filter((u) => !u.bot).random();
gchannel.send(`CONGRATULATIONS ${winner}! you just won the **${prize}!**`
);
}, ms(args[1]));
  }
   })

任何帮助,请

1 个答案:

答案 0 :(得分:0)