-
Notifications
You must be signed in to change notification settings - Fork 134
Self destructing messages with styling. #59
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.
Just a few small tweaks and this will be good to go!
src/commands/Fun/destruct.js
Outdated
throw 'Please provide a secret message'; | ||
} | ||
|
||
let text = parsedArgs.leftover; |
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 variable can be inlined into the message
variable declaration.
src/commands/Fun/destruct.js
Outdated
|
||
switch(style) { | ||
case 'embed': | ||
message = bot.utils.embed( |
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.
If you change this to
message = {
embed: bot.utils.embed(...)
};
Then you can just move the msg.channel.send call out of the switch statement and that way you'll stop repeating yourself.
src/commands/Fun/destruct.js
Outdated
case 'embed': | ||
message = bot.utils.embed( | ||
`This message self-destructs in ${delay/1000} seconds.`, | ||
`${message}`, |
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.
A template string is not needed here. This can simply be replaced by message
.
src/commands/Fun/destruct.js
Outdated
msg.channel.send(message).then(m => { m.delete(delay); }); | ||
break; | ||
default: | ||
message = `${message}`; |
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 entire case is not needed. You're literally setting message to itself :P
src/commands/Fun/destruct.js
Outdated
|
||
let text = parsedArgs.leftover; | ||
let message = text.join(' '); | ||
let delay = isNaN(parsedArgs.options.d) ? 5000 : parsedArgs.options.d; |
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.
You should call parseInt on the option value. After that, you should add a check to make sure that the value is not negative.
src/commands/Fun/destruct.js
Outdated
{ | ||
inline: true, | ||
footer: 'Secret Message', | ||
color: [255, 0, 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.
I would prefer to not set the color and leave the embed color handling to bot.utils.embed itself. The reason for this is that I'm planning on writing a settings system, and I want to allow the bot settings to control the default embed color handling. For example, if you wanted all your embeds for the bot to be pink, you could do something like //settings embedColor #ff00ff
.
src/commands/Fun/destruct.js
Outdated
@@ -0,0 +1,61 @@ | |||
exports.run = function(bot,msg,args) { | |||
|
|||
let parsedArgs = bot.utils.parseArgs(args, ['d:','s:']); |
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 variable and the style
variable should probably be const
s to follow the code style, but I won't shoot you if you don't change this.
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.
Well then, don't shoot me. :P
Adds a command for self-destructing messages.
Command Syntax:
destruct [-d <delay in ms>] [-s <embed|inline|code|plain>] <message>
Usage Example & Previews:
destruct -d 5000 -s embed <message>
destruct -d 5000 -s inline <message>
destruct -d 5000 -s code <message>
destruct -d 5000 -s plain <message>