Skip to content

Commit

Permalink
feat(bot): ban info command
Browse files Browse the repository at this point in the history
closes #379
  • Loading branch information
Blumlaut committed May 17, 2022
1 parent 28577ad commit 01a3928
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions server/bot/commands/baninfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@


module.exports = {
data: new SlashCommandBuilder()
.setName('baninfo')
.setDescription('Shows details of a ban')
.addIntegerOption(option =>
option.setName('banid')
.setDescription('Ban ID')
.setRequired(true)),
async execute(interaction, exports) {
const banId = interaction.options.getInteger('banid')

var ban = await exports[EasyAdmin].fetchBan(banId)
if (ban) {

// TODO: embed


var embed = new EmbedBuilder()
.setColor((65280))
.setTimestamp()

var discordAccount = false
for (let identifier of ban.identifiers) {
if (identifier.search("discord:") != -1) {
discordAccount = await client.users.fetch(identifier.substring(identifier.indexOf(":") + 1))
}
}

embed.addFields({ name: 'Ban Info', value: `Ban infos for **#${banId}**`})
embed.addFields({ name: 'Username', value: `\`\`\`${ban.name}\`\`\``, inline: true})
if (discordAccount) {
embed.addFields({ name: 'Discord Account', value: `\`\`\`${discordAccount.tag}\`\`\``, inline: true})
embed.setThumbnail(discordAccount.avatarURL())
}
embed.addFields({ name: 'Banned by', value: `\`\`\`${ban.banner}\`\`\``, inline: true})
embed.addFields({ name: 'Reason', value: `\`\`\`\n${ban.reason}\`\`\``, inline: false})
embed.addFields({ name: 'Expires', value: `\`\`\`${ban.expireString}\`\`\``, inline: true})


interaction.reply({ embeds: [embed]})


} else {
var embed = await prepareGenericEmbed(`No ban was found with this ID.`)
interaction.reply({ embeds: [embed]})
}
},
};

0 comments on commit 01a3928

Please sign in to comment.