woomy-v2/bot/commands/Test/retrieve.js

33 lines
972 B
JavaScript
Raw Normal View History

2020-10-09 05:04:01 +00:00
const Command = require("../../base/Command.js");
class Retrieve extends Command {
constructor (client) {
super(client, {
description: "Retrieves a key's value from the Redis DB.",
usage: "retrieve [key]",
guildOnly: true
});
}
2020-10-10 03:01:56 +00:00
async run (message, args, data) { // eslint-disable-line no-unused-vars
if (!args[0]) return message.channel.send("You didn't specify what database to access!");
if (args[0].toLowerCase() !== 'guild' && args[0].toLowerCase() !== 'member' && args[0].toLowerCase() !== 'user') {
return message.channel.send('Invalid database. Valid databases: `guild`, `member`, `user`');
2020-10-09 05:04:01 +00:00
}
2020-10-10 05:26:27 +00:00
if (!args[1]) {
message.channel.send(
`\`\`\`js
${JSON.stringify(data[args[0]])}
\`\`\``
);
} else {
let res = data[args[0]][args[1]];
if (!res) return message.channel.send('Invalid key. Check for typing errors and try again.');
message.channel.send('```' + res + '```');
}
2020-10-09 05:04:01 +00:00
}
}
module.exports = Retrieve;