diff --git a/apps/discord/src/commands/slash/economy/ShopProfileCommand.js b/apps/discord/src/commands/slash/economy/ShopProfileCommand.js index 704f9f40b..4a3db5b16 100644 --- a/apps/discord/src/commands/slash/economy/ShopProfileCommand.js +++ b/apps/discord/src/commands/slash/economy/ShopProfileCommand.js @@ -40,7 +40,7 @@ export default class ShopProfileCommand extends Command { componentSelected: '', profileType: user.profileType, married: user.isMarry, - partnerName: marryWith ? `${marryWith?.username}#${marryWith.discriminator}` : '', + partnerName: marryWith ? `@${marryWith?.username}` : '', user, marryWith, avatar, diff --git a/apps/discord/src/commands/slash/mod/AnnounceCommand.js b/apps/discord/src/commands/slash/mod/AnnounceCommand.js index bfd68db78..75eb68dc0 100644 --- a/apps/discord/src/commands/slash/mod/AnnounceCommand.js +++ b/apps/discord/src/commands/slash/mod/AnnounceCommand.js @@ -47,7 +47,7 @@ export default class AnnounceCommand extends Command { embed.setColor('DEFAULT') embed.setAuthor(guild.name, guild.iconURL) embed.setDescription(announce) - embed.setFooter(ctx._locale('commands:announce.embedSendBy', { 0: `${ctx.message.member.username}#${ctx.message.member.discriminator}` }), ctx.message.member.avatarURL) + embed.setFooter(ctx._locale('commands:announce.embedSendBy', { 0: `@${ctx.message.member.username}` }), ctx.message.member.avatarURL) const everyone = new Button() everyone.setStyle(1) everyone.setLabel(ctx._locale('commands:announce.mentionEveryone')) diff --git a/apps/discord/src/commands/slash/mod/BanCommand.js b/apps/discord/src/commands/slash/mod/BanCommand.js index e51a2180e..141faeffb 100644 --- a/apps/discord/src/commands/slash/mod/BanCommand.js +++ b/apps/discord/src/commands/slash/mod/BanCommand.js @@ -40,7 +40,7 @@ export default class BanCommand extends Command { const member = await ctx.getUser(ctx.args.get('user').value?.id ?? ctx.args.get('user').value) const guildMember = ctx.message.guild.members.get(member.id) const reason = ctx._locale('basic:punishment.reason', { - 0: `${ctx.message.member.user.username}#${ctx.message.member.user.discriminator}`, 1: ctx.args.get('reason') ? + 0: `@${ctx.message.member.user.username}`, 1: ctx.args.get('reason') ? ctx.args.get('reason').value : ctx._locale('basic:noReason') }) let quantity = ctx.args.get('message_days')?.value @@ -56,9 +56,9 @@ export default class BanCommand extends Command { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(ctx._locale('basic:punishment.banned', { 0: `${member.username}#${member.discriminator}` })) - embed.addField(ctx._locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(ctx._locale('basic:punishment.embed.staffName'), `${ctx.message.member.username}#${ctx.message.member.discriminator} (\`${ctx.message.member.id}\`)`) + embed.setTitle(ctx._locale('basic:punishment.banned', { 0: `@${member.username}` })) + embed.addField(ctx._locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(ctx._locale('basic:punishment.embed.staffName'), `@${ctx.message.member.username} (\`${ctx.message.member.id}\`)`) embed.addField(ctx._locale('basic:punishment.embed.reason'), ctx.args.get('reason')?.value ?? ctx._locale('basic:noReason')) ctx.send(embed.build()) diff --git a/apps/discord/src/commands/slash/mod/BanInfoCommand.js b/apps/discord/src/commands/slash/mod/BanInfoCommand.js index b56e55ca7..a36d1153f 100644 --- a/apps/discord/src/commands/slash/mod/BanInfoCommand.js +++ b/apps/discord/src/commands/slash/mod/BanInfoCommand.js @@ -42,7 +42,7 @@ export default class BanInfoCommand extends Command { embed.setColor('MODERATION') embed.setThumbnail(member.user.avatarURL) embed.setTitle(ctx._locale('commands:baninfo.title')) - embed.addField(ctx._locale('commands:baninfo.memberName'), `${member.user.username}#${member.user.discriminator} (\`${member.user.id}\`)`) + embed.addField(ctx._locale('commands:baninfo.memberName'), `@${member.user.username} (\`${member.user.id}\`)`) embed.addField(ctx._locale('commands:baninfo.reason'), member.reason ? member.reason : ctx._locale('basic:noReason')) const unban = new Button() .setStyle(4) @@ -70,13 +70,13 @@ export default class BanInfoCommand extends Command { } unban(guild, member, ctx, ack) { - guild.unbanMember(member.user.id, ctx._locale('basic:punishment.reason', { 0: `${ctx.message.member.user.username}#${ctx.message.member.user.discriminator}`, 1: ctx._locale('basic:noReason') })).then(() => { + guild.unbanMember(member.user.id, ctx._locale('basic:punishment.reason', { 0: `@${ctx.message.member.user.username}`, 1: ctx._locale('basic:noReason') })).then(() => { const unbanEmbed = new EmbedBuilder() unbanEmbed.setColor('MODERATION') unbanEmbed.setThumbnail(member.user.avatarURL) - unbanEmbed.setTitle(ctx._locale('basic:punishment.unbanned', { 0: `${member.user.username}#${member.user.discriminator}` })) - unbanEmbed.addField(ctx._locale('basic:punishment.embed.memberName'), `${member.user.username}#${member.user.discriminator} (\`${member.user.id}\`)`) - unbanEmbed.addField(ctx._locale('basic:punishment.embed.staffName'), `${ctx.message.member.user.username}#${ctx.message.member.user.discriminator} (\`${ctx.message.member.user.id}\`)`) + unbanEmbed.setTitle(ctx._locale('basic:punishment.unbanned', { 0: `@${member.user.username}` })) + unbanEmbed.addField(ctx._locale('basic:punishment.embed.memberName'), `@${member.user.username} (\`${member.user.id}\`)`) + unbanEmbed.addField(ctx._locale('basic:punishment.embed.staffName'), `@${ctx.message.member.user.username} (\`${ctx.message.member.user.id}\`)`) unbanEmbed.addField(ctx._locale('basic:punishment.embed.reason'), ctx._locale('basic:noReason')) ack.sendAck('update', { diff --git a/apps/discord/src/commands/slash/mod/KickCommand.js b/apps/discord/src/commands/slash/mod/KickCommand.js index 601a62279..b7f7549de 100644 --- a/apps/discord/src/commands/slash/mod/KickCommand.js +++ b/apps/discord/src/commands/slash/mod/KickCommand.js @@ -48,11 +48,11 @@ export default class KickCommand extends Command { if (!guildMember) return ctx.replyT('error', 'basic:invalidUser') try { const embed = new EmbedBuilder() - embed.setTitle(ctx._locale('basic:punishment.kicked', { 0: `${member.username}#${member.discriminator}` })) + embed.setTitle(ctx._locale('basic:punishment.kicked', { 0: `@${member.username}` })) embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.addField(ctx._locale('basic:punishment.embed.memberName'), `${guildMember.user.username}#${guildMember.user.discriminator} (\`${guildMember.user.id}\`)`) - embed.addField(ctx._locale('basic:punishment.embed.staffName'), `${ctx.message.author.username}#${ctx.message.author.discriminator} (\`${ctx.message.author.id}\`)`) + embed.addField(ctx._locale('basic:punishment.embed.memberName'), `@${guildMember.user.username} (\`${guildMember.user.id}\`)`) + embed.addField(ctx._locale('basic:punishment.embed.staffName'), `@${ctx.message.author.username} (\`${ctx.message.author.id}\`)`) embed.addField(ctx._locale('basic:punishment.embed.reason'), reason) guildMember.kick(reason).then(() => ctx.send(embed.build())) diff --git a/apps/discord/src/commands/slash/mod/MuteCommand.js b/apps/discord/src/commands/slash/mod/MuteCommand.js index ea12bfcbb..cd66c96e4 100644 --- a/apps/discord/src/commands/slash/mod/MuteCommand.js +++ b/apps/discord/src/commands/slash/mod/MuteCommand.js @@ -42,7 +42,7 @@ export default class MuteCommand extends Command { const member = await ctx.getUser(ctx.args.get('user').value?.id ?? ctx.args.get('user').value) const guildMember = ctx.message.guild.members.get(member.id) const reason = ctx._locale('basic:punishment.reason', { - 0: `${ctx.message.member.user.username}#${ctx.message.member.user.discriminator}`, 1: ctx.args.get('reason') ? + 0: `@${ctx.message.member.user.username}`, 1: ctx.args.get('reason') ? ctx.args.get('reason').value : ctx._locale('basic:noReason') }) const time = ctx.args.get('time')?.value @@ -64,9 +64,9 @@ export default class MuteCommand extends Command { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(ctx._locale('basic:punishment.muted', { 0: `${member.username}#${member.discriminator}` })) - embed.addField(ctx._locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(ctx._locale('basic:punishment.embed.staffName'), `${ctx.message.member.username}#${ctx.message.member.discriminator} (\`${ctx.message.member.id}\`)`) + embed.setTitle(ctx._locale('basic:punishment.muted', { 0: `@${member.username}` })) + embed.addField(ctx._locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(ctx._locale('basic:punishment.embed.staffName'), `@${ctx.message.member.username} (\`${ctx.message.member.id}\`)`) embed.addField(ctx._locale('basic:punishment.embed.reason'), ctx.args.get('reason')?.value ?? ctx._locale('basic:noReason')) ctx.send(embed.build()) diff --git a/apps/discord/src/commands/slash/mod/ReportCommand.js b/apps/discord/src/commands/slash/mod/ReportCommand.js index 9d7f38cec..bbf1ad8b2 100644 --- a/apps/discord/src/commands/slash/mod/ReportCommand.js +++ b/apps/discord/src/commands/slash/mod/ReportCommand.js @@ -55,8 +55,8 @@ export default class ReportCommand extends Command { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.addField(ctx._locale('commands:report.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(ctx._locale('commands:report.embed.authorName'), `${ctx.message.author.username}#${ctx.message.author.discriminator} (\`${ctx.message.author.id}\`)`) + embed.addField(ctx._locale('commands:report.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(ctx._locale('commands:report.embed.authorName'), `@${ctx.message.author.username} (\`${ctx.message.author.id}\`)`) embed.addField(ctx._locale('commands:report.embed.channel'), ctx.message.channel.mention) embed.addField(ctx._locale('commands:report.embed.reason'), proof ? `[${reason}](${proof})` : reason) diff --git a/apps/discord/src/commands/slash/mod/SoftBanCommand.js b/apps/discord/src/commands/slash/mod/SoftBanCommand.js index 0f73e99a8..7ca63c1cb 100644 --- a/apps/discord/src/commands/slash/mod/SoftBanCommand.js +++ b/apps/discord/src/commands/slash/mod/SoftBanCommand.js @@ -49,12 +49,12 @@ export default class SoftBanCommand extends Command { })) .then(() => { const embed = new EmbedBuilder() - embed.setTitle(ctx._locale('basic:punishment.softBan', { 0: `${member.username}#${member.discriminator}` })) + embed.setTitle(ctx._locale('basic:punishment.softBan', { 0: `@${member.username}` })) embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.addField(ctx._locale('basic:punishment.memberName'), `${member.username}#${member.discriminator}`, true) - embed.addField(ctx._locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(ctx._locale('basic:punishment.embed.staffName'), `${ctx.message.author.username}#${ctx.message.author.discriminator} (\`${ctx.message.author.id}\`)`) + embed.addField(ctx._locale('basic:punishment.memberName'), `@${member.username}`, true) + embed.addField(ctx._locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(ctx._locale('basic:punishment.embed.staffName'), `@${ctx.message.author.username} (\`${ctx.message.author.id}\`)`) embed.addField(ctx._locale('basic:punishment.embed.reason'), reason) ctx.send(embed.build()) diff --git a/apps/discord/src/commands/slash/mod/UnbanCommand.js b/apps/discord/src/commands/slash/mod/UnbanCommand.js index 227b42f7b..24810080f 100644 --- a/apps/discord/src/commands/slash/mod/UnbanCommand.js +++ b/apps/discord/src/commands/slash/mod/UnbanCommand.js @@ -43,13 +43,13 @@ export default class UnbanCommand extends Command { if (!member) return ctx.replyT('error', 'commands:unban.notBanned') const reason = ctx.args.get('reason')?.value ?? ctx._locale('basic:noReason') - guild.unbanMember(member.user.id, ctx._locale('basic:punishment.reason', { 0: `${ctx.message.author.username}#${ctx.message.author.discriminator}`, 1: reason })).then(() => { + guild.unbanMember(member.user.id, ctx._locale('basic:punishment.reason', { 0: `@${ctx.message.author.username}`, 1: reason })).then(() => { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.user.avatarURL) - embed.setTitle(ctx._locale('basic:punishment.unbanned', { 0: `${member.user.username}#${member.user.discriminator}` })) - embed.addField(ctx._locale('basic:punishment.embed.memberName'), `${member.user.username}#${member.user.discriminator} (\`${member.user.id}\`)`) - embed.addField(ctx._locale('basic:punishment.embed.staffName'), `${ctx.message.author.username}#${ctx.message.author.discriminator} (\`${ctx.message.author.id}\`)`) + embed.setTitle(ctx._locale('basic:punishment.unbanned', { 0: `@${member.user.username}` })) + embed.addField(ctx._locale('basic:punishment.embed.memberName'), `@${member.user.username} (\`${member.user.id}\`)`) + embed.addField(ctx._locale('basic:punishment.embed.staffName'), `@${ctx.message.author.username} (\`${ctx.message.author.id}\`)`) embed.addField(ctx._locale('basic:punishment.embed.reason'), reason) ctx.send(embed.build()) diff --git a/apps/discord/src/commands/slash/mod/UnmuteCommand.js b/apps/discord/src/commands/slash/mod/UnmuteCommand.js index 1b94a4ef1..f0e15056b 100644 --- a/apps/discord/src/commands/slash/mod/UnmuteCommand.js +++ b/apps/discord/src/commands/slash/mod/UnmuteCommand.js @@ -36,7 +36,7 @@ export default class UnmuteCommand extends Command { const member = await ctx.getUser(ctx.args.get('user').value?.id ?? ctx.args.get('user').value) const guildMember = ctx.message.guild.members.get(member.id) const reason = ctx._locale('basic:punishment.reason', { - 0: `${ctx.message.member.user.username}#${ctx.message.member.user.discriminator}`, 1: ctx.args.get('reason') ? + 0: `@${ctx.message.member.user.username}`, 1: ctx.args.get('reason') ? ctx.args.get('reason').value : ctx._locale('basic:noReason') }) if (!member) return ctx.replyT('error', 'basic:invalidUser') @@ -52,9 +52,9 @@ export default class UnmuteCommand extends Command { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(ctx._locale('basic:punishment.unmuted', { 0: `${member.username}#${member.discriminator}` })) - embed.addField(ctx._locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(ctx._locale('basic:punishment.embed.staffName'), `${ctx.message.member.username}#${ctx.message.member.discriminator} (\`${ctx.message.member.id}\`)`) + embed.setTitle(ctx._locale('basic:punishment.unmuted', { 0: `@${member.username}` })) + embed.addField(ctx._locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(ctx._locale('basic:punishment.embed.staffName'), `@${ctx.message.member.username} (\`${ctx.message.member.id}\`)`) embed.addField(ctx._locale('basic:punishment.embed.reason'), ctx.args.get('reason')?.value ?? ctx._locale('basic:noReason')) ctx.send(embed.build()) diff --git a/apps/discord/src/commands/slash/social/InventoryProfileCommand.js b/apps/discord/src/commands/slash/social/InventoryProfileCommand.js index 9ca3af3af..80b559fab 100644 --- a/apps/discord/src/commands/slash/social/InventoryProfileCommand.js +++ b/apps/discord/src/commands/slash/social/InventoryProfileCommand.js @@ -40,7 +40,7 @@ export default class InventoryProfileCommand extends Command { componentSelected: '', profileType: user.profileType, married: user.isMarry, - partnerName: marryWith ? `${marryWith?.username}#${marryWith.discriminator}` : '', + partnerName: marryWith ? `@${marryWith?.username}` : '', user, marryWith, avatar, diff --git a/apps/discord/src/commands/slash/social/ProfileCommand.js b/apps/discord/src/commands/slash/social/ProfileCommand.js index 8019d3207..1a982311f 100644 --- a/apps/discord/src/commands/slash/social/ProfileCommand.js +++ b/apps/discord/src/commands/slash/social/ProfileCommand.js @@ -105,7 +105,7 @@ export default class ProfileCommand extends Command { money: Number(user.yens).toLocaleString(), aboutMe: user.aboutme !== '' ? user.aboutme : ctx._locale('commands:profile.defaultAboutMe', { 0: ctx.db.guild.prefix }), married: user.isMarry, - partnerName: `${couple?.username}#${couple.discriminator}`, + partnerName: `@${couple?.username}`, bgId: user.background, stickerId: user.sticker, favColor: user.profileColor, diff --git a/apps/discord/src/commands/slash/social/WorkCommand.js b/apps/discord/src/commands/slash/social/WorkCommand.js index b098f02b9..5187f2ec3 100644 --- a/apps/discord/src/commands/slash/social/WorkCommand.js +++ b/apps/discord/src/commands/slash/social/WorkCommand.js @@ -34,7 +34,7 @@ export default class WorkCommand extends Command { const jobsList = Object.entries(TypeProfession) .map(([k, [type, salary, emoji, text, time]]) => { return { - label: ctx._locale(text), + label: ctx._locale(text.toString()), value: k, description: ctx._locale(`commands:work.description.${k}`), custom_id: k, diff --git a/apps/discord/src/commands/slash/utils/EmojiCommand.js b/apps/discord/src/commands/slash/utils/EmojiCommand.js index ca4de532b..882d8430f 100644 --- a/apps/discord/src/commands/slash/utils/EmojiCommand.js +++ b/apps/discord/src/commands/slash/utils/EmojiCommand.js @@ -1,6 +1,6 @@ -import { Command, SlashCommandContext } from '../../../structures/util' import axios from 'axios' import { CommandBase, CommandOptions } from 'eris' +import { Command, SlashCommandContext } from '../../../structures/util' export default class EmojiCommand extends Command { constructor() { diff --git a/apps/discord/src/commands/slash/utils/server/ServerInfoCommand.js b/apps/discord/src/commands/slash/utils/server/ServerInfoCommand.js index 68f7562e4..91614a121 100644 --- a/apps/discord/src/commands/slash/utils/server/ServerInfoCommand.js +++ b/apps/discord/src/commands/slash/utils/server/ServerInfoCommand.js @@ -40,7 +40,7 @@ export default class ServerInfoCommand extends Command { } const description = [ `**${_locale('commands:serverinfo.guildName')}:** ${guild.name} (\`${guild.id}\`)`, - `**${_locale('commands:serverinfo.guildOwner')}:** ${owner.username}#${owner.discriminator} (\`${owner.id}\`)`, + `**${_locale('commands:serverinfo.guildOwner')}:** @${owner.username} (\`${owner.id}\`)`, `**${_locale('commands:serverinfo.guildAFKChannel.title')}:** ${guild.channels.get(guild.afkChannelID) ? `${guild.channels.get(guild.afkChannelID).name} (\`${guild.channels.get(guild.afkChannelID).id}\`)` : _locale('commands:serverinfo.guildAFKChannel.noAfkChannel')}`, `**${_locale('commands:serverinfo.booster.levelCount')}:** ${guild.premiumTier} (${_locale('commands:serverinfo.booster.boosterCount')}: ${guild.premiumSubscriptionCount})`, `**${_locale('commands:serverinfo.guildMember')}:** ${guild.memberCount}`, diff --git a/apps/discord/src/commands/slash/utils/user/UserInfoCommand.js b/apps/discord/src/commands/slash/utils/user/UserInfoCommand.js index 68672c2c1..3fdc339a6 100644 --- a/apps/discord/src/commands/slash/utils/user/UserInfoCommand.js +++ b/apps/discord/src/commands/slash/utils/user/UserInfoCommand.js @@ -36,7 +36,7 @@ export default class UserInfoCommand extends Command { const embed = new EmbedBuilder() embed.setColor(`#${highRole?.color.toString(16)}` ?? null) embed.setThumbnail(avatar) - embed.addField(ctx._locale('commands:userinfo.username'), `${member.username}#${member.discriminator}`, true) + embed.addField(ctx._locale('commands:userinfo.username'), `@${member.username}`, true) embed.addField(ctx._locale('commands:userinfo.userid'), member.id, true) embed.addField(ctx._locale('commands:userinfo.createdAt'), ``, true) guildMember ? embed.addField(ctx._locale('commands:userinfo.joinedAt'), ` ()`, true) : null diff --git a/apps/discord/src/commands/vanilla/dev/BlackListCommand.js b/apps/discord/src/commands/vanilla/dev/BlackListCommand.js index 4e779669c..6fa86523e 100644 --- a/apps/discord/src/commands/vanilla/dev/BlackListCommand.js +++ b/apps/discord/src/commands/vanilla/dev/BlackListCommand.js @@ -32,7 +32,7 @@ export default class BlackListCommand extends Command { const user = await ctx.getUser(ctx.args[1]) if (!user) return ctx.reply('error', 'eu não posso editar algo de uma pessoa que não foi informada.') const dbUser = await ctx.db.db.getOrCreate(user.id) - const userInfo = user ? `${user.username}#${user.discriminator} - (${user.id})` : dbUser.id + const userInfo = user ? `@${user.username} - (${user.id})` : dbUser.id const msg = `\`\`\`asciidoc\n== USER BANNED INFO ==\n\n• User :: ${userInfo}\n• Banned :: ${dbUser.blacklist}\n• Reason :: ${dbUser.blacklistReason}\`\`\`` ctx.send(msg) } diff --git a/apps/discord/src/defineTypes/defineState.js b/apps/discord/src/defineTypes/defineState.js index 6652610cb..41e8af19d 100644 --- a/apps/discord/src/defineTypes/defineState.js +++ b/apps/discord/src/defineTypes/defineState.js @@ -8,16 +8,43 @@ const isJson = (data) => { return false } } + +/** + * @template T + */ export class StateData { + /** + * + * @param {T} actionState + */ constructor(actionState) { this.actionState = actionState } } /** - * + * @template T + * @typedef StateEffect + * @property {(property: T) => keyof property} get + * @property {(data: S) => StateDataEffect} setState + * @property {(property: keyof T) => StateDataEffect} del + * @property {import('events').EventEmitter | null} [event] + * @property {() => void} destroy; + * @memberof StateEffect + */ + +/** + * @template T + * @typedef StateDataEffect + * @type {StateData> & T} + */ + +/** + * @template T * @description This will help save unnecessary variable and after you are done and set the data to null and let the GC work. - * @returns {StateData?} + * @param {T} [data] + * @param {{eventEmitter: boolean;}} [options] + * @returns {StateDataEffect} */ export const defineState = (data, options = { eventEmitter: false }) => { let state = data ?? {} diff --git a/apps/discord/src/lib/tokamak.js b/apps/discord/src/lib/tokamak.js index a9bc4d50a..37525e759 100644 --- a/apps/discord/src/lib/tokamak.js +++ b/apps/discord/src/lib/tokamak.js @@ -307,6 +307,7 @@ const renderRize = async (options = optionsTokamak) => { /** * * @param {keyof ConstantBackground} name + * @param {cache: boolean} [options] * @returns {Promise} */ export const getBackground = async (name, options = { cache: false }) => { diff --git a/apps/discord/src/listeners/client/ErrorListener.js b/apps/discord/src/listeners/client/ErrorListener.js index 15ae965ae..bad4b6272 100644 --- a/apps/discord/src/listeners/client/ErrorListener.js +++ b/apps/discord/src/listeners/client/ErrorListener.js @@ -34,7 +34,7 @@ export default class ErrorListener extends Listener { embed.setColor('ERROR') embed.setTitle(_locale('events:executionFailure.embedTitle')) embed.setDescription(`\`\`\`js\n${error.stack.removePath().slice(0, 1800)}\`\`\``) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { embeds: [embed], diff --git a/apps/discord/src/listeners/guilds/GuildBanAddListener.js b/apps/discord/src/listeners/guilds/GuildBanAddListener.js index 9038e048c..b682a3227 100644 --- a/apps/discord/src/listeners/guilds/GuildBanAddListener.js +++ b/apps/discord/src/listeners/guilds/GuildBanAddListener.js @@ -20,9 +20,9 @@ export default class GuildBanAddListener extends Listener { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(_locale('basic:punishment.banned', { 0: `${member.username}#${member.discriminator}` })) - embed.addField(_locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(_locale('basic:punishment.embed.staffName'), `${mod.username}#${mod.discriminator} (\`${mod.id}\`)`) + embed.setTitle(_locale('basic:punishment.banned', { 0: `@${member.username}` })) + embed.addField(_locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(_locale('basic:punishment.embed.staffName'), `@${mod.username} (\`${mod.id}\`)`) embed.addField(_locale('basic:punishment.embed.reason'), reason) if (!server.punishModule) return @@ -42,8 +42,8 @@ export default class GuildBanAddListener extends Listener { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(_locale('basic:punishment.banned', { 0: `${member.username}#${member.discriminator}` })) - embed.addField(_locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) + embed.setTitle(_locale('basic:punishment.banned', { 0: `@${member.username}` })) + embed.addField(_locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) embed.addField(_locale('basic:punishment.embed.reason'), reason) if (!server.punishModule) return diff --git a/apps/discord/src/listeners/guilds/GuildBanRemoveListener.js b/apps/discord/src/listeners/guilds/GuildBanRemoveListener.js index 8a6853ea2..d5fa3533f 100644 --- a/apps/discord/src/listeners/guilds/GuildBanRemoveListener.js +++ b/apps/discord/src/listeners/guilds/GuildBanRemoveListener.js @@ -20,9 +20,9 @@ export default class GuildBanRemoveListener extends Listener { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(_locale('basic:punishment.unbanned', { 0: `${member.username}#${member.discriminator}` })) - embed.addField(_locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(_locale('basic:punishment.embed.staffName'), `${mod.username}#${mod.discriminator} (\`${mod.id}\`)`) + embed.setTitle(_locale('basic:punishment.unbanned', { 0: `@${member.username}` })) + embed.addField(_locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(_locale('basic:punishment.embed.staffName'), `@${mod.username} (\`${mod.id}\`)`) embed.addField(_locale('basic:punishment.embed.reason'), reason) if (!server.punishModule) return @@ -42,8 +42,8 @@ export default class GuildBanRemoveListener extends Listener { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(_locale('basic:punishment.unbanned', { 0: `${member.username}#${member.discriminator}` })) - embed.addField(_locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) + embed.setTitle(_locale('basic:punishment.unbanned', { 0: `@${member.username}` })) + embed.addField(_locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) embed.addField(_locale('basic:punishment.embed.reason'), reason) if (!server.punishModule) return diff --git a/apps/discord/src/listeners/guilds/GuildCreateListener.js b/apps/discord/src/listeners/guilds/GuildCreateListener.js index 3488da5e7..828b941d1 100644 --- a/apps/discord/src/listeners/guilds/GuildCreateListener.js +++ b/apps/discord/src/listeners/guilds/GuildCreateListener.js @@ -34,8 +34,8 @@ export default class GuildCreateListener extends Listener { const embed = new EmbedBuilder() embed.setColor('#730101') embed.setTitle('Guild Blacklisted') - embed.setDescription(`Someone tried to add me on this guild, but the guild is on my blacklist\n**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** ${owner.username}#${owner.discriminator}`) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setDescription(`Someone tried to add me on this guild, but the guild is on my blacklist\n**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** @${owner.username}`) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { @@ -51,8 +51,8 @@ export default class GuildCreateListener extends Listener { const embed = new EmbedBuilder() embed.setColor('#187000') embed.setTitle('Guild Joined') - embed.setDescription(`**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** ${owner.username}#${owner.discriminator}\n**Members:** ${guild.memberCount}`) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setDescription(`**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** @${owner.username}\n**Members:** ${guild.memberCount}`) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { diff --git a/apps/discord/src/listeners/guilds/GuildDeleteListener.js b/apps/discord/src/listeners/guilds/GuildDeleteListener.js index 08be1e799..6e0cd3a80 100644 --- a/apps/discord/src/listeners/guilds/GuildDeleteListener.js +++ b/apps/discord/src/listeners/guilds/GuildDeleteListener.js @@ -30,8 +30,8 @@ export default class GuildDeleteListener extends Listener { const embed = new EmbedBuilder() embed.setColor('#730101') embed.setTitle('Guild Blacklisted') - embed.setDescription(`I quited of this guild because it is in my blacklist\n**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** ${owner.username}#${owner.discriminator}`) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setDescription(`I quited of this guild because it is in my blacklist\n**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** @${owner.username}`) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { @@ -45,8 +45,8 @@ export default class GuildDeleteListener extends Listener { const embed = new EmbedBuilder() embed.setColor('#eb2323') embed.setTitle('Guild Deleted') - embed.setDescription(`**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** ${owner.username}#${owner.discriminator}`) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setDescription(`**Name:** ${guild.name} (\`${guild.id}\`)\n**Owner:** @${owner.username}`) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { diff --git a/apps/discord/src/listeners/guilds/GuildMemberRemoveListener.js b/apps/discord/src/listeners/guilds/GuildMemberRemoveListener.js index f0efaef35..2401168d4 100644 --- a/apps/discord/src/listeners/guilds/GuildMemberRemoveListener.js +++ b/apps/discord/src/listeners/guilds/GuildMemberRemoveListener.js @@ -22,9 +22,9 @@ export default class GuildMemberRemoveListener extends Listener { const embed = new EmbedBuilder() embed.setColor('MODERATION') embed.setThumbnail(member.avatarURL) - embed.setTitle(_locale('basic:punishment.kicked', { member: `${member.username}#${member.discriminator}` })) - embed.addField(_locale('basic:punishment.embed.memberName'), `${member.username}#${member.discriminator} (\`${member.id}\`)`) - embed.addField(_locale('basic:punishment.embed.staffName'), `${mod.username}#${mod.discriminator} (\`${mod.id}\`)`) + embed.setTitle(_locale('basic:punishment.kicked', { member: `@${member.username}` })) + embed.addField(_locale('basic:punishment.embed.memberName'), `@${member.username} (\`${member.id}\`)`) + embed.addField(_locale('basic:punishment.embed.staffName'), `@${mod.username} (\`${mod.id}\`)`) embed.addField(_locale('basic:punishment.embed.reason'), reason) if (!server.punishModule) return diff --git a/apps/discord/src/listeners/shards/ShardDisconnectListener.js b/apps/discord/src/listeners/shards/ShardDisconnectListener.js index 1f9836b6e..c641c8b91 100644 --- a/apps/discord/src/listeners/shards/ShardDisconnectListener.js +++ b/apps/discord/src/listeners/shards/ShardDisconnectListener.js @@ -31,7 +31,7 @@ export default class ShardDisconnectListener extends Listener { embed.setTitle('Shard Disconnected') embed.setDescription(`Cluster: #${process.env.CLUSTER_ID ?? '0'} = Shard: ${shardID} => \`Disconnected\``) embed.addField('Maybe the error?', error.message) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { diff --git a/apps/discord/src/listeners/shards/ShardPreReadyListener.js b/apps/discord/src/listeners/shards/ShardPreReadyListener.js index 4a4ba1cd7..3ba0a0cea 100644 --- a/apps/discord/src/listeners/shards/ShardPreReadyListener.js +++ b/apps/discord/src/listeners/shards/ShardPreReadyListener.js @@ -26,7 +26,7 @@ export default class ShardPreReadyListener extends Listener { embed.setColor('ERROR') embed.setTitle('Shard Reconnecting') embed.setDescription(`Cluster: #${process.env.CLUSTER_ID ?? '0'} = Shard: ${shardID} => \`Reconnecting\``) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { diff --git a/apps/discord/src/listeners/shards/ShardReadyListener.js b/apps/discord/src/listeners/shards/ShardReadyListener.js index d39a72be1..256246a5b 100644 --- a/apps/discord/src/listeners/shards/ShardReadyListener.js +++ b/apps/discord/src/listeners/shards/ShardReadyListener.js @@ -31,7 +31,7 @@ export default class ShardReadyListener extends Listener { embed.setColor('ERROR') embed.setTitle('Shard Ready') embed.setDescription(`Cluster: #${process.env.CLUSTER_ID ?? '0'} = Shard: ${shardID} => \`Ready\``) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { diff --git a/apps/discord/src/listeners/shards/ShardResumeListener.js b/apps/discord/src/listeners/shards/ShardResumeListener.js index bd91de4ae..1b9714f0b 100644 --- a/apps/discord/src/listeners/shards/ShardResumeListener.js +++ b/apps/discord/src/listeners/shards/ShardResumeListener.js @@ -26,7 +26,7 @@ export default class ShardResumeListener extends Listener { embed.setColor('ERROR') embed.setTitle('Shard Resumed') embed.setDescription(`Cluster: #${process.env.CLUSTER_ID ?? '0'} = Shard: ${shardID} => \`Resumed\``) - embed.setFooter(`Instance: ${client.user.username}#${client.user.discriminator}`, client.user.avatarURL) + embed.setFooter(`Instance: @${client.user.username}`, client.user.avatarURL) embed.setTimestamp() client.executeWebhook(webhook.id, webhook.token, { diff --git a/apps/discord/src/structures/command/CommandContext.js b/apps/discord/src/structures/command/CommandContext.js index 6de066aeb..058d7ce88 100644 --- a/apps/discord/src/structures/command/CommandContext.js +++ b/apps/discord/src/structures/command/CommandContext.js @@ -149,7 +149,7 @@ export class CommandContext { return member } catch { - const member = this.message.guild.members.find((member) => member.username.toLowerCase().includes(args.toLowerCase())) || this.message.guild.members.find((member) => `${member.username}#${member.discriminator}`.toLowerCase() === args.toLowerCase()) + const member = this.message.guild.members.find((member) => member.username.toLowerCase().includes(args.toLowerCase())) || this.message.guild.members.find((member) => `@${member.username}`.toLowerCase() === args.toLowerCase()) if (!member) { if (hasAuthor) { return await this.client.getRESTUser(this.message.author.id) diff --git a/framework/developer/WebsocketServerDeveloper.js b/framework/developer/WebsocketServerDeveloper.js index 663e2823f..443fda30c 100644 --- a/framework/developer/WebsocketServerDeveloper.js +++ b/framework/developer/WebsocketServerDeveloper.js @@ -1,6 +1,7 @@ import { EventEmitter } from 'events' import { WebSocketServer } from 'ws' import { LoggerSystem } from '../logger/defineLogger.js' + import { ProcessModel } from './model/ProcessModel.js' const isDeveloperMode = () => process.argv.includes('--dev') const enableServer = () => process.argv.includes('--watch-server') diff --git a/framework/index.js b/framework/index.js index c0d875823..ac6a3e6a6 100644 --- a/framework/index.js +++ b/framework/index.js @@ -1,13 +1,48 @@ -import { readFileSync } from 'fs' +import { existsSync, mkdirSync, readFileSync } from 'fs' import { resolve } from 'path' +import { NodeLinkResolver } from './NodeLinkResolver.js' +import { initializeCacheManager } from './cache.js' import { watchStart } from './developer/WatchCommand.js' import { WebSocketServerDeveloper } from './developer/WebsocketServerDeveloper.js' import { LoggerSystem } from './logger/defineLogger.js' -import { NodeLinkResolver } from './NodeLinkResolver.js' import { executeCommand } from './utils/helperCommand.js' import { resolveDir } from './utils/resolveDir.js' - +/** + * Initialize `.chinokafuu` folder + */ +const checkDir = () => { + if (!existsSync('.chinokafuu')) { + mkdirSync('.chinokafuu', { recursive: true }) + } + if (!existsSync('.chinokafuu/cache/image')) { + mkdirSync('.chinokafuu/cache/image', { recursive: true }) + } + if (!existsSync('.chinokafuu/cache/tmp')) { + mkdirSync('.chinokafuu/cache/tmp', { recursive: true }) + } + if (!existsSync('.chinokafuu/cache/map')) { + mkdirSync('.chinokafuu/cache/map', { recursive: true }) + } + if (!existsSync('.chinokafuu/image/resize')) { + mkdirSync('.chinokafuu/image/resize', { recursive: true }) + } + if (!existsSync('.chinokafuu/locale/cache')) { + mkdirSync('.chinokafuu/locale/cache', { recursive: true }) + } + if (!existsSync('.chinokafuu/apps/tsc')) { + mkdirSync('.chinokafuu/apps/tsc', { recursive: true }) + } + if (!existsSync('.chinokafuu/test')) { + mkdirSync('.chinokafuu/test', { recursive: true }) + } + if (!existsSync('.chinokafuu/lavalink/tracks')) { + mkdirSync('.chinokafuu/lavalink/tracks', { recursive: true }) + } + if (!existsSync('.chinokafuu/tmp')) { + mkdirSync('.chinokafuu/tmp', { recursive: true }) + } +} // Clear chat :) @@ -16,6 +51,7 @@ if (process.argv.includes('--clear-log')) { } + const packageFramework = () => { const p = JSON.parse(readFileSync(resolve('package.json'))) @@ -29,8 +65,14 @@ const logger = new LoggerSystem('FrameworkRepository') const startFramework = async () => { - // Start WebSocketServerDeveloper + // check /.chinokafuu/* + checkDir() + + initializeCacheManager() + + + // Start WebSocketServerDeveloper const t = packageFramework() logger.log(`The ${t.name} is working with version ${t.version}`) @@ -54,3 +96,4 @@ if (!executeCommand() && !watchStart()) { + diff --git a/framework/tester/NodeTest.js b/framework/tester/NodeTest.js index dafab3740..76b483fc3 100644 --- a/framework/tester/NodeTest.js +++ b/framework/tester/NodeTest.js @@ -14,6 +14,7 @@ export class NodeTest { logger.log(`Starting a Jest in repository ${this.node.getNameProject()}`) console.log('\n') return new Promise((resolved, rejects) => { + if (process.argv0.includes('--lint')) return; const test = spawn('yarn', ['test'], { cwd: this.node.resolved, shell: true, @@ -50,6 +51,7 @@ export class NodeTest { logger.log(`Starting a Eslint in repository ${this.node.getNameProject()}`) console.log('\n') return new Promise((resolved, rejects) => { + if (!process.argv0.includes('--lint')) return; const test = spawn('yarn', ['test:lint'], { cwd: this.node.resolved, shell: true,