mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-22 21:33:17 +00:00
Add replace method to messages variable
This commit is contained in:
parent
3686cd1b0e
commit
78d6b92dbd
@ -11,16 +11,15 @@ export default {
|
||||
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()
|
||||
.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, ''))
|
||||
.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')
|
||||
.setFooter({
|
||||
text: client.messages.footerText,
|
||||
|
@ -12,8 +12,6 @@ export default {
|
||||
ephemeral: true
|
||||
});
|
||||
|
||||
let message: any = {};
|
||||
|
||||
const categories : any= [];
|
||||
for (let i = 0; i < client.commands.size; i++) {
|
||||
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`;
|
||||
}
|
||||
|
||||
message.helpTitle = client.messages.helpTitle.replace("%client.user.username%", client.user?.username || "-");
|
||||
message.helpDescription = client.messages.helpDescription.replace("%commands%", commands);
|
||||
|
||||
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, ''))
|
||||
.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')
|
||||
.setFooter({
|
||||
text: client.messages.footerText,
|
||||
|
@ -13,9 +13,10 @@ export default {
|
||||
});
|
||||
|
||||
let message: any = {};
|
||||
message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);
|
||||
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)
|
||||
.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')
|
||||
|
@ -9,9 +9,10 @@ export default {
|
||||
let message: any = {};
|
||||
|
||||
if(!client.stations) {
|
||||
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
||||
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
|
||||
});
|
||||
}
|
||||
|
@ -15,15 +15,15 @@ export default {
|
||||
radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime);
|
||||
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()
|
||||
.setTitle(client.messages.nowplayingTitle)
|
||||
.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)
|
||||
.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')
|
||||
.setFooter({
|
||||
text: client.messages.footerText,
|
||||
|
@ -14,9 +14,10 @@ export default {
|
||||
let message: any = {};
|
||||
|
||||
if(!client.stations) {
|
||||
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
||||
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
|
||||
});
|
||||
}
|
||||
|
@ -20,9 +20,10 @@ export default {
|
||||
let statistics = "";
|
||||
|
||||
if(!client.stations) {
|
||||
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
||||
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
|
||||
});
|
||||
}
|
||||
|
@ -17,7 +17,9 @@ export default {
|
||||
let uptime = client.funcs.msToTime(client.uptime || 0);
|
||||
|
||||
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, ''))
|
||||
.setColor(client.config.embedColor as ColorResolvable)
|
||||
.addFields([
|
||||
|
@ -4,9 +4,10 @@ export default function check(client: RadioClient, interaction: any, command: co
|
||||
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.messages.emojis["error"] + message.errorToGetPlaylist,
|
||||
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
|
||||
"%client.config.supportGuild%": client.config.supportGuild
|
||||
}),
|
||||
ephemeral: true
|
||||
});
|
||||
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) {
|
||||
if(!guild) return;
|
||||
let message: any = {};
|
||||
|
||||
const radio = client.radio?.get(guild.id);
|
||||
const audioPlayer = client.streamer?.listen(station);
|
||||
radio.connection.subscribe(audioPlayer);
|
||||
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()
|
||||
.setTitle(client.user?.username || "-")
|
||||
.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,
|
||||
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')
|
||||
.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({
|
||||
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
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,16 @@
|
||||
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!",
|
||||
noPerms: "You need the %command.permission% permission to use this command!",
|
||||
notPlaying: "There is nothing playing!",
|
||||
|
Loading…
Reference in New Issue
Block a user