Move emojis to messages variable

This commit is contained in:
Christer Warén 2023-06-06 02:27:46 +03:00
parent 2d17c33d21
commit 348ac90cba
19 changed files with 68 additions and 106 deletions

View File

@ -6,9 +6,10 @@ import Streamer from "./client/classes/Streamer";
import Statistics from "./client/classes/Statistics";
import { command } from "./client/commands";
import config from "./config";
import { messages } from "./client/messages";
import { events } from "./client/events"
import { funcs } from "./client/funcs";
import { messages } from "./client/messages";
const GatewayIntents = new IntentsBitField();
GatewayIntents.add(
@ -28,7 +29,6 @@ export default class RadioClient extends Client {
public streamer: Streamer | null;
public statistics: Statistics | null;
public radio: Radio | null;
public messageEmojis: any | null;
public developers: string | undefined;
constructor() {
@ -41,7 +41,6 @@ export default class RadioClient extends Client {
this.streamer = null;
this.statistics = null;
this.radio = null;
this.messageEmojis = null;
console.log('RadioX ' + this.config.version);
console.log('Internet Radio to your Discord guild');

View File

@ -7,7 +7,7 @@ export default {
category: 'info',
async execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
if(!client.user) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
@ -18,13 +18,13 @@ export default {
const embed = new EmbedBuilder()
.setTitle(message.bugTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(message.bugDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -8,7 +8,7 @@ export default {
execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
if(!client.user) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
@ -28,13 +28,13 @@ export default {
const embed = new EmbedBuilder()
.setTitle(message.helpTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(message.helpDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -8,7 +8,7 @@ export default {
execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
if(!client.user) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
@ -21,7 +21,7 @@ export default {
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -11,7 +11,7 @@ export default {
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return interaction.reply({
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
content: client.messages.emojis["error"] + message.errorToGetPlaylist,
ephemeral: true
});
}
@ -29,13 +29,13 @@ export default {
let embed = new EmbedBuilder()
.setTitle(client.messages.listTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["list"].replace(/[^0-9]+/g, ''))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["list"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(stations)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -14,7 +14,7 @@ export default {
let message: any = {};
if(!client.funcs.isDev(client.config.devId, interaction.user.id)) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.notAllowed,
content: client.messages.emojis["error"] + client.messages.notAllowed,
ephemeral: true
});
@ -123,7 +123,7 @@ export default {
.setDescription(options.find((option: APISelectMenuOption) => option.value == action)?.label || "-")
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -11,7 +11,7 @@ export default {
const radio = client.radio?.get(interaction.guild?.id);
if(!client.stations) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
@ -21,7 +21,7 @@ export default {
let station = client.stations[index];
if(!station) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noSearchResults,
content: client.messages.emojis["error"] + client.messages.noSearchResults,
ephemeral: true
});

View File

@ -21,13 +21,13 @@ export default {
const embed = new EmbedBuilder()
.setTitle(client.messages.nowplayingTitle)
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messageEmojis["play"].replace(/[^0-9]+/g, '')))
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(message.nowplayingDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -16,7 +16,7 @@ export default {
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return interaction.reply({
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
content: client.messages.emojis["error"] + message.errorToGetPlaylist,
ephemeral: true
});
}
@ -39,12 +39,12 @@ export default {
if(!(interaction.member instanceof GuildMember)) return;
const voiceChannel = interaction.member?.voice.channel;
if (!voiceChannel) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noVoiceChannel,
content: client.messages.emojis["error"] + client.messages.noVoiceChannel,
ephemeral: true
});
if (radio) {
if (voiceChannel !== radio.voiceChannel) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.wrongVoiceChannel,
content: client.messages.emojis["error"] + client.messages.wrongVoiceChannel,
ephemeral: true
});
}
@ -55,13 +55,13 @@ export default {
const permissions = voiceChannel.permissionsFor(interaction.client.user);
if (!permissions?.has(PermissionFlagsBits.Connect)) {
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noPermsConnect,
content: client.messages.emojis["error"] + client.messages.noPermsConnect,
ephemeral: true
});
}
if (!permissions?.has(PermissionFlagsBits.Speak)) {
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noPermsSpeak,
content: client.messages.emojis["error"] + client.messages.noPermsSpeak,
ephemeral: true
});
}
@ -71,7 +71,7 @@ export default {
const number = parseInt((query - 1) as unknown as string);
if (number > client.stations.length - 1) {
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.wrongStationNumber,
content: client.messages.emojis["error"] + client.messages.wrongStationNumber,
ephemeral: true
});
} else {
@ -80,7 +80,7 @@ export default {
} else {
if(!(typeof query === 'string')) return;
if(query.length < 3) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.tooShortSearch,
content: client.messages.emojis["error"] + client.messages.tooShortSearch,
ephemeral: true
});
@ -96,7 +96,7 @@ export default {
const sstation = await client.stations.search(query, type);
if (!sstation) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noSearchResults,
content: client.messages.emojis["error"] + client.messages.noSearchResults,
ephemeral: true
});
station = sstation;
@ -142,7 +142,7 @@ export default {
console.log(error);
client.radio?.delete(interaction.guild?.id);
return interaction.reply({
content: client.messageEmojis["error"] + `An error occured: ${error}`,
content: client.messages.emojis["error"] + `An error occured: ${error}`,
ephemeral: true
});
}

View File

@ -12,7 +12,7 @@ export default {
const radio = client.radio?.get(interaction.guild?.id);
if(!client.stations) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
@ -22,7 +22,7 @@ export default {
let station = client.stations[index];
if(!station) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noSearchResults,
content: client.messages.emojis["error"] + client.messages.noSearchResults,
ephemeral: true
});

View File

@ -10,7 +10,7 @@ export default {
let message: any = {};
if(!interaction.guild) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
@ -22,7 +22,7 @@ export default {
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return interaction.reply({
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
content: client.messages.emojis["error"] + message.errorToGetPlaylist,
ephemeral: true
});
}
@ -35,13 +35,13 @@ export default {
const embed = new EmbedBuilder()
.setTitle(client.messages.statisticsTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["statistics"].replace(/[^0-9]+/g, ''))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["statistics"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor as ColorResolvable)
.setDescription(statistics)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -9,7 +9,7 @@ export default {
let message: any = {};
if(!client.user) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
@ -18,7 +18,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(message.statusTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor as ColorResolvable)
.addFields([
{ name: client.messages.statusField1, value: uptime },
@ -30,7 +30,7 @@ export default {
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({

View File

@ -14,7 +14,7 @@ export default {
const embed = new EmbedBuilder()
.setTitle(client.user?.username || "-")
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["stop"].replace(/[^0-9]+/g, ''))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["stop"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor as ColorResolvable)
.addFields({
name: client.messages.nowplayingTitle,
@ -23,7 +23,7 @@ export default {
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
if(!radio.message){
@ -43,7 +43,7 @@ export default {
client.radio?.delete(interaction.guild?.id);
interaction.reply({
content: client.messageEmojis["stop"] + client.messages.stop,
content: client.messages.emojis["stop"] + client.messages.stop,
ephemeral: true
});
}

View File

@ -1,44 +0,0 @@
import RadioClient from "../Client";
export const emojis = {
name: 'emojis',
async execute(client: RadioClient): Promise<any> {
let customEmojis: any = {
logo: "<:RadioX:688765708808487072>",
eximiabots: "<:EximiaBots:693277919929303132>",
list: "<:RadioXList:688541155519889482>",
play: "<:RadioXPlay:688541155712827458>",
stop: "<:RadioXStop:688541155377414168>",
statistics: "<:RadioXStatistics:694954485507686421>",
maintenance: "<:RadioXMaintenance:695043843057254493>",
error: "<:RadioXError:688541155792781320>",
prev: "<:RadioXPrev:882153637370023957>",
next: "<:RadioXNext:882153637474893834>"
};
let fallbackEmojis: any = {
logo: "RadioX",
eximiabots: "EximiaBots",
list: "📜",
play: "▶️",
stop: "⏹️",
statistics: "📊",
maintenance: "🛠️",
error: "❌",
prev: "⏪",
next: "⏩"
};
client.messageEmojis = {};
for (const customEmojiName in customEmojis) {
const customEmojiID = customEmojis[customEmojiName].replace(/[^0-9]+/g, '');
const customEmoji = client.emojis.cache.get(customEmojiID);
if (customEmoji) {
client.messageEmojis[customEmojiName] = customEmojis[customEmojiName];
} else {
client.messageEmojis[customEmojiName] = fallbackEmojis[customEmojiName];
}
}
}
}

View File

@ -7,7 +7,7 @@ export default {
if(client.config.maintenanceMode){
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.maintenance,
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
}
@ -16,7 +16,7 @@ export default {
if (!permissions.has(PermissionFlagsBits.ViewChannel)) return;
if (!permissions.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noPermsEmbed,
content: client.messages.emojis["error"] + client.messages.noPermsEmbed,
ephemeral: true
});
@ -29,7 +29,7 @@ export default {
command.execute(interaction, client);
} catch (error) {
interaction.reply({
content: client.messageEmojis["error"] + client.messages.runningCommandFailed,
content: client.messages.emojis["error"] + client.messages.runningCommandFailed,
ephemeral: true
});
console.error(error);
@ -43,7 +43,7 @@ export default {
command.execute(interaction, client, command);
} catch (error) {
interaction.reply({
content: client.messageEmojis["error"] + client.messages.runningCommandFailed,
content: client.messages.emojis["error"] + client.messages.runningCommandFailed,
ephemeral: true
});
console.error(error);

View File

@ -4,7 +4,6 @@ import Radio from "../classes/Radio";
import Stations from "../classes/Stations";
import Streamer from "../classes/Streamer";
import Statistics from "../classes/Statistics";
import { emojis } from "../emojis"
import commands from "../commands";
export default {
@ -65,9 +64,6 @@ export default {
client.statistics = new Statistics();
client.statistics.calculateGlobal(client);
/*EMOJIS*/
emojis.execute(client);
/*COMMANDS*/
commands.execute(client);

View File

@ -1,27 +1,26 @@
import RadioClient from "../../Client";
import { command } from "../commands";
export default function check(client: RadioClient, interaction: any, command: command) {
let message: any = {};
const radio = client.radio?.get(interaction.guild.id);
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
interaction.reply({
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
content: client.messages.emojis["error"] + message.errorToGetPlaylist,
ephemeral: true
});
return false;
}
if (!radio) {
interaction.reply({
content: client.messageEmojis["error"] + client.messages.notPlaying,
content: client.messages.emojis["error"] + client.messages.notPlaying,
ephemeral: true
});
return false;
}
if (interaction.member.voice.channel !== radio.voiceChannel) {
interaction.reply({
content: client.messageEmojis["error"] + client.messages.wrongVoiceChannel,
content: client.messages.emojis["error"] + client.messages.wrongVoiceChannel,
ephemeral: true
});
return false;

View File

@ -16,7 +16,7 @@ export default async function play(client: RadioClient, interaction: any, guild:
const embed = new EmbedBuilder()
.setTitle(client.user?.username || "-")
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messageEmojis["play"].replace(/[^0-9]+/g, '')))
.setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["play"].replace(/[^0-9]+/g, '')))
.setColor(client.config.embedColor as ColorResolvable)
.addFields({
name: client.messages.nowplayingTitle,
@ -25,38 +25,38 @@ export default async function play(client: RadioClient, interaction: any, guild:
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
const buttons = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('list')
.setEmoji(client.messageEmojis["list"])
.setEmoji(client.messages.emojis["list"])
.setStyle(ButtonStyle.Secondary)
)
.addComponents(
new ButtonBuilder()
.setCustomId('prev')
.setEmoji(client.messageEmojis["prev"])
.setEmoji(client.messages.emojis["prev"])
.setStyle(ButtonStyle.Secondary)
)
.addComponents(
new ButtonBuilder()
.setCustomId('stop')
.setEmoji(client.messageEmojis["stop"])
.setEmoji(client.messages.emojis["stop"])
.setStyle(ButtonStyle.Secondary)
)
.addComponents(
new ButtonBuilder()
.setCustomId('next')
.setEmoji(client.messageEmojis["next"])
.setEmoji(client.messages.emojis["next"])
.setStyle(ButtonStyle.Secondary)
)
.addComponents(
new ButtonBuilder()
.setCustomId('statistics')
.setEmoji(client.messageEmojis["statistics"])
.setEmoji(client.messages.emojis["statistics"])
.setStyle(ButtonStyle.Secondary)
);
@ -74,7 +74,7 @@ export default async function play(client: RadioClient, interaction: any, guild:
message.play = client.messages.play.replace("%radio.station.name%", radio.station.name);
interaction?.reply({
content: client.messageEmojis["play"] + message.play,
content: client.messages.emojis["play"] + message.play,
ephemeral: true
});

View File

@ -35,5 +35,17 @@ export const messages = {
statusField4: ":hourglass: Latency",
statusField5: ":globe_with_meridians: Hosted by",
errorStationURL: "Station can't be URL",
maintenance: "Shhhh... We are now sleeping and dreaming about new features to implement. Will be back soon."
maintenance: "Shhhh... We are now sleeping and dreaming about new features to implement. Will be back soon.",
emojis: {
logo: "<:RadioX:688765708808487072>",
eximiabots: "<:EximiaBots:693277919929303132>",
list: "<:RadioXList:688541155519889482>",
play: "<:RadioXPlay:688541155712827458>",
stop: "<:RadioXStop:688541155377414168>",
statistics: "<:RadioXStatistics:694954485507686421>",
maintenance: "<:RadioXMaintenance:695043843057254493>",
error: "<:RadioXError:688541155792781320>",
prev: "<:RadioXPrev:882153637370023957>",
next: "<:RadioXNext:882153637474893834>"
}
};