Popcorn-moe / migi

Our right hand to write Discord bots
MIT License
7 stars 3 forks source link

Run command using a mention instead of prefix #11

Closed cchudant closed 6 years ago

cchudant commented 6 years ago

add a configuration option mentionIsPrefix to allow the bot to trigger commands when the prefix of the command is the bot's mention

lightdiscord commented 6 years ago

Unresolved question, should we still run the command if the option is on and the prefix is the bot's prefix (i.e. /) ?

cchudant commented 6 years ago

we should enable the developer to disable prefix by setting it to a falsy value -- '', null or whatever

lightdiscord commented 6 years ago

I thought of something like this

@command(/^command$/i, {
    name: 'Command',
    desc: 'Description',
    prefix: Mode.MENTION_ONLY
})

Where Mode is

const Mode = {
    PREFIX: Symbol('Prefix'),
    MENTION: Symbol('Prefix and Mentions'),
    MENTION_ONLY: Symbol('Mentions only')
}
cchudant commented 6 years ago

this should be configurable not inside the module but in the global config of the bot, no?

DeltaEvo commented 6 years ago

I think, we could simplify this a lot Just let the prefix take an array, of string or functions

prefix: ["/", ({ client }) => `${client.user} `]

And let this global setting, be overriden by a command

@command(/^command$/i, {
    name: 'Command',
    desc: 'Description',
    prefix: ["/", ({  client }) => `${client.user} `]
})

And that can also be a function

@command(/^command$/i, {
    name: 'Command',
    desc: 'Description',
    prefix: ({ client }) => client.settings.prefix.concat([({ client }) => `${client.user} `])
})
cchudant commented 6 years ago

we need the length to remove from the message in order to pass it to the regexes