Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
feat(Client): add a toggle for username and mention prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexthemaster committed Jul 30, 2020
1 parent e0c5cb7 commit 956821d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/events/OnceReady.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]));
Expand Down Expand Up @@ -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}!`
Expand Down

0 comments on commit 956821d

Please sign in to comment.