Formatting

This commit is contained in:
MSWS
2023-04-12 16:49:17 -07:00
parent e72a6d38da
commit 3c569e5dbf
7 changed files with 15 additions and 32 deletions

View File

@@ -28,7 +28,6 @@ export class FileConfig implements BotConfig {
if (!config) {
console.log(`Creating new guild config: ${guildId}`);
config = new FileGuildConfig(this.parent + `/guilds/${guildId}.json`, guildId);
this.configs.push(config);
}
@@ -56,7 +55,6 @@ export class FileConfig implements BotConfig {
return Promise.reject(`Config entry not found: ${id}`);
entry.value = value;
return Promise.resolve();
}
@@ -105,13 +103,12 @@ export class FileConfig implements BotConfig {
registerEntry(entry: ConfigEntry): ConfigEntry {
this.entries.push(entry);
return entry;
}
removeEntry(entry: ConfigEntry): void {
this.entries.splice(this.entries.indexOf(entry), 1);
}
save(): Promise<void> {
async save() {
// JSON stringify entries and write to file
const data: any = {};
this.entries.forEach(entry => {
@@ -120,8 +117,6 @@ export class FileConfig implements BotConfig {
fs.writeFileSync(this.file, JSON.stringify(data));
return Promise.resolve();
}
getConfigEntry(name: string): ConfigEntry | undefined {

View File

@@ -55,7 +55,6 @@ export class CommandManager extends Module {
async hookCommand(purge = false, ...commands: Command[]): Promise<void> {
if (!commands || commands.length === 0) {
this.hookCommand(purge, ...Object.values(this.commands));
return;
}

View File

@@ -45,16 +45,13 @@ export class ReactRoles extends Module {
return;
const channel = guild.channels.cache.get(config.channel) ?? await guild.channels.fetch(config.channel);
if (!channel)
return;
if (channel.type !== ChannelType.GuildText)
if (!channel || channel.type !== ChannelType.GuildText)
return;
if (config.embedId) {
const preExistingEmbed = await channel.messages.fetch(config.embedId ?? "").catch(() => undefined);
if (preExistingEmbed) {
this.reactRoles(preExistingEmbed).catch(console.error);
return;
}
}
@@ -66,7 +63,6 @@ export class ReactRoles extends Module {
const configEntry = this.configs[guild.id];
if (configEntry) {
configEntry.value = config;
(await this.main.config.getGuildConfig(guild.id)).save(configEntry);
}
@@ -98,7 +94,6 @@ export class ReactRoles extends Module {
if (!guildUser)
return;
if (config.unique) {
for (const role of config.roles) {
if (guildUser.roles.cache.has(role))

View File

@@ -52,7 +52,6 @@ export class VoiceCommand extends Command {
}
sub.handleCommand(interaction);
return true;
}
}

View File

@@ -36,7 +36,6 @@ export class GenericListCommand extends SubGroupCommand {
const command = this.subs[interaction.options.getSubcommand(true)];
if (!command) {
interaction.reply({ content: "Unknown sub-command.", ephemeral: true });
return false;
}

View File

@@ -39,25 +39,22 @@ export class RenameCommand extends SubCommand {
interaction.reply(Lang.DS.MINIMUM_TIER(requiredTier));
return false;
}
const userData = await dsVoice.getVoiceData(interaction.user.id, interaction.guildId);
dsVoice.getVoiceData(interaction.user.id, interaction.guildId).then((userData) => {
if (!interaction.guildId) {
interaction.reply(Lang.GUILD_ONLY);
return false;
}
if (!userData) {
interaction.reply(Lang.VOICE.NO_CHANNEL());
return false;
}
if (!interaction.guildId) {
interaction.reply(Lang.GUILD_ONLY);
return false;
}
if (!userData) {
interaction.reply(Lang.VOICE.NO_CHANNEL());
return false;
}
userData.channelName = name;
userData.channelName = name;
interaction.reply(Lang.VOICE.RENAMED(name));
if (interaction.guildId)
dsVoice.updateUserChannel(userData, interaction.guildId);
return true;
});
interaction.reply(Lang.VOICE.RENAMED(name));
if (interaction.guildId)
dsVoice.updateUserChannel(userData, interaction.guildId);
return true;
}

View File

@@ -18,7 +18,6 @@ export class ListCommand extends AbstractListCommand {
async handleListCommand(interaction: CommandInteraction, list: string[], voiceModule: DSVoice, maxSize: number): Promise<boolean> {
if (list.length === 0) {
interaction.reply(Lang.LISTS.EMPTY(this.type));
return false;
}