Skip to content

Commit 91ad6d4

Browse files
committed
Trust getPrefix()'s result instead of re-checking startsWith(prefix), which duplicated logic and broke prefixCaseInsensitive
1 parent d7ee33a commit 91ad6d4

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

dist/handlers/events/messageCreate.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/handlers/events/messageCreate.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/handlers/events/messageCreate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default new DiscordEventHandler({
1313
listener: async function (message) {
1414
const prefix = await this.getPrefix(message)
1515
const content = message.content.trim()
16-
const hasPrefix = !!prefix && content.startsWith(prefix)
16+
const hasPrefix = prefix !== null
1717
const rawArgs = (hasPrefix ? content.slice(prefix!.length) : content).trim().split(/ +/g)
1818
const name = rawArgs[0]?.toLowerCase()
1919

@@ -22,8 +22,8 @@ export default new DiscordEventHandler({
2222
// Allow always execute commands
2323
!cmd.name ||
2424
// Check if it matches the command name or one of aliases
25-
((cmd.name === name ||
26-
!!cmd.data.aliases?.includes(name!)) &&
25+
((cmd.name === name || !!cmd.data.aliases?.includes(name!)) &&
26+
// If unprefixed there can be no prefix
2727
(cmd.data.unprefixed ? true : hasPrefix))
2828
)
2929

0 commit comments

Comments
 (0)