Added unban command
This commit is contained in:
28
src/events/autocomplete/unban.js
Normal file
28
src/events/autocomplete/unban.js
Normal file
@@ -0,0 +1,28 @@
|
||||
module.exports = {
|
||||
name: "unban",
|
||||
description: "Unban a user from the server",
|
||||
type: "autocomplete",
|
||||
|
||||
/** @param { import("discord.js").AutocompleteInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
if (!interaction.isAutocomplete()) return
|
||||
if (interaction.commandName !== "unban") return
|
||||
const focusedOption = interaction.options.getFocused(true)
|
||||
if (focusedOption.name !== "user") return
|
||||
|
||||
console.log
|
||||
|
||||
const bannedUsers = await interaction.guild.bans.fetch()
|
||||
const filteredUsers = bannedUsers.filter((user) =>
|
||||
user.user.username.toLowerCase().includes(focusedOption.value.toLowerCase())
|
||||
)
|
||||
|
||||
const results = filteredUsers.map((user) => ({
|
||||
name: user.user.username,
|
||||
value: user.user.id,
|
||||
}))
|
||||
|
||||
await interaction.respond(results.slice(0, 25)).catch((err) => { console.log(err) })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user