Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/apis/economy/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EconomyExecutor } from './action.ts';
import Money from '@/util/money.ts';
import { Ternary } from '@/defs.ts';
import { cfg } from '@/bot/cfg.ts';
import m from '@/util/mentions.ts';

export interface EconomyActionsFormatterConfig {
indentStep?: string;
Expand Down Expand Up @@ -40,7 +41,7 @@ export class MinimalActionsFormatter implements EconomyActionsFormatter {
case 'has-role': {
const role = this.ctx.getRoleById(cond.roleId);
if (!role) return null;
return `masz rolę <@&${role.discordRoleId}>`;
return `masz rolę ${m.role(role)}`;
}

case 'has-item': {
Expand Down Expand Up @@ -87,7 +88,7 @@ export class MinimalActionsFormatter implements EconomyActionsFormatter {
case 'rem-role': {
const role = this.ctx.getRoleById(action.roleId);
if (!role) break;
return `${this.isGood(action) ? 'rolę' : '**usunięcie** roli'} <@&${role.discordRoleId}>`;
return `${this.isGood(action) ? 'rolę' : '**usunięcie** roli'} ${m.role(role)}`;
}

case 'add-item':
Expand Down
3 changes: 2 additions & 1 deletion src/apis/mod/bans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PredefinedColors } from '@/util/color.ts';
import { sendLog } from '@/log/send-log.ts';

import User from '@/apis/db/user.ts';
import m from '@/util/mentions.ts';

export default async function ban(
member: dsc.GuildMember,
Expand Down Expand Up @@ -38,7 +39,7 @@ export default async function ban(
{
color: PredefinedColors.DarkGrey,
title: 'Zbanowano członka',
description: `Użytkownik <@${smember.id}> (${smember.user.username}) został zbanowany z serwera przez <@${data.mod}>!`,
description: `Użytkownik ${m.user(smember)} (${smember.user.username}) został zbanowany z serwera przez ${m.user(data.mod)}!`,
fields: [{ name: 'Powód', value: data.reason }],
},
);
Expand Down
4 changes: 3 additions & 1 deletion src/apis/mod/kicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ReplyEmbed } from '@/apis/translations/reply-embed.ts';
import { PredefinedColors } from '@/util/color.ts';
import { sendLog } from '@/log/send-log.ts';

import m from '@/util/mentions.ts';

export default async function kick(
member: dsc.GuildMember,
data: { reason: string; mod: dsc.Snowflake },
Expand All @@ -22,7 +24,7 @@ export default async function kick(
sendLog({
color: PredefinedColors.DarkGrey,
title: 'Wywalono członka',
description: `Użytkownik <@${member.id}> (${member.user.username}) został wyrzucony z serwera przez <@${data.mod}>!`,
description: `Użytkownik ${m.user(member)} (${member.user.username}) został wyrzucony z serwera przez ${m.user(data.mod)}!`,
fields: [{ name: 'Powód', value: data.reason }],
});
return bannedMember;
Expand Down
7 changes: 5 additions & 2 deletions src/apis/mod/muting.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import * as dsc from 'discord.js';

import { sendLog } from '@/log/send-log.ts';
import { PredefinedColors } from '@/util/color.ts';
import { cfg } from '@/bot/cfg.ts';

import m from '@/util/mentions.ts';

export default function mute(
member: dsc.GuildMember,
data: { reason: string; duration?: number; moderator: string; },
): Promise<dsc.GuildMember> {
sendLog({
color: PredefinedColors.Purple,
title: 'Użytkownik dostał mute',
description: `Użytkownik <@${member.id}> został wyciszony przez <@${data.moderator}>.`,
fields: [{ name: 'Powód', value: data.reason }, { name: 'Wygasa', value: `<t:${(Date.now() + (data.duration ?? 1))/1000}:R>` }],
description: `Użytkownik ${m.user(member)} został wyciszony przez ${m.user(data.moderator)}.`,
fields: [{ name: 'Powód', value: data.reason }, { name: 'Wygasa', value: `<t:${Date.now() + (data.duration ?? 1)/1000}:R>` }],
}, [ cfg.channels.mod.punishments ]);

return member.timeout(data.duration ?? null, data.reason);
Expand Down
19 changes: 8 additions & 11 deletions src/bot/level.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as dsc from 'discord.js';

import User from '@/apis/db/user.ts';

import actionsManager, { Action } from '@/features/actions.ts';
import { mkProgressBar } from '@/util/progressbar.ts';
import { findLowerClosestKey } from '@/util/objects/lower-closest-key.ts';
Expand All @@ -10,6 +8,9 @@ import { cfg } from '@/bot/cfg.ts';
import { client } from '@/client.ts';
import { output } from './logging.ts';

import User from '@/apis/db/user.ts';
import m from '@/util/mentions.ts';

export const OnSetXpEvent = actionsManager.mkEvent('OnSetXpEvent');
export interface XpEventCtx {
userID: dsc.Snowflake;
Expand All @@ -31,10 +32,6 @@ export function levelToXp(level: number, levelDivider: number = cfg.features.lev

export const lvlRoles = Object.values(cfg.features.leveling.milestoneRoles);

function getMention(user: dsc.GuildMember) {
return `<@${user.user.id}>`;
}

export function mkLvlProgressBar(xp: number, levelDivider: number, totalLength: number = 10): string {
const level = xpToLevel(xp, levelDivider);
const xpCurrentLevel = levelToXp(level, levelDivider);
Expand Down Expand Up @@ -138,7 +135,7 @@ export async function addExperiencePoints(msg: dsc.OmitPartialGroupDMChannel<dsc
const channelLvl = await msg.client.channels.fetch(cfg.channels.important.levels);
if (!channelLvl || !channelLvl.isSendable()) return;

let content = `${getMention(msg.member!)} wbił poziom ${newLevel}! Wow co za osiągnięcie!`;
let content = `${m.user(msg.member!)} wbił poziom ${newLevel}! Wow co za osiągnięcie!`;
if (gotNewRole) content += 'I btw nową rolę zdobyłeś!';
channelLvl.send(cfg.features.leveling.shallPingWhenNewLevel ? content : { content, allowedMentions: { parse: [] } });
}
Expand Down Expand Up @@ -182,16 +179,16 @@ const updateXpAction: Action<XpEventCtx> = {
const newLevel = xpToLevel(newXp, cfg.features.leveling.levelDivider);

if (newLevel > prevLevel) {
content = `Level użytkownika ${getMention(member)} został zmieniony i teraz ma aż ${newLevel} level!`;
content = `Level użytkownika ${m.user(member)} został zmieniony i teraz ma aż ${newLevel} level!`;
await addLvlRole(member.guild, newLevel, member.id);
} else if (newLevel < prevLevel) {
content = `Level użytkownika ${getMention(member)} został zmieniony, przez co cofnął się do levela ${newLevel}!`;
content = `Level użytkownika ${m.user(member)} został zmieniony, przez co cofnął się do levela ${newLevel}!`;
await addLvlRole(member.guild, newLevel, member.id);
} else {
if (prevXp == newXp) {
content = `Administrator próbował zmienić level użytkownika ${getMention(member)}, ale ma autyzm i ustawił dokladnie taki sam jaki był wcześniej czyli ${prevLevel} level. Nic tylko pogratulować`;
content = `Administrator próbował zmienić level użytkownika ${m.user(member)}, ale ma autyzm i ustawił dokladnie taki sam jaki był wcześniej czyli ${prevLevel} level. Nic tylko pogratulować`;
} else {
content = `Level użytkownika ${getMention(member)} został zmieniony, co prawda dalej ma ${prevLevel} level, ale tym razem ${newXp}xp zamiast ${prevXp}xp?` +
content = `Level użytkownika ${m.user(member)} został zmieniony, co prawda dalej ma ${prevLevel} level, ale tym razem ${newXp}xp zamiast ${prevXp}xp?` +
` Dobra przestane yappowac tych nerdowskich liczb i dam ci progress bar do następnego levela:` +
'\n' + mkLvlProgressBar(newXp, cfg.features.leveling.levelDivider);
}
Expand Down
6 changes: 4 additions & 2 deletions src/cmd/4fun/random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { CommandFlags } from '@/bot/command/misc.ts';
import { db, ContentEntry } from '@/apis/db/bot-db.ts';
import { cfg } from '@/bot/cfg.ts';

import m from '@/util/mentions.ts';

export default {
name: 'random',
aliases: ['rand'],
Expand Down Expand Up @@ -54,10 +56,10 @@ export default {
}

return api.reply({
content: `polecam zasugerowane przez <@${content.authorId}> ${content.contentUrl}`,
content: `polecam zasugerowane przez ${m.user(content.authorId)}: ${content.contentUrl}`,
allowedMentions: {
parse: [],
},
});
},
} satisfies Command;
} satisfies Command;
3 changes: 2 additions & 1 deletion src/cmd/4fun/votepin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ReplyEmbed } from '@/apis/translations/reply-embed.ts';

import User from '@/apis/db/user.ts';
import sleep from '@/util/sleep.ts';
import m from '@/util/mentions.ts';

const MIN_VOTES = 5;
const TIME = 120_000;
Expand Down Expand Up @@ -41,7 +42,7 @@ export default {
new ReplyEmbed()
.setTitle('📌 Przypnij wiadomość')
.setDescription([
`Użytkownik <@${api.executor.id}> chce przypiąć wiadomość od <@${quoted.author.id}>: https://discord.com/channels/${quoted.guildId}/${quoted.channelId}/${quoted.id}`,
`Użytkownik ${m.user(api.executor)} chce przypiąć wiadomość od ${m.user(quoted.author)}: https://discord.com/channels/${quoted.guildId}/${quoted.channelId}/${quoted.id}`,
'',
`**Głosów:** ${votes}/${MIN_VOTES}`,
`**Głosowanie wygasa** <t:${Math.floor(expiresAt / 1000)}:R>`
Expand Down
11 changes: 9 additions & 2 deletions src/cmd/dev/reset.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import * as dsc from 'discord.js';

import {
getErrorEmbed, getSuccessEmbed, getWarnEmbed,
} from '@/util/log.ts';

import { Command } from '@/bot/command.ts';
import { CommandFlags } from '@/bot/command/misc.ts';
import { CommandPermissions } from '@/bot/command/permissions.ts';
import { CommandAPI } from '@/bot/command/api.ts';

import { db } from '@/apis/db/bot-db.ts';
import { output } from '@/bot/logging.ts';
import { getErrorEmbed, getSuccessEmbed, getWarnEmbed } from '@/util/log.ts';
import { cfg } from '@/bot/cfg.ts';

import m from '@/util/mentions.ts';

export default {
name: 'reset',
aliases: [],
Expand Down Expand Up @@ -106,7 +113,7 @@ export default {
break;
}

const scopeText = userId ? `dla użytkownika <@${userId}>` : 'dla WSZYSTKICH użytkowników';
const scopeText = userId ? `dla użytkownika ${m.user(userId)}` : 'dla WSZYSTKICH użytkowników';
await interaction.update({
embeds: [getSuccessEmbed('Reset zakończony', `Pomyślnie zresetowano tabele **${table}** ${scopeText}.`)],
components: [],
Expand Down
9 changes: 7 additions & 2 deletions src/cmd/economy/ecomod.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { cfg } from '@/bot/cfg.ts';
import { db } from '@/apis/db/bot-db.ts';

import { Command } from '@/bot/command.ts';
import { CommandFlags } from '@/bot/command/misc.ts';

import User from '@/apis/db/user.ts';
import User from '@/apis/db/user.ts';
import Money from '@/util/money.ts';
import m from '@/util/mentions.ts';

export default {
name: 'ecomod',
Expand Down Expand Up @@ -88,6 +90,9 @@ export default {
await targetUser.economy.setBalance(bal);
});

return api.log.replySuccess(api, 'Operacja zakończona!', `Pomyślnie zmodyfikowałeś balans użytkownika <@${targetId}>, tak że ${actionToString()}. Przed tą operacją w tej lokalizacji miał ${before!.format()}.`)
return api.log.replySuccess(
api, 'Operacja zakończona!',
`Pomyślnie zmodyfikowałeś balans użytkownika ${m.user(targetId)}, tak że ${actionToString()}. Przed tą operacją w tej lokalizacji miał ${before!.format()}.`
)
},
} satisfies Command;
17 changes: 11 additions & 6 deletions src/cmd/economy/rob.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { db } from '@/apis/db/bot-db.ts';
import { output } from '@/bot/logging.ts';
import { getRandomFloat } from '@/util/math/rand.ts';

import { Command } from '@/bot/command.ts';
import { CommandFlags } from '@/bot/command/misc.ts';
import { PredefinedColors } from '@/util/color.ts';
import { output } from '@/bot/logging.ts';
import { ReplyEmbed } from '@/apis/translations/reply-embed.ts';
import Money from '@/util/money.ts';

import User from '@/apis/db/user.ts';
import Money from '@/util/money.ts';
import User from '@/apis/db/user.ts';
import m from '@/util/mentions.ts';

const CooldownMs = 5 * 60 * 1000;
const BaseSuccessChance = 0.5;
Expand Down Expand Up @@ -115,7 +116,7 @@ export default {
const embed = new ReplyEmbed()
.setColor(PredefinedColors.Yellow)
.setTitle('Cel jest zbyt biedny')
.setDescription(`<@${targetMember.id}> ma za mało pieniędzy (mniej niż ${MinStealable.format()}).`);
.setDescription(`${m.user(targetMember)} ma za mało pieniędzy (mniej niż ${MinStealable.format()}).`);
return api.reply({ embeds: [embed] });
}

Expand All @@ -125,12 +126,16 @@ export default {
const embed = new ReplyEmbed()
.setColor(result.success ? PredefinedColors.Green : PredefinedColors.Red)
.setTitle(result.success ? 'TAAAAAAAAAAAAAAAAK!' : 'System ochrony w banku się włączył.')
.setDescription(result.success ? `Udało Ci się ukraść <@${targetMember.id}> **${result.amount?.format()}** (${result.percent}%).` : `Nie udało Ci się nic ukraść od <@${targetMember.id}>!`);
.setDescription(
result.success
? `Udało Ci się ukraść ${m.user(targetMember)} **${result.amount?.format()}** (${result.percent}%).`
: `Nie udało Ci się nic ukraść od ${m.user(targetMember)}!`
);

return api.reply({ embeds: [embed] });
} catch (error) {
output.err(error);
return api.log.replyError(api, 'Coś się odwaliło...', 'Proszę, pytaj sqlite3 a nie mnie obwiniasz.');
}
},
} satisfies Command;
} satisfies Command;
6 changes: 4 additions & 2 deletions src/cmd/economy/topeco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import * as dsc from 'discord.js';

import { Command } from '@/bot/command.ts';
import { CommandFlags } from '@/bot/command/misc.ts';
import { ReplyEmbed } from '@/apis/translations/reply-embed.ts';

import { db } from '@/apis/db/bot-db.ts';
import { output } from '@/bot/logging.ts';
import { ReplyEmbed } from '@/apis/translations/reply-embed.ts';
import { cfg } from '@/bot/cfg.ts';

import m from '@/util/mentions.ts';

const ecoRoles = cfg.features.economy.roles.filter((x) => x.id.includes('vip')).map((x) => x.discordRoleId);

export default {
Expand Down Expand Up @@ -47,7 +49,7 @@ export default {
fields.push({
name: `${i} » ${member.user.username}`,
value: [
`${userEcoRole ? `<@&${userEcoRole}>` : `<@&${cfg.features.welcomer.freeRolesForEveryone[0]}>`}`,
userEcoRole ? m.role(userEcoRole) : m.role(cfg.features.welcomer.freeRolesForEveryone[0]),
`**${balance.wallet.add(balance.bank).format()}**`,
].join('\n'),
inline: true,
Expand Down
12 changes: 7 additions & 5 deletions src/cmd/economy/use.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import * as config from '@/bot/config/schema.ts';

import { Command } from '@/bot/command.ts';
import { CommandFlags } from '@/bot/command/misc.ts';
import { CommandAPI } from '@/bot/command/api.ts';
import { PredefinedColors } from '@/util/color.ts';
import { ReplyEmbed } from '@/apis/translations/reply-embed.ts';

import { output } from '@/bot/logging.ts';
import { formatEmoji } from 'discord.js';
import { cfg } from '@/bot/cfg.ts';

import * as config from '@/bot/config/schema.ts';

import Money from '@/util/money.ts';
import m from '@/util/mentions.ts';

export function formatAction(api: CommandAPI, action: config.economy.Action): ReplyEmbed | null {
const SuccessColor = PredefinedColors.Green;
Expand Down Expand Up @@ -41,15 +43,15 @@ export function formatAction(api: CommandAPI, action: config.economy.Action): Re
if (!role) return null;
return new ReplyEmbed()
.setTitle(`${SuccessEmoji} Dodano rolę`)
.setDescription(`Otrzymałeś rolę <@&${role.discordRoleId}>!\n\n**Opis:** ${role.desc}`)
.setDescription(`Otrzymałeś rolę ${m.role(role)}!\n\n**Opis:** ${role.desc}`)
.setColor(SuccessColor);
}
case 'rem-role': {
const role = api.economy.getRoleById(action.roleId);
if (!role) return null;
return new ReplyEmbed()
.setTitle(`${LossEmoji} Usunięto rolę`)
.setDescription(`Straciłeś rolę <@&${role.discordRoleId}>!\n\n**Opis:** ${role.desc}`)
.setDescription(`Straciłeś rolę ${m.role(role)}!\n\n**Opis:** ${role.desc}`)
.setColor(LossColor);
}

Expand Down Expand Up @@ -153,4 +155,4 @@ export default {
);
}
},
} satisfies Command;
} satisfies Command;
13 changes: 8 additions & 5 deletions src/cmd/general/add-primary-account.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import * as dsc from 'discord.js';

import { Command } from '@/bot/command.ts';
import { CommandFlags } from '@/bot/command/misc.ts';
import { CommandPermissions } from '@/bot/command/permissions.ts';

import * as dsc from 'discord.js';
import { db } from '@/apis/db/bot-db.ts';
import User from '@/apis/db/user.ts';
import { addLvlRole, xpToLevel } from '@/bot/level.ts';

import User from '@/apis/db/user.ts';
import m from '@/util/mentions.ts';

export default {
name: 'add-primary-account',
aliases: [],
Expand Down Expand Up @@ -63,7 +66,7 @@ export default {
embeds: [
api.log.getWarnEmbed(
'Ostrzeżenie',
`Właśnie zamierzasz **ODDAĆ CAŁY SWÓJ PROGRESS NA RZECZ UŻYTKOWNIKA <@${primary.id}>!**. Zasoby będą współdzielone pomiędzy Tymi dwoma kontami, co oznacza, że będziesz w stanie z dwóch kont korzystać np. ze swoich pieniędzy na ekonomii. Po transferze, cały twój indywidualny postęp **zostanie bezpowrotnie usunięty** z bazy danych, sprawiając, że jeżeli będziesz chciał się odłączyć, będziesz musiał to przeprowadzić z pomocą administracji i zaczynać od nowa...\n\n` +
`Właśnie zamierzasz **ODDAĆ CAŁY SWÓJ PROGRESS NA RZECZ UŻYTKOWNIKA ${m.user(primary)}!**. Zasoby będą współdzielone pomiędzy Tymi dwoma kontami, co oznacza, że będziesz w stanie z dwóch kont korzystać np. ze swoich pieniędzy na ekonomii. Po transferze, cały twój indywidualny postęp **zostanie bezpowrotnie usunięty** z bazy danych, sprawiając, że jeżeli będziesz chciał się odłączyć, będziesz musiał to przeprowadzić z pomocą administracji i zaczynać od nowa...\n\n` +
'Ta operacja jest **nieodwracalna**.',
),
],
Expand Down Expand Up @@ -152,7 +155,7 @@ export default {
embeds: [
api.log.getSuccessEmbed(
'Sukces',
`Od teraz <@${primary.id}> jest oficjalnie twym głównem kontem.\nJeżeli czegoś nie masz, poproś administrację o dodanie Ci tego na alcie.`,
`Od teraz ${m.user(primary)} jest oficjalnie twym głównem kontem.\nJeżeli czegoś nie masz, poproś administrację o dodanie Ci tego na alcie.`,
),
],
components: [],
Expand All @@ -170,4 +173,4 @@ export default {
}
});
},
} satisfies Command;
} satisfies Command;
Loading
Loading