chore(bot): fixed remaining issues

This commit is contained in:
Ahmad 2025-04-17 01:24:52 -04:00
parent 7c2a99daf5
commit 77c4b75440
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
5 changed files with 29 additions and 17 deletions

View file

@ -104,7 +104,17 @@ const command: SubcommandCommand = {
return;
}
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}**.`,
});

View file

@ -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,

View file

@ -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.',
});

View file

@ -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 (

View file

@ -33,7 +33,7 @@ const command: OptionsCommand = {
return;
}
if (
!interaction.memberPermissions!.has(
!interaction.memberPermissions?.has(
PermissionsBitField.Flags.ModerateMembers,
)
) {