Pull request review fixes

This commit is contained in:
smartfrigde 2022-01-05 21:27:24 +01:00
parent 1106cf7a4d
commit eb05654085
4 changed files with 31 additions and 32 deletions

View File

@ -6,7 +6,7 @@ import {CommandInteraction} from "discord.js";
export const header = new SlashCommandBuilder().setDescription("Insult TravBot >:D");
export async function handler(interaction: CommandInteraction) {
interaction.reply(
`@${interaction.user.tag} What the fuck did you just fucking say about me, you little bitch? I'll have you know I graduated top of my class in the Navy Seals, and I've been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I'm the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You're fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that's just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little "clever" comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldn't, you didn't, and now you're paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. You're fucking dead, kiddo.`
`<@${interaction.user.id}> What the fuck did you just fucking say about me, you little bitch? I'll have you know I graduated top of my class in the Navy Seals, and I've been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I'm the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You're fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that's just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little "clever" comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldn't, you didn't, and now you're paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. You're fucking dead, kiddo.`
);
}
export default new NamedCommand({

View File

@ -1,5 +1,5 @@
import {Command, NamedCommand, confirm, poll} from "onion-lasers";
import {pluralise} from "../../../lib";
import {pluralise, parseDuration} from "../../../lib";
import {Storage} from "../../../structures";
import {isAuthorized, getMoneyEmbed} from "./eco-utils";
import {User} from "discord.js";
@ -167,30 +167,3 @@ export const BetCommand = new NamedCommand({
})
})
});
/**
* Parses a duration string into milliseconds
* Examples:
* - 3d -> 3 days -> 259200000ms
* - 2h -> 2 hours -> 7200000ms
* - 7m -> 7 minutes -> 420000ms
* - 3s -> 3 seconds -> 3000ms
*/
function parseDuration(duration: string): number {
// extract last char as unit
const unit = duration[duration.length - 1].toLowerCase();
// get the rest as value
let value: number = +duration.substring(0, duration.length - 1);
if (!["d", "h", "m", "s"].includes(unit) || isNaN(value)) return 0;
if (unit === "d") value *= 86400000;
// 1000ms * 60s * 60m * 24h
else if (unit === "h") value *= 3600000;
// 1000ms * 60s * 60m
else if (unit === "m") value *= 60000;
// 1000ms * 60s
else if (unit === "s") value *= 1000; // 1000ms
return value;
}

View File

@ -2,7 +2,7 @@ import {MessageEmbed, Message, User, MessageActionRow, MessageButton} from "disc
import {NamedCommand, RestCommand, poll, CHANNEL_TYPE, SendFunction, Command} from "onion-lasers";
import {SlashCommandBuilder} from "@discordjs/builders";
import {CommandInteraction} from "discord.js";
import {pluralise} from "../../lib";
import {pluralise, parseDuration} from "../../lib";
export const header = new SlashCommandBuilder()
.setDescription("Create a poll.")
@ -14,8 +14,8 @@ export const header = new SlashCommandBuilder()
export async function handler(interaction: CommandInteraction) {
const {options} = interaction;
const question = options.getString("question", true);
const duration = options.getInteger("duration", false);
var duration = options.getInteger("duration", false);
duration = parseDuration(duration + "s"); //override the duration variable with miliseconds one
execSlashPoll(interaction, question, duration || 60000);
}

View File

@ -269,3 +269,29 @@ export function split<T>(array: T[], lengthOfEachSection: number): T[][] {
export function requireAllCasesHandledFor(variable: never): never {
throw new Error(`This function should never be called but got the value: ${variable}`);
}
/**
* Parses a duration string into milliseconds
* Examples:
* - 3d -> 3 days -> 259200000ms
* - 2h -> 2 hours -> 7200000ms
* - 7m -> 7 minutes -> 420000ms
* - 3s -> 3 seconds -> 3000ms
*/
export function parseDuration(duration: string): number {
// extract last char as unit
const unit = duration[duration.length - 1].toLowerCase();
// get the rest as value
let value: number = +duration.substring(0, duration.length - 1);
if (!["d", "h", "m", "s"].includes(unit) || isNaN(value)) return 0;
if (unit === "d") value *= 86400000;
// 1000ms * 60s * 60m * 24h
else if (unit === "h") value *= 3600000;
// 1000ms * 60s * 60m
else if (unit === "m") value *= 60000;
// 1000ms * 60s
else if (unit === "s") value *= 1000; // 1000ms
return value;
}