Ney*_*iev 2 javascript bots bulk discord discord.js
我尝试使用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.
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
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 = [];
Run Code Online (Sandbox Code Playgroud)
批量删除需要什么?是消息ID还是其他什么?
我不知道我这样做是否正确(显然我不是),因为我开始编码时对 javascript 或任何相关知识的了解为零。
x
从通道中删除消息的最简单方法是提供一个整数 from2 - 100
作为<TextChannel>.bulkDelete
方法的参数。
例子:
message.channel.bulkDelete(100).then(() => {
message.channel.send("Deleted 100 messages.").then(msg => msg.delete(3000));
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
25509 次 |
最近记录: |