💥 user language is now presented via discord lang
This commit is contained in:
parent
f0dec60687
commit
bc0bce4419
3 changed files with 2 additions and 111 deletions
|
@ -4,7 +4,6 @@ import { CommandInteraction } from "discord.js";
|
|||
|
||||
// Groups
|
||||
import guildGroup from "./guild";
|
||||
import userGroup from "./user";
|
||||
|
||||
// Handlers
|
||||
import logger from "@logger";
|
||||
|
@ -15,8 +14,8 @@ export default {
|
|||
data: new SlashCommandBuilder()
|
||||
.setName("settings")
|
||||
.setDescription("Manage settings.")
|
||||
.addSubcommandGroup(guildGroup.data)
|
||||
.addSubcommandGroup(userGroup.data),
|
||||
|
||||
.addSubcommandGroup(guildGroup.data),
|
||||
|
||||
async execute(interaction: CommandInteraction) {
|
||||
const { options } = interaction;
|
||||
|
@ -27,12 +26,6 @@ export default {
|
|||
return guildGroup.execute(interaction);
|
||||
}
|
||||
|
||||
if (options.getSubcommandGroup() === "user") {
|
||||
logger.verbose(`Executing user subcommand`);
|
||||
|
||||
return userGroup.execute(interaction);
|
||||
}
|
||||
|
||||
logger.verbose(`No subcommand group found`);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// Dependencies
|
||||
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
||||
import { CommandInteraction } from "discord.js";
|
||||
|
||||
// Handlers
|
||||
import logger from "@logger";
|
||||
|
||||
// Modules
|
||||
import appearance from "./modules/appearance";
|
||||
|
||||
// Function
|
||||
export default {
|
||||
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
||||
return group
|
||||
.setName("user")
|
||||
.setDescription("User settings.")
|
||||
.addSubcommand((command) =>
|
||||
command
|
||||
.setName("appearance")
|
||||
.setDescription("User appearance settings.")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("language")
|
||||
.setDescription("Set the language.")
|
||||
.addChoice("English", "en")
|
||||
.addChoice("Swedish", "sv")
|
||||
)
|
||||
);
|
||||
},
|
||||
execute: async (interaction: CommandInteraction) => {
|
||||
const { options } = interaction;
|
||||
|
||||
if (options?.getSubcommand() === "appearance") {
|
||||
logger?.verbose(`Executing appearance subcommand`);
|
||||
|
||||
await appearance(interaction);
|
||||
}
|
||||
|
||||
logger?.verbose(`No subcommand found`);
|
||||
},
|
||||
};
|
|
@ -1,61 +0,0 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction } from "discord.js";
|
||||
|
||||
// Configurations
|
||||
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||
|
||||
// Handlers
|
||||
import logger from "@logger";
|
||||
|
||||
// Models
|
||||
import fetchUser from "@helpers/fetchUser";
|
||||
|
||||
// Function
|
||||
export default async (interaction: CommandInteraction) => {
|
||||
// Destructure member
|
||||
const { options, user, guild } = interaction;
|
||||
|
||||
// Get options
|
||||
const language = options?.getString("language");
|
||||
|
||||
if (guild === null) {
|
||||
return logger?.verbose(`Guild is null`);
|
||||
}
|
||||
|
||||
// Get user object
|
||||
const userDB = await fetchUser(user, guild);
|
||||
|
||||
if (userDB === null) {
|
||||
return logger?.verbose(`User is null`);
|
||||
}
|
||||
|
||||
// Modify values
|
||||
userDB.language = language !== null ? language : userDB?.language;
|
||||
|
||||
// Save guild
|
||||
await userDB?.save()?.then(async () => {
|
||||
logger?.verbose(`Updated user language.`);
|
||||
|
||||
return interaction?.editReply({
|
||||
embeds: [
|
||||
{
|
||||
title: ":hammer: Settings - User [Appearance]",
|
||||
description: "Successfully updated user settings.",
|
||||
color: successColor,
|
||||
fields: [
|
||||
{
|
||||
name: "🏳️🌈 Language",
|
||||
value: `${userDB?.language}`,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
timestamp: new Date(),
|
||||
footer: {
|
||||
iconURL: footerIcon,
|
||||
text: footerText,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
};
|
Loading…
Add table
Reference in a new issue