Skip to content

Commit

Permalink
fix: minor command bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolutionX-10 committed Feb 3, 2025
1 parent b60672c commit 2165559
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
12 changes: 9 additions & 3 deletions src/commands/Moderation/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type BaseModActionData, PermissionLevels, RadonEvents } from '#lib/type
import { runAllChecks, sec } from '#lib/utility';
import { ApplyOptions } from '@sapphire/decorators';
import { type APIApplicationCommandOptionChoice, PermissionFlagsBits } from 'discord-api-types/v9';
import { type User, InteractionContextType, MessageFlags } from 'discord.js';
import { type User, GuildMember, InteractionContextType, MessageFlags } from 'discord.js';

@ApplyOptions<RadonCommand.Options>({
description: `Ban a user`,
Expand All @@ -25,7 +25,7 @@ export class UserCommand extends RadonCommand {
];

public override chatInputRun(interaction: RadonCommand.ChatInputCommandInteraction) {
const user = interaction.options.getUser('user', true);
const user = interaction.options.getMember('user') ?? interaction.options.getUser('user', true);
const reason = interaction.options.getString('reason') ?? undefined;
const days = interaction.options.getInteger('days') ?? 0;
const dm = interaction.options.getBoolean('dm') ?? false;
Expand Down Expand Up @@ -84,7 +84,13 @@ export class UserCommand extends RadonCommand {
);
}

private async ban(interaction: RadonCommand.ChatInputCommandInteraction, user: User, reason: string | undefined, days: number, dm = false) {
private async ban(
interaction: RadonCommand.ChatInputCommandInteraction,
user: GuildMember | User,
reason: string | undefined,
days: number,
dm = false
) {
let content = `${Emojis.Confirm} ${user} has been [banned](https://tenor.com/view/11035060) ${
reason ? `for the following reason: __${reason}__` : ''
}`;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/Moderation/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class UserCommand extends RadonCommand {
let content = `${Emojis.Confirm} ${member} has been timed out for ${new DurationFormatter().format(duration)}`;

const reason = interaction.options.getString('reason') ?? undefined;
await member.timeout(duration, reason);
await member.timeout(duration === 0 ? null : duration, reason);

if (duration !== 0 && dm) {
await member
Expand Down
2 changes: 1 addition & 1 deletion src/lib/structures/classes/Confirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class Confirmation {
if (id !== i.user.id) {
await i.reply({
content: this.options.wrongUserResponse ?? 'Not for you!',
ephemeral: true
flags: MessageFlags.Ephemeral
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utility/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const config: Config = {
},
partials: [Partials.GuildMember, Partials.Message, Partials.User, Partials.Channel],
logger: {
level: LogLevel.Debug
level: LogLevel.Info
},
// botlist: {
// keys: {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utility/functions/modperms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Emojis } from '#constants';
import { GuildMember, User } from 'discord.js';
import { isAdmin } from './permissions.js';
import { isAdmin, isGuildOwner } from './permissions.js';
/**
* Runs all checks before executing a moderation command
* @param executor The member who executed the command
Expand All @@ -13,9 +13,9 @@ export function runAllChecks(executor: GuildMember, target: GuildMember | User,
if (target instanceof User) {
result = true;
content = '';
} else if (!target.manageable || isAdmin(target)) {
result = false;
} else if (!target.manageable || isAdmin(target) || isGuildOwner(target)) {
content = `${Emojis.Cross} I can't ${action} ${target}`;
result = false;
} else if (executor.roles.highest.position === target.roles.highest.position) {
content = `${Emojis.Cross} You can't ${action} ${target}`;
result = false;
Expand Down
2 changes: 1 addition & 1 deletion src/listeners/System/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class UserListener extends Listener {
this.container.logger.info(`Logged in as ${fruit(client.user!.username)}`);
this.printBanner();
this.container.logger.info(`${greenBright('[')}${blueBright('READY')}${greenBright(']')}`);
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.VerboseOverwrite);
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.LogToConsole);
const guilds = client.guilds.cache;
for (const guild of guilds.values()) {
guild.settings = new GuildSettings(guild, this.container.prisma);
Expand Down

0 comments on commit 2165559

Please sign in to comment.