diff --git a/src/blueprints/attribute.blueprint.ts b/src/blueprints/attribute.blueprint.ts index 8085ac78..04ee652a 100644 --- a/src/blueprints/attribute.blueprint.ts +++ b/src/blueprints/attribute.blueprint.ts @@ -4,9 +4,11 @@ import { OverwriteType, Role } from 'discord.js'; + import { getKeyFromEnum, isMod } from '../libraries/help.library'; import { updateGuild, updateMember, updatePortal, updateVoice } from '../libraries/mongo.library'; import { PGuild } from '../types/classes/PGuild.class'; +import { PMember } from '../types/classes/PMember.class'; import { PChannel } from '../types/classes/PPortalChannel.class'; import { Blueprint, ReturnPromise } from '../types/classes/PTypes.interface'; import { PVoiceChannel } from '../types/classes/PVoiceChannel.class'; @@ -14,7 +16,6 @@ import { AuthType } from '../types/enums/Admin.enum'; import { Locale, LocaleList } from '../types/enums/Locales.enum'; import { ProfanityLevel, ProfanityLevelList } from '../types/enums/ProfanityLevel.enum'; import { RankSpeed } from '../types/enums/RankSpeed.enum'; -import { PMember } from '../types/classes/PMember.class'; function getResponse(response: boolean, category: string[], attribute: string, value: string | number) { const responseValue = response @@ -1105,9 +1106,7 @@ export const AttributeBlueprints: Blueprint[] = [ if (locale === undefined) { return { result: false, - value: `attribute ${category.join('.') + '.' + attribute} can only be **${LocaleList.join( - ', ' - )}**`, + value: `attribute ${category.join('.') + '.' + attribute} can only be **${LocaleList.join(', ')}**`, }; } @@ -1164,9 +1163,7 @@ export const AttributeBlueprints: Blueprint[] = [ if (locale === undefined) { return { result: false, - value: `attribute ${category.join('.') + '.' + attribute} can only be **${LocaleList.join( - ', ' - )}**`, + value: `attribute ${category.join('.') + '.' + attribute} can only be **${LocaleList.join(', ')}**`, }; } @@ -1215,9 +1212,7 @@ export const AttributeBlueprints: Blueprint[] = [ if (locale === undefined) { return { result: false, - value: `attribute ${category.join('.') + '.' + attribute} can only be **${LocaleList.join( - ', ' - )}**`, + value: `attribute ${category.join('.') + '.' + attribute} can only be **${LocaleList.join(', ')}**`, }; } diff --git a/src/commands/noAuth/join.ts b/src/commands/noAuth/join.ts index 1de19907..8ae5c31e 100644 --- a/src/commands/noAuth/join.ts +++ b/src/commands/noAuth/join.ts @@ -31,7 +31,7 @@ export = { }; } - clientTalk(interaction, pGuild, AnnouncementAction.join); + clientTalk(interaction, pGuild, AnnouncementAction.join, true); return { result: true, diff --git a/src/commands/noAuth/leave.ts b/src/commands/noAuth/leave.ts index e1316c6e..322925e1 100644 --- a/src/commands/noAuth/leave.ts +++ b/src/commands/noAuth/leave.ts @@ -43,7 +43,7 @@ export = { }; } - clientTalk(interaction, pGuild, AnnouncementAction.leave); + clientTalk(interaction, pGuild, AnnouncementAction.leave, true); setTimeout(function () { voiceConnection.disconnect(); }, 4000); diff --git a/src/events/channelDelete.event.ts b/src/events/channelDelete.event.ts index b62513d3..499d7901 100644 --- a/src/events/channelDelete.event.ts +++ b/src/events/channelDelete.event.ts @@ -1,5 +1,6 @@ import { ChannelType, DMChannel, GuildChannel, TextChannel, VoiceChannel } from 'discord.js'; import { handleChannelDeletion } from '../libraries/mongo.library'; + import { PortalChannelType } from '../types/enums/PortalChannel.enum'; export default async function channelDelete(args: { channel: DMChannel | GuildChannel }): Promise { @@ -18,7 +19,6 @@ export default async function channelDelete(args: { channel: DMChannel | GuildCh } return deletedChannelPortalType > 0 - ? `${PortalChannelType[deletedChannelPortalType].toString()} channel removed from ` + - `${deletedChannel.guild.name}|${deletedChannel.guild.id}` + ? `${PortalChannelType[deletedChannelPortalType].toString()} channel removed from ${deletedChannel.guild.name}|${deletedChannel.guild.id}` : `${deletedChannel.name} channel is not controlled by Portal`; } diff --git a/src/events/ready.event.ts b/src/events/ready.event.ts index cd37bcde..640fdc02 100644 --- a/src/events/ready.event.ts +++ b/src/events/ready.event.ts @@ -1,4 +1,5 @@ import { ActivityOptions, ActivityType, Client, Guild, PresenceData } from 'discord.js'; + import { removeDeletedChannels, removeEmptyVoiceChannels } from '../libraries/help.library'; import { getFunction } from '../libraries/localisation.library'; import { fetchGuildMembers, guildExists, insertGuild, insertMember, removeMember } from '../libraries/mongo.library'; @@ -17,16 +18,20 @@ export default async (args: { client: Client }): Promise => { url: 'https://github.com/keybraker', }; - const data: PresenceData = { activities: [activitiesOptions], status: 'online', afk: false }; + const data: PresenceData = { + activities: [activitiesOptions], + status: 'online', + afk: false + }; args.client.user.setPresence(data); + let index = 0; args.client.guilds.cache.forEach((guild: Guild) => { logger.info(`${index++}. logged onto guild ${guild} (${guild.id})`); - addGuildAgain(guild, args.client).catch((e) => { - return `failed to add guild again: ${e}`; - }); + addGuildAgain(guild, args.client) + .catch((e) => logger.warn(`failed to add guild ${guild.name} [${guild.id}] (${e})`)); removeDeletedChannels(guild); removeEmptyVoiceChannels(guild); diff --git a/src/libraries/localisation.library.ts b/src/libraries/localisation.library.ts index 252b65d7..5b1227e6 100644 --- a/src/libraries/localisation.library.ts +++ b/src/libraries/localisation.library.ts @@ -230,18 +230,11 @@ export const consoleText: LocalisationConsoleOption[] = [ }, ]; -function isAnnouncementAction(value: AnnouncementAction | string): value is AnnouncementAction { - return Object.values(AnnouncementAction).includes(value); -} - -function isEventAction(value: EventAction | string): value is EventAction { - return Object.values(EventAction).includes(value); -} - export function clientTalk( interaction: ChatInputCommandInteraction, pGuild: PGuild, - context: AnnouncementAction | EventAction + context: AnnouncementAction | EventAction, + isAction: boolean ): boolean { if (!interaction.guild) { return false; @@ -276,28 +269,30 @@ export function clientTalk( [EventAction.userDisconnected]: 'user_disconnected', }; - for (const p of pGuild.pChannels) { - for (const v of p.pVoiceChannels) { - if (isAnnouncementAction(context.toString())&& !isEventAction(context.toString()) && v.annAnnounce) { + for (let i = 0; i < pGuild.pChannels.length; i++) { + for (let j = 0; j < pGuild.pChannels[i].pVoiceChannels.length; j++) { + const v = pGuild.pChannels[i].pVoiceChannels[j]; + + if (isAction) { const locale = localeToString[v.locale]; const contextAsAction = AnnouncementActionToString[context]; const random = Math.floor(Math.random() * 3); - const resource = createAudioResource(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}${random}.mp3`); - logger.info(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}${random}.mp3, ${!!resource}`); + const resource = createAudioResource(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}_${random}.mp3`); + logger.info(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}_${random}.mp3, ${!!resource}`); player.play(resource); voiceConnection.subscribe(player); return true; - } else if (!isAnnouncementAction(context.toString()) && isEventAction(context.toString()) && v.annUser) { + } else { const locale = localeToString[v.locale]; const contextAsAction = EventActionToString[context as EventAction]; const random = Math.floor(Math.random() * 3); - const resource = createAudioResource(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}${random}.mp3`); - logger.info(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}${random}.mp3, ${!!resource}`); + const resource = createAudioResource(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}_${random}.mp3`); + logger.info(`src/assets/mp3s/${locale}/${contextAsAction}/${contextAsAction}_${random}.mp3, ${!!resource}`); player.play(resource); voiceConnection.subscribe(player);