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)
.setDescription(message.bugDescription)
.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)
.setDescription(message.helpDescription)
.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)
.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, ''));
return interaction.reply({ embeds: [embed] });
interaction.reply({
embeds: [embed],
ephemeral: true
});
}
};

View File

@ -23,6 +23,10 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(stations)
.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)
.setDescription("Stopped all radios" + "\n" + stoppedRadios)
.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;
if (!radio) {
if (!interaction.member.voice.channel)
return interaction.reply(
client.messageEmojis["error"] + client.messages.noVoiceChannel
);
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noVoiceChannel,
ephemeral: true
});
} else {
if (voiceChannel !== radio.voiceChannel)
return interaction.reply(
client.messageEmojis["error"] + client.messages.wrongVoiceChannel
);
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.wrongVoiceChannel,
ephemeral: true
});
}
if (!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace(
"%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);
const permissions = voiceChannel.permissionsFor(interaction.client.user);
@ -51,28 +56,32 @@ module.exports = {
let station;
const number = parseInt(query - 1);
if (url.startsWith("http")) {
return interaction.reply(
client.messageEmojis["error"] + client.messages.errorStationURL
);
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.errorStationURL,
ephemeral: true
});
} else if (!isNaN(number)) {
if (number > client.stations.length - 1) {
return interaction.reply(
client.messageEmojis["error"] + client.messages.wrongStationNumber
);
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.wrongStationNumber,
ephemeral: true
});
} else {
url = client.stations[number].stream[client.stations[number].stream.default];
station = client.stations[number];
}
} else {
if (query.length < 3)
return interaction.reply(
client.messageEmojis["error"] + client.messages.tooShortSearch
);
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.tooShortSearch,
ephemeral: true
});
const sstation = await searchStation(query.slice(1), client);
if (!sstation)
return interaction.reply(
client.messageEmojis["error"] + client.messages.noSearchResults
);
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noSearchResults,
ephemeral: true
});
url = sstation.stream[sstation.stream.default];
station = sstation;
}
@ -163,7 +172,15 @@ function searchStation(key, client) {
let foundStations = [];
if (!key) 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;
for (let i = 0; i < key.split(" ").length; i++) {
client.stations

View File

@ -34,6 +34,10 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(statistics)
.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.statusField5, client.config.hostedBy, true)
.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 permissions = interaction.channel.permissionsFor(interaction.user);
if (!radio) {
interaction.reply(client.messageEmojis["error"] + client.messages.notPlaying);
interaction.reply({
content: client.messageEmojis["error"] + client.messages.notPlaying,
ephemeral: true
});
return false;
}
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;
}
if(!command.permission == 'none'){
if (!permissions.has(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;
} else return true;
} else return true;