Convert database handler into service, fix skip issue with sound player

This commit is contained in:
Essem 2021-08-10 16:34:29 -05:00
parent 9a1fd3b6f3
commit b2c7a43baa
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
13 changed files with 58 additions and 25 deletions

View file

@ -8,7 +8,7 @@ class ChannelCommand extends Command {
if (this.args.length === 0) return "You need to provide whether I should be enabled or disabled in this channel!";
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
const guildDB = await db.getGuild(this.message.channel.guild.id);
const guildDB = await db(this.ipc, "getGuild", this.message.channel.guild.id);
if (this.args[0].toLowerCase() === "disable") {
let channel;
@ -21,7 +21,7 @@ class ChannelCommand extends Command {
channel = this.message.channel;
}
await db.disableChannel(channel);
await db(this.ipc, "disableChannel", channel);
return `I have been disabled in this channel. To re-enable me, just run \`${guildDB.prefix}channel enable\`.`;
} else if (this.args[0].toLowerCase() === "enable") {
let channel;
@ -34,7 +34,7 @@ class ChannelCommand extends Command {
channel = this.message.channel;
}
await db.enableChannel(channel);
await db(this.ipc, "enableChannel", channel);
return "I have been re-enabled in this channel.";
}
}

View file

@ -6,7 +6,7 @@ class CountCommand extends Command {
async run() {
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return "I don't have the `Add Reactions` permission!";
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
const counts = await database.getCounts();
const counts = await database(this.ipc, "getCounts");
const countArray = [];
for (const entry of Object.entries(counts)) {
countArray.push(entry);

View file

@ -8,13 +8,13 @@ const Command = require("../../classes/command.js");
class HelpCommand extends Command {
async run() {
const { prefix } = this.message.channel.guild ? await database.getGuild(this.message.channel.guild.id) : "N/A";
const { prefix } = this.message.channel.guild ? await database(this.ipc, "getGuild", this.message.channel.guild.id) : "N/A";
const commands = collections.commands;
const aliases = collections.aliases;
if (this.args.length !== 0 && (commands.has(this.args[0].toLowerCase()) || aliases.has(this.args[0].toLowerCase()))) {
const command = aliases.has(this.args[0].toLowerCase()) ? collections.aliases.get(this.args[0].toLowerCase()) : this.args[0].toLowerCase();
const info = collections.info.get(command);
const counts = await database.getCounts();
const counts = await database(this.ipc, "getCounts");
const embed = {
"embed": {
"author": {

View file

@ -4,10 +4,10 @@ const Command = require("../../classes/command.js");
class PrefixCommand extends Command {
async run() {
if (!this.message.channel.guild) return "This command only works in servers!";
const guild = await database.getGuild(this.message.channel.guild.id);
const guild = await database(this.ipc, "getGuild", this.message.channel.guild.id);
if (this.args.length !== 0) {
if (!this.message.member.permissions.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to change the bot prefix!";
await database.setPrefix(this.args[0], this.message.channel.guild);
await database(this.ipc, "setPrefix", this.args[0], this.message.channel.guild);
return `The prefix has been changed to ${this.args[0]}.`;
} else {
return `The current prefix is \`${guild.prefix}\`.`;