diff --git a/functions.js b/functions.js index 0a9fb50..5aa0f74 100644 --- a/functions.js +++ b/functions.js @@ -370,6 +370,41 @@ const functions = { if (err) throw err; functions.download.gifs(client); }); + }, + setup(interaction) { + /* Tables: + * - gifs + * - joints + * - pastas + * - requests + * - strains */ + const gifsQuery = "CREATE TABLE 'gifs' (id int(11), name varchar(100), embed_url varchar(1000), PRIMARY KEY(id))"; + const jointsQuery = "CREATE TABLE 'joints' (id int(11), content varchar(1000), PRIMARY KEY(id))"; + const pastasQuery = "CREATE TABLE 'pastas' (id int(11), name varchar(100), content varchar(1900), iconurl varchar(200) DEFAULT 'https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128', PRIMARY KEY(id))"; + const requestsQuery = "CREATE TABLE 'requests' (id int(11), author varchar(100), request varchar(1000), status varchar(10) DEFAULT 'Active', PRIMARY KEY(id))"; + const strainsQuery = "CREATE TABLE 'strains' (id smallint(6), name varchar(60), type varchar(10), effects varchat(80), ailment varchar(70), flavor varchar(30), PRIMARY KEY(id))"; + + // Check for owner + if (interaction.user.id == ownerId) { + db.query(gifsQuery, (err, rows, fields) => { + if (err) throw err; + }); + db.query(jointsQuery, (err, rows, fields) => { + if (err) throw err; + }); + db.query(pastasQuery, (err, rows, fields) => { + if (err) throw err; + }); + db.query(requestsQuery, (err, rows, fields) => { + if (err) throw err; + }); + db.query(strainsQuery, (err, rows, fields) => { + if (err) throw err; + }); + return 'I\'ve created the required tables. Please check your database to validate this.'; + } else { + return 'Sorry, you don\'t have permission to do that.'; + } } }, download: { diff --git a/slash-commands/setup.js b/slash-commands/setup.js new file mode 100644 index 0000000..fb955dd --- /dev/null +++ b/slash-commands/setup.js @@ -0,0 +1,15 @@ +// UNDER DEVELOPMENT +// This *should* create the tables required to use Nodbot, +// assuming you have a database set up with proper permissions. + +const { SlashCommandBuilder } = require('@discordjs/builders'); +const fn = require('../functions.js'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('setup') + .setDescription('Create the tables required to use Nodbot'), + async execute(interaction) { + await interaction.reply({ content: fn.upload.setup(), ephemeral: true }); + }, +}; \ No newline at end of file