Ephemeral replies

This commit is contained in:
Christer Warén 2021-08-26 22:06:15 +03:00
parent 294aa28849
commit 4498efcdcd
9 changed files with 83 additions and 30 deletions

View File

@ -17,7 +17,10 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setDescription(message.bugDescription) .setDescription(message.bugDescription)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
} }
}; };

View File

@ -27,6 +27,10 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setDescription(message.helpDescription) .setDescription(message.helpDescription)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
} }
}; };

View File

@ -13,6 +13,10 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setURL("https://discordapp.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://discordapp.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
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
} }
}; };

View File

@ -23,6 +23,10 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setDescription(stations) .setDescription(stations)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
} }
}; };

View File

@ -48,6 +48,10 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setDescription("Stopped all radios" + "\n" + stoppedRadios) .setDescription("Stopped all radios" + "\n" + stoppedRadios)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
} }
}; };

View File

@ -24,21 +24,26 @@ module.exports = {
const voiceChannel = interaction.member.voice.channel; const voiceChannel = interaction.member.voice.channel;
if (!radio) { if (!radio) {
if (!interaction.member.voice.channel) if (!interaction.member.voice.channel)
return interaction.reply( return interaction.reply({
client.messageEmojis["error"] + client.messages.noVoiceChannel content: client.messageEmojis["error"] + client.messages.noVoiceChannel,
); ephemeral: true
});
} else { } else {
if (voiceChannel !== radio.voiceChannel) if (voiceChannel !== radio.voiceChannel)
return interaction.reply( return interaction.reply({
client.messageEmojis["error"] + client.messages.wrongVoiceChannel content: client.messageEmojis["error"] + client.messages.wrongVoiceChannel,
); ephemeral: true
});
} }
if (!client.stations) { if (!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace( message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace(
"%client.config.supportGuild%", "%client.config.supportGuild%",
client.config.supportGuild client.config.supportGuild
); );
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist); return interaction.reply({
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
ephemeral: true
});
} }
if (!query) return interaction.reply(client.messages.noQuery); if (!query) return interaction.reply(client.messages.noQuery);
const permissions = voiceChannel.permissionsFor(interaction.client.user); const permissions = voiceChannel.permissionsFor(interaction.client.user);
@ -51,28 +56,32 @@ module.exports = {
let station; let station;
const number = parseInt(query - 1); const number = parseInt(query - 1);
if (url.startsWith("http")) { if (url.startsWith("http")) {
return interaction.reply( return interaction.reply({
client.messageEmojis["error"] + client.messages.errorStationURL content: client.messageEmojis["error"] + client.messages.errorStationURL,
); ephemeral: true
});
} else if (!isNaN(number)) { } else if (!isNaN(number)) {
if (number > client.stations.length - 1) { if (number > client.stations.length - 1) {
return interaction.reply( return interaction.reply({
client.messageEmojis["error"] + client.messages.wrongStationNumber content: client.messageEmojis["error"] + client.messages.wrongStationNumber,
); ephemeral: true
});
} else { } else {
url = client.stations[number].stream[client.stations[number].stream.default]; url = client.stations[number].stream[client.stations[number].stream.default];
station = client.stations[number]; station = client.stations[number];
} }
} else { } else {
if (query.length < 3) if (query.length < 3)
return interaction.reply( return interaction.reply({
client.messageEmojis["error"] + client.messages.tooShortSearch content: client.messageEmojis["error"] + client.messages.tooShortSearch,
); ephemeral: true
});
const sstation = await searchStation(query.slice(1), client); const sstation = await searchStation(query.slice(1), client);
if (!sstation) if (!sstation)
return interaction.reply( return interaction.reply({
client.messageEmojis["error"] + client.messages.noSearchResults content: client.messageEmojis["error"] + client.messages.noSearchResults,
); ephemeral: true
});
url = sstation.stream[sstation.stream.default]; url = sstation.stream[sstation.stream.default];
station = sstation; station = sstation;
} }
@ -163,7 +172,15 @@ function searchStation(key, client) {
let foundStations = []; let foundStations = [];
if (!key) return false; if (!key) return false;
if (key == "radio") return false; if (key == "radio") return false;
if (key.startsWith("radio ")) key = key.slice(6); /*client.stations
.filter(
x => x.name.toUpperCase().includes(key.toUpperCase()) || x === key
)
.forEach(x =>
foundStations.push({ station: x, name: x.name, probability: probabilityIncrement })
);*/
//if (key.startsWith("radio ")) key = key.slice(6);
const probabilityIncrement = 100 / key.split(" ").length / 2; const probabilityIncrement = 100 / key.split(" ").length / 2;
for (let i = 0; i < key.split(" ").length; i++) { for (let i = 0; i < key.split(" ").length; i++) {
client.stations client.stations

View File

@ -34,6 +34,10 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setDescription(statistics) .setDescription(statistics)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
} }
}; };

View File

@ -21,7 +21,11 @@ module.exports = {
.addField(client.messages.statusField4, client.config.version, true) .addField(client.messages.statusField4, client.config.version, true)
.addField(client.messages.statusField5, client.config.hostedBy, true) .addField(client.messages.statusField5, client.config.hostedBy, true)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
} }
}; };

View File

@ -3,17 +3,26 @@ module.exports = function (client, interaction, command) {
const radio = client.radio.get(interaction.guild.id); const radio = client.radio.get(interaction.guild.id);
const permissions = interaction.channel.permissionsFor(interaction.user); const permissions = interaction.channel.permissionsFor(interaction.user);
if (!radio) { if (!radio) {
interaction.reply(client.messageEmojis["error"] + client.messages.notPlaying); interaction.reply({
content: client.messageEmojis["error"] + client.messages.notPlaying,
ephemeral: true
});
return false; return false;
} }
if (interaction.member.voice.channel !== radio.voiceChannel) { if (interaction.member.voice.channel !== radio.voiceChannel) {
interaction.reply(client.messageEmojis["error"] + client.messages.wrongVoiceChannel); interaction.reply({
content: client.messageEmojis["error"] + client.messages.wrongVoiceChannel,
ephemeral: true
});
return false; return false;
} }
if(!command.permission == 'none'){ if(!command.permission == 'none'){
if (!permissions.has(command.permission)) { if (!permissions.has(command.permission)) {
message.noPerms = client.messages.noPerms.replace("%command.permission%", command.permission); message.noPerms = client.messages.noPerms.replace("%command.permission%", command.permission);
interaction.reply(client.messageEmojis["error"] + message.noPerms); interaction.reply({
content: client.messageEmojis["error"] + message.noPerms,
ephemeral: true
});
return false; return false;
} else return true; } else return true;
} else return true; } else return true;