Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Fix: Lobby info uses the wrong prefix
Browse files Browse the repository at this point in the history
Fixes #31
  • Loading branch information
jftanner committed Oct 28, 2020
1 parent 3c31a01 commit efce033
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
23 changes: 8 additions & 15 deletions classes/GuildConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 7 additions & 2 deletions classes/Lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 <In-Game Name>` 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.
Expand Down

0 comments on commit efce033

Please sign in to comment.