🧑💻 Fixed some more code smells
This commit is contained in:
parent
3333063a47
commit
6a5d480438
4 changed files with 22 additions and 42 deletions
|
@ -18,11 +18,17 @@ export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||||
// Destructure
|
// Destructure
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
if (options?.getSubcommandGroup() === "credits") {
|
switch (options.getSubcommandGroup()) {
|
||||||
return modules.credits.execute(interaction);
|
case "credits": {
|
||||||
}
|
await modules.credits.execute(interaction);
|
||||||
|
break;
|
||||||
if (options?.getSubcommandGroup() === "counters") {
|
}
|
||||||
return modules.counters.execute(interaction);
|
case "counters": {
|
||||||
|
await modules.counters.execute(interaction);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error("Could not find an module for the command.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
Message,
|
Message
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import encryption from "../../../../../helpers/encryption";
|
import encryption from "../../../../../helpers/encryption";
|
||||||
|
@ -206,35 +206,13 @@ export default {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(async (error) => {
|
.catch(() => {
|
||||||
logger?.silly(`Error saving new credits. - ${error}`);
|
throw new Error("Failed to update credits for user.")
|
||||||
|
|
||||||
const interactionEmbed = new EmbedBuilder()
|
|
||||||
.setTitle("[:shopping_cart:] CPGG")
|
|
||||||
.setDescription(`Something went wrong.`)
|
|
||||||
.setTimestamp()
|
|
||||||
.setColor(errorColor)
|
|
||||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
|
||||||
|
|
||||||
return interaction?.editReply({
|
|
||||||
embeds: [interactionEmbed],
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(async (error) => {
|
.catch(() => {
|
||||||
logger?.silly(`Error creating voucher. - ${error}`);
|
throw new Error("Failed generating an voucher.")
|
||||||
|
|
||||||
const interactionEmbed = new EmbedBuilder()
|
|
||||||
.setTitle("[:shopping_cart:] CPGG")
|
|
||||||
.setDescription(`Something went wrong.`)
|
|
||||||
.setTimestamp()
|
|
||||||
.setColor(errorColor)
|
|
||||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
|
||||||
|
|
||||||
return interaction?.editReply({
|
|
||||||
embeds: [interactionEmbed],
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
ColorResolvable,
|
ColorResolvable,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
GuildMemberRoleManager,
|
GuildMemberRoleManager
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
// Configurations
|
// Configurations
|
||||||
import getEmbedConfig from "../../../../../../../helpers/getEmbedData";
|
import getEmbedConfig from "../../../../../../../helpers/getEmbedData";
|
||||||
|
@ -110,8 +110,8 @@ export default {
|
||||||
embeds: [interactionEmbed],
|
embeds: [interactionEmbed],
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(async (error) => {
|
.catch(() => {
|
||||||
return logger?.silly(`Role could not be created. ${error}`);
|
throw new Error("Failed creating role.")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { ChannelType, Message } from "discord.js";
|
import { ChannelType, Message } from "discord.js";
|
||||||
import logger from "../../../../../middlewares/logger";
|
import logger from "../../../../../middlewares/logger";
|
||||||
import counterSchema from "../../../../../models/counter";
|
import counterSchema from "../../../../../models/counter";
|
||||||
import logger from "../../../../../middlewares/logger";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
execute: async (message: Message) => {
|
execute: async (message: Message) => {
|
||||||
|
@ -23,10 +22,7 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (counter === null) {
|
if (counter === null) {
|
||||||
logger.silly(
|
throw new Error("No counter found in database.");
|
||||||
`No counter found for guild ${guildId} and channel ${channelId}`
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -57,7 +53,7 @@ export default {
|
||||||
`Counter for guild ${guildId} and channel ${channelId} is now ${counter.counter}`
|
`Counter for guild ${guildId} and channel ${channelId} is now ${counter.counter}`
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(() => {
|
||||||
throw new Error(`Error saving counter to database.`);
|
throw new Error(`Error saving counter to database.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue