Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Self destructing messages with styling. #59

Merged
merged 6 commits into from
May 21, 2017
Merged

Self destructing messages with styling. #59

merged 6 commits into from
May 21, 2017

Conversation

Doxylamin
Copy link
Contributor

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>
auswahl_225

destruct -d 5000 -s inline <message>
auswahl_226

destruct -d 5000 -s code <message>
auswahl_227

destruct -d 5000 -s plain <message>
auswahl_228

Copy link
Member

@foxfirecodes foxfirecodes left a 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!

throw 'Please provide a secret message';
}

let text = parsedArgs.leftover;
Copy link
Member

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.


switch(style) {
case 'embed':
message = bot.utils.embed(
Copy link
Member

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.

case 'embed':
message = bot.utils.embed(
`This message self-destructs in ${delay/1000} seconds.`,
`${message}`,
Copy link
Member

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.

msg.channel.send(message).then(m => { m.delete(delay); });
break;
default:
message = `${message}`;
Copy link
Member

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


let text = parsedArgs.leftover;
let message = text.join(' ');
let delay = isNaN(parsedArgs.options.d) ? 5000 : parsedArgs.options.d;
Copy link
Member

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.

{
inline: true,
footer: 'Secret Message',
color: [255, 0, 0]
Copy link
Member

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.

@@ -0,0 +1,61 @@
exports.run = function(bot,msg,args) {

let parsedArgs = bot.utils.parseArgs(args, ['d:','s:']);
Copy link
Member

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 consts to follow the code style, but I won't shoot you if you don't change this.

Copy link
Contributor Author

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

@abyss abyss merged commit aa7b1f8 into rayzrdev:master May 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants