🎨 code smells fixed
This commit is contained in:
parent
0919ce9f78
commit
e658bd665b
1 changed files with 53 additions and 48 deletions
|
@ -1,14 +1,14 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { ColorResolvable, CommandInteraction } from "discord.js";
|
import { ColorResolvable, CommandInteraction } from 'discord.js';
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import config from "../../../../../config.json";
|
import config from '../../../../../config.json';
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
import logger from "../../../../handlers/logger";
|
import logger from '../../../../handlers/logger';
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
import counterSchema from "../../../../helpers/database/models/counterSchema";
|
import counterSchema from '../../../../helpers/database/models/counterSchema';
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default async (interaction: CommandInteraction) => {
|
export default async (interaction: CommandInteraction) => {
|
||||||
|
@ -16,29 +16,31 @@ export default async (interaction: CommandInteraction) => {
|
||||||
const { options, guild, user } = interaction;
|
const { options, guild, user } = interaction;
|
||||||
|
|
||||||
// Channel option
|
// Channel option
|
||||||
const optionChannel = options?.getChannel("channel");
|
const optionChannel = options?.getChannel('channel');
|
||||||
|
|
||||||
// Word option
|
// Word option
|
||||||
const optionWord = options?.getString("word");
|
const optionWord = options?.getString('word');
|
||||||
|
|
||||||
// Start option
|
// Start option
|
||||||
const optionStart = options?.getNumber("start");
|
const optionStart = options?.getNumber('start');
|
||||||
|
|
||||||
if (optionChannel?.type !== "GUILD_TEXT") {
|
if (optionChannel?.type !== 'GUILD_TEXT') {
|
||||||
const embed = {
|
// Return interaction reply
|
||||||
title: ":toolbox: Admin - Counters [Add]" as string,
|
return interaction?.editReply({
|
||||||
|
embeds: [
|
||||||
|
{
|
||||||
|
title: ':toolbox: Admin - Counters [Add]' as string,
|
||||||
description:
|
description:
|
||||||
"That channel is not supported, it needs to be a text channel." as string,
|
'That channel is not supported, it needs to be a text channel.' as string,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
color: config?.colors?.error as ColorResolvable,
|
color: config?.colors?.error as ColorResolvable,
|
||||||
footer: {
|
footer: {
|
||||||
iconURL: config?.footer?.icon as string,
|
iconURL: config?.footer?.icon as string,
|
||||||
text: config?.footer?.text as string,
|
text: config?.footer?.text as string,
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
|
],
|
||||||
// Return interaction reply
|
});
|
||||||
return interaction?.editReply({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const counterExist = await counterSchema?.findOne({
|
const counterExist = await counterSchema?.findOne({
|
||||||
|
@ -55,8 +57,16 @@ export default async (interaction: CommandInteraction) => {
|
||||||
counter: optionStart || 0,
|
counter: optionStart || 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const embed = {
|
// Log debug message
|
||||||
title: ":toolbox: Admin - Counters [Add]" as string,
|
logger?.debug(
|
||||||
|
`Guild: ${guild?.id} User: ${user?.id} added ${optionChannel?.id} as a counter using word "${optionWord}" for counting.`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Return interaction reply
|
||||||
|
return interaction?.editReply({
|
||||||
|
embeds: [
|
||||||
|
{
|
||||||
|
title: ':toolbox: Admin - Counters [Add]' as string,
|
||||||
description: `${optionChannel} is now counting when hearing word ${optionWord} and it starts at number ${
|
description: `${optionChannel} is now counting when hearing word ${optionWord} and it starts at number ${
|
||||||
optionStart || 0
|
optionStart || 0
|
||||||
}.`,
|
}.`,
|
||||||
|
@ -66,20 +76,16 @@ export default async (interaction: CommandInteraction) => {
|
||||||
iconURL: config?.footer?.icon as string,
|
iconURL: config?.footer?.icon as string,
|
||||||
text: config?.footer?.text as string,
|
text: config?.footer?.text as string,
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
|
],
|
||||||
// Log debug message
|
});
|
||||||
logger?.debug(
|
|
||||||
`Guild: ${guild?.id} User: ${user?.id} added ${optionChannel?.id} as a counter using word "${optionWord}" for counting.`
|
|
||||||
);
|
|
||||||
|
|
||||||
// Return interaction reply
|
|
||||||
return interaction?.editReply({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Embed object
|
// Return interaction reply
|
||||||
const embed = {
|
return interaction?.editReply({
|
||||||
title: ":toolbox: Admin - Counters [Add]" as string,
|
embeds: [
|
||||||
|
{
|
||||||
|
title: ':toolbox: Admin - Counters [Add]' as string,
|
||||||
description: `${optionChannel} is already a counting channel.`,
|
description: `${optionChannel} is already a counting channel.`,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
color: config?.colors?.error as ColorResolvable,
|
color: config?.colors?.error as ColorResolvable,
|
||||||
|
@ -87,8 +93,7 @@ export default async (interaction: CommandInteraction) => {
|
||||||
iconURL: config?.footer?.icon as string,
|
iconURL: config?.footer?.icon as string,
|
||||||
text: config?.footer?.text as string,
|
text: config?.footer?.text as string,
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
|
],
|
||||||
// Return interaction reply
|
});
|
||||||
return interaction?.editReply({ embeds: [embed] });
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue