diff --git a/src/commands/fun/counting.ts b/src/commands/fun/counting.ts index 773ee1d..d576637 100644 --- a/src/commands/fun/counting.ts +++ b/src/commands/fun/counting.ts @@ -104,7 +104,17 @@ const command: SubcommandCommand = { return; } - await setCount(count); + try { + await setCount(count); + await interaction.editReply({ + content: `Count has been set to **${count}**. The next number should be **${count + 1}**.`, + }); + } catch (error) { + await interaction.editReply({ + content: `Failed to set the count: ${error}`, + }); + } + await interaction.editReply({ content: `Count has been set to **${count}**. The next number should be **${count + 1}**.`, }); diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index e1049a5..d2dfccd 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -52,37 +52,38 @@ const command: OptionsCommand = { PermissionsBitField.Flags.BanMembers, ) ) { - await interaction.reply({ + await interaction.editReply({ content: 'You do not have permission to ban members.', - flags: ['Ephemeral'], }); return; } if (moderator.roles.highest.position <= member.roles.highest.position) { - await interaction.reply({ + await interaction.editReply({ content: 'You cannot ban a member with equal or higher role than yours.', - flags: ['Ephemeral'], }); return; } if (!member.bannable) { - await interaction.reply({ + await interaction.editReply({ content: 'I do not have permission to ban this member.', - flags: ['Ephemeral'], }); return; } + const config = loadConfig(); + const invite = interaction.guild.vanityURLCode ?? config.serverInvite; + const until = banDuration + ? new Date(Date.now() + parseDuration(banDuration)).toUTCString() + : 'indefinitely'; + try { await member.user.send( banDuration - ? `You have been banned from ${interaction.guild!.name} for ${banDuration}. Reason: ${reason}. You can join back at ${new Date( - Date.now() + parseDuration(banDuration), - ).toUTCString()} using the link below:\n${interaction.guild.vanityURLCode ?? loadConfig().serverInvite}` - : `You been indefinitely banned from ${interaction.guild!.name}. Reason: ${reason}.`, + ? `You have been banned from ${interaction.guild.name} for ${banDuration}. Reason: ${reason}. You can join back at ${until} using the link below:\n${invite}` + : `You been indefinitely banned from ${interaction.guild.name}. Reason: ${reason}.`, ); } catch (error) { console.error('Failed to send DM:', error); @@ -95,7 +96,7 @@ const command: OptionsCommand = { await scheduleUnban( interaction.client, - interaction.guild!.id, + interaction.guild.id, member.id, expiresAt, ); @@ -117,7 +118,7 @@ const command: OptionsCommand = { }); await logAction({ - guild: interaction.guild!, + guild: interaction.guild, action: 'ban', target: member, moderator, diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index 3778d96..ea7d386 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -22,7 +22,7 @@ const command: OptionsCommand = { execute: async (interaction) => { if (!interaction.isChatInputCommand() || !interaction.guild) return; - interaction.deferReply({ flags: ['Ephemeral'] }); + await interaction.deferReply({ flags: ['Ephemeral'] }); try { const userId = interaction.options.get('userid')?.value as string; @@ -38,6 +38,7 @@ const command: OptionsCommand = { }); return; } + try { const ban = await interaction.guild.bans.fetch(userId); if (!ban) { @@ -64,7 +65,7 @@ const command: OptionsCommand = { content: `<@${userId}> has been unbanned. Reason: ${reason}`, }); } catch (error) { - console.error(error); + console.error(`Unable to unban user: ${error}`); await interaction.editReply({ content: 'Unable to unban user.', }); diff --git a/src/commands/util/restart.ts b/src/commands/util/restart.ts index a8dbc91..b2bd091 100644 --- a/src/commands/util/restart.ts +++ b/src/commands/util/restart.ts @@ -27,7 +27,7 @@ const command: Command = { (role) => role.name === 'Manager', )?.roleId; - const member = await interaction.guild?.members.fetch(interaction.user.id); + const member = await interaction.guild.members.fetch(interaction.user.id); const hasManagerRole = member?.roles.cache.has(managerRoleId || ''); if ( diff --git a/src/commands/util/user-info.ts b/src/commands/util/user-info.ts index 9a222dd..f3d83d1 100644 --- a/src/commands/util/user-info.ts +++ b/src/commands/util/user-info.ts @@ -33,7 +33,7 @@ const command: OptionsCommand = { return; } if ( - !interaction.memberPermissions!.has( + !interaction.memberPermissions?.has( PermissionsBitField.Flags.ModerateMembers, ) ) {