From 57769f95ff2ef23ac6e39dfc0744f45a903b7506 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 27 Jan 2023 19:42:04 -0500 Subject: [PATCH] Partial rollback to v1.1.2 DO NOT DEPLOY --- slash-commands/DEV_dumptree.js | 20 -------------------- slash-commands/optout.js | 20 -------------------- slash-commands/setping.js | 31 +++++++++---------------------- slash-commands/setping.js.bak | 18 ------------------ slash-commands/setpingrole.js | 24 ++++++++++++++++++++++++ 5 files changed, 33 insertions(+), 80 deletions(-) delete mode 100644 slash-commands/DEV_dumptree.js delete mode 100644 slash-commands/optout.js delete mode 100644 slash-commands/setping.js.bak create mode 100644 slash-commands/setpingrole.js diff --git a/slash-commands/DEV_dumptree.js b/slash-commands/DEV_dumptree.js deleted file mode 100644 index 8301c66..0000000 --- a/slash-commands/DEV_dumptree.js +++ /dev/null @@ -1,20 +0,0 @@ -const { SlashCommandBuilder } = require('discord.js'); -const dbfn = require('../modules/dbfn.js'); -const fn = require('../modules/functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('dumptree') - .setDescription('Dump the contents of the tree message to console'), - async execute(interaction) { - await interaction.deferReply({ ephemeral: true }); - const getGuildInfoResponse = await dbfn.getGuildInfo(interaction.guildId); - const { treeMessageId, treeChannelId } = getGuildInfoResponse.data; - interaction.guild.channels.fetch(treeChannelId).then(treeChannel => { - treeChannel.messages.fetch(treeMessageId).then(treeMessage => { - interaction.editReply("done"); - console.log(JSON.stringify(treeMessage.embeds[0])); - }); - }); - }, -}; \ No newline at end of file diff --git a/slash-commands/optout.js b/slash-commands/optout.js deleted file mode 100644 index 1d1cf37..0000000 --- a/slash-commands/optout.js +++ /dev/null @@ -1,20 +0,0 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); -const dbfn = require('../modules/dbfn.js'); -const fn = require('../modules/functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('optout') - .setDescription('Opt-out of automatic water reminders') - .setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles), - async execute(interaction) { - try { - await interaction.deferReply({ ephemeral: true }); - const setReminderOptInResponse = await dbfn.setReminderOptIn(interaction.guildId, 0); - interaction.editReply(setReminderOptInResponse.status); - } catch(err) { - console.error(err); - await interaction.editReply(fn.builders.errorEmbed(err)); - } - }, -}; \ No newline at end of file diff --git a/slash-commands/setping.js b/slash-commands/setping.js index 8674e5f..4d13791 100644 --- a/slash-commands/setping.js +++ b/slash-commands/setping.js @@ -1,31 +1,18 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { SlashCommandBuilder } = require('discord.js'); const dbfn = require('../modules/dbfn.js'); const fn = require('../modules/functions.js'); module.exports = { data: new SlashCommandBuilder() .setName('setping') - .setDescription('Opt-in to automatic water reminders') - .addStringOption(o => - o.setName('pingmsg') - .setDescription('The message to send for a water reminder') - .setRequired(true)) - .addChannelOption(o => - o.setName('pingchannel') - .setDescription('The channel to send the water reminder in') - .setRequired(true)) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles), + .setDescription('Run this command when you water your tree to have a reminder sent.'), async execute(interaction) { - try { - await interaction.deferReply({ ephemeral: true }); - const reminderMessage = interaction.options.getString('pingmsg'); - const reminderChannel = interaction.options.getChannel('pingchannel'); - const setPingRoleResponse = await dbfn.setReminderInfo(interaction.guildId, reminderMessage, reminderChannel.id); - await dbfn.setReminderOptIn(interaction.guildId, 1); - interaction.editReply(setPingRoleResponse.status); - } catch(err) { - console.error(err); - await interaction.editReply(fn.builders.errorEmbed(err)); - } + await interaction.deferReply({ ephemeral: true }); + const getGuildInfoResponse = await dbfn.getGuildInfo(interaction.guildId); + const guildInfo = getGuildInfoResponse.data; + const reminderTimeS = fn.getWaterTime(guildInfo.treeHeight); + const reminderTimeMs = reminderTimeS * 1000; + fn.setReminder(interaction, reminderTimeMs, guildInfo.pingRoleId); + interaction.editReply("A reminder has been set."); }, }; \ No newline at end of file diff --git a/slash-commands/setping.js.bak b/slash-commands/setping.js.bak deleted file mode 100644 index 4d13791..0000000 --- a/slash-commands/setping.js.bak +++ /dev/null @@ -1,18 +0,0 @@ -const { SlashCommandBuilder } = require('discord.js'); -const dbfn = require('../modules/dbfn.js'); -const fn = require('../modules/functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('setping') - .setDescription('Run this command when you water your tree to have a reminder sent.'), - async execute(interaction) { - await interaction.deferReply({ ephemeral: true }); - const getGuildInfoResponse = await dbfn.getGuildInfo(interaction.guildId); - const guildInfo = getGuildInfoResponse.data; - const reminderTimeS = fn.getWaterTime(guildInfo.treeHeight); - const reminderTimeMs = reminderTimeS * 1000; - fn.setReminder(interaction, reminderTimeMs, guildInfo.pingRoleId); - interaction.editReply("A reminder has been set."); - }, -}; \ No newline at end of file diff --git a/slash-commands/setpingrole.js b/slash-commands/setpingrole.js new file mode 100644 index 0000000..a79fc44 --- /dev/null +++ b/slash-commands/setpingrole.js @@ -0,0 +1,24 @@ +const { SlashCommandBuilder } = require('discord.js'); +const dbfn = require('../modules/dbfn.js'); +const fn = require('../modules/functions.js'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('setpingrole') + .setDescription('Set the role to ping when you run /setping') + .addRoleOption(o => + o.setName('pingrole') + .setDescription('The role to ping') + .setRequired(true)), + async execute(interaction) { + try { + await interaction.deferReply({ ephemeral: true }); + const pingRole = interaction.options.getRole('pingrole'); + const setPingRoleResponse = await dbfn.setPingRole(interaction.guildId, pingRole.id); + interaction.editReply(setPingRoleResponse.status); + } catch(err) { + console.error(err); + await interaction.editReply(fn.builders.errorEmbed(err)); + } + }, +}; \ No newline at end of file