Merge branch 'dev' into 'main'
Bug fix for unban See merge request illegitimate/illegitimate-bot!126
This commit is contained in:
@@ -36,6 +36,7 @@ module.exports = {
|
||||
const reason = interaction.options.getString("reason") || "No reason provided"
|
||||
const mod = interaction.user
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
let user
|
||||
|
||||
if (userid === "none") {
|
||||
await interaction.editReply({
|
||||
@@ -47,7 +48,17 @@ module.exports = {
|
||||
return
|
||||
}
|
||||
|
||||
const user = await interaction.client.users.fetch(userid)
|
||||
try {
|
||||
user = await interaction.client.users.fetch(userid)
|
||||
} catch (error) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "The user you specified is not valid",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
await interaction.guild.members.unban(user.id, reason)
|
||||
|
||||
await interaction.editReply({
|
||||
|
||||
@@ -6,7 +6,6 @@ module.exports = {
|
||||
/** @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
|
||||
|
||||
@@ -14,7 +14,19 @@ function loadAutocompleteEvents(client) {
|
||||
const autocomplete = require(filePath)
|
||||
|
||||
if ("name" in autocomplete && "execute" in autocomplete && autocomplete.type === "autocomplete") {
|
||||
client.on(Events.InteractionCreate, autocomplete.execute)
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isAutocomplete()) return
|
||||
|
||||
try {
|
||||
await autocomplete.execute(interaction)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
await interaction.respond({
|
||||
content: "There was an error while executing this command!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log(`[WARNING] The autocomplete at ${filePath} is missing a required "name", "execute" or "type" property.`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user