Pushing up changes to main before I branch
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { addCalendar } = require('../../utilities/googlecalendar.js');
|
||||
// const { getTimeZones } = require('@vvo/tzdb');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -12,15 +13,20 @@ module.exports = {
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('description')
|
||||
.setDescription('The description of this new calendar')),
|
||||
.setName('timezone')
|
||||
.setDescription('The Time Zone of this new calendar, must be in IANA format')
|
||||
.setRequired(true)),
|
||||
// .addChoices(getTimeZones().map(tz => {
|
||||
// return { name: tz.name, value: tz.name };
|
||||
// }))),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
const name = interaction.options.getString('name');
|
||||
const timezone = interaction.options.getString('timezone');
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
addCalendar(name, async (success, message, extra) => {
|
||||
addCalendar(name, timezone, async (success, message, extra) => {
|
||||
const embedResponse = new EmbedBuilder()
|
||||
.setColor(success ? 0x00FF00 : 0xFF0000)
|
||||
.setTitle(message);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { getListOfCalendars } = require('../../utilities/googlecalendar');
|
||||
const { stdout } = require('node:process');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -9,25 +8,13 @@ module.exports = {
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
getListOfCalendars({}, async (err, res) => {
|
||||
if (err) {
|
||||
const errorEmbed = new EmbedBuilder()
|
||||
.setColor(0xFF0000)
|
||||
.setTitle('Failed to get a list of calendars')
|
||||
.setDescription('Ask Bradley to check Breadbot console');
|
||||
getListOfCalendars({}, async (success, message, extra) => {
|
||||
const embedResponse = new EmbedBuilder()
|
||||
.setColor(success ? 0x00FF00 : 0xFF0000)
|
||||
.setTitle(message)
|
||||
.setDescription(extra.map(x => x.summary + ' --- ' + x.timeZone).join('\n\n'));
|
||||
|
||||
await interaction.editReply({ embeds: errorEmbed });
|
||||
stdout.write('[ERROR]: ');
|
||||
console.log(err.errors);
|
||||
return;
|
||||
}
|
||||
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setColor(0x00FF00)
|
||||
.setTitle('Calendar List')
|
||||
.setDescription(res.data.items.map((x) => x.summary).join('\n'));
|
||||
|
||||
await interaction.editReply({ embeds: [ successEmbed ] });
|
||||
await interaction.editReply({ embeds: [ embedResponse ] });
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user