Skip to content

Commit

Permalink
Add translation for mentioning users in information commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Delemangi committed Feb 10, 2025
1 parent a9b6995 commit 59e926d
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
11 changes: 5 additions & 6 deletions src/commands/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
type GuildMember,
roleMention,
SlashCommandBuilder,
userMention,
} from 'discord.js';

import {
Expand Down Expand Up @@ -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],
});
};
Expand All @@ -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],
});
};
Expand Down Expand Up @@ -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],
});
};
Expand All @@ -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],
});
};
Expand All @@ -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,
});
};
Expand Down
3 changes: 1 addition & 2 deletions src/commands/courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
type ChatInputCommandInteraction,
type GuildMember,
SlashCommandBuilder,
userMention,
} from 'discord.js';

import { getCoursesPrerequisiteEmbed } from '../components/commands.js';
Expand Down Expand Up @@ -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],
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/commands/link.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
type ChatInputCommandInteraction,
SlashCommandBuilder,
userMention,
} from 'discord.js';

import { getLinkComponents, getLinkEmbed } from '../components/commands.js';
import { getLink, getNthLink } from '../data/Link.js';
import {
commandDescriptions,
commandErrors,
commandResponseFunctions,
} from '../translations/commands.js';

const name = 'link';
Expand Down Expand Up @@ -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],
});
};
6 changes: 3 additions & 3 deletions src/commands/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
type ChatInputCommandInteraction,
SlashCommandBuilder,
userMention,
} from 'discord.js';

import {
Expand All @@ -13,6 +12,7 @@ import { getQuestions } from '../data/Question.js';
import {
commandDescriptions,
commandErrors,
commandResponseFunctions,
} from '../translations/commands.js';

const name = 'list';
Expand Down Expand Up @@ -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],
});
};
Expand All @@ -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],
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/commands/session.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
type ChatInputCommandInteraction,
SlashCommandBuilder,
userMention,
} from 'discord.js';
import { access } from 'node:fs/promises';

import { getSessions } from '../configuration/files.js';
import {
commandDescriptions,
commandErrors,
commandResponseFunctions,
} from '../translations/commands.js';

const name = 'session';
Expand Down Expand Up @@ -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],
});
};
4 changes: 2 additions & 2 deletions src/commands/staff.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
type ChatInputCommandInteraction,
SlashCommandBuilder,
userMention,
} from 'discord.js';

import { getStaffEmbed } from '../components/commands.js';
import { getStaff } from '../configuration/files.js';
import {
commandDescriptions,
commandErrors,
commandResponseFunctions,
} from '../translations/commands.js';

const name = 'staff';
Expand Down Expand Up @@ -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],
});
};
4 changes: 2 additions & 2 deletions src/shared/commands/classroom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
type ChatInputCommandInteraction,
SlashCommandBuilder,
userMention,
} from 'discord.js';

import { getClassroomEmbed } from '../../components/commands.js';
Expand All @@ -10,6 +9,7 @@ import { type Command } from '../../lib/types/Command.js';
import {
commandDescriptions,
commandErrors,
commandResponseFunctions,
} from '../../translations/commands.js';

export const getCommonCommand = (
Expand Down Expand Up @@ -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,
});
},
Expand Down
4 changes: 2 additions & 2 deletions src/shared/commands/faq.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
type ChatInputCommandInteraction,
SlashCommandBuilder,
userMention,
} from 'discord.js';

import {
Expand All @@ -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) => ({
Expand Down Expand Up @@ -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],
});
},
Expand Down
3 changes: 3 additions & 0 deletions src/translations/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
codeBlock,
type GuildPremiumTier,
inlineCode,
italic,
roleMention,
userMention,
} from 'discord.js';
Expand Down Expand Up @@ -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(
'НАПОМЕНА',
Expand Down

0 comments on commit 59e926d

Please sign in to comment.