Fixed addcalendar, added other file stubs

This commit is contained in:
Bradley Bickford 2022-11-24 17:39:30 -05:00
parent dce3b6ecc4
commit 30a2114ff4
9 changed files with 28 additions and 11 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
.env
config.json
node_modules
node_modules
keyfile.json

View File

@ -17,8 +17,14 @@ async function main() {
auth: jwtClient,
});
const response = calendar.calendarList.list({});
console.log('Output: ' + response.data);
calendar.calendarList.list({}, (err, res) => {
if (err) {
console.log('[ERROR]');
console.log(err.errors);
return;
}
console.log(res.data.items.map(x => x.summary));
});
}
main().catch(e => {

View File

@ -1,6 +1,7 @@
const { SlashCommandBuilder } = require('discord.js');
const { google } = require('googleapis');
const { googlePrivateKey, googleClientEmail, googleProjectNumber } = require('../../config.json');
const { stdout } = require('node:process');
const SCOPES = ['https://www.googleapis.com/auth/calendar'];
module.exports = {
@ -20,11 +21,10 @@ module.exports = {
await interaction.deferReply({ ephemeral: true });
const name = interaction.options.getString('name');
const description = interaction.options.getString('description');
const jwtClient = new google.auth.JWT(
googleClientEmail,
null,
'./keyfile.json',
googlePrivateKey,
SCOPES,
);
@ -35,11 +35,21 @@ module.exports = {
auth: jwtClient,
});
calendar.calendarList.insert({
'summary': name,
'description': description,
});
await interaction.editReply('New Calendar ' + name + ' Created');
calendar.calendars.insert({
resource: {
summary: name,
},
},
// eslint-disable-next-line no-unused-vars
async (err, res) => {
if (err) {
await interaction.editReply('Failed to create calendar ' + name + '\nAsk an Admin to check Breadbot console');
stdout.write('[ERROR]: ');
console.log(err.errors);
return;
}
await interaction.editReply('New Calendar ' + name + ' Created');
},
);
},
};

View File

View File

View File

View File

View File