Adding medical advice
This commit is contained in:
parent
8a09ef3707
commit
3a6ca87b00
16
dot-commands/md.js
Normal file
16
dot-commands/md.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
const fn = require('../functions.js');
|
||||||
|
// const { emoji } = require('../strings.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'md',
|
||||||
|
description: 'Get some medical advice.',
|
||||||
|
usage: '.md',
|
||||||
|
execute(message, commandData) {
|
||||||
|
let medicalAdviceArr = [];
|
||||||
|
for (const entry of message.client.medicalAdviceColl.map(medicalAdvice => medicalAdvice.content)) {
|
||||||
|
medicalAdviceArr.push(entry);
|
||||||
|
}
|
||||||
|
const randIndex = Math.floor(Math.random() * medicalAdviceArr.length);
|
||||||
|
message.reply(`${medicalAdviceArr[randIndex]}`);
|
||||||
|
}
|
||||||
|
}
|
28
functions.js
28
functions.js
@ -139,7 +139,19 @@ const functions = {
|
|||||||
// if (isDev) console.log(strain)
|
// if (isDev) console.log(strain)
|
||||||
}
|
}
|
||||||
if (isDev) console.log('Strains Collection Built');
|
if (isDev) console.log('Strains Collection Built');
|
||||||
}
|
},
|
||||||
|
medicalAdvice(rows, client) {
|
||||||
|
if (!client.medicalAdviceCol) client.medicalAdviceColl = new Discord.Collection();
|
||||||
|
client.medicalAdviceColl.clear();
|
||||||
|
for (const row of rows) {
|
||||||
|
const medicalAdvice = {
|
||||||
|
id: row.id,
|
||||||
|
content: row.content
|
||||||
|
};
|
||||||
|
client.medicalAdviceColl.set(medicalAdvice.id, medicalAdvice);
|
||||||
|
}
|
||||||
|
if (isDev) console.log('Medical Advice Collection Built');
|
||||||
|
},
|
||||||
},
|
},
|
||||||
dot: {
|
dot: {
|
||||||
getCommandData(message) {
|
getCommandData(message) {
|
||||||
@ -414,6 +426,13 @@ const functions = {
|
|||||||
} else {
|
} else {
|
||||||
return 'Sorry, you don\'t have permission to do that.';
|
return 'Sorry, you don\'t have permission to do that.';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
medicalAdvice(content, client) {
|
||||||
|
const query = `INSERT INTO medical_advice (content) VALUES (${db.escape(content)})`;
|
||||||
|
db.query(query, (err, rows, fields) => {
|
||||||
|
if (err) throw err;
|
||||||
|
functions.download.medicalAdvice(client);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
download: {
|
download: {
|
||||||
@ -470,6 +489,13 @@ const functions = {
|
|||||||
functions.collections.strains(rows, client);
|
functions.collections.strains(rows, client);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
medicalAdvice(client) {
|
||||||
|
const query = 'SELECT * FROM medical_advice ORDER BY id ASC';
|
||||||
|
db.query(query, (err, rows, fields) => {
|
||||||
|
if (err) throw err;
|
||||||
|
functions.collections.medicalAdvice(rows, client);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
weed: {
|
weed: {
|
||||||
strain: {
|
strain: {
|
||||||
|
1
main.js
1
main.js
@ -38,6 +38,7 @@ client.once('ready', () => {
|
|||||||
fn.download.joints(client);
|
fn.download.joints(client);
|
||||||
fn.download.requests(client);
|
fn.download.requests(client);
|
||||||
fn.download.strains(client);
|
fn.download.strains(client);
|
||||||
|
fn.download.medicalAdvice(client);
|
||||||
console.log('Ready!');
|
console.log('Ready!');
|
||||||
client.channels.fetch(statusChannelId).then(channel => {
|
client.channels.fetch(statusChannelId).then(channel => {
|
||||||
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);
|
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);
|
||||||
|
17
slash-commands/savemd.js
Normal file
17
slash-commands/savemd.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
|
const fn = require('../functions.js');
|
||||||
|
// const { emoji } = require('../strings.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('savemd')
|
||||||
|
.setDescription('Add medical advice to NodBot\'s Database!')
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('advice-content')
|
||||||
|
.setDescription('What is the advice?')
|
||||||
|
.setRequired(true)),
|
||||||
|
async execute(interaction) {
|
||||||
|
fn.upload.medicalAdvice(interaction.options.getString('advice-content'), interaction.client);
|
||||||
|
interaction.reply({ content: `The advice has been saved!`, ephemeral: true });
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user