Limit commands in maintenance mode

This commit is contained in:
Christer Warén 2023-06-08 00:28:48 +03:00
parent 3f1d576c44
commit 408c5aaab8
4 changed files with 37 additions and 15 deletions

View File

@ -8,6 +8,13 @@ export default {
category: 'radio',
execute(interaction: ButtonInteraction | ChatInputCommandInteraction | StringSelectMenuInteraction, client: RadioClient) {
if(client.config.maintenanceMode){
return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
}
if(!client.stations) {
return interaction.reply({
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {

View File

@ -11,10 +11,21 @@ export default {
if (client.funcs.check(client, interaction, command)) {
const radio = client.radio?.get(interaction.guild?.id);
if(!client.stations) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
if(client.config.maintenanceMode){
return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
}
if(!client.stations) {
return interaction.reply({
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild
}),
ephemeral: true
});
}
let index: number = client.stations.findIndex((station: station) => station.name == radio.station.name) + 1;
if(index == client.stations?.length) index = 0;

View File

@ -11,10 +11,21 @@ export default {
if (client.funcs.check(client, interaction, command)) {
const radio = client.radio?.get(interaction.guild?.id);
if(!client.stations) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
if(client.config.maintenanceMode){
return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
}
if(!client.stations) {
return interaction.reply({
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild
}),
ephemeral: true
});
}
let index = client.stations.findIndex((station: station) => station.name == radio.station.name) - 1;
if(index == -1) index = client.stations.length - 1;

View File

@ -4,13 +4,6 @@ import RadioClient from "../../Client";
export default function interactionCreate(client: RadioClient, interaction: Interaction) {
if(!(interaction.isButton()) && !(interaction.isChatInputCommand()) && !(interaction.isStringSelectMenu())) return;
if(client.config.maintenanceMode){
return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
}
//@ts-ignore
const permissions = interaction.channel?.permissionsFor(interaction.client.user);
if (!permissions.has(PermissionFlagsBits.ViewChannel)) return;