Skip to content

Commit 26ef1dd

Browse files
megatank58favna
andauthored
feat: allow mention prefix to be disabled (#350)
Co-authored-by: Jeroen Claassens <[email protected]>
1 parent ab7c5b1 commit 26ef1dd

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/lib/SapphireClient.ts

+16
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ export interface SapphireClientOptions {
120120
* @default "No cooldown options"
121121
*/
122122
defaultCooldown?: CooldownOptions;
123+
/**
124+
* Controls whether the bot has mention as a prefix disabled
125+
* @default false
126+
*/
127+
disableMentionPrefix?: boolean;
123128
}
124129

125130
/**
@@ -211,6 +216,16 @@ export class SapphireClient<Ready extends boolean = boolean> extends Client<Read
211216
*/
212217
public logger: ILogger;
213218

219+
/**
220+
* Whether the bot has mention as a prefix disabled
221+
* @default false
222+
* @example
223+
* ```typescript
224+
* client.disableMentionPrefix = false;
225+
* ```
226+
*/
227+
public disableMentionPrefix?: boolean;
228+
214229
/**
215230
* The registered stores.
216231
* @since 1.0.0
@@ -237,6 +252,7 @@ export class SapphireClient<Ready extends boolean = boolean> extends Client<Read
237252
container.stores = this.stores;
238253

239254
this.fetchPrefix = options.fetchPrefix ?? (() => this.options.defaultPrefix ?? null);
255+
this.disableMentionPrefix = options.disableMentionPrefix;
240256

241257
for (const plugin of SapphireClient.plugins.values(PluginHook.PreInitialization)) {
242258
plugin.hook.call(this, options);

src/listeners/command-handler/CoreMessageParser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class CoreListener extends Listener<typeof Events.PreMessageParsed> {
4949
}
5050

5151
private getMentionPrefix(message: Message): string | null {
52+
if (this.container.client.disableMentionPrefix) return null;
5253
// If the content is shorter than 20 characters, or does not start with `<@` then skip early:
5354
if (message.content.length < 20 || !message.content.startsWith('<@')) return null;
5455

0 commit comments

Comments
 (0)