[英]unban all command not responding
I want to make an unban all command in discord.js
v13 with reactions but whenever I have 0 bans in the server, it does not send the message that we have 0 bans and also, when I click on a reaction, it does not respond with anything我想在
discord.js
v13 中发出一个 unban all 命令并做出反应,但是每当我在服务器中有 0 个禁令时,它不会发送我们有 0 个禁令的消息,而且,当我点击一个反应时,它没有任何响应
const { MessageEmbed } = require("discord.js");
const Discord = require("discord.js");
const { parse } = require("twemoji-parser");
const JUGNU = require("../../../handlers/Client");
const { Queue } = require("distube");
module.exports = {
name: "unbanall",
aliases: ["allunban"],
description: `....`,
userPermissions: ['ADMINISTRATOR'],
botPermissions: ['EMBED_LINKS', "ADMINISTRATOR"],
category: "Mod",
cooldown: 5,
inVoiceChannel: false,
inSameVoiceChannel: false,
Player: false,
djOnly: false,
/**
*
* @param {JUGNU} client
* @param {Message} message
* @param {String[]} args
* @param {String} prefix
* @param {Queue} queue
*/
run: async (client, message, args, prefix, queue, interaction, com) => {
// Code
try {
if(message.author.id == message.guild.ownerId) {
const someembedlol = new MessageEmbed()
.setColor("RED")
.setTitle(`Remove Bans`)
.setDescription(`Please confirm that you wish to revoke all current server bans in this guild.\n\n**Note:** This process may take awhile, and cannot be easily stopped or un-done.\n\n**Do you still wish to continue?**\n✅ - Yes, remove all bans.\n❌ - No, cancel command.`)
.setThumbnail(`${client.user.displayAvatarURL({dynamic: true})}`)
.setTimestamp()
.setFooter({text: "copyright plusbot"})
message.channel.send({ embeds: [someembedlol] }).then(balls => {
balls.react('✅').then(() => balls.react('❌'));
const johncena = (reaction, user) => {
return ['✅', '❌'].includes(reaction.emoji.name) && user.bot == false && user.id === message.author.id;
};
balls.awaitReactions({ johncena, max: 1, time: ms("1m")}).then(collected => {
const react23847= collected.first();
if(react23847.emoji.name === '✅') {
message.channel.send({ content: `Please Wait! We are beginning the process now...` }).catch(e => {})
setTimeout(() => {
message.guild.bans.fetch().then(bans => {
if (bans.size == 0) {message.channel.send({ content: "There are no banned users." }); throw "No members to unban."};
bans.forEach(ban => {
message.guild.members.unban(ban.user.id);
})
}).then(() => console.log("Users are being unbanned.")).catch(e => console.log(e))
}, 6000);
}
if(react23847.emoji.name === '❌') {
return message.channel.send(`Cancelling update bans process...`).catch(e => {})
}
})
}).catch(e => {if(client.config.debugmode) return console.log(e);});
} else {
message.channel.send({ content: `Only the guild owner may use this command...` }).catch(e => {});
}
} catch (e) {
console.log(e)
}
}
}
I don't get any error in the console.我在控制台中没有收到任何错误。 When I click on the reaction, it still doesn't give any error
当我点击反应时,它仍然没有给出任何错误
When the ban list is empty it will undefined hence not calling your function afterwards.当禁止列表为空时,它将未定义,因此之后不会调用您的 function。 Try using
if (message.guilds.bans.fetch()) {your code} else {error message}
尝试使用
if (message.guilds.bans.fetch()) {your code} else {error message}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.