Compare commits
No commits in common. "93626ff8e569c300c3d7c082c7c8369b9b08114b" and "643eb0caa0d3a3054a5060c1541bc3b0d296458c" have entirely different histories.
93626ff8e5
...
643eb0caa0
@ -56,9 +56,7 @@ module.exports = {
|
||||
this.name = "";
|
||||
this.type = "";
|
||||
this.effects = "";
|
||||
this.flavor = "";
|
||||
this.rating = "0.0";
|
||||
this.description = "";
|
||||
}
|
||||
|
||||
// Initial Strain configuration
|
||||
@ -69,8 +67,7 @@ module.exports = {
|
||||
details: {
|
||||
type: String,
|
||||
effects: String,
|
||||
rating: String,
|
||||
description: String
|
||||
rating: String
|
||||
}
|
||||
*/
|
||||
|
||||
@ -83,9 +80,7 @@ module.exports = {
|
||||
this.name = typeof name === 'string' ? name : this.name;
|
||||
this.type = typeof details.type === 'string' ? details.type : this.type;
|
||||
this.effects = typeof details.effects === 'string' ? details.effects : this.effects;
|
||||
this.flavor = typeof details.flavor === 'string' ? details.flavor : this.flavor;
|
||||
this.rating = typeof details.rating === 'string' ? details.rating : this.rating;
|
||||
this.description = typeof details.description === 'string' ? details.description : this.description;
|
||||
|
||||
|
||||
return this; // For chaining
|
||||
|
55
functions.js
55
functions.js
@ -45,7 +45,7 @@ const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.en
|
||||
|
||||
// MySQL database connection
|
||||
const mysql = require('mysql');
|
||||
const { GifData, PastaData, StrainData } = require('./CustomModules/NodBot');
|
||||
const { GifData, PastaData } = require('./CustomModules/NodBot');
|
||||
const db = new mysql.createPool({
|
||||
connectionLimit: 10,
|
||||
host: dbHost,
|
||||
@ -151,18 +151,11 @@ const functions = {
|
||||
if (!client.strains) client.strains = new Discord.Collection();
|
||||
client.strains.clear();
|
||||
for (const row of rows) {
|
||||
const strainData = new StrainData().setInfo(
|
||||
row.strain,
|
||||
{
|
||||
type: row.type,
|
||||
effects: row.effects,
|
||||
rating: row.rating,
|
||||
description: row.description,
|
||||
flavor: row.flavor
|
||||
},
|
||||
row.id
|
||||
);
|
||||
client.strains.set(strainData.name, strainData);
|
||||
const strain = {
|
||||
id: row.id,
|
||||
name: row.strain,
|
||||
};
|
||||
client.strains.set(strain.name, strain);
|
||||
// if (isDev) console.log(strain)
|
||||
}
|
||||
if (isDev) console.log('Strains Collection Built');
|
||||
@ -477,8 +470,14 @@ const functions = {
|
||||
functions.download.medicalAdvice(client);
|
||||
});
|
||||
},
|
||||
strain(interaction, strainData) {
|
||||
const strainQuery = `INSERT INTO strains (strain, type, effects, description, flavor, rating) VALUES (${db.escape(strainData.name)}, ${db.escape(strainData.type)}, ${db.escape(strainData.effects)}, ${db.escape(strainData.description)}, ${db.escape(strainData.flavor)}, ${db.escape(strainData.rating)}) ON DUPLICATE KEY UPDATE strain=${db.escape(strainData.strain)}, type=${db.escape(strainData.type)}, effects=${db.escape(strainData.effects)}, description=${db.escape(strainData.description)}, flavor=${db.escape(strainData.flavor)}, rating=${db.escape(strainData.rating)}`;
|
||||
strain(interaction) {
|
||||
const strain = db.escape(interaction.options.getString('name'));
|
||||
const type = db.escape(interaction.options.getString('type'));
|
||||
const effects = db.escape(( interaction.options.getString('effects') || 'Unkown' ));
|
||||
const description = db.escape(( interaction.options.getString('description') || 'Unknown' ));
|
||||
const flavor = db.escape(( interaction.options.getString('flavor') || 'Unknown' ));
|
||||
const rating = db.escape(( interaction.options.getString('rating') || '3' ));
|
||||
const strainQuery = `INSERT INTO strains (strain, type, effects, description, flavor, rating) VALUES (${strain}, ${type}, ${effects}, ${description}, ${flavor}, ${rating}) ON DUPLICATE KEY UPDATE strain=${db.escape(strain)}, type=${db.escape(type)}, effects=${db.escape(effects)}, description=${db.escape(description)}, flavor=${db.escape(flavor)}, rating=${db.escape(rating)}`;
|
||||
console.log(strainQuery);
|
||||
return new Promise((resolve, reject) => {
|
||||
db.query(strainQuery, (err, rows, fields) => {
|
||||
@ -496,16 +495,16 @@ const functions = {
|
||||
}
|
||||
},
|
||||
download: {
|
||||
async requests(client) {
|
||||
requests(client) {
|
||||
const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC';
|
||||
await db.query(query, (err, rows, fields) => {
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.collections.requests(rows, client);
|
||||
});
|
||||
},
|
||||
async pastas(client) {
|
||||
pastas(client) {
|
||||
const query = 'SELECT * FROM pastas ORDER BY id ASC';
|
||||
await db.query(query, (err, rows, fields) => {
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.collections.pastas(rows, client);
|
||||
});
|
||||
@ -517,16 +516,16 @@ const functions = {
|
||||
functions.collections.gifs(rows, client);
|
||||
});
|
||||
},
|
||||
async joints(client) {
|
||||
joints(client) {
|
||||
const query = 'SELECT * FROM joints ORDER BY id ASC';
|
||||
await db.query(query, (err, rows, fields) => {
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.collections.joints(rows, client);
|
||||
});
|
||||
},
|
||||
async strain(strainName, interaction) {
|
||||
strain(strainName, interaction) {
|
||||
const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`;
|
||||
await db.query(query, (err, rows, fields) => {
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (rows != undefined) {
|
||||
const strainInfo = {
|
||||
id: `${rows[0].id}`,
|
||||
@ -541,16 +540,16 @@ const functions = {
|
||||
}
|
||||
});
|
||||
},
|
||||
async strains(client) {
|
||||
const query = 'SELECT * FROM strains';
|
||||
await db.query(query, (err, rows, fields) => {
|
||||
strains(client) {
|
||||
const query = 'SELECT id, strain FROM strains';
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.collections.strains(rows, client);
|
||||
});
|
||||
},
|
||||
async medicalAdvice(client) {
|
||||
medicalAdvice(client) {
|
||||
const query = 'SELECT * FROM medical_advice ORDER BY id ASC';
|
||||
await db.query(query, (err, rows, fields) => {
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.collections.medicalAdvice(rows, client);
|
||||
});
|
||||
|
24
main.js
24
main.js
@ -30,18 +30,18 @@ const strings = require('./strings.json');
|
||||
const { GifData } = require('./CustomModules/NodBot.js');
|
||||
const isDev = process.env.isDev;
|
||||
|
||||
client.once('ready', async () => {
|
||||
client.once('ready', () => {
|
||||
fn.collections.slashCommands(client);
|
||||
fn.collections.dotCommands(client);
|
||||
fn.collections.setvalidCommands(client);
|
||||
await fn.download.gifs(client);
|
||||
await fn.download.pastas(client);
|
||||
await fn.download.joints(client);
|
||||
await fn.download.requests(client);
|
||||
await fn.download.strains(client);
|
||||
await fn.download.medicalAdvice(client);
|
||||
fn.download.gifs(client);
|
||||
fn.download.pastas(client);
|
||||
fn.download.joints(client);
|
||||
fn.download.requests(client);
|
||||
fn.download.strains(client);
|
||||
fn.download.medicalAdvice(client);
|
||||
console.log('Ready!');
|
||||
await client.channels.fetch(statusChannelId).then(channel => {
|
||||
client.channels.fetch(statusChannelId).then(channel => {
|
||||
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);
|
||||
});
|
||||
});
|
||||
@ -203,14 +203,6 @@ client.on('interactionCreate', async interaction => {
|
||||
pastaChoices.map(choice => ({ name: choice, value: choice }))
|
||||
);
|
||||
break;
|
||||
case "strain":
|
||||
//TODO
|
||||
const strainQuery = interaction.options.getFocused();
|
||||
const strainChoices = fn.weed.strain.lookup(strainQuery, interaction.client);
|
||||
await interaction.respond(
|
||||
strainChoices.map(choice => ({ name: choice, value: choice }))
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@ const tenor = require('tenorjs').client({
|
||||
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
||||
const { GifData, PastaData, StrainData } = require('../CustomModules/NodBot');
|
||||
const { GifData, PastaData } = require('../CustomModules/NodBot');
|
||||
const fn = require('../functions.js');
|
||||
const strings = require('../strings.json');
|
||||
const { emoji } = strings;
|
||||
@ -54,54 +54,6 @@ module.exports = {
|
||||
.setDescription('The new content of the copypasta')
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
// Strain
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName('strain')
|
||||
.setDescription('Edit a strain\'s data')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('name')
|
||||
.setDescription('Name of the strain')
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('type')
|
||||
.setDescription('Indica/Sativa/Hybrid')
|
||||
.setRequired(false)
|
||||
.addChoices(
|
||||
{ name: "Indica", value: "Indica" },
|
||||
{ name: "Hybrid", value: "Hybrid" },
|
||||
{ name: "Sativa", value: "Sativa" }
|
||||
)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('effects')
|
||||
.setDescription('What effects does the strain produce?')
|
||||
.setRequired(false)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('flavor')
|
||||
.setDescription('Flavor Profile')
|
||||
.setRequired(false)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('rating')
|
||||
.setDescription('Star rating of the strain on Leaf.ly')
|
||||
.setRequired(false)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('description')
|
||||
.setDescription('Summary of the strain')
|
||||
.setRequired(false)
|
||||
)
|
||||
),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
@ -130,7 +82,6 @@ module.exports = {
|
||||
// Strain
|
||||
case "strain":
|
||||
//TODO
|
||||
await this.editStrain(interaction);
|
||||
break;
|
||||
break;
|
||||
// Default
|
||||
@ -155,16 +106,5 @@ module.exports = {
|
||||
await fn.upload.pasta(pastaData, interaction.client);
|
||||
await fn.download.gifs(interaction.client);
|
||||
await interaction.editReply(`I've updated ${name}.pasta`);
|
||||
},
|
||||
async editStrain(interaction) {
|
||||
const details = {
|
||||
type: interaction.options.getString('type'),
|
||||
effects: interaction.options.getString('effects'),
|
||||
flavor: interaction.options.getString('flavor'),
|
||||
rating: interaction.options.getString('rating'),
|
||||
description: interaction.options.getString('description')
|
||||
};
|
||||
const strainData = new StrainData().setInfo(interaction.options.getString('name'), details);
|
||||
await fn.upload.strain(interaction);
|
||||
}
|
||||
};
|
@ -10,7 +10,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
||||
const fn = require('../functions.js');
|
||||
const strings = require('../strings.json');
|
||||
const { GifData, StrainData } = require('../CustomModules/NodBot.js');
|
||||
const { GifData } = require('../CustomModules/NodBot.js');
|
||||
const { emoji } = strings;
|
||||
|
||||
module.exports = {
|
||||
@ -213,17 +213,7 @@ module.exports = {
|
||||
// Strain
|
||||
case "strain":
|
||||
//TODO
|
||||
const strainData = new StrainData().setInfo(
|
||||
interaction.options.getString('name'),
|
||||
{
|
||||
type: interaction.options.getString('type'),
|
||||
effects: interaction.options.getString('effects'),
|
||||
flavor: interaction.options.getString('flavor'),
|
||||
rating: interaction.options.getString('rating'),
|
||||
description: interaction.options.getString('description')
|
||||
}
|
||||
);
|
||||
fn.upload.strain(interaction, strainData).then(res => {
|
||||
fn.upload.strain(interaction).then(res => {
|
||||
interaction.editReply({
|
||||
content: `The strain information has been saved. (${interaction.options.getString('name')})`,
|
||||
ephemeral: true
|
||||
|
Loading…
Reference in New Issue
Block a user