mirror of
				https://github.com/warengroup/eximiabots-radiox.git
				synced 2025-10-31 20:41:35 +00:00 
			
		
		
		
	Add replace method to messages variable
This commit is contained in:
		| @@ -11,16 +11,15 @@ export default { | |||||||
|             ephemeral: true |             ephemeral: true | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         let message : any = {}; |  | ||||||
|  |  | ||||||
|         message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username); |  | ||||||
|         message.bugDescription = client.messages.bugDescription.replace("%client.config.supportGuild%", client.config.supportGuild); |  | ||||||
|  |  | ||||||
|         const embed = new EmbedBuilder() |         const embed = new EmbedBuilder() | ||||||
|             .setTitle(message.bugTitle) |             .setTitle(client.messages.replace(client.messages.bugTitle, { | ||||||
|  |                 "%client.user.username%": client.user.username | ||||||
|  |             })) | ||||||
|             .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["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) |             .setColor(client.config.embedColor as ColorResolvable) | ||||||
|             .setDescription(message.bugDescription) |             .setDescription(client.messages.replace(client.messages.bugDescription, { | ||||||
|  |                     "%client.config.supportGuild%": client.config.supportGuild | ||||||
|  |             })) | ||||||
|             .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') |             .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') | ||||||
|             .setFooter({ |             .setFooter({ | ||||||
|                 text: client.messages.footerText, |                 text: client.messages.footerText, | ||||||
|   | |||||||
| @@ -12,8 +12,6 @@ export default { | |||||||
|             ephemeral: true |             ephemeral: true | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         let message: any = {}; |  | ||||||
|  |  | ||||||
|         const categories : any= []; |         const categories : any= []; | ||||||
|         for (let i = 0; i < client.commands.size; i++) { |         for (let i = 0; i < client.commands.size; i++) { | ||||||
|             if (!categories.includes([...client.commands.values()][i].category)) categories.push([...client.commands.values()][i].category); |             if (!categories.includes([...client.commands.values()][i].category)) categories.push([...client.commands.values()][i].category); | ||||||
| @@ -23,14 +21,15 @@ export default { | |||||||
|             commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i]).map((x: { name: any; }) => `\`${x.name}\``).join(', ')}\n`; |             commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i]).map((x: { name: any; }) => `\`${x.name}\``).join(', ')}\n`; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         message.helpTitle = client.messages.helpTitle.replace("%client.user.username%", client.user?.username || "-"); |  | ||||||
|         message.helpDescription = client.messages.helpDescription.replace("%commands%", commands); |  | ||||||
|  |  | ||||||
|         const embed = new EmbedBuilder() |         const embed = new EmbedBuilder() | ||||||
|             .setTitle(message.helpTitle) |             .setTitle(client.messages.replace(client.messages.helpTitle, { | ||||||
|  |                 "%client.user.username%": client.user.username | ||||||
|  |             })) | ||||||
|             .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["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) |             .setColor(client.config.embedColor as ColorResolvable) | ||||||
|             .setDescription(message.helpDescription) |             .setDescription(client.messages.replace(client.messages.helpDescription, { | ||||||
|  |                 "%commands%": commands | ||||||
|  |             })) | ||||||
|             .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') |             .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') | ||||||
|             .setFooter({ |             .setFooter({ | ||||||
|                 text: client.messages.footerText, |                 text: client.messages.footerText, | ||||||
|   | |||||||
| @@ -13,9 +13,10 @@ export default { | |||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         let message: any = {}; |         let message: any = {}; | ||||||
|         message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username); |  | ||||||
|         const embed = new EmbedBuilder() |         const embed = new EmbedBuilder() | ||||||
|             .setTitle(message.inviteTitle) |             .setTitle(client.messages.replace(client.messages.inviteTitle, { | ||||||
|  |                 "%client.user.username%": client.user.username | ||||||
|  |             })) | ||||||
|             .setColor(client.config.embedColor as ColorResolvable) |             .setColor(client.config.embedColor as ColorResolvable) | ||||||
|             .setURL("https://discord.com/api/oauth2/authorize?client_id=" + client.user.id + "&permissions=2184465408&scope=applications.commands%20bot") //View Channels, Send Messages, Embed Links, Use External Emojis, Use Slash Commands, Connect, Speak, Use Voice Activity |             .setURL("https://discord.com/api/oauth2/authorize?client_id=" + client.user.id + "&permissions=2184465408&scope=applications.commands%20bot") //View Channels, Send Messages, Embed Links, Use External Emojis, Use Slash Commands, Connect, Speak, Use Voice Activity | ||||||
|             .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') |             .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') | ||||||
|   | |||||||
| @@ -9,9 +9,10 @@ export default { | |||||||
|         let message: any = {}; |         let message: any = {}; | ||||||
|  |  | ||||||
|         if(!client.stations) { |         if(!client.stations) { | ||||||
|             message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); |  | ||||||
|             return interaction.reply({ |             return interaction.reply({ | ||||||
|                 content: client.messages.emojis["error"] + message.errorToGetPlaylist, |                 content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { | ||||||
|  |                     "%client.config.supportGuild%": client.config.supportGuild | ||||||
|  |                 }), | ||||||
|                 ephemeral: true |                 ephemeral: true | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -15,15 +15,15 @@ export default { | |||||||
|             radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime); |             radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime); | ||||||
|             const completed = (radio.playTime); |             const completed = (radio.playTime); | ||||||
|  |  | ||||||
|             message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); |  | ||||||
|             message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%" + "\n", radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""); |  | ||||||
|             message.nowplayingDescription = message.nowplayingDescription.replace("%client.funcs.msToTime(completed)%", client.funcs.msToTime(completed)); |  | ||||||
|  |  | ||||||
|             const embed = new EmbedBuilder() |             const embed = new EmbedBuilder() | ||||||
|                 .setTitle(client.messages.nowplayingTitle) |                 .setTitle(client.messages.nowplayingTitle) | ||||||
|                 .setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["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) |                 .setColor(client.config.embedColor as ColorResolvable) | ||||||
|                 .setDescription(message.nowplayingDescription) |                 .setDescription(client.messages.replace(client.messages.nowplayingDescription, { | ||||||
|  |                     "%radio.station.name%": radio.station.name, | ||||||
|  |                     "%radio.station.owner%\n": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : "", | ||||||
|  |                     "%client.funcs.msToTime(completed)%": client.funcs.msToTime(completed) | ||||||
|  |                 })) | ||||||
|                 .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') |                 .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') | ||||||
|                 .setFooter({ |                 .setFooter({ | ||||||
|                     text: client.messages.footerText, |                     text: client.messages.footerText, | ||||||
|   | |||||||
| @@ -14,9 +14,10 @@ export default { | |||||||
|         let message: any = {}; |         let message: any = {}; | ||||||
|  |  | ||||||
|         if(!client.stations) { |         if(!client.stations) { | ||||||
|             message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); |  | ||||||
|             return interaction.reply({ |             return interaction.reply({ | ||||||
|                 content: client.messages.emojis["error"] + message.errorToGetPlaylist, |                 content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { | ||||||
|  |                     "%client.config.supportGuild%": client.config.supportGuild | ||||||
|  |                 }), | ||||||
|                 ephemeral: true |                 ephemeral: true | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -20,9 +20,10 @@ export default { | |||||||
|         let statistics = ""; |         let statistics = ""; | ||||||
|  |  | ||||||
|         if(!client.stations) { |         if(!client.stations) { | ||||||
|             message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); |  | ||||||
|             return interaction.reply({ |             return interaction.reply({ | ||||||
|                 content: client.messages.emojis["error"] + message.errorToGetPlaylist, |                 content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { | ||||||
|  |                     "%client.config.supportGuild%": client.config.supportGuild | ||||||
|  |                 }), | ||||||
|                 ephemeral: true |                 ephemeral: true | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -17,7 +17,9 @@ export default { | |||||||
|         let uptime = client.funcs.msToTime(client.uptime || 0); |         let uptime = client.funcs.msToTime(client.uptime || 0); | ||||||
|  |  | ||||||
|         const embed = new EmbedBuilder() |         const embed = new EmbedBuilder() | ||||||
|             .setTitle(message.statusTitle) |             .setTitle(client.messages.replace(client.messages.statusTitle, { | ||||||
|  |                 "%client.user.username%": client.user.username | ||||||
|  |             })) | ||||||
|             .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["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) |             .setColor(client.config.embedColor as ColorResolvable) | ||||||
|             .addFields([ |             .addFields([ | ||||||
|   | |||||||
| @@ -4,9 +4,10 @@ export default function check(client: RadioClient, interaction: any, command: co | |||||||
|     let message: any = {}; |     let message: any = {}; | ||||||
|     const radio = client.radio?.get(interaction.guild.id); |     const radio = client.radio?.get(interaction.guild.id); | ||||||
|     if(!client.stations) { |     if(!client.stations) { | ||||||
|         message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); |  | ||||||
|         interaction.reply({ |         interaction.reply({ | ||||||
|             content: client.messages.emojis["error"] + message.errorToGetPlaylist, |             content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { | ||||||
|  |                 "%client.config.supportGuild%": client.config.supportGuild | ||||||
|  |             }), | ||||||
|             ephemeral: true |             ephemeral: true | ||||||
|         }); |         }); | ||||||
|         return false; |         return false; | ||||||
|   | |||||||
| @@ -4,26 +4,25 @@ import { station } from "../classes/Stations"; | |||||||
|  |  | ||||||
| export default async function play(client: RadioClient, interaction: ChatInputCommandInteraction | StringSelectMenuInteraction | null, guild: Guild | null, station: station) { | export default async function play(client: RadioClient, interaction: ChatInputCommandInteraction | StringSelectMenuInteraction | null, guild: Guild | null, station: station) { | ||||||
|     if(!guild) return; |     if(!guild) return; | ||||||
|     let message: any = {}; |  | ||||||
|  |  | ||||||
|     const radio = client.radio?.get(guild.id); |     const radio = client.radio?.get(guild.id); | ||||||
|     const audioPlayer = client.streamer?.listen(station); |     const audioPlayer = client.streamer?.listen(station); | ||||||
|     radio.connection.subscribe(audioPlayer); |     radio.connection.subscribe(audioPlayer); | ||||||
|     client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name); |     client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name); | ||||||
|  |  | ||||||
|     message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name); |  | ||||||
|     message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.name != radio.station.owner ? radio.station.owner + "\n" : ""); |  | ||||||
|     message.nowplayingDescription = message.nowplayingDescription.replace("%client.funcs.msToTime(completed)%", ""); |  | ||||||
|     message.nowplayingDescription = message.nowplayingDescription.replace("**", ""); |  | ||||||
|     message.nowplayingDescription = message.nowplayingDescription.replace("**", ""); |  | ||||||
|  |  | ||||||
|     const embed = new EmbedBuilder() |     const embed = new EmbedBuilder() | ||||||
|         .setTitle(client.user?.username || "-") |         .setTitle(client.user?.username || "-") | ||||||
|         .setThumbnail((radio.station.logo || "https://cdn.discordapp.com/emojis/" + client.messages.emojis["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) |         .setColor(client.config.embedColor as ColorResolvable) | ||||||
|         .addFields({ |         .addFields({ | ||||||
|             name: client.messages.nowplayingTitle, |             name: client.messages.nowplayingTitle, | ||||||
|             value: message.nowplayingDescription |             value: client.messages.replace(client.messages.nowplayingDescription, { | ||||||
|  |                 "%radio.station.name%": radio.station.name, | ||||||
|  |                 "%radio.station.owner%\n": radio.station.name != radio.station.owner ? radio.station.owner + "\n" : "", | ||||||
|  |                 "%client.funcs.msToTime(completed)%": "", | ||||||
|  |                 "**": "", | ||||||
|  |                 "**:2": "" | ||||||
|  |             }) | ||||||
|         }) |         }) | ||||||
|         .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') |         .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') | ||||||
|         .setFooter({ |         .setFooter({ | ||||||
| @@ -74,10 +73,10 @@ export default async function play(client: RadioClient, interaction: ChatInputCo | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     message.play = client.messages.play.replace("%radio.station.name%", radio.station.name); |  | ||||||
|  |  | ||||||
|     interaction?.reply({ |     interaction?.reply({ | ||||||
|         content: client.messages.emojis["play"] + message.play, |         content: client.messages.emojis["play"] + client.messages.replace(client.messages.play, { | ||||||
|  |             "%radio.station.name%": radio.station.name | ||||||
|  |         }), | ||||||
|         ephemeral: true |         ephemeral: true | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,16 @@ | |||||||
| export const messages = { | export const messages = { | ||||||
|  |     replace(message: string, variables: { [key: string]: string }){ | ||||||
|  |         for(let variable in variables){ | ||||||
|  |             if(variable.includes('%')){ | ||||||
|  |                 message = message.replace(variable, variables[variable]); | ||||||
|  |             } else if(variable.includes(':')){ | ||||||
|  |                 message = message.replace(variable.split(':')[0], variables[variable]); | ||||||
|  |             } else { | ||||||
|  |                 message = message.replace(variable, variables[variable]); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return message; | ||||||
|  |     }, | ||||||
|     wrongVoiceChannel: "You need to be in the same voice channel as RadioX to use this command!", |     wrongVoiceChannel: "You need to be in the same voice channel as RadioX to use this command!", | ||||||
|     noPerms: "You need the %command.permission% permission to use this command!", |     noPerms: "You need the %command.permission% permission to use this command!", | ||||||
|     notPlaying: "There is nothing playing!", |     notPlaying: "There is nothing playing!", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Christer Warén
					Christer Warén