Quote db stuff

master
Talon 2022-01-16 23:52:41 +01:00
parent 6f9113a463
commit e1f5f81338
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
const fetch = require('node-fetch');
module.exports = function (bot, api) {
api.registerCommand('randomquote', async (args, message) => {
const data = await fetch(process.env["QDB_URL"], {
headers: {
Authorization: 'Basic ' + Buffer.from(`${process.env["QDB_USER"]}:${process.env["QDB_PASS"]}`).toString('base64')
}
});
const quotes = await data.json();
const quote = quotes[Math.floor(Math.random()*quotes.length)];
let chan=message.member.voice.channel;
api.queue.add(__dirname + "/sysmsg.wav");
api.speak(chan, `${quote.author}, on ${quote.medium}: ${quote.quote}`);
})
}