forked from amanv8060/DSCKIIT-BOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listbans.js
53 lines (51 loc) · 1.86 KB
/
listbans.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Copyright 2021 Aman Verma. All rights reserved.
Use of this source code is governed by a MIT license that can be
found in the LICENSE file.
*/
const { MessageEmbed } = require("discord.js");
module.exports = {
name: "listbans",
run: async (client, message, args) => {
if (!message.member.permissions.has("BAN_MEMBERS"))
message.channel.send(
"You don't have permission to use that command."
);
else {
try {
let bans = await message.guild.bans.fetch();
bans = [...bans.values()];
if (bans.length === 0) {
return message.channel.send("No users banned till now");
}
let embed = new MessageEmbed();
embed.setTitle("Banned Users");
embed.setColor(0xff0000);
embed.setFooter(`${message.guild.name} | ${message.guild.id}`);
embed.setTimestamp();
embed.setThumbnail(message.guild.iconURL());
embed.setAuthor(
message.author.tag,
message.author.displayAvatarURL
);
embed.setDescription("List of Banned Users");
for (let ban of bans) {
embed.addField(
`${ban.user.tag} (${ban.user.id})`,
ban.reason !== null
? `${ban.reason}`
: "No reason provided"
);
}
message.channel.send({ embeds: [embed] });
} catch (err) {
console.log(err);
message.channel.send(
"Some Error Occurred , Please inform the issue "
);
}
}
},
aliases: [],
description: "Lists all banned users"
};