diff --git a/src/bot/commands/slashCommands/anom.ts b/src/bot/commands/slashCommands/anom.ts index eafc11c..1e032fe 100644 --- a/src/bot/commands/slashCommands/anom.ts +++ b/src/bot/commands/slashCommands/anom.ts @@ -1,9 +1,4 @@ -import { - SlashCommandBuilder, - EmbedBuilder, - ChannelType, - TextChannel, -} from 'discord.js'; +import { SlashCommandBuilder, ChannelType, TextChannel } from 'discord.js'; import { SlashCommand } from '@marquinhos/types'; @@ -29,11 +24,10 @@ export const anom: SlashCommand = { execute: async (interaction) => { const channel = interaction.options.get('canal')?.channel as TextChannel; const message = interaction.options.get('mensagem')?.value as string; + const anomEmbed = interaction.client.baseEmbed(); channel.send({ embeds: [ - new EmbedBuilder() - .setDescription(message) - .setTitle('👀 Alguém disse isso:'), + anomEmbed.setTitle('👀 Alguém disse isso:').setDescription(message), ], }); }, diff --git a/src/bot/commands/slashCommands/audio.ts b/src/bot/commands/slashCommands/audio.ts index 5086389..642f3d1 100644 --- a/src/bot/commands/slashCommands/audio.ts +++ b/src/bot/commands/slashCommands/audio.ts @@ -1,4 +1,4 @@ -import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; +import { SlashCommandBuilder } from 'discord.js'; import { join } from 'path'; import { readdirSync } from 'fs'; @@ -39,12 +39,11 @@ export const audio: SlashCommand = { execute: (interaction) => { const channel = voiceChannelPresence(interaction); const file = interaction.options.get('audio'); + const audioEmbed = interaction.client.baseEmbed(); playAudio(interaction, channel, file?.value as string); interaction.reply({ embeds: [ - new EmbedBuilder().setDescription( - `Reproduzindo ${file?.value as string}` - ), + audioEmbed.setDescription(`Reproduzindo ${file?.value as string}`), ], }); }, diff --git a/src/bot/commands/slashCommands/balance.ts b/src/bot/commands/slashCommands/balance.ts index 4c62095..2069a19 100644 --- a/src/bot/commands/slashCommands/balance.ts +++ b/src/bot/commands/slashCommands/balance.ts @@ -1,4 +1,4 @@ -import { SlashCommandBuilder, EmbedBuilder, GuildMember } from 'discord.js'; +import { SlashCommandBuilder, GuildMember } from 'discord.js'; import { SlashCommand } from '@marquinhos/types'; import { getCoinBalance } from '@marquinhos/services/coinBalanceManager'; @@ -13,16 +13,7 @@ export const balance: SlashCommand = { interaction.guild?.id ?? '' ); - const balanceEmbed = new EmbedBuilder(); - - balanceEmbed - .setColor('#0099ff') - .setThumbnail(interaction.user.displayAvatarURL()) - .setTimestamp() - .setFooter({ - text: 'Marquinhos Bot ™️', - iconURL: interaction.client.user?.displayAvatarURL(), - }); + const balanceEmbed = interaction.client.baseEmbed(); if (balance === null) { balanceEmbed diff --git a/src/bot/commands/slashCommands/balanceOperation.ts b/src/bot/commands/slashCommands/balanceOperation.ts index 24f517f..7ecfc05 100644 --- a/src/bot/commands/slashCommands/balanceOperation.ts +++ b/src/bot/commands/slashCommands/balanceOperation.ts @@ -7,10 +7,8 @@ import { } from '@marquinhos/services/coinBalanceManager'; import { BalanceChangeStatus, BalanceOperationType } from '@marquinhos/types'; import { - BaseInteraction, CommandInteraction, CommandInteractionOptionResolver, - EmbedBuilder, PermissionsBitField, } from 'discord.js'; @@ -88,14 +86,9 @@ export const balanceOperation = { const amount = interaction.options.get('valor')?.value as number; - const baseEmbed = new EmbedBuilder() - .setColor('#0099ff') - .setTitle('Operação no saldo') - .setTimestamp() - .setFooter({ - text: 'Marquinhos Bot ™️', - iconURL: interaction.client.user?.displayAvatarURL(), - }); + const baseEmbed = interaction.client + .baseEmbed() + .setTitle('Operação no saldo'); let operationResult: BalanceChangeStatus & { operationType: BalanceOperationType | null; diff --git a/src/bot/commands/slashCommands/checkIn.ts b/src/bot/commands/slashCommands/checkIn.ts index adddee2..ca99684 100644 --- a/src/bot/commands/slashCommands/checkIn.ts +++ b/src/bot/commands/slashCommands/checkIn.ts @@ -26,7 +26,9 @@ export const checkIn: SlashCommand = { const guildName = interaction.guild?.name as string; interaction.reply({ embeds: [ - new EmbedBuilder().setDescription(checkInReply(member, guildName)), + interaction.client + .baseEmbed() + .setDescription(checkInReply(member, guildName)), ], }); }, diff --git a/src/bot/commands/slashCommands/configRoles.ts b/src/bot/commands/slashCommands/configRoles.ts index 8934eae..a3b4d66 100644 --- a/src/bot/commands/slashCommands/configRoles.ts +++ b/src/bot/commands/slashCommands/configRoles.ts @@ -1,4 +1,4 @@ -import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; +import { SlashCommandBuilder } from 'discord.js'; import { SlashCommand } from '@marquinhos/types'; import GuildModel from '@schemas/guild'; @@ -30,12 +30,11 @@ export const configRoles: SlashCommand = { const roleType = interaction.options.get('tipo_do_cargo'); const role = interaction.options.get('cargo'); const guildId = interaction.guild?.id; + const configRolesEmbed = interaction.client.baseEmbed(); if (!roleType || !role || !guildId) { return interaction.reply({ - embeds: [ - new EmbedBuilder().setDescription(`Falha ao configurar cargo`), - ], + embeds: [configRolesEmbed.setDescription(`Falha ao configurar cargo`)], }); } const roleId = role.value as string; @@ -56,7 +55,7 @@ export const configRoles: SlashCommand = { interaction.reply({ embeds: [ - new EmbedBuilder().setDescription( + configRolesEmbed.setDescription( `Cargo ${roleType.value} configurado como ${roleName}` ), ], diff --git a/src/bot/commands/slashCommands/disconnectAll.ts b/src/bot/commands/slashCommands/disconnectAll.ts index 6b20cec..4ae1d53 100644 --- a/src/bot/commands/slashCommands/disconnectAll.ts +++ b/src/bot/commands/slashCommands/disconnectAll.ts @@ -10,10 +10,11 @@ export const disconnectAll: SlashCommand = { execute: async (interaction) => { const member = interaction.member as GuildMember; const voiceChannel = member?.voice.channel; + const disconnectAllEmbed = interaction.client.baseEmbed(); if (!voiceChannel) { interaction.reply({ embeds: [ - new EmbedBuilder().setDescription( + disconnectAllEmbed.setDescription( 'Você precisa estar em um canal de voz para usar esse comando' ), ], @@ -28,7 +29,7 @@ export const disconnectAll: SlashCommand = { interaction.reply({ embeds: [ - new EmbedBuilder().setDescription( + disconnectAllEmbed.setDescription( 'Todos os usuários foram desconectados' ), ], diff --git a/src/bot/commands/slashCommands/getRoles.ts b/src/bot/commands/slashCommands/getRoles.ts index 0da4eb1..e33dbf0 100644 --- a/src/bot/commands/slashCommands/getRoles.ts +++ b/src/bot/commands/slashCommands/getRoles.ts @@ -1,4 +1,4 @@ -import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; +import { SlashCommandBuilder } from 'discord.js'; import { SlashCommand } from '@marquinhos/types'; import GuildModel from '@schemas/guild'; @@ -12,6 +12,7 @@ export const getRoles: SlashCommand = { const { externalRoleId, baseRoleId, vipRoleId } = await findRoles( interaction.guild?.id as string ); + const getRolesEmbed = interaction.client.baseEmbed(); const externalRoleName = externalRoleId ? interaction.guild?.roles.cache.get(externalRoleId)?.name @@ -24,7 +25,7 @@ export const getRoles: SlashCommand = { : 'Não definido'; interaction.reply({ embeds: [ - new EmbedBuilder().setDescription( + getRolesEmbed.setDescription( `Cargo externo: ${externalRoleName}\n Cargo base: ${baseRoleName}\n Cargo VIP: ${vipRoleName}` diff --git a/src/bot/commands/slashCommands/lastfm.ts b/src/bot/commands/slashCommands/lastfm.ts index 06c81b7..6067fee 100644 --- a/src/bot/commands/slashCommands/lastfm.ts +++ b/src/bot/commands/slashCommands/lastfm.ts @@ -7,9 +7,10 @@ export const lastfm: SlashCommand = { .setName('lastfm') .setDescription('Mostra informações sobre a integração com o last.fm'), execute: (interaction) => { + const lastfmEmbed = interaction.client.baseEmbed(); interaction.reply({ embeds: [ - new EmbedBuilder() + lastfmEmbed .setThumbnail( 'https://play-lh.googleusercontent.com/VFmAfWqcuV3aReZG8MMQdHRSdKWx85IW22f4RQ5xhR5U-o1_u03P7TVwsnTYa26Q1No' ) diff --git a/src/bot/commands/slashCommands/minecraftStatus.ts b/src/bot/commands/slashCommands/minecraftStatus.ts index f27f34a..2d50962 100644 --- a/src/bot/commands/slashCommands/minecraftStatus.ts +++ b/src/bot/commands/slashCommands/minecraftStatus.ts @@ -38,11 +38,12 @@ export const minecraftStatus: SlashCommand = { const ip = interaction.options.get('ip')?.value as string; const port = interaction.options.get('port')?.value as number; const guildID = interaction.guildId as string; + const minecraftStatusBaseEmbed = interaction.client.baseEmbed(); if (!guildID) { await interaction.reply({ embeds: [ - new EmbedBuilder() + minecraftStatusBaseEmbed .setTitle(`Falha ao criar o monitoramento!`) .setDescription( `Não foi possível encontrar o ID do servidor de discord!` @@ -57,7 +58,7 @@ export const minecraftStatus: SlashCommand = { } catch (error) { await interaction.reply({ embeds: [ - new EmbedBuilder() + minecraftStatusBaseEmbed .setTitle(`Falha ao criar o monitoramento!`) .setDescription( `Não foi possível conectar ao servidor de minecraft!` @@ -96,7 +97,7 @@ export const minecraftStatus: SlashCommand = { if (existingServer) { await interaction.reply({ embeds: [ - new EmbedBuilder() + minecraftStatusBaseEmbed .setTitle(`Servidor já está sendo monitorado!`) .setDescription( `O servidor já tem status em <#${statusChannel.id}>` @@ -123,7 +124,7 @@ export const minecraftStatus: SlashCommand = { await interaction.reply({ embeds: [ - new EmbedBuilder() + minecraftStatusBaseEmbed .setTitle(`Monitoramento do servidor de minecraft criado!`) .setDescription( `Agora você pode ver o status do servidor de minecraft em tempo real em <#${statusChannel.id}>` diff --git a/src/bot/commands/slashCommands/ping.ts b/src/bot/commands/slashCommands/ping.ts index 6ae4d15..8a637c4 100644 --- a/src/bot/commands/slashCommands/ping.ts +++ b/src/bot/commands/slashCommands/ping.ts @@ -7,9 +7,10 @@ export const ping: SlashCommand = { .setName('ping') .setDescription("Shows the bot's ping"), execute: (interaction) => { + const pingEmbed = interaction.client.baseEmbed(); interaction.reply({ embeds: [ - new EmbedBuilder() + pingEmbed .setAuthor({ name: interaction.user.username, iconURL: interaction.user.avatarURL() ?? undefined, diff --git a/src/bot/events/guildMemberAdd.ts b/src/bot/events/guildMemberAdd.ts index 29b982e..3f79820 100644 --- a/src/bot/events/guildMemberAdd.ts +++ b/src/bot/events/guildMemberAdd.ts @@ -6,6 +6,7 @@ import GuildModel from '@schemas/guild'; export const guildMemberAdd: BotEvent = { name: 'guildMemberAdd', execute: async (member: GuildMember) => { + const guildMemberAddEmbed = member.client.baseEmbed(); const guild = await GuildModel.findOne({ guildID: member.guild.id }).exec(); if (!guild) { throw new Error('Guild not found'); @@ -78,7 +79,7 @@ export const guildMemberAdd: BotEvent = { channel.send({ embeds: [ - new EmbedBuilder() + guildMemberAddEmbed .setThumbnail(member.user.avatarURL()) .setColor('#0099ff') .setDescription( diff --git a/src/utils/lastfm.ts b/src/utils/lastfm.ts index 2ae6337..9c51341 100644 --- a/src/utils/lastfm.ts +++ b/src/utils/lastfm.ts @@ -16,6 +16,7 @@ const tempo = new TempoDataProvider(); const marquinhosApi = new MarquinhosApiService(); export const musicBotMessageHandler = async (message: Message) => { + const musicEmbed = message.client.baseEmbed(); if (!tempo.isHandleableMessage(message)) return; const playbackData = await tempo.getPlaybackDataFromMessage(message); if (playbackData) { @@ -27,7 +28,7 @@ export const musicBotMessageHandler = async (message: Message) => { ); await message.channel.send({ embeds: [ - new EmbedBuilder() + musicEmbed .setTitle('Erro ao adicionar a fila de scrobbling :cry:') .setDescription( `A música **${playbackData.title}** não foi adicionada a fila de scrobbling.` @@ -46,7 +47,7 @@ export const musicBotMessageHandler = async (message: Message) => { logger.error(`track: ${!!track}, scrobbleId: ${!!scrobbleId}`); await message.channel.send({ embeds: [ - new EmbedBuilder() + musicEmbed .setTitle('Erro ao adicionar a fila de scrobbling :cry:') .setDescription( `A música **${playbackData.title}** não foi adicionada a fila de scrobbling.` @@ -88,7 +89,7 @@ export const musicBotMessageHandler = async (message: Message) => { `Added ${playbackData.title} to scrobble queue to ${scrobblesOnUsers.length} users` ); - const scrobbleEmbed = new EmbedBuilder() + const scrobbleEmbed = musicEmbed .setTitle('Adicionado a fila de scrobbling :headphones:') .setDescription(getOngoingScrobbleDescription(track, scrobblesOnUsers)) .setFooter({ diff --git a/src/utils/minecraftServerStatus.ts b/src/utils/minecraftServerStatus.ts index 3218fad..d845552 100644 --- a/src/utils/minecraftServerStatus.ts +++ b/src/utils/minecraftServerStatus.ts @@ -93,8 +93,9 @@ export default class MinecraftServerStatus { } generateMinecraftStatusEmbed(status: util.FullQueryResponse | null) { + const minecraftStatusBaseEmbed = this._client.baseEmbed(); if (!status) { - return new EmbedBuilder() + return minecraftStatusBaseEmbed .setTitle(`O servidor está offline!`) .setThumbnail('https://i.imgur.com/TSai5Im.png') .setColor('#ff0000') @@ -114,7 +115,7 @@ export default class MinecraftServerStatus { ]); } - return new EmbedBuilder() + return minecraftStatusBaseEmbed .setTitle(`${status?.motd?.clean}`) .setThumbnail('https://i.imgur.com/TSai5Im.png')