Add replace method to messages variable

This commit is contained in:
Christer Warén
2023-06-06 06:04:28 +03:00
parent 3686cd1b0e
commit 78d6b92dbd
11 changed files with 57 additions and 41 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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')

View File

@ -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
});
}

View File

@ -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,

View File

@ -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
});
}

View File

@ -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
});
}

View File

@ -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([