formatting fixes + update commands for postgres

This commit is contained in:
Emily 2020-10-18 00:16:11 +11:00
parent 432caf5276
commit 06d5cc55cb
3 changed files with 65 additions and 63 deletions

View file

@ -1,14 +1,13 @@
const { DiscordAPIError } = require("discord.js"); const { MessageEmbed } = require('discord.js');
const { MessageEmbed } = require("discord.js"); const Command = require('../../base/Command.js');
const Command = require("../../base/Command.js");
class Settings extends Command { class Settings extends Command {
constructor (client) { constructor (client) {
super(client, { super(client, {
description: "View all of your server's settings.", description: 'View all of your server\'s settings.',
usage: "settings", usage: 'settings',
guildOnly: true, guildOnly: true,
aliases: ["config"] aliases: ['config']
}); });
} }
@ -20,7 +19,7 @@ class Settings extends Command {
.setDescription('All the settings for this server are listed below. To set a setting, use `set [setting] [what you want to set it to]') .setDescription('All the settings for this server are listed below. To set a setting, use `set [setting] [what you want to set it to]')
.addFields( .addFields(
{ name: '**Prefix**', value: settings.prefix } { name: '**Prefix**', value: settings.prefix }
) );
} }
} }

View file

@ -1,25 +1,28 @@
const Command = require("../../base/Command.js"); const Command = require('../../base/Command.js');
class Userprefix extends Command { class Userprefix extends Command {
constructor (client) { constructor (client) {
super(client, { super(client, {
description: "Change the prefix you use for Woomy. This will affect servers and commands in DM's.", description: 'Change the prefix you use for Woomy. This will affect servers and commands in DM\'s.',
usage: "`userprefix` <new prefix>", usage: '`userprefix` <new prefix>',
examples: "`userprefix !!` - Sets your personal prefix to !!" examples: '`userprefix !!` - Sets your personal prefix to !!'
}); });
} }
async run (message, args) { // eslint-disable-line no-unused-vars async run (message, args, data) { // eslint-disable-line no-unused-vars
if (!args[0]) { if (!args[0]) {
return message.channel.send( return message.channel.send(
`Your prefix for Woomy is currently: \`${await this.client.db.getUserKey(message.author.id, 'prefix')}\`` `Your prefix for Woomy is currently: \`${data.user.prefix}\``
); );
}; }
await this.client.db.setUserKey(message.author.id, 'prefix', args[0]); await this.client.db.updateUser(message.author.id, 'prefix', args[0]);
// Update cache
this.client.prefixCache.set(message.author.id, args[0]);
message.channel.send(`Your personal prefix has been set to: \`${args[0]}\``); message.channel.send(`Your personal prefix has been set to: \`${args[0]}\``);
}; }
}; }
module.exports = Userprefix; module.exports = Userprefix;

View file

@ -1,16 +1,16 @@
const Command = require("../../base/Command.js"); const Command = require('../../base/Command.js');
class Retrieve extends Command { class Retrieve extends Command {
constructor (client) { constructor (client) {
super(client, { super(client, {
description: "Retrieves a key's value from the Redis DB.", description: 'Retrieves a key\'s value from the Postgres DB.',
usage: "retrieve [key]", usage: 'retrieve [setting]',
guildOnly: true guildOnly: true
}); });
} }
async run (message, args, data) { // eslint-disable-line no-unused-vars 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]) 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') { if (args[0].toLowerCase() !== 'guild' && args[0].toLowerCase() !== 'member' && args[0].toLowerCase() !== 'user') {
return message.channel.send('Invalid database. Valid databases: `guild`, `member`, `user`'); return message.channel.send('Invalid database. Valid databases: `guild`, `member`, `user`');
} }
@ -22,7 +22,7 @@ class Retrieve extends Command {
\`\`\`` \`\`\``
); );
} else { } else {
let res = data[args[0]][args[1]]; const res = data[args[0]][args[1]];
if (!res) return message.channel.send('Invalid key. Check for typing errors and try again.'); if (!res) return message.channel.send('Invalid key. Check for typing errors and try again.');
message.channel.send('```' + res + '```'); message.channel.send('```' + res + '```');
} }