owengombas / discord.ts

🤖 Create your discord bot by using TypeScript and decorators!
https://owencalvin.github.io/discord.ts/
325 stars 40 forks source link

Able to use command anywhere within message #12

Closed NeutronicMC closed 4 years ago

NeutronicMC commented 4 years ago

If a command prefix is found anywhere within a message (not just the beginning) the command still executes.

owengombas commented 4 years ago

Thank’s for sharing your issue, could you please provide a simple example to reproduce ?

owengombas commented 4 years ago

When you use a function to return the prefix you must explicitly put ^ before the prefix event if it's string:

function(command: CommandMessage) {
  switch(command.guild.name) {
    case "guildA":
      return "^!";
    case "guildB":
      return "^.";
  }
}

@Discord(dynamicPrefix)
class MyBot {
  // ...
}