fix(command): broke when user sent just prefix
This commit is contained in:
parent
844a408c74
commit
d0f48f601a
2 changed files with 4 additions and 2 deletions
|
@ -503,12 +503,13 @@ export const parseCommand = (
|
||||||
client: CommandClient,
|
client: CommandClient,
|
||||||
msg: Message,
|
msg: Message,
|
||||||
prefix: string
|
prefix: string
|
||||||
): ParsedCommand => {
|
): ParsedCommand | undefined => {
|
||||||
let content = msg.content.slice(prefix.length)
|
let content = msg.content.slice(prefix.length)
|
||||||
if (client.spacesAfterPrefix === true) content = content.trim()
|
if (client.spacesAfterPrefix === true) content = content.trim()
|
||||||
const args = parse(content)._.map((e) => e.toString())
|
const args = parse(content)._.map((e) => e.toString())
|
||||||
|
|
||||||
const name = args.shift() as string
|
const name = args.shift()
|
||||||
|
if (name === undefined) return
|
||||||
const argString = content.slice(name.length).trim()
|
const argString = content.slice(name.length).trim()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -187,6 +187,7 @@ export class CommandClient extends Client implements CommandClientOptions {
|
||||||
prefix = usedPrefix
|
prefix = usedPrefix
|
||||||
|
|
||||||
const parsed = parseCommand(this, msg, prefix)
|
const parsed = parseCommand(this, msg, prefix)
|
||||||
|
if (parsed === undefined) return
|
||||||
const command = this.commands.fetch(parsed)
|
const command = this.commands.fetch(parsed)
|
||||||
|
|
||||||
if (command === undefined) return
|
if (command === undefined) return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue