【发布时间】:2021-05-30 22:21:28
【问题描述】:
代码:
const discord = require('discord.js')
module.exports.run = async (bot, message, args) =>{
message.delete()
if(!message.member.roles.some(r=> ["TESTER"].includes(r.name)) ) {
return message.reply(`<:prohibited:814861316715839488> você não tem permissão de fazer isso!`)
}
let mensagem = args.join(' ')
if(!args[0]) {
return message.reply(`<:prohibited:814861316715839488> você não adicionou algo para ser avisado!`)
}
var embed = new discord.RichEmbed()
.setColor("RANDOM")
.setAuthor('SERVER - AVISO', bot.user.avatarURL)
.setDescription(mensagem)
.setFooter(message.author.username, message.author.avatarURL)
.setTimestamp()
.setThumbnail(bot.user.avatarURL)
bot.channels.cache.get(`786364360071053403`).send('@everyone').then(m =>{
m.delete(100)
})
bot.channels.cache.get(`786364360071053403`).send(embed);
}
module.exports.config = {
name: 'anuncio',
aliases: ['anunciar', 'sendbell']
}
错误:
(node:3196) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied options is not an object.
at Message.delete (C:\Users\Pc\Desktop\RemakeTO\node_modules\discord.js\src\structures\Message.js:577:60)
at C:\Users\Pc\Desktop\RemakeTO\comandos\staffbell.js:21:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3196) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3196) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我做错了什么?有人能帮我吗?向 Discord.JS v12 的过渡让我很困惑!发送和删除“@everyone”时出现错误。我不知道如何解决它。
【问题讨论】:
-
How do I ask a good question?:“写一个总结具体问题的标题”
-
错误很明显:“提供的选项不是对象”
Message.delete。只有一个地方您尝试删除消息...
标签: javascript node.js discord discord.js