Merge pull request #429 from VermiumSifell/dev
🧑💻 Fixed some more code smells
This commit is contained in:
commit
0554893e78
8 changed files with 51 additions and 39 deletions
|
@ -151,9 +151,7 @@ export default {
|
|||
|
||||
// Save toUser
|
||||
await toUser?.save()?.then(async () => {
|
||||
logger?.silly(`Saved toUser`);
|
||||
|
||||
return interaction?.editReply({
|
||||
await interaction?.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setTitle("[:toolbox:] Manage - Credits (Take)")
|
||||
|
@ -165,6 +163,7 @@ export default {
|
|||
.setFooter({ text: footerText, iconURL: footerIcon }),
|
||||
],
|
||||
});
|
||||
return;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -10,13 +10,17 @@ export const builder = new SlashCommandBuilder()
|
|||
|
||||
.addSubcommand(modules.prune.builder);
|
||||
|
||||
// Execute the command
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case "prune":
|
||||
return modules.prune.execute(interaction);
|
||||
default:
|
||||
case "prune": {
|
||||
await modules.prune.execute(interaction);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new Error(
|
||||
`Unknown subcommand: ${interaction.options.getSubcommand()}`
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@ import { ChatInputCommandInteraction } from "discord.js";
|
|||
import modules from "../../commands/profile/modules";
|
||||
|
||||
// Handlers
|
||||
import logger from "../../../middlewares/logger";
|
||||
|
||||
export const moduleData = modules;
|
||||
|
||||
|
@ -16,14 +15,17 @@ export const builder = new SlashCommandBuilder()
|
|||
.setDescription("Check a profile.")
|
||||
.addSubcommand(modules.view.builder);
|
||||
|
||||
// Execute the command
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
const { options } = interaction;
|
||||
|
||||
if (options?.getSubcommand() === "view") {
|
||||
logger?.silly(`Executing view subcommand`);
|
||||
|
||||
return modules.view.execute(interaction);
|
||||
switch (options.getSubcommand()) {
|
||||
case "view": {
|
||||
await modules.view.execute(interaction);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new Error("Could not find module for that command");
|
||||
}
|
||||
}
|
||||
|
||||
logger?.silly(`No subcommand found`);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { User } from "discord.js";
|
||||
|
||||
export default async (to: User | null, from: User | null) => {
|
||||
export default (to: User | null, from: User | null) => {
|
||||
if (from?.id === to?.id) {
|
||||
throw new Error("You cannot give reputation to yourself.");
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import { ChatInputCommandInteraction } from "discord.js";
|
|||
import modules from "./modules";
|
||||
|
||||
// Handlers
|
||||
import logger from "../../../middlewares/logger";
|
||||
|
||||
export const moduleData = modules;
|
||||
|
||||
|
@ -17,20 +16,27 @@ export const builder = new SlashCommandBuilder()
|
|||
.addSubcommand(modules.cpgg.builder)
|
||||
.addSubcommandGroup(modules.roles.builder);
|
||||
|
||||
// Execute the command
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
const { options } = interaction;
|
||||
|
||||
if (options?.getSubcommand() === "cpgg") {
|
||||
logger.silly(`Executing cpgg subcommand`);
|
||||
|
||||
return modules.cpgg.execute(interaction);
|
||||
switch (options.getSubcommand()) {
|
||||
case "cpgg": {
|
||||
await modules.cpgg.execute(interaction);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new Error("Could not find module for that command.");
|
||||
}
|
||||
}
|
||||
|
||||
if (options?.getSubcommandGroup() === "roles") {
|
||||
logger?.silly(`Subcommand group is roles`);
|
||||
|
||||
return modules.roles.execute(interaction);
|
||||
switch (options.getSubcommandGroup()) {
|
||||
case "roles": {
|
||||
await modules.roles.execute(interaction);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new Error("Could not find module for that command.");
|
||||
}
|
||||
}
|
||||
|
||||
logger?.silly(`No subcommand found.`);
|
||||
};
|
||||
|
|
|
@ -13,16 +13,21 @@ export const builder = new SlashCommandBuilder()
|
|||
.addSubcommand(modules.avatar.builder)
|
||||
.addSubcommand(modules.ping.builder);
|
||||
|
||||
// Execute the command
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case "about":
|
||||
return modules.about.execute(interaction);
|
||||
await modules.about.execute(interaction);
|
||||
break;
|
||||
case "stats":
|
||||
return modules.stats.execute(interaction);
|
||||
await modules.stats.execute(interaction);
|
||||
break;
|
||||
case "avatar":
|
||||
return modules.avatar.execute(interaction);
|
||||
await modules.avatar.execute(interaction);
|
||||
break;
|
||||
case "ping":
|
||||
return modules.ping.execute(interaction);
|
||||
await modules.ping.execute(interaction);
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Unknown subcommand: ${interaction.options.getSubcommand()}`
|
||||
|
|
|
@ -48,12 +48,10 @@ export default {
|
|||
]),
|
||||
],
|
||||
})
|
||||
.then(async () => {
|
||||
logger.debug(
|
||||
`Audit log sent for event guildMemberAdd in guild ${member.guild.name} (${member.guild.id})`
|
||||
);
|
||||
.then(() => {
|
||||
logger.debug(`Audit log sent for event guildMemberAdd`);
|
||||
})
|
||||
.catch(async () => {
|
||||
.catch(() => {
|
||||
throw new Error("Audit log failed to send");
|
||||
});
|
||||
},
|
||||
|
|
|
@ -48,12 +48,10 @@ export default {
|
|||
]),
|
||||
],
|
||||
})
|
||||
.then(async () => {
|
||||
logger.debug(
|
||||
`Audit log sent for event guildMemberRemove in guild ${member.guild.name} (${member.guild.id})`
|
||||
);
|
||||
.then(() => {
|
||||
logger.debug(`Audit log sent for event guildMemberRemove.`);
|
||||
})
|
||||
.catch(async () => {
|
||||
.catch(() => {
|
||||
throw new Error("Audit log failed to send");
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue