Pushing up changes to main before I branch
This commit is contained in:
parent
febbd1fa8e
commit
e68272236f
@ -11,6 +11,7 @@ I have a subset of features that I want it to have before I call it "production
|
||||
"Production Ready" Features
|
||||
- [ ] Google Calendar Integration for Event Management
|
||||
- [ ] Create/Manage/Remove Events and Calendars
|
||||
- [ ] Add Autocomplete for common elements like Calendar Names, Event Names, Timezones, etc.
|
||||
- [ ] Calendar Announcements for Upcoming Events
|
||||
- [ ] Poll Creation and Results Announcements
|
||||
- [ ] Conversation Archiving (May be Removed)
|
||||
|
@ -23,7 +23,7 @@ async function main() {
|
||||
console.log(err.errors);
|
||||
return;
|
||||
}
|
||||
console.log(res.data.items.map(x => x.summary));
|
||||
console.log(res.data.items.map(x => x.summary + '---' + x.timeZone));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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 ] });
|
||||
});
|
||||
},
|
||||
};
|
35
datetesting.js
Normal file
35
datetesting.js
Normal file
@ -0,0 +1,35 @@
|
||||
const readline = require('readline');
|
||||
|
||||
const r1 = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
terminal: false,
|
||||
});
|
||||
|
||||
let date1 = null;
|
||||
let date2 = null;
|
||||
let result = null;
|
||||
|
||||
r1.on('line', line => {
|
||||
if (line.startsWith('date1')) {
|
||||
date1 = new Date(line.split(':')[1]);
|
||||
}
|
||||
else if (line.startsWith('date2')) {
|
||||
date2 = new Date(line.split(':')[1]);
|
||||
}
|
||||
else if (line.startsWith('result')) {
|
||||
if (date1 !== null && date2 !== null) {
|
||||
result = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate(),
|
||||
date2.getHours(), date2.getMinutes(), date2.getSeconds());
|
||||
|
||||
console.log(result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('Bad command');
|
||||
}
|
||||
});
|
||||
|
||||
r1.once('close', () => {
|
||||
console.log('Closing');
|
||||
});
|
11
package-lock.json
generated
11
package-lock.json
generated
@ -9,6 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@vvo/tzdb": "^6.77.0",
|
||||
"discord.js": "^14.6.0",
|
||||
"googleapis": "^109.0.1"
|
||||
},
|
||||
@ -206,6 +207,11 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@vvo/tzdb": {
|
||||
"version": "6.77.0",
|
||||
"resolved": "https://registry.npmjs.org/@vvo/tzdb/-/tzdb-6.77.0.tgz",
|
||||
"integrity": "sha512-t7aN3GAznzt8fQ5enJiM3C7HKPEDBoqKExp2W7nYu2AgS0J9FfMk6rwWhL2jjTe0+27REmO9C+TL3XM2evileQ=="
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.8.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
||||
@ -1975,6 +1981,11 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@vvo/tzdb": {
|
||||
"version": "6.77.0",
|
||||
"resolved": "https://registry.npmjs.org/@vvo/tzdb/-/tzdb-6.77.0.tgz",
|
||||
"integrity": "sha512-t7aN3GAznzt8fQ5enJiM3C7HKPEDBoqKExp2W7nYu2AgS0J9FfMk6rwWhL2jjTe0+27REmO9C+TL3XM2evileQ=="
|
||||
},
|
||||
"acorn": {
|
||||
"version": "8.8.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
||||
|
@ -9,6 +9,7 @@
|
||||
"author": "Bradley Bickford",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@vvo/tzdb": "^6.77.0",
|
||||
"discord.js": "^14.6.0",
|
||||
"googleapis": "^109.0.1"
|
||||
},
|
||||
|
@ -31,18 +31,26 @@ async function doesCalendarExist(calendarName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO This needs to be changed so that it uses the common callback
|
||||
// format that I've created
|
||||
async function getListOfCalendars(options, callback) {
|
||||
const calendarReference = await getCalendarReference();
|
||||
calendarReference.calendarList.list(options, callback);
|
||||
calendarReference.calendarList.list(options, async (err, res) => {
|
||||
if (err) {
|
||||
callback(false, 'Failed to retrieve the list of calendars\nAsk Bradley to check Breadbot console');
|
||||
stdout.write('[ERROR]:');
|
||||
console.log(err.errors);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(true, 'Calendar List', res.data.items);
|
||||
});
|
||||
}
|
||||
|
||||
async function addCalendar(calendarName, callback) {
|
||||
async function addCalendar(calendarName, timezone, callback) {
|
||||
const calendarReference = await getCalendarReference();
|
||||
calendarReference.calendars.insert({
|
||||
resource: {
|
||||
summary: calendarName,
|
||||
timeZone: timezone,
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
@ -83,6 +91,28 @@ async function deleteCalendar(calendarName, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
async function addEvent(calendarName, eventName, location, description, startDate, startTime, endDate, endTime) {
|
||||
const exists = await doesCalendarExist(calendarName);
|
||||
|
||||
if (exists) {
|
||||
const calendarReference = await getCalendarReference();
|
||||
calendarReference.events.insert({
|
||||
calendarId: exists.id,
|
||||
resource: {
|
||||
summary: eventName,
|
||||
location: location,
|
||||
description: description,
|
||||
start: {
|
||||
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
else {
|
||||
callback(false, 'The calendar name specified doesn\'t exist', null);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCalendarReference,
|
||||
getListOfCalendars,
|
||||
|
Loading…
Reference in New Issue
Block a user