From efce033c92d433c9277fa3c3f2692329430dac0d Mon Sep 17 00:00:00 2001 From: James Tanner Date: Tue, 27 Oct 2020 21:27:52 -0400 Subject: [PATCH] Fix: Lobby info uses the wrong prefix Fixes #31 --- classes/GuildConfig.js | 23 ++++++++--------------- classes/Lobby.js | 9 +++++++-- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/classes/GuildConfig.js b/classes/GuildConfig.js index 8fa5145..0875efe 100644 --- a/classes/GuildConfig.js +++ b/classes/GuildConfig.js @@ -77,26 +77,19 @@ class GuildConfig { reset(key) { const { defaultValue, getter } = getSetting(key); - if (this._document.config.hasOwnProperty(key)){ - delete this._document.config[key] + if (this._document.config.hasOwnProperty(key)) { + delete this._document.config[key]; this.scheduleSave(); } return getter ? getter(defaultValue) : defaultValue; } - get commandPrefixes() { - return this._document.commandPrefixes ?? ['!sau', '!s']; - } - - async updateCommandPrefixes(...params) { - const prefixes = params.map(param => param.trim()); - - // Skip the rest, if it's the same as what we already have. - if (deepEquals(prefixes, this.commandPrefixes)) return; - - // Store the prefix and save. - this._document.commandPrefixes = prefixes; - await this.save(); + /** + * A helper method for getting the default command prefix. + * @returns {string} + */ + get defaultPrefix() { + return this.get('prefix').split(/\|/g)[0]; } scheduleSave() { diff --git a/classes/Lobby.js b/classes/Lobby.js index 66fa079..c832cdd 100644 --- a/classes/Lobby.js +++ b/classes/Lobby.js @@ -2,9 +2,10 @@ const chance = require('chance').Chance(); const deepEqual = require('deep-equal'); const { Permissions, MessageEmbed } = require('discord.js'); const { client, clientReady } = require('../discord-bot/discord-bot'); +const Database = require('./Database'); +const GuildConfig = require('./GuildConfig'); const Player = require('./Player'); const Room = require('./Room'); -const Database = require('./Database'); const requiredTextPermissionsFlags = [ 'VIEW_CHANNEL', @@ -743,8 +744,12 @@ class Lobby { .setFooter(`Capture Status: ${this.automation}`); if (spectators) { + const guildConfig = await GuildConfig.load(this.voiceChannel.guild.id); + const prefix = guildConfig.defaultPrefix; embed.addField('Spectators', spectators); - embed.addField('Join the Game!', 'Use `!sau join ` to join!'); + embed.addField('Join the Game!', [ + `Use \`${prefix} join [In-Game Name]\` to join! (_Without the brackets._)` + ].join('\n')); } // If there's a text channel bound, send the embed to it.