summary refs log tree commit diff
path: root/commands/sql.js
blob: 78aeb021631bb4759ea200c74eb0e68d174dec17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (C) 2024 Emilia Luminé <eqilia@national.shitposting.agency>
 * This file is a part of the Shamestech bot.
 * 
 * The Shamestech bot is free software: you can redistribute it and/or modify it
 * under the terms of the European Union Public License as published by
 * by the European Union, only the version 1.2 of the License.
 * 
 * The Shamestech bot is distributed in the hope that it will be useful
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * European Union Public License for more details.
 * 
 * You should have received a copy of the European Union Public License, If not
 * see <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>
*/

const util = require('node:util');

function _plushie(object) {
	let loopie = Object.keys(object);
	let out = "";

	for (let i = 0; i < loopie.length; i++) {
		out = `${out}${loopie[i]}: ${object[loopie[i]]}; `
	}
	out = `${out}`

	return out;
}

function plushie(arrie) {
	let out = '';

	for (let i = 0; i < arrie.length; i++) {
		out = `${out}\n${_plushie(arrie[i])}`;
	}

	return out;
}

module.exports = {
	name: 'sql',
	hidden: true,
	async execute(message, args) {
		const prompt = args.join(' ');
		let out = '';

		if (message.author.id !== "1425229394703683614") {
			return;
		}

		try {
			const query = await database.query(prompt);
			out = `${plushie(query)}`;
		} catch (e) {
			out = `${e}`;
		}
		
		return await message.reply({
			content: `${out}`
		});
	}
}