var result = await rcon.SendCommand(command);
if (!result.success)
{
await Context.Channel.SendMessageAsync(result.message);
return;
}
await Context.Channel.SendMessageAsync(result.message);
exactly, I eventually stopped thinking, the success part is used in other places to decide what should it do next, so I used the same pattern everywhere even in places it doesn't make sense like here
Been there, done that and just say fuck it or leave a note saying that this should probably be refactored out to a separate function where its somewhat generic.
Usually takes about 4-5 times of writing the pattern to notice and begin to figure out how to refactor it and keep it generic.
I learned to do the inverse. Rush it in the first 3 days, then procrastinate the rest of the time. If any errors or changes pop up later it's usually an easy change. The time balance is basically the same, but the pressure and anxiety are gone. lol
Would shoot for moving the deadline instead of brute forcing it tbh, tired programming leads to bugs and time wasted on patching shit up. Rested zen programming leads to happy design and happy life.
I'm not sure what makes me more sad. Running the same command where it's successful or not. Or not utilizing the already asynchronous nature of the command to .catch() instead of the if.
"promises" is the word you want. Using async await is a way to force a promise to act as a synchronous function. Prepare to go down a rabbit hole because promises are fun!!
Pretty sure it was a path with some logging or tracing involved (or even other logic) and later on it was scraped without too much attention. Happens sometimes.
28
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 03 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
23
u/SensitiveTrap Jan 03 '22
Was there any legit reason as to why you were doing this?
19
u/Tvde1 Jan 03 '22
The deadline should have been moved up weeks ago... How can you guarantee quality programming the day before release
6
u/mrnatbus122 Jan 04 '22
Hi I am very dumb.
Is the issue that regardless of if statement the context.channel function is called?
1
u/[deleted] Jan 16 '22
I'm not sure what makes me more sad. Running the same command where it's successful or not. Or not utilizing the already asynchronous nature of the command to .catch() instead of the if.
2
u/Gallardo994 Jan 04 '22
Pretty sure it was a path with some logging or tracing involved (or even other logic) and later on it was scraped without too much attention. Happens sometimes.
2
u/themancabbage Jan 04 '22
If this, then do this.
If not, fuck it, do it anyway.