Partial rollback to v1.1.2 DO NOT DEPLOY

This commit is contained in:
Skylar Grant 2023-01-27 19:42:04 -05:00
parent a8ceecff9a
commit 57769f95ff
5 changed files with 33 additions and 80 deletions

View File

@ -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]));
});
});
},
};

View File

@ -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));
}
},
};

View File

@ -1,31 +1,18 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); const { SlashCommandBuilder } = require('discord.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');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('setping') .setName('setping')
.setDescription('Opt-in to automatic water reminders') .setDescription('Run this command when you water your tree to have a reminder sent.'),
.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),
async execute(interaction) { async execute(interaction) {
try {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const reminderMessage = interaction.options.getString('pingmsg'); const getGuildInfoResponse = await dbfn.getGuildInfo(interaction.guildId);
const reminderChannel = interaction.options.getChannel('pingchannel'); const guildInfo = getGuildInfoResponse.data;
const setPingRoleResponse = await dbfn.setReminderInfo(interaction.guildId, reminderMessage, reminderChannel.id); const reminderTimeS = fn.getWaterTime(guildInfo.treeHeight);
await dbfn.setReminderOptIn(interaction.guildId, 1); const reminderTimeMs = reminderTimeS * 1000;
interaction.editReply(setPingRoleResponse.status); fn.setReminder(interaction, reminderTimeMs, guildInfo.pingRoleId);
} catch(err) { interaction.editReply("A reminder has been set.");
console.error(err);
await interaction.editReply(fn.builders.errorEmbed(err));
}
}, },
}; };

View File

@ -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.");
},
};

View File

@ -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));
}
},
};