Skip to content

Commit f199d92

Browse files
committed
Support prefixes with length != 1
Resolves #545
1 parent 872264c commit f199d92

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ login().then(
171171
await botContext.textChannels.hauptchat.send(
172172
`Hallo, ich wurde gerade gestartet!\nMeine Präfixe sind: \`${botContext.prefix.command}\`/\`${botContext.prefix.modCommand}\``,
173173
);
174+
log.info("Sent welcome message");
174175
}
175176
},
176177
err => {

src/handler/commandHandler.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,15 @@ export const messageCommandHandler = async (
288288
// TODO: The Prefix is now completely irrelevant, since the commands itself define their permission.
289289
const plebPrefix = context.prefix.command;
290290
const modPrefix = context.prefix.modCommand;
291-
if (message.content.startsWith(plebPrefix) || message.content.startsWith(modPrefix)) {
292-
const cmdString = message.content.split(/\s+/)[0].slice(1);
291+
292+
const { content } = message;
293+
if (content.startsWith(plebPrefix) || content.startsWith(modPrefix)) {
294+
const splitContent = content.split(/\s+/);
295+
296+
const cmdString = content.startsWith(plebPrefix)
297+
? splitContent[0].slice(plebPrefix.length)
298+
: splitContent[0].slice(modPrefix.length);
299+
293300
if (cmdString) {
294301
try {
295302
await commandMessageHandler(cmdString, message, context);
@@ -299,7 +306,7 @@ export const messageCommandHandler = async (
299306

300307
// Not using message.reply because the original message might be deleted by the command handler
301308
await message.channel.send(
302-
`${message.author} wollte gerade dieses Command ausführen:\n\`${message.content}\`\nDabei ist irgendwas explodiert. Irgendjemand sollte das fixen.`,
309+
`${message.author} wollte gerade dieses Command ausführen:\n\`${content}\`\nDabei ist irgendwas explodiert. Irgendjemand sollte das fixen.`,
303310
);
304311
}
305312
}

0 commit comments

Comments
 (0)