我尝试使用bulkDelete
让我的机器人删除其消息,但我收到此错误:
(node:5724) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Bad Request
(node:5724) 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.
这是我的代码:
const Discord = require('discord.js');
const bot = new Discord.Client();
const config = require("./config.json");
bot.on('ready', () =>{
console.log('I am ready!');
});
//var cleanarr=[];
bot.on("message", message =>{
if (message.author.bot) return;
var cleanarr=[];
let command = message.content.split(" ")[0];
command = command.slice(config.prefix.length);
let args = message.content.split(" ").slice(1);
if (message.content == 'lol'){
message.channel.sendMessage('LUL');
cleanarr.unshift(`${message.channel.lastMessageID}`);
}
if (command == "clean") {
message.channel.sendMessage('Cleaning...');
message.channel.bulkDelete(cleanarr);
var cleanarr = [];
批量删除需要什么?是消息id还是其他什么?
我不知道我这样做是否正确(显然我不是),因为我开始编码时对 javascript 或任何相关知识都是零。
最简单的删除方法x
来自通道的消息是提供一个整数2 - 100
作为参数<TextChannel>.bulkDelete https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=bulkDelete method.
Example:
message.channel.bulkDelete(100).then(() => {
message.channel.send("Deleted 100 messages.").then(msg => msg.delete(3000));
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)