✨ utilities plugin avatar module
This commit is contained in:
parent
bc0bce4419
commit
52f5ae36c5
3 changed files with 80 additions and 24 deletions
|
@ -3,9 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders";
|
|||
import { CommandInteraction } from "discord.js";
|
||||
|
||||
// Modules
|
||||
import lookup from "./modules/lookup";
|
||||
import about from "./modules/about";
|
||||
import stats from "./modules/stats";
|
||||
import modules from "@plugins/utilities/modules";
|
||||
|
||||
// Handlers
|
||||
import logger from "../../logger";
|
||||
|
@ -16,30 +14,26 @@ export default {
|
|||
data: new SlashCommandBuilder()
|
||||
.setName("utilities")
|
||||
.setDescription("Common utilities.")
|
||||
.addSubcommand(lookup.data)
|
||||
.addSubcommand(about.data)
|
||||
.addSubcommand(stats.data),
|
||||
|
||||
.addSubcommand(modules.lookup.data)
|
||||
.addSubcommand(modules.about.data)
|
||||
.addSubcommand(modules.stats.data)
|
||||
.addSubcommand(modules.avatar.data),
|
||||
|
||||
async execute(interaction: CommandInteraction) {
|
||||
const { options } = interaction;
|
||||
|
||||
if (options?.getSubcommand() === "lookup") {
|
||||
logger.verbose(`Executing lookup subcommand`);
|
||||
|
||||
return lookup.execute(interaction);
|
||||
switch (options.getSubcommand()) {
|
||||
case "lookup":
|
||||
return modules.lookup.execute(interaction);
|
||||
case "about":
|
||||
return modules.about.execute(interaction);
|
||||
case "stats":
|
||||
return modules.stats.execute(interaction);
|
||||
case "avatar":
|
||||
return modules.avatar.execute(interaction);
|
||||
default:
|
||||
logger.error(`Unknown subcommand ${options.getSubcommand()}`);
|
||||
}
|
||||
|
||||
if (options?.getSubcommand() === "about") {
|
||||
logger.verbose(`Executing about subcommand`);
|
||||
|
||||
return about.execute(interaction);
|
||||
}
|
||||
|
||||
if (options?.getSubcommand() === "stats") {
|
||||
logger.verbose(`Executing stats subcommand`);
|
||||
|
||||
return stats.execute(interaction);
|
||||
}
|
||||
|
||||
logger.verbose(`No subcommand found.`);
|
||||
},
|
||||
};
|
||||
|
|
51
src/plugins/utilities/modules/avatar.ts
Normal file
51
src/plugins/utilities/modules/avatar.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||
import { hosterName, hosterUrl } from "@config/other";
|
||||
|
||||
import i18next from "i18next";
|
||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||
|
||||
export default {
|
||||
data: (command: SlashCommandSubcommandBuilder) => {
|
||||
return command
|
||||
.setName("avatar")
|
||||
.setDescription("Check someones avatar!)")
|
||||
.addUserOption((option) =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user whose avatar you want to check")
|
||||
);
|
||||
},
|
||||
execute: async (interaction: CommandInteraction) => {
|
||||
const { locale } = interaction;
|
||||
|
||||
const userOption = interaction.options.getUser("user");
|
||||
|
||||
const targetUser = userOption || interaction.user;
|
||||
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(
|
||||
i18next.t("utilities:modules:avatar:general:title", {
|
||||
lng: locale,
|
||||
ns: "plugins",
|
||||
})
|
||||
)
|
||||
.setTimestamp(new Date())
|
||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(
|
||||
i18next.t("utilities:modules:avatar:success01:description", {
|
||||
lng: locale,
|
||||
ns: "plugins",
|
||||
user: targetUser,
|
||||
})
|
||||
)
|
||||
.setThumbnail(targetUser.displayAvatarURL())
|
||||
.setColor(successColor),
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
11
src/plugins/utilities/modules/index.ts
Normal file
11
src/plugins/utilities/modules/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import avatar from "@plugins/utilities/modules/avatar";
|
||||
import about from "@plugins/utilities/modules/about";
|
||||
import lookup from "@plugins/utilities/modules/lookup";
|
||||
import stats from "@plugins/utilities/modules/stats";
|
||||
|
||||
export default {
|
||||
avatar,
|
||||
about,
|
||||
lookup,
|
||||
stats,
|
||||
};
|
Loading…
Add table
Reference in a new issue