Implement leveling and economy features with associated models and commands

- Added new models for leveling and economy functionalities in the Prisma schema, including LevelingConfig, MemberLevel, LevelReward, EconomyConfig, MemberEconomy, ShopItem, and InventoryItem.
- Introduced commands for managing XP, economy transactions, and shop interactions, enhancing user engagement.
- Updated job handling to include reminders and poll closing functionalities.
- Enhanced localization support for new commands and features in both German and English.
- Improved the bot's job processing capabilities with a dedicated reminder worker for scheduled tasks.
This commit is contained in:
smueller
2026-07-22 12:49:17 +02:00
parent 2518119257
commit fa5910ec43
38 changed files with 6759 additions and 144 deletions

View File

@@ -0,0 +1,50 @@
import { ContextMenuCommandBuilder, ApplicationCommandType } from 'discord.js';
import { t } from '@nexumi/shared';
import type { BotContext, ContextMenuCommand } from '../../types.js';
import { getGuildLocale } from '../../i18n.js';
async function translateText(text: string, targetLang: string): Promise<string | null> {
const url = new URL('https://api.mymemory.translated.net/get');
url.searchParams.set('q', text.slice(0, 500));
url.searchParams.set('langpair', `auto|${targetLang}`);
const response = await fetch(url.toString());
if (!response.ok) {
return null;
}
const data = (await response.json()) as {
responseData?: { translatedText?: string };
};
return data.responseData?.translatedText ?? null;
}
const translateContextMenu: ContextMenuCommand = {
data: new ContextMenuCommandBuilder()
.setName('Translate')
.setType(ApplicationCommandType.Message),
async execute(interaction, context) {
const locale = await getGuildLocale(context.prisma, interaction.guildId);
const content = interaction.targetMessage.content;
if (!content?.trim()) {
await interaction.reply({ content: t(locale, 'utility.translate.noContent'), ephemeral: true });
return;
}
const targetLang = locale === 'de' ? 'de' : 'en';
const translated = await translateText(content, targetLang);
if (!translated) {
await interaction.reply({ content: t(locale, 'utility.translate.failed'), ephemeral: true });
return;
}
await interaction.reply({
content: t(locale, 'utility.translate.result').replace('{text}', translated),
ephemeral: true
});
}
};
export const utilityContextMenus: ContextMenuCommand[] = [translateContextMenu];