-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add !topic #209
base: master
Are you sure you want to change the base?
add !topic #209
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good start!
The linter still isn't happy.. it's kinda unfortunately picky, so it helps to have an eslint plugin in your editor that suggests stylistic changes as you go.
I left some additional small suggestions too.
Thanks for picking this one up!
topic(a, parts, b, c, user, channel) { | ||
let msg; | ||
chan = bot.client.chanData(channel); | ||
switch(parts[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you could also make it something like:
module.exports.commands {
topic: {
help(_, parts, reply, _, ...) {
...
}
}
}
The sugar for defining commands as object keys does allow nesting.
You can define a function named _default
under topic
if you e.g. want !topic
with no additional parts to print out help as well.
chan = bot.client.chanData(channel); | ||
switch(parts[0]) { | ||
case 'help': | ||
bot.client.say(channel, helpMsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, the reply
object passed in to the module should be used whenever possible. bot.client
is not meant to be a stable interface, so we should use it as little as possible.
}; | ||
|
||
module.exports.commands = { | ||
topic(a, parts, b, c, user, channel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible this could be called from privmsg session too (e.g. /msg bot !topic
).
One solution could be to use the bot.isChannel(channel)
check and handle it appropriately.
#74