From 956821df6fe3328a52993a55d0cfb5cd10ac234d Mon Sep 17 00:00:00 2001 From: Kovacs Alex Date: Thu, 30 Jul 2020 22:59:36 +0300 Subject: [PATCH] feat(Client): add a toggle for username and mention prefixes --- src/events/OnceReady.ts | 3 ++- src/lib/Client.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/events/OnceReady.ts b/src/events/OnceReady.ts index 972e4eec..2bd0bf9e 100644 --- a/src/events/OnceReady.ts +++ b/src/events/OnceReady.ts @@ -28,7 +28,8 @@ export default class extends Event { // This will remove the duplicates this.client.owners = [...new Set(this.client.owners)]; - this.client.prefixes.push(`${this.client.user!.username}, `, `<@!${this.client.user!.id}>`); + if (this.client.options.useUsernamePrefix) this.client.prefixes.push(`${this.client.user!.username}, `); + if (this.client.options.useMentionPrefix) this.client.prefixes.push(`<@!${this.client.user!.id}>`); this.client.pools.forEach(pool => pool.init()); } diff --git a/src/lib/Client.ts b/src/lib/Client.ts index 509ff607..f6d3057a 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -61,6 +61,8 @@ export class MoonlightClient extends Client { super(options); options.displayErrors = options.displayErrors ?? true; + options.useMentionPrefix = options.useMentionPrefix ?? true; + options.useUsernamePrefix = options.useUsernamePrefix ?? true; if (options?.prefix) { if (Array.isArray(options.prefix)) this.prefixes.push(...(options.prefix as string[])); @@ -122,6 +124,10 @@ export interface MoonlightClientOptions extends ClientOptions { displayErrors?: boolean; /** An array that contains the ID's of the owners */ owners?: string[]; + /** Whether or not to use mention prefix */ + useMentionPrefix?: boolean; + /** Whether or not to use username prefix - e.g. if the bot is called "Penfold" then the username prefix will be "Penfold, " */ + useUsernamePrefix?: boolean; /** * Set the ready message to display when the bot is ready -> should return a string * @example readyMessage: (client) => `Logged in and serving in ${client.guilds.size}!`