Add opt out method
This commit is contained in:
parent
cfca3135d7
commit
dbefee209d
@ -2,6 +2,7 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
|
|||||||
const { GuildInfo } = require('../modules/CustomClasses.js');
|
const { GuildInfo } = require('../modules/CustomClasses.js');
|
||||||
const dbfn = require('../modules/dbfn.js');
|
const dbfn = require('../modules/dbfn.js');
|
||||||
const fn = require('../modules/functions.js');
|
const fn = require('../modules/functions.js');
|
||||||
|
const strings = require('../data/strings.json');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
@ -55,6 +56,10 @@ module.exports = {
|
|||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.addSubcommand(sc =>
|
||||||
|
sc.setName('disable')
|
||||||
|
.setDescription('Disable the notification relay')
|
||||||
|
)
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles),
|
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
try {
|
try {
|
||||||
@ -69,7 +74,7 @@ module.exports = {
|
|||||||
const fruitMessage = interaction.options.getString('fruitmessage') ? interaction.options.getString('fruitmessage') : interaction.options.getString('watermessage');
|
const fruitMessage = interaction.options.getString('fruitmessage') ? interaction.options.getString('fruitmessage') : interaction.options.getString('watermessage');
|
||||||
const reminderChannel = interaction.options.getChannel('pingchannel');
|
const reminderChannel = interaction.options.getChannel('pingchannel');
|
||||||
let guildInfo = interaction.client.guildInfos.get(interaction.guildId);
|
let guildInfo = interaction.client.guildInfos.get(interaction.guildId);
|
||||||
guildInfo.setReminders(waterMessage, fruitMessage, reminderChannel.id, watchChannel.id);
|
guildInfo.setReminders(waterMessage, fruitMessage, reminderChannel.id, watchChannel.id, true);
|
||||||
let query = guildInfo.queryBuilder("setReminders");
|
let query = guildInfo.queryBuilder("setReminders");
|
||||||
await dbfn.setGuildInfo(query);
|
await dbfn.setGuildInfo(query);
|
||||||
const replyParts = [
|
const replyParts = [
|
||||||
@ -86,7 +91,7 @@ module.exports = {
|
|||||||
const reminderChannel = interaction.options.getChannel('pingchannel');
|
const reminderChannel = interaction.options.getChannel('pingchannel');
|
||||||
let guildInfo = new GuildInfo()
|
let guildInfo = new GuildInfo()
|
||||||
.setId(interaction.guildId)
|
.setId(interaction.guildId)
|
||||||
.setReminders(waterMessage, fruitMessage, reminderChannel.id, watchChannel.id);
|
.setReminders(waterMessage, fruitMessage, reminderChannel.id, watchChannel.id, true);
|
||||||
let query = guildInfo.queryBuilder("setReminders");
|
let query = guildInfo.queryBuilder("setReminders");
|
||||||
await dbfn.setGuildInfo(query);
|
await dbfn.setGuildInfo(query);
|
||||||
const replyParts = [
|
const replyParts = [
|
||||||
@ -111,7 +116,7 @@ module.exports = {
|
|||||||
const outFruitMessage = inFruitMessage ? inFruitMessage : guildInfo.fruitMessage;
|
const outFruitMessage = inFruitMessage ? inFruitMessage : guildInfo.fruitMessage;
|
||||||
const outReminderChannelId = inReminderChannel ? inReminderChannel.id : guildInfo.reminderChannelId;
|
const outReminderChannelId = inReminderChannel ? inReminderChannel.id : guildInfo.reminderChannelId;
|
||||||
|
|
||||||
guildInfo.setReminders(outWaterMessage, outFruitMessage, outReminderChannelId, outWatchChannelId);
|
guildInfo.setReminders(outWaterMessage, outFruitMessage, outReminderChannelId, outWatchChannelId, true);
|
||||||
let query = guildInfo.queryBuilder("setReminders");
|
let query = guildInfo.queryBuilder("setReminders");
|
||||||
await dbfn.setGuildInfo(query);
|
await dbfn.setGuildInfo(query);
|
||||||
const replyParts = [
|
const replyParts = [
|
||||||
@ -125,6 +130,17 @@ module.exports = {
|
|||||||
await interaction.editReply(fn.builders.errorEmbed("There is no existing notification relay to update!")).catch(e => console.error(e));
|
await interaction.editReply(fn.builders.errorEmbed("There is no existing notification relay to update!")).catch(e => console.error(e));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'disable':
|
||||||
|
if (interaction.client.guildInfos.has(interaction.guildId)) {
|
||||||
|
let guildInfo = interaction.client.guildInfos.get(interaction.guildId);
|
||||||
|
guildInfo.setReminders(undefined, undefined, undefined, undefined, false);
|
||||||
|
await dbfn.setGuildInfo(guildInfo.queryBuilder("setReminders")).catch(e => console.error(e));
|
||||||
|
await fn.collectionBuilders.guildInfos(interaction.client);
|
||||||
|
await interaction.editReply(fn.builders.embed(strings.status.optout)).catch(e => console.error(e));
|
||||||
|
} else {
|
||||||
|
await interaction.editReply(fn.builders.errorEmbed("A notification relay has not been set up yet!")).catch(e => console.error(e));
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
await interaction.editReply(fn.builders.errorEmbed("Invalid subcommand detected.")).catch(e => console.error(e));
|
await interaction.editReply(fn.builders.errorEmbed("Invalid subcommand detected.")).catch(e => console.error(e));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user