From 59e926d2ca11745c7091b497628c209e4e1f70bf Mon Sep 17 00:00:00 2001 From: Delemangi Date: Mon, 10 Feb 2025 21:02:35 +0100 Subject: [PATCH] Add translation for mentioning users in information commands --- src/commands/course.ts | 11 +++++------ src/commands/courses.ts | 3 +-- src/commands/link.ts | 4 ++-- src/commands/list.ts | 6 +++--- src/commands/session.ts | 4 ++-- src/commands/staff.ts | 4 ++-- src/shared/commands/classroom.ts | 4 ++-- src/shared/commands/faq.ts | 4 ++-- src/translations/commands.ts | 3 +++ 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/commands/course.ts b/src/commands/course.ts index 6f50243..47cb749 100644 --- a/src/commands/course.ts +++ b/src/commands/course.ts @@ -3,7 +3,6 @@ import { type GuildMember, roleMention, SlashCommandBuilder, - userMention, } from 'discord.js'; import { @@ -153,7 +152,7 @@ const handleCourseParticipants = async ( const embed = getCourseParticipantsEmbed(information); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; @@ -176,7 +175,7 @@ const handleCourseProfessors = async ( const embed = getCourseProfessorsEmbed(information); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; @@ -242,7 +241,7 @@ const handleCoursePrerequisite = async ( const embed = getCoursePrerequisiteEmbed(information); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; @@ -265,7 +264,7 @@ const handleCourseInfo = async ( const embed = getCourseInfoEmbed(information); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; @@ -284,7 +283,7 @@ const handleCourseSummary = async ( const embeds = getCourseSummaryEmbed(course); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds, }); }; diff --git a/src/commands/courses.ts b/src/commands/courses.ts index fdc1430..1b0bd54 100644 --- a/src/commands/courses.ts +++ b/src/commands/courses.ts @@ -2,7 +2,6 @@ import { type ChatInputCommandInteraction, type GuildMember, SlashCommandBuilder, - userMention, } from 'discord.js'; import { getCoursesPrerequisiteEmbed } from '../components/commands.js'; @@ -70,7 +69,7 @@ const handleCoursesPrerequisite = async ( const embed = getCoursesPrerequisiteEmbed(course); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; diff --git a/src/commands/link.ts b/src/commands/link.ts index 375063f..a1b8288 100644 --- a/src/commands/link.ts +++ b/src/commands/link.ts @@ -1,7 +1,6 @@ import { type ChatInputCommandInteraction, SlashCommandBuilder, - userMention, } from 'discord.js'; import { getLinkComponents, getLinkEmbed } from '../components/commands.js'; @@ -9,6 +8,7 @@ import { getLink, getNthLink } from '../data/Link.js'; import { commandDescriptions, commandErrors, + commandResponseFunctions, } from '../translations/commands.js'; const name = 'link'; @@ -45,7 +45,7 @@ export const execute = async (interaction: ChatInputCommandInteraction) => { const components = getLinkComponents(link); await interaction.editReply({ components, - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; diff --git a/src/commands/list.ts b/src/commands/list.ts index 137c75e..1c4f9dd 100644 --- a/src/commands/list.ts +++ b/src/commands/list.ts @@ -1,7 +1,6 @@ import { type ChatInputCommandInteraction, SlashCommandBuilder, - userMention, } from 'discord.js'; import { @@ -13,6 +12,7 @@ import { getQuestions } from '../data/Question.js'; import { commandDescriptions, commandErrors, + commandResponseFunctions, } from '../translations/commands.js'; const name = 'list'; @@ -54,7 +54,7 @@ const handleListQuestions = async ( const embed = getListQuestionsEmbed(questions); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; @@ -74,7 +74,7 @@ const handleListLinks = async (interaction: ChatInputCommandInteraction) => { const embed = getListLinksEmbed(links); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; diff --git a/src/commands/session.ts b/src/commands/session.ts index eadf5a7..277bef2 100644 --- a/src/commands/session.ts +++ b/src/commands/session.ts @@ -1,7 +1,6 @@ import { type ChatInputCommandInteraction, SlashCommandBuilder, - userMention, } from 'discord.js'; import { access } from 'node:fs/promises'; @@ -9,6 +8,7 @@ import { getSessions } from '../configuration/files.js'; import { commandDescriptions, commandErrors, + commandResponseFunctions, } from '../translations/commands.js'; const name = 'session'; @@ -52,7 +52,7 @@ export const execute = async (interaction: ChatInputCommandInteraction) => { } await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, files: [path], }); }; diff --git a/src/commands/staff.ts b/src/commands/staff.ts index 276c6fd..c90536b 100644 --- a/src/commands/staff.ts +++ b/src/commands/staff.ts @@ -1,7 +1,6 @@ import { type ChatInputCommandInteraction, SlashCommandBuilder, - userMention, } from 'discord.js'; import { getStaffEmbed } from '../components/commands.js'; @@ -9,6 +8,7 @@ import { getStaff } from '../configuration/files.js'; import { commandDescriptions, commandErrors, + commandResponseFunctions, } from '../translations/commands.js'; const name = 'staff'; @@ -43,7 +43,7 @@ export const execute = async (interaction: ChatInputCommandInteraction) => { const embed = getStaffEmbed(information); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }; diff --git a/src/shared/commands/classroom.ts b/src/shared/commands/classroom.ts index 8bc46d2..c4ac526 100644 --- a/src/shared/commands/classroom.ts +++ b/src/shared/commands/classroom.ts @@ -1,7 +1,6 @@ import { type ChatInputCommandInteraction, SlashCommandBuilder, - userMention, } from 'discord.js'; import { getClassroomEmbed } from '../../components/commands.js'; @@ -10,6 +9,7 @@ import { type Command } from '../../lib/types/Command.js'; import { commandDescriptions, commandErrors, + commandResponseFunctions, } from '../../translations/commands.js'; export const getCommonCommand = ( @@ -51,7 +51,7 @@ export const getCommonCommand = ( const embeds = classrooms.map((cl) => getClassroomEmbed(cl)); await interaction.editReply({ - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds, }); }, diff --git a/src/shared/commands/faq.ts b/src/shared/commands/faq.ts index 301cfcb..2dc46aa 100644 --- a/src/shared/commands/faq.ts +++ b/src/shared/commands/faq.ts @@ -1,7 +1,6 @@ import { type ChatInputCommandInteraction, SlashCommandBuilder, - userMention, } from 'discord.js'; import { @@ -12,6 +11,7 @@ import { getNthQuestion, getQuestion } from '../../data/Question.js'; import { commandDescriptions, commandErrors, + commandResponseFunctions, } from '../../translations/commands.js'; export const getCommonCommand = (name: keyof typeof commandDescriptions) => ({ @@ -47,7 +47,7 @@ export const getCommonCommand = (name: keyof typeof commandDescriptions) => ({ const components = getQuestionComponents(question); await interaction.editReply({ components, - content: user ? userMention(user.id) : null, + content: user ? commandResponseFunctions.commandFor(user.id) : null, embeds: [embed], }); }, diff --git a/src/translations/commands.ts b/src/translations/commands.ts index df99cda..594f8d5 100644 --- a/src/translations/commands.ts +++ b/src/translations/commands.ts @@ -3,6 +3,7 @@ import { codeBlock, type GuildPremiumTier, inlineCode, + italic, roleMention, userMention, } from 'discord.js'; @@ -170,6 +171,8 @@ export const commandResponseFunctions = { colorAddedOrRemoved: (roleId: string, added: boolean) => `Ја ${added ? 'земавте' : 'отстранивте'} бојата ${roleMention(roleId)}.`, + commandFor: (userId: string) => italic(`за ${userMention(userId)}`), + courseAdded: (roleId: string) => `Го земавте предметот ${roleMention(roleId)}. ${bold( 'НАПОМЕНА',