dos to unix

This commit is contained in:
night0721 2023-11-02 01:04:53 +00:00
parent 3fb164c552
commit b3cf434218
40 changed files with 1689 additions and 1689 deletions

View file

@ -1,22 +1,22 @@
export interface CODMClientOptions {
/**
* Authorisation key for the API
*/
key: string;
}
export interface PerkData {
name: string;
perk: string;
effects: string;
type: string;
}
export interface ScorestreakData {
name: string;
description: string;
special: string;
cost: number;
type: string;
manual: boolean;
preview: string;
preview_video: string;
}
export interface CODMClientOptions {
/**
* Authorisation key for the API
*/
key: string;
}
export interface PerkData {
name: string;
perk: string;
effects: string;
type: string;
}
export interface ScorestreakData {
name: string;
description: string;
special: string;
cost: number;
type: string;
manual: boolean;
preview: string;
preview_video: string;
}

View file

@ -1,47 +1,47 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
import { PerkData, ScorestreakData } from "./codmclient.interface";
/**
* @name APIClient
* @kind constructor
* @param {String} key Authorization Key for API (Only for CODM commands)
*/
export class CODMClient {
constructor(public key: string) {
if (!key) throw new CathError("Missing 'key' property");
if (key && typeof key !== "string")
throw new CathError("API key must be a string");
}
/**
* Sends a CODM perk object
* @return {Promise<PerkData>}
* @param {String} name
*/
public async getperk(name: string): Promise<PerkData> {
const data = await axios
.get(`${config.api}/api/v1/codm/perk?name=${name}`, {
headers: {
Authorization: this.key,
},
})
.then(res => res.data)
.catch(err => {
throw new CathError(`Unauthorized to use`);
});
return data;
}
public async getscorestreak(name: string): Promise<ScorestreakData> {
const data = await axios
.get(`${config.api}/api/v1/codm/scorestreak?name=${name}`, {
headers: {
Authorization: this.key,
},
})
.then(res => res.data)
.catch(err => {
throw new CathError(`Unauthorized to use`);
});
return data;
}
}
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
import { PerkData, ScorestreakData } from "./codmclient.interface";
/**
* @name APIClient
* @kind constructor
* @param {String} key Authorization Key for API (Only for CODM commands)
*/
export class CODMClient {
constructor(public key: string) {
if (!key) throw new CathError("Missing 'key' property");
if (key && typeof key !== "string")
throw new CathError("API key must be a string");
}
/**
* Sends a CODM perk object
* @return {Promise<PerkData>}
* @param {String} name
*/
public async getperk(name: string): Promise<PerkData> {
const data = await axios
.get(`${config.api}/api/v1/codm/perk?name=${name}`, {
headers: {
Authorization: this.key,
},
})
.then(res => res.data)
.catch(err => {
throw new CathError(`Unauthorized to use`);
});
return data;
}
public async getscorestreak(name: string): Promise<ScorestreakData> {
const data = await axios
.get(`${config.api}/api/v1/codm/scorestreak?name=${name}`, {
headers: {
Authorization: this.key,
},
})
.then(res => res.data)
.catch(err => {
throw new CathError(`Unauthorized to use`);
});
return data;
}
}

View file

@ -1,6 +1,6 @@
export {
CODMClientOptions,
PerkData,
ScorestreakData,
} from "./codmclient.interface";
export { CODMClient } from "./codmclient";
export {
CODMClientOptions,
PerkData,
ScorestreakData,
} from "./codmclient.interface";
export { CODMClient } from "./codmclient";

View file

@ -1,3 +1,3 @@
export interface CodeData {
id: string;
}
export interface CodeData {
id: string;
}

View file

@ -1,32 +1,32 @@
import axios from "axios";
import { config } from "../";
import { CodeData } from "./codeclient.interface";
import { CathError } from "../Error/CathError";
/**
* @name CodeClient
* @kind constructor
*/
export class CodeClient {
constructor() {}
/**
* Sends the link of the code
* @return {Promise<CodeData>}
* @param {String} key
* @param {String} code
*/
public async createBin(key: String, code: String): Promise<CodeData> {
if (!key) throw new CathError("Missing 'key' property");
if (!code) throw new CathError("Missing 'code' property");
const data = await axios
.post(config.code, {
key,
value: code,
})
.then(res => res.data);
if (data?.url) {
return data?.url;
} else {
throw new CathError(`Code already exist`);
}
}
}
import axios from "axios";
import { config } from "../";
import { CodeData } from "./codeclient.interface";
import { CathError } from "../Error/CathError";
/**
* @name CodeClient
* @kind constructor
*/
export class CodeClient {
constructor() {}
/**
* Sends the link of the code
* @return {Promise<CodeData>}
* @param {String} key
* @param {String} code
*/
public async createBin(key: String, code: String): Promise<CodeData> {
if (!key) throw new CathError("Missing 'key' property");
if (!code) throw new CathError("Missing 'code' property");
const data = await axios
.post(config.code, {
key,
value: code,
})
.then(res => res.data);
if (data?.url) {
return data?.url;
} else {
throw new CathError(`Code already exist`);
}
}
}

View file

@ -1,2 +1,2 @@
export { CodeData } from "./codeclient.interface";
export { CodeClient } from "./codeclient";
export { CodeData } from "./codeclient.interface";
export { CodeClient } from "./codeclient";

View file

@ -1,6 +1,6 @@
export class CathError extends Error {
constructor(err: string) {
super(err);
console.log(`Cath Error: ${err}`);
}
}
export class CathError extends Error {
constructor(err: string) {
super(err);
console.log(`Cath Error: ${err}`);
}
}

View file

@ -1,60 +1,60 @@
import { Client } from "discord.js";
export interface GiveawaySchema {
Guild: string;
Channel: string;
Message: string;
HostBy: string;
End: number;
Start: number;
Award: string;
Winners: number;
Ended: boolean;
Invites: number;
Requirements: { Enabled: boolean; Roles?: [string] };
Clickers: [string];
}
export interface InviteSchema {
User: string;
Invites: [
object: {
Guild: string;
Invite: string;
Invited: string;
Inviter: string;
Uses: number;
}
];
}
export interface GiveawaysClientOptions {
/**
* Discord Client
*/
client: Client;
/**
* Connection URI for the MongoDB
*/
MongooseConnectionURI: string;
/**
* Customizable messages for the giveaway embed
*/
GiveawayMessages: DefaultGiveawayMessages;
}
export interface DefaultGiveawayMessages {
dmWinner: true;
giveaway: "🎉🎉 **GIVEAWAY!** 🎉🎉";
giveawayDescription: "🎁 Award: **{award}**\n🎊 Hosted by: {hostedBy}\n⏲ Winner(s): `{winners}` \n🙏 Entrants: {totalParticipants} \n\n**Requirements:** {requirements}\n**Required Invites:** {invites}";
giveawayFooterImage: "https://emoji.gg/assets/emoji/3461-giveaway.gif";
winMessage: "congratulations {winners}! You have won **{prize}** from total `{totalParticipants}` entrants!";
rerolledMessage: "Rerolled! {winner} is the new winner of the giveaway!"; // only {winner} placeholder
toParticipate: "**Click the `Enter` button to enter the giveaway!**";
newParticipant: "You have successfully entered for this giveaway! There are total `{totalParticipants}` entrants"; // no placeholders | ephemeral
alreadyParticipated: "**You have already participated in this giveaway!**"; // no placeholders | ephemeral
noParticipants: "There isn't enough entrant in this giveaway!"; // no placeholders
dmMessage: "You have won a giveaway in **{guildName}**!\nPrize: [{prize}]({giveawayURL})";
noWinner: "There isn't any winner in this giveaway due to not enough entrants"; // no {winner} placerholder
alreadyEnded: "The giveaway had already ended!"; // no {winner} placeholder
noWeeklyExp: "you dont have the required minimum weekly xp to join this giveaway";
noLevel: "You dont have the minimum required level to join this giveaway";
nonoRole: "You don't the required role(s)\n{requiredRoles} role(s) to join the giveaway";
editParticipants: true;
}
import { Client } from "discord.js";
export interface GiveawaySchema {
Guild: string;
Channel: string;
Message: string;
HostBy: string;
End: number;
Start: number;
Award: string;
Winners: number;
Ended: boolean;
Invites: number;
Requirements: { Enabled: boolean; Roles?: [string] };
Clickers: [string];
}
export interface InviteSchema {
User: string;
Invites: [
object: {
Guild: string;
Invite: string;
Invited: string;
Inviter: string;
Uses: number;
}
];
}
export interface GiveawaysClientOptions {
/**
* Discord Client
*/
client: Client;
/**
* Connection URI for the MongoDB
*/
MongooseConnectionURI: string;
/**
* Customizable messages for the giveaway embed
*/
GiveawayMessages: DefaultGiveawayMessages;
}
export interface DefaultGiveawayMessages {
dmWinner: true;
giveaway: "🎉🎉 **GIVEAWAY!** 🎉🎉";
giveawayDescription: "🎁 Award: **{award}**\n🎊 Hosted by: {hostedBy}\n⏲ Winner(s): `{winners}` \n🙏 Entrants: {totalParticipants} \n\n**Requirements:** {requirements}\n**Required Invites:** {invites}";
giveawayFooterImage: "https://emoji.gg/assets/emoji/3461-giveaway.gif";
winMessage: "congratulations {winners}! You have won **{prize}** from total `{totalParticipants}` entrants!";
rerolledMessage: "Rerolled! {winner} is the new winner of the giveaway!"; // only {winner} placeholder
toParticipate: "**Click the `Enter` button to enter the giveaway!**";
newParticipant: "You have successfully entered for this giveaway! There are total `{totalParticipants}` entrants"; // no placeholders | ephemeral
alreadyParticipated: "**You have already participated in this giveaway!**"; // no placeholders | ephemeral
noParticipants: "There isn't enough entrant in this giveaway!"; // no placeholders
dmMessage: "You have won a giveaway in **{guildName}**!\nPrize: [{prize}]({giveawayURL})";
noWinner: "There isn't any winner in this giveaway due to not enough entrants"; // no {winner} placerholder
alreadyEnded: "The giveaway had already ended!"; // no {winner} placeholder
noWeeklyExp: "you dont have the required minimum weekly xp to join this giveaway";
noLevel: "You dont have the minimum required level to join this giveaway";
nonoRole: "You don't the required role(s)\n{requiredRoles} role(s) to join the giveaway";
editParticipants: true;
}

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
export { GiveawaysClient } from "./giveaway";
export {
GiveawaySchema,
GiveawaysClientOptions,
DefaultGiveawayMessages,
} from "./giveaway.interface";
export { GiveawaysClient } from "./giveaway";
export {
GiveawaySchema,
GiveawaysClientOptions,
DefaultGiveawayMessages,
} from "./giveaway.interface";

View file

@ -1,67 +1,67 @@
import { config } from "../";
/**
* @name ImageClient
* @kind constructor
*/
export class ImageClient {
constructor() {}
private endpoint(end: string, ava: string, ava1?: string, ava2?: string) {
if (ava && ava1 && !ava2)
return `${config.api}/api/v1/image/${end}?image=${ava}&image2=${ava1}`;
else if (ava && ava1 && ava2)
return `${config.api}/api/v1/image/${end}?image=${ava}&image2=${ava1}&image3=${ava2}`;
else return `${config.api}/api/v1/image/${end}?image=${ava}`;
}
public busted(AvatarURL: string) {
return this.endpoint("busted", AvatarURL);
}
public communism(AvatarURL: string) {
return this.endpoint("communism", AvatarURL);
}
public gun(AvatarURL: string) {
return this.endpoint("gun", AvatarURL);
}
public mask(AvatarURL: string) {
return this.endpoint("mask", AvatarURL);
}
public whodidthis(AvatarURL: string) {
return this.endpoint("whodidthis", AvatarURL);
}
public pray(AvatarURL: string) {
return this.endpoint("pray", AvatarURL);
}
public pressplay(AvatarURL: string) {
return this.endpoint("pressplay", AvatarURL);
}
public vr(AvatarURL: string) {
return this.endpoint("vr", AvatarURL);
}
public rifleshoot(AvatarURL: string) {
return this.endpoint("rifleshoot", AvatarURL);
}
public bestmeme(AvatarURL: string) {
return this.endpoint("bestmeme", AvatarURL);
}
public robert(AvatarURL: string) {
return this.endpoint("robert", AvatarURL);
}
public saveonlyone(
AvatarURL1: string,
AvatarURL2: string,
AvatarURL3: string
) {
return this.endpoint("saveonlyone", AvatarURL1, AvatarURL2, AvatarURL3);
}
public alone(AvatarURL: string) {
return this.endpoint("alone", AvatarURL);
}
public toilet(AvatarURL: string) {
return this.endpoint("toilet", AvatarURL);
}
public moment(AvatarURL: string) {
return this.endpoint("moment", AvatarURL);
}
public awesome(AvatarURL: string) {
return this.endpoint("awesome", AvatarURL);
}
}
import { config } from "../";
/**
* @name ImageClient
* @kind constructor
*/
export class ImageClient {
constructor() {}
private endpoint(end: string, ava: string, ava1?: string, ava2?: string) {
if (ava && ava1 && !ava2)
return `${config.api}/api/v1/image/${end}?image=${ava}&image2=${ava1}`;
else if (ava && ava1 && ava2)
return `${config.api}/api/v1/image/${end}?image=${ava}&image2=${ava1}&image3=${ava2}`;
else return `${config.api}/api/v1/image/${end}?image=${ava}`;
}
public busted(AvatarURL: string) {
return this.endpoint("busted", AvatarURL);
}
public communism(AvatarURL: string) {
return this.endpoint("communism", AvatarURL);
}
public gun(AvatarURL: string) {
return this.endpoint("gun", AvatarURL);
}
public mask(AvatarURL: string) {
return this.endpoint("mask", AvatarURL);
}
public whodidthis(AvatarURL: string) {
return this.endpoint("whodidthis", AvatarURL);
}
public pray(AvatarURL: string) {
return this.endpoint("pray", AvatarURL);
}
public pressplay(AvatarURL: string) {
return this.endpoint("pressplay", AvatarURL);
}
public vr(AvatarURL: string) {
return this.endpoint("vr", AvatarURL);
}
public rifleshoot(AvatarURL: string) {
return this.endpoint("rifleshoot", AvatarURL);
}
public bestmeme(AvatarURL: string) {
return this.endpoint("bestmeme", AvatarURL);
}
public robert(AvatarURL: string) {
return this.endpoint("robert", AvatarURL);
}
public saveonlyone(
AvatarURL1: string,
AvatarURL2: string,
AvatarURL3: string
) {
return this.endpoint("saveonlyone", AvatarURL1, AvatarURL2, AvatarURL3);
}
public alone(AvatarURL: string) {
return this.endpoint("alone", AvatarURL);
}
public toilet(AvatarURL: string) {
return this.endpoint("toilet", AvatarURL);
}
public moment(AvatarURL: string) {
return this.endpoint("moment", AvatarURL);
}
public awesome(AvatarURL: string) {
return this.endpoint("awesome", AvatarURL);
}
}

View file

@ -1 +1 @@
export { ImageClient } from "./image";
export { ImageClient } from "./image";

View file

@ -1,2 +1,2 @@
export { URLClient } from "./urlclient";
export { URLData } from "./urlclient.interface";
export { URLClient } from "./urlclient";
export { URLData } from "./urlclient.interface";

View file

@ -1,3 +1,3 @@
export interface URLData {
url: String;
}
export interface URLData {
url: String;
}

View file

@ -1,33 +1,33 @@
import axios from "axios";
import { config } from "../";
import { URLData } from "./urlclient.interface";
import { CathError } from "../Error/CathError";
/**
* @name URLClient
* @kind constructor
*/
export class URLClient {
constructor() {}
/**
* Sends the link of the URL
* @return {Promise<URLData>}
* @param {String} shortName
* @param {String} targetURL
*/
public async createShortURL(
shortName: string,
targetURL: string
): Promise<URLData> {
if (!shortName) throw new CathError("Missing 'shortName' property");
if (!targetURL) throw new CathError("Missing 'targetURL' property");
const data = await axios
.post(`${config.url}`, {
shortUrl: shortName,
fullUrl: targetURL,
})
.then(res => res.data);
if (data?.name) {
return data?.name;
}
}
}
import axios from "axios";
import { config } from "../";
import { URLData } from "./urlclient.interface";
import { CathError } from "../Error/CathError";
/**
* @name URLClient
* @kind constructor
*/
export class URLClient {
constructor() {}
/**
* Sends the link of the URL
* @return {Promise<URLData>}
* @param {String} shortName
* @param {String} targetURL
*/
public async createShortURL(
shortName: string,
targetURL: string
): Promise<URLData> {
if (!shortName) throw new CathError("Missing 'shortName' property");
if (!targetURL) throw new CathError("Missing 'targetURL' property");
const data = await axios
.post(`${config.url}`, {
shortUrl: shortName,
fullUrl: targetURL,
})
.then(res => res.data);
if (data?.name) {
return data?.name;
}
}
}

View file

@ -1,11 +1,11 @@
import axios from "axios";
import { config } from "../";
/**
* Sends a 8ball response
*/
export async function random8ball(): Promise<string> {
const data = await axios
.get(`${config.api}/api/v1/fun/8ball`)
.then(res => res.data);
return data.answer;
}
import axios from "axios";
import { config } from "../";
/**
* Sends a 8ball response
*/
export async function random8ball(): Promise<string> {
const data = await axios
.get(`${config.api}/api/v1/fun/8ball`)
.then(res => res.data);
return data.answer;
}

View file

@ -1,21 +1,21 @@
import { CathError } from "../Error/CathError";
/**
* Returns a string(00:00:00)
*/
export function HHMMSS(str: string) {
if (!str) throw new CathError("Missing 'str'");
var sec_num = parseInt(str, 10);
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - hours * 3600) / 60);
var seconds = sec_num - hours * 3600 - minutes * 60;
if (hours < 10) {
hours = 0 + hours;
}
if (minutes < 10) {
minutes = 0 + minutes;
}
if (seconds < 10) {
seconds = 0 + seconds;
}
return hours + ":" + minutes + ":" + seconds;
}
import { CathError } from "../Error/CathError";
/**
* Returns a string(00:00:00)
*/
export function HHMMSS(str: string) {
if (!str) throw new CathError("Missing 'str'");
var sec_num = parseInt(str, 10);
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - hours * 3600) / 60);
var seconds = sec_num - hours * 3600 - minutes * 60;
if (hours < 10) {
hours = 0 + hours;
}
if (minutes < 10) {
minutes = 0 + minutes;
}
if (seconds < 10) {
seconds = 0 + seconds;
}
return hours + ":" + minutes + ":" + seconds;
}

View file

@ -1,8 +1,8 @@
/**
* Returns true/false
*/
export function bool() {
const arr = [true, false];
const num = arr[Math.floor(Math.random() * arr.length)];
return num;
}
/**
* Returns true/false
*/
export function bool() {
const arr = [true, false];
const num = arr[Math.floor(Math.random() * arr.length)];
return num;
}

View file

@ -1,12 +1,12 @@
/**
* Returns a string without " ` " or " @ "
*/
export function cleanText(text: string): string {
if (typeof text === "string") {
return text
.replace(/`/g, "`" + String.fromCharCode(8203))
.replace(/@/g, "@" + String.fromCharCode(8203));
} else {
return text;
}
}
/**
* Returns a string without " ` " or " @ "
*/
export function cleanText(text: string): string {
if (typeof text === "string") {
return text
.replace(/`/g, "`" + String.fromCharCode(8203))
.replace(/@/g, "@" + String.fromCharCode(8203));
} else {
return text;
}
}

View file

@ -1,19 +1,19 @@
import { Message } from "discord.js";
export async function confirmation(
message: Message,
author,
validReactions = [],
time = 60000
) {
try {
for (const reaction of validReactions) await message.react(reaction);
const filter = (reaction, user) =>
validReactions.includes(reaction.emoji.name) && user.id === author.id;
return message
.awaitReactions({ filter, max: 1, time: time })
.then(collected => collected.first() && collected.first().emoji.name);
} catch (e) {
console.log(e);
}
}
import { Message } from "discord.js";
export async function confirmation(
message: Message,
author,
validReactions = [],
time = 60000
) {
try {
for (const reaction of validReactions) await message.react(reaction);
const filter = (reaction, user) =>
validReactions.includes(reaction.emoji.name) && user.id === author.id;
return message
.awaitReactions({ filter, max: 1, time: time })
.then(collected => collected.first() && collected.first().emoji.name);
} catch (e) {
console.log(e);
}
}

View file

@ -1,9 +1,9 @@
import { CathError } from "../Error/CathError";
export function daysAgo(date: Date) {
if (!date) throw new CathError("Missing 'date'");
let now = new Date();
let diff = now.getTime() - date.getTime();
let days = Math.floor(diff / 86400000);
return days + (days == 1 ? " day" : " days") + " ago";
}
import { CathError } from "../Error/CathError";
export function daysAgo(date: Date) {
if (!date) throw new CathError("Missing 'date'");
let now = new Date();
let diff = now.getTime() - date.getTime();
let days = Math.floor(diff / 86400000);
return days + (days == 1 ? " day" : " days") + " ago";
}

View file

@ -1,80 +1,80 @@
import { CathError } from "../Error/CathError";
import axios from "axios";
/**
* Start a Discord Activity session
* @example
* const Cath = require("cath")
* const client = new Client()
* const d = await Cath.DiscordActivity({
application: "youtube",
channel_id: "901542111005012099",
token: client.token,
});
message.channel.send({ content: d });
*/
export async function DiscordActivity(options: DiscordActivityOptions) {
const all = {
youtube: "880218394199220334",
youtubedev: "880218832743055411",
poker: "755827207812677713",
betrayal: "773336526917861400",
fishing: "814288819477020702",
chess: "832012774040141894",
chessdev: "832012586023256104",
lettertile: "879863686565621790",
wordsnack: "879863976006127627",
doodlecrew: "878067389634314250",
awkword: "879863881349087252",
spellcast: "852509694341283871",
};
if (!all[options.application]) {
throw new CathError(
"Application ID is not valid, if you want to see the list of applications, check the docs at https://cath.js.org/interfaces/Applications.html"
);
}
if (!options.token) {
throw new CathError("Missing 'token'");
}
if (!options.channel_id) {
throw new CathError("Missing 'Channel ID'");
}
const data = await axios
.post(
`https://discord.com/api/v9/channels/${options.channel_id}/invites`,
{
max_age: 86400,
max_uses: 0,
target_application_id: all[options.application],
target_type: 2,
temporary: false,
validate: null,
},
{
headers: {
Authorization: `Bot ${options.token}`,
"Content-Type": "application/json",
},
}
)
.then(res => res.data);
return `https://discord.com/invite/${data.code}`;
}
export interface DiscordActivityOptions {
application: string;
token: string;
channel_id: string;
}
export interface Applications {
youtube: "880218394199220334";
youtubedev: "880218832743055411";
poker: "755827207812677713";
betrayal: "773336526917861400";
fishing: "814288819477020702";
chess: "832012774040141894";
chessdev: "832012586023256104";
lettertile: "879863686565621790";
wordsnack: "879863976006127627";
doodlecrew: "878067389634314250";
awkword: "879863881349087252";
spellcast: "852509694341283871";
}
import { CathError } from "../Error/CathError";
import axios from "axios";
/**
* Start a Discord Activity session
* @example
* const Cath = require("cath")
* const client = new Client()
* const d = await Cath.DiscordActivity({
application: "youtube",
channel_id: "901542111005012099",
token: client.token,
});
message.channel.send({ content: d });
*/
export async function DiscordActivity(options: DiscordActivityOptions) {
const all = {
youtube: "880218394199220334",
youtubedev: "880218832743055411",
poker: "755827207812677713",
betrayal: "773336526917861400",
fishing: "814288819477020702",
chess: "832012774040141894",
chessdev: "832012586023256104",
lettertile: "879863686565621790",
wordsnack: "879863976006127627",
doodlecrew: "878067389634314250",
awkword: "879863881349087252",
spellcast: "852509694341283871",
};
if (!all[options.application]) {
throw new CathError(
"Application ID is not valid, if you want to see the list of applications, check the docs at https://cath.js.org/interfaces/Applications.html"
);
}
if (!options.token) {
throw new CathError("Missing 'token'");
}
if (!options.channel_id) {
throw new CathError("Missing 'Channel ID'");
}
const data = await axios
.post(
`https://discord.com/api/v9/channels/${options.channel_id}/invites`,
{
max_age: 86400,
max_uses: 0,
target_application_id: all[options.application],
target_type: 2,
temporary: false,
validate: null,
},
{
headers: {
Authorization: `Bot ${options.token}`,
"Content-Type": "application/json",
},
}
)
.then(res => res.data);
return `https://discord.com/invite/${data.code}`;
}
export interface DiscordActivityOptions {
application: string;
token: string;
channel_id: string;
}
export interface Applications {
youtube: "880218394199220334";
youtubedev: "880218832743055411";
poker: "755827207812677713";
betrayal: "773336526917861400";
fishing: "814288819477020702";
chess: "832012774040141894";
chessdev: "832012586023256104";
lettertile: "879863686565621790";
wordsnack: "879863976006127627";
doodlecrew: "878067389634314250";
awkword: "879863881349087252";
spellcast: "852509694341283871";
}

View file

@ -1,16 +1,16 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
/**
* Dobulestruck words
*/
export async function doublestruck(word: string): Promise<string> {
if (!word) {
throw new CathError("Missing 'word'");
}
const data = await axios
.get(`${config.api}/api/v1/fun/doublestruck?text=${word}`)
.then(res => res.data);
console.log(data);
return data.text;
}
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
/**
* Dobulestruck words
*/
export async function doublestruck(word: string): Promise<string> {
if (!word) {
throw new CathError("Missing 'word'");
}
const data = await axios
.get(`${config.api}/api/v1/fun/doublestruck?text=${word}`)
.then(res => res.data);
console.log(data);
return data.text;
}

View file

@ -1,34 +1,34 @@
/**
* Emoji-ify a string
*/
export function emojify(str: string): string {
const s = {
0: ":zero:",
1: ":one:",
2: ":two:",
3: ":three:",
4: ":four:",
5: ":five:",
6: ":six:",
7: ":seven:",
8: ":eight:",
9: ":nine:",
"#": ":hash:",
"*": ":asterisk:",
"!": ":grey_exclamation:",
"?": ":grey_question:",
" ": " ",
};
let ar = str
.toLowerCase()
.split("")
.map(l => {
if (/[a-z]/g.test(l)) {
return `:regional_indicator_${l}:`;
} else if (s[l]) {
return `${s[l]}`;
}
})
.join("");
return ar;
}
/**
* Emoji-ify a string
*/
export function emojify(str: string): string {
const s = {
0: ":zero:",
1: ":one:",
2: ":two:",
3: ":three:",
4: ":four:",
5: ":five:",
6: ":six:",
7: ":seven:",
8: ":eight:",
9: ":nine:",
"#": ":hash:",
"*": ":asterisk:",
"!": ":grey_exclamation:",
"?": ":grey_question:",
" ": " ",
};
let ar = str
.toLowerCase()
.split("")
.map(l => {
if (/[a-z]/g.test(l)) {
return `:regional_indicator_${l}:`;
} else if (s[l]) {
return `${s[l]}`;
}
})
.join("");
return ar;
}

View file

@ -1,9 +1,9 @@
import { CathError } from "../Error/CathError";
/**
* Edit the first letter of the string to uppercase
*/
export function formatUpper(str: string) {
if (!str) throw new CathError("Missing 'str'");
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}
import { CathError } from "../Error/CathError";
/**
* Edit the first letter of the string to uppercase
*/
export function formatUpper(str: string) {
if (!str) throw new CathError("Missing 'str'");
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}

View file

@ -1,16 +1,16 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
/**
* Sends a 8ball response
*/
export async function fractur(word: string): Promise<string> {
if (!word) {
throw new CathError("Missing 'word'");
}
const data = await axios
.get(`${config.api}/api/v1/fun/fractur?text=${word}`)
.then(res => res.data);
console.log(data);
return data.text;
}
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
/**
* Sends a 8ball response
*/
export async function fractur(word: string): Promise<string> {
if (!word) {
throw new CathError("Missing 'word'");
}
const data = await axios
.get(`${config.api}/api/v1/fun/fractur?text=${word}`)
.then(res => res.data);
console.log(data);
return data.text;
}

View file

@ -1,35 +1,35 @@
/**
* Generate a random password
* @param length The length of the password
* @param options The options for the password
*/
export function generatePassword(
length: number,
options: GeneratePasswordOptions
) {
const upper = options.upper || false;
const lower = options.lower || false;
const numbers = options.numbers || false;
const special = options.special || false;
const upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowerChars = "abcdefghijklmnopqrstuvwxyz";
const numberChars = "0123456789";
const specialChars = "!@#$%^&*()_+-=[]{}|;':\",./<>?";
let password = "";
let chars = "";
if (upper) chars += upperChars;
if (lower) chars += lowerChars;
if (numbers) chars += numberChars;
if (special) chars += specialChars;
for (let i = 0; i < length; i++) {
password += chars.charAt(Math.floor(Math.random() * chars.length));
}
return password;
}
export interface GeneratePasswordOptions {
upper: boolean;
lower: boolean;
numbers: boolean;
special: boolean;
}
/**
* Generate a random password
* @param length The length of the password
* @param options The options for the password
*/
export function generatePassword(
length: number,
options: GeneratePasswordOptions
) {
const upper = options.upper || false;
const lower = options.lower || false;
const numbers = options.numbers || false;
const special = options.special || false;
const upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowerChars = "abcdefghijklmnopqrstuvwxyz";
const numberChars = "0123456789";
const specialChars = "!@#$%^&*()_+-=[]{}|;':\",./<>?";
let password = "";
let chars = "";
if (upper) chars += upperChars;
if (lower) chars += lowerChars;
if (numbers) chars += numberChars;
if (special) chars += specialChars;
for (let i = 0; i < length; i++) {
password += chars.charAt(Math.floor(Math.random() * chars.length));
}
return password;
}
export interface GeneratePasswordOptions {
upper: boolean;
lower: boolean;
numbers: boolean;
special: boolean;
}

View file

@ -1,15 +1,15 @@
const axios = require("axios");
/**
* @name getLilaseDownloads
* @description Get the number of downloads
*/
export async function getLilaseDownloads(): Promise<number> {
const { data } = await axios.get(
"https://api.github.com/repos/night0721/Lilase/releases"
);
let sum = 0;
data.forEach(release => {
sum += release.assets[0].download_count;
});
return sum;
}
const axios = require("axios");
/**
* @name getLilaseDownloads
* @description Get the number of downloads
*/
export async function getLilaseDownloads(): Promise<number> {
const { data } = await axios.get(
"https://api.github.com/repos/night0721/Lilase/releases"
);
let sum = 0;
data.forEach(release => {
sum += release.assets[0].download_count;
});
return sum;
}

View file

@ -1,138 +1,138 @@
import { CathError } from "../Error/CathError";
var s = 1000;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var mn = d * 30;
var w = d * 7;
var y = d * 365.25;
export function parseString(val: string) {
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse(val);
}
throw new CathError("Missing 'val' or type of 'val' isn't a string");
}
export function parseMS(val: number, options?: msOptions) {
options = options || {};
if (isFinite(val)) {
return options?.long ? fmtLong(val) : fmtShort(val);
}
throw new CathError("Missing 'val' or type of 'val' isn't a number");
}
function parse(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match =
/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mths|mn|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
return;
}
var n = parseFloat(match[1]);
var type = (match[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n * y;
case "month":
case "months":
case "mth":
case "mths":
return n * mn;
case "weeks":
case "week":
case "w":
return n * w;
case "days":
case "day":
case "d":
return n * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n;
default:
return undefined;
}
}
function fmtShort(ms: number): string {
var msAbs = Math.abs(ms);
if (msAbs >= mn) {
return Math.round(ms / mn) + "mo";
}
if (msAbs >= w) {
return Math.round(ms / w) + "w";
}
if (msAbs >= d) {
return Math.round(ms / d) + "d";
}
if (msAbs >= h) {
return Math.round(ms / h) + "h";
}
if (msAbs >= m) {
return Math.round(ms / m) + "m";
}
if (msAbs >= s) {
return Math.round(ms / s) + "s";
}
return ms + "ms";
}
function fmtLong(ms: number) {
var msAbs = Math.abs(ms);
if (msAbs >= mn) {
return plural(ms, msAbs, mn, "month");
}
if (msAbs >= w) {
return plural(ms, msAbs, w, "week");
}
if (msAbs >= d) {
return plural(ms, msAbs, d, "day");
}
if (msAbs >= h) {
return plural(ms, msAbs, h, "hour");
}
if (msAbs >= m) {
return plural(ms, msAbs, m, "minute");
}
if (msAbs >= s) {
return plural(ms, msAbs, s, "second");
}
return ms + " ms";
}
function plural(ms: number, msAbs: number, n: number, name: string) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
}
export interface msOptions {
long?: boolean;
short?: boolean;
}
import { CathError } from "../Error/CathError";
var s = 1000;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var mn = d * 30;
var w = d * 7;
var y = d * 365.25;
export function parseString(val: string) {
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse(val);
}
throw new CathError("Missing 'val' or type of 'val' isn't a string");
}
export function parseMS(val: number, options?: msOptions) {
options = options || {};
if (isFinite(val)) {
return options?.long ? fmtLong(val) : fmtShort(val);
}
throw new CathError("Missing 'val' or type of 'val' isn't a number");
}
function parse(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match =
/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mths|mn|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
return;
}
var n = parseFloat(match[1]);
var type = (match[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n * y;
case "month":
case "months":
case "mth":
case "mths":
return n * mn;
case "weeks":
case "week":
case "w":
return n * w;
case "days":
case "day":
case "d":
return n * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n;
default:
return undefined;
}
}
function fmtShort(ms: number): string {
var msAbs = Math.abs(ms);
if (msAbs >= mn) {
return Math.round(ms / mn) + "mo";
}
if (msAbs >= w) {
return Math.round(ms / w) + "w";
}
if (msAbs >= d) {
return Math.round(ms / d) + "d";
}
if (msAbs >= h) {
return Math.round(ms / h) + "h";
}
if (msAbs >= m) {
return Math.round(ms / m) + "m";
}
if (msAbs >= s) {
return Math.round(ms / s) + "s";
}
return ms + "ms";
}
function fmtLong(ms: number) {
var msAbs = Math.abs(ms);
if (msAbs >= mn) {
return plural(ms, msAbs, mn, "month");
}
if (msAbs >= w) {
return plural(ms, msAbs, w, "week");
}
if (msAbs >= d) {
return plural(ms, msAbs, d, "day");
}
if (msAbs >= h) {
return plural(ms, msAbs, h, "hour");
}
if (msAbs >= m) {
return plural(ms, msAbs, m, "minute");
}
if (msAbs >= s) {
return plural(ms, msAbs, s, "second");
}
return ms + " ms";
}
function plural(ms: number, msAbs: number, n: number, name: string) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
}
export interface msOptions {
long?: boolean;
short?: boolean;
}

View file

@ -1,42 +1,42 @@
/**
* Obama!
*/
export function obama() {
const o = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠛⠛⠛⠉⠉⠉⠋⠛⠛⠛⠻⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const b = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠛⠉⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠉⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const a = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const m = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠏⠄⠄⠄⠄⠄⠄⠄⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠹⣿⣿⣿⣿⣿⣿⣿";
const a2 = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⢻⣿⣿⣿⣿⣿";
const aa = "⣿⣿⣿⣿⣿⣿⣿⣿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠄⢠⠄⠄⡀⠄⠄⢀⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⡁⠄⠄⢛⣿⣿⣿⣿";
const ab = "⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠐⡈⢔⠸⣐⢕⢕⢵⢰⢱⢰⢐⢤⡡⡢⣕⢄⢢⢠⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿";
const ac = "⣿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡁⠂⠅⢕⠌⡎⡎⣎⢎⢮⢮⣳⡳⣝⢮⢺⢜⢕⢕⢍⢎⠪⡐⠄⠁⠄⠸⣿⣿";
const ad = "⣿⣿⣿⣿⣿⣿⠏⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠐⠄⠄⢅⠣⡡⡣⣣⡳⡵⣝⡮⣗⣗⡯⣗⣟⡮⡮⣳⣣⣳⢱⢱⠱⣐⠄⠂⠄⢿⣿";
const ae = "⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠂⠄⠄⠄⠄⠄⠄⢂⢈⠢⡱⡱⡝⣮⣿⣟⣿⣽⣷⣿⣯⣿⣷⣿⣿⣿⣾⣯⣗⡕⡇⡇⠄⠂⡀⢹⣿";
const af = "⣿⣿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠂⠄⠄⠄⠄⠄⠄⠐⢀⢂⢕⢸⢨⢪⢳⡫⣟⣿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡺⡮⡣⡣⠠⢂⠒⢸⣿";
const ag = "⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠐⠄⡂⠆⡇⣗⣝⢮⢾⣻⣞⣿⣿⣿⣿⣿⣿⣿⣿⢿⣽⣯⡯⣺⢸⢘⠨⠔⡅⢨⣿";
const ah = "⣿⣿⠋⠉⠙⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠄⡂⡪⡪⡪⡮⡮⡯⣻⣽⣾⣿⣿⣿⣟⣿⣿⣿⣽⣿⣿⡯⣯⡺⡸⡰⡱⢐⡅⣼⣿";
const ai = "⣿⠡⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠈⠆⠱⠑⠝⠜⠕⡝⡝⣞⢯⢿⣿⣿⡿⣟⣿⣿⣿⡿⡿⣽⣷⣽⡸⡨⡪⣂⠊⣿⣿";
const aj = "⣿⠡⠄⡨⣢⠐⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠐⠍⡓⣗⡽⣝⠽⠍⠅⠑⠁⠉⠘⠘⠘⠵⡑⢜⢀⢀⢉⢽";
const ak = "⣿⠁⠠⢱⢘⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠈⠱⣁⠜⡘⠌⠄⠄⡪⣳⣟⡮⢅⠤⠠⠄⠄⣀⣀⡀⡀⠄⠈⡂⢲⡪⡠⣿";
const al = "⣿⡇⠨⣺⢐⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡀⠄⠄⠄⠤⡠⡢⢒⠦⠠⠄⠄⠄⡸⢽⣟⢮⠢⡂⡐⠄⡈⡀⠤⡀⠄⠑⢄⠨⢸⡺⣐⣿";
const am = "⣿⣿⠈⠕⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡂⡪⡐⡥⢤⣰⣰⣰⡴⡮⠢⠂⠄⠄⡊⢮⢺⢕⢵⢥⡬⣌⣒⡚⣔⢚⢌⢨⢚⠌⣾⡪⣾⣿";
const an = "⣿⣿⣆⠄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡑⢕⢕⡯⡷⣕⢧⢓⢭⠨⡀⠄⡂⠨⡨⣪⡳⣝⢝⡽⣻⣻⣞⢽⣲⢳⢱⢡⠱⠨⣟⢺⣿⣿";
const ao = "⣿⣿⣿⡆⠄⡅⠇⡄⠄⠄⠄⠄⠄⠄⠄⠐⠨⢪⢹⢽⢽⣺⢝⠉⠁⠁⠄⠄⠄⢌⢎⡖⡯⡎⡗⢝⠜⣶⣯⣻⢮⡻⣟⣳⡕⠅⣷⣿⣿⣿";
const ap = "⣿⣿⣿⣿⣶⣶⣿⣷⠄⠄⠄⠄⠄⠄⠄⠄⠈⠔⡑⠕⠝⠄⡀⠄⠄⠊⢆⠂⠨⡪⣺⣮⣿⡾⡜⣜⡜⣄⠙⢞⣿⢿⡿⣗⢝⢸⣾⣿⣿⣿";
const aq = "⣿⣿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⡀⠄⠄⠄⠄⢀⠄⠠⠄⠠⠄⠄⠄⠄⠄⠄⠊⠺⡹⠳⡙⡜⡓⡭⡺⡀⠄⠣⡻⡹⡸⠨⣣⣿⣿⣿⣿";
const ar = "⣿⣿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠠⠄⠄⣂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢄⠤⡤⡄⡆⡯⡢⡣⡣⡓⢕⠽⣄⠄⠨⡂⢌⣼⣿⣿⣿⣿⣿";
const a_ = "⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠈⠆⠄⠸⡂⠄⠄⠄⢀⠄⢀⠈⠄⠂⠁⠙⠝⠼⠭⠣⠣⠣⠑⠌⠢⠣⡣⡠⡘⣰⣱⣿⣿⣿⣿⣿⣿";
const at = "⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⢑⠄⠈⡱⠄⢘⠄⡀⠨⢐⣧⣳⣷⣶⣦⣤⣴⣶⣶⣶⡶⠄⡠⡢⡕⣜⠎⡮⣣⣿⣿⣿⣿⣿⣿⣿";
const au = "⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠢⠄⠨⠄⠄⠣⡀⠄⢀⢀⢙⠃⡿⢿⠿⡿⡿⢟⢋⢔⡱⣝⢜⡜⡪⡪⣵⣿⣿⣿⣿⣿⣿⣿⣿";
const av = "⣿⣿⣿⣿⣿⣿⣿⣿⡁⠄⠄⠄⠄⠄⠄⠄⠅⠄⠡⠄⠄⠡⢀⢂⠢⡡⠡⠣⡑⣏⢯⡻⡳⣹⡺⡪⢎⠎⡆⢣⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const aw = "⣿⣿⣿⣿⣿⣿⣿⣿⣇⠄⠄⠄⠄⠄⠄⠄⠐⠄⠄⠁⠄⢈⠄⢂⠕⡕⡝⢕⢎⢎⢮⢎⢯⢺⢸⢬⠣⢃⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const ax = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠨⡐⠌⢆⢇⢧⢭⣣⡳⣵⢫⣳⢱⠱⢑⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const ay = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠁⡊⢌⢢⢡⢣⢪⡺⡪⡎⡎⡎⡚⣨⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const az = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠕⡅⢗⢕⡳⡭⣳⢕⠕⡱⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const ba = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠌⠄⠑⠩⢈⢂⣱⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const bb = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡀⢄⠄⣀⠄⡀⣀⢠⢄⣖⣖⣞⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const bc = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣱⡐⡕⡕⡽⣝⣟⣮⣾⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
console.log(
`${o}\n${b}\n${a}\n${m}\n${a2}\n${aa}\n${ab}\n${ac}\n${ad}\n${ae}\n${af}\n${ag}\n${ah}\n${ai}\n${aj}\n${ak}\n${al}\n${am}\n${an}\n${ao}\n${ap}\n${aq}\n${ar}\n${a_}\n${at}\n${au}\n${av}\n${aw}\n${ax}\n${ay}\n${az}\n${ba}\n${bb}\n${bc}`
);
}
/**
* Obama!
*/
export function obama() {
const o = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠛⠛⠛⠉⠉⠉⠋⠛⠛⠛⠻⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const b = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠛⠉⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠉⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const a = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const m = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠏⠄⠄⠄⠄⠄⠄⠄⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠹⣿⣿⣿⣿⣿⣿⣿";
const a2 = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⢻⣿⣿⣿⣿⣿";
const aa = "⣿⣿⣿⣿⣿⣿⣿⣿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠄⢠⠄⠄⡀⠄⠄⢀⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⡁⠄⠄⢛⣿⣿⣿⣿";
const ab = "⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠐⡈⢔⠸⣐⢕⢕⢵⢰⢱⢰⢐⢤⡡⡢⣕⢄⢢⢠⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿";
const ac = "⣿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡁⠂⠅⢕⠌⡎⡎⣎⢎⢮⢮⣳⡳⣝⢮⢺⢜⢕⢕⢍⢎⠪⡐⠄⠁⠄⠸⣿⣿";
const ad = "⣿⣿⣿⣿⣿⣿⠏⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠐⠄⠄⢅⠣⡡⡣⣣⡳⡵⣝⡮⣗⣗⡯⣗⣟⡮⡮⣳⣣⣳⢱⢱⠱⣐⠄⠂⠄⢿⣿";
const ae = "⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠂⠄⠄⠄⠄⠄⠄⢂⢈⠢⡱⡱⡝⣮⣿⣟⣿⣽⣷⣿⣯⣿⣷⣿⣿⣿⣾⣯⣗⡕⡇⡇⠄⠂⡀⢹⣿";
const af = "⣿⣿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠂⠄⠄⠄⠄⠄⠄⠐⢀⢂⢕⢸⢨⢪⢳⡫⣟⣿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡺⡮⡣⡣⠠⢂⠒⢸⣿";
const ag = "⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠐⠄⡂⠆⡇⣗⣝⢮⢾⣻⣞⣿⣿⣿⣿⣿⣿⣿⣿⢿⣽⣯⡯⣺⢸⢘⠨⠔⡅⢨⣿";
const ah = "⣿⣿⠋⠉⠙⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠄⡂⡪⡪⡪⡮⡮⡯⣻⣽⣾⣿⣿⣿⣟⣿⣿⣿⣽⣿⣿⡯⣯⡺⡸⡰⡱⢐⡅⣼⣿";
const ai = "⣿⠡⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠈⠆⠱⠑⠝⠜⠕⡝⡝⣞⢯⢿⣿⣿⡿⣟⣿⣿⣿⡿⡿⣽⣷⣽⡸⡨⡪⣂⠊⣿⣿";
const aj = "⣿⠡⠄⡨⣢⠐⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠐⠍⡓⣗⡽⣝⠽⠍⠅⠑⠁⠉⠘⠘⠘⠵⡑⢜⢀⢀⢉⢽";
const ak = "⣿⠁⠠⢱⢘⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠈⠱⣁⠜⡘⠌⠄⠄⡪⣳⣟⡮⢅⠤⠠⠄⠄⣀⣀⡀⡀⠄⠈⡂⢲⡪⡠⣿";
const al = "⣿⡇⠨⣺⢐⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡀⠄⠄⠄⠤⡠⡢⢒⠦⠠⠄⠄⠄⡸⢽⣟⢮⠢⡂⡐⠄⡈⡀⠤⡀⠄⠑⢄⠨⢸⡺⣐⣿";
const am = "⣿⣿⠈⠕⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡂⡪⡐⡥⢤⣰⣰⣰⡴⡮⠢⠂⠄⠄⡊⢮⢺⢕⢵⢥⡬⣌⣒⡚⣔⢚⢌⢨⢚⠌⣾⡪⣾⣿";
const an = "⣿⣿⣆⠄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡑⢕⢕⡯⡷⣕⢧⢓⢭⠨⡀⠄⡂⠨⡨⣪⡳⣝⢝⡽⣻⣻⣞⢽⣲⢳⢱⢡⠱⠨⣟⢺⣿⣿";
const ao = "⣿⣿⣿⡆⠄⡅⠇⡄⠄⠄⠄⠄⠄⠄⠄⠐⠨⢪⢹⢽⢽⣺⢝⠉⠁⠁⠄⠄⠄⢌⢎⡖⡯⡎⡗⢝⠜⣶⣯⣻⢮⡻⣟⣳⡕⠅⣷⣿⣿⣿";
const ap = "⣿⣿⣿⣿⣶⣶⣿⣷⠄⠄⠄⠄⠄⠄⠄⠄⠈⠔⡑⠕⠝⠄⡀⠄⠄⠊⢆⠂⠨⡪⣺⣮⣿⡾⡜⣜⡜⣄⠙⢞⣿⢿⡿⣗⢝⢸⣾⣿⣿⣿";
const aq = "⣿⣿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⡀⠄⠄⠄⠄⢀⠄⠠⠄⠠⠄⠄⠄⠄⠄⠄⠊⠺⡹⠳⡙⡜⡓⡭⡺⡀⠄⠣⡻⡹⡸⠨⣣⣿⣿⣿⣿";
const ar = "⣿⣿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠠⠄⠄⣂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢄⠤⡤⡄⡆⡯⡢⡣⡣⡓⢕⠽⣄⠄⠨⡂⢌⣼⣿⣿⣿⣿⣿";
const a_ = "⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠈⠆⠄⠸⡂⠄⠄⠄⢀⠄⢀⠈⠄⠂⠁⠙⠝⠼⠭⠣⠣⠣⠑⠌⠢⠣⡣⡠⡘⣰⣱⣿⣿⣿⣿⣿⣿";
const at = "⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⢑⠄⠈⡱⠄⢘⠄⡀⠨⢐⣧⣳⣷⣶⣦⣤⣴⣶⣶⣶⡶⠄⡠⡢⡕⣜⠎⡮⣣⣿⣿⣿⣿⣿⣿⣿";
const au = "⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠢⠄⠨⠄⠄⠣⡀⠄⢀⢀⢙⠃⡿⢿⠿⡿⡿⢟⢋⢔⡱⣝⢜⡜⡪⡪⣵⣿⣿⣿⣿⣿⣿⣿⣿";
const av = "⣿⣿⣿⣿⣿⣿⣿⣿⡁⠄⠄⠄⠄⠄⠄⠄⠅⠄⠡⠄⠄⠡⢀⢂⠢⡡⠡⠣⡑⣏⢯⡻⡳⣹⡺⡪⢎⠎⡆⢣⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const aw = "⣿⣿⣿⣿⣿⣿⣿⣿⣇⠄⠄⠄⠄⠄⠄⠄⠐⠄⠄⠁⠄⢈⠄⢂⠕⡕⡝⢕⢎⢎⢮⢎⢯⢺⢸⢬⠣⢃⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const ax = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠨⡐⠌⢆⢇⢧⢭⣣⡳⣵⢫⣳⢱⠱⢑⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const ay = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠁⡊⢌⢢⢡⢣⢪⡺⡪⡎⡎⡎⡚⣨⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const az = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠕⡅⢗⢕⡳⡭⣳⢕⠕⡱⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const ba = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠌⠄⠑⠩⢈⢂⣱⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const bb = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡀⢄⠄⣀⠄⡀⣀⢠⢄⣖⣖⣞⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
const bc = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣱⡐⡕⡕⡽⣝⣟⣮⣾⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿";
console.log(
`${o}\n${b}\n${a}\n${m}\n${a2}\n${aa}\n${ab}\n${ac}\n${ad}\n${ae}\n${af}\n${ag}\n${ah}\n${ai}\n${aj}\n${ak}\n${al}\n${am}\n${an}\n${ao}\n${ap}\n${aq}\n${ar}\n${a_}\n${at}\n${au}\n${av}\n${aw}\n${ax}\n${ay}\n${az}\n${ba}\n${bb}\n${bc}`
);
}

View file

@ -1,52 +1,52 @@
import { Message, MessageEmbed, User } from "discord.js";
export class Pagination {
constructor() {}
public chunk(arr, size: number) {
const temp = [];
for (let i = 0; i < arr.length; i += size) {
temp.push(arr.slice(i, i + size));
}
return temp;
}
paginationEmojis = ["◀", "⛔", "▶"];
public async pagination(
msg: Message,
author: User,
contents: MessageEmbed,
init = true,
currPage = 0
) {
if (init) for (const emoji of this.paginationEmojis) await msg.react(emoji);
const filter = (reaction, user) => {
return (
this.paginationEmojis.includes(reaction.emoji.name) &&
user.id === author.id
);
};
const collector = msg.createReactionCollector({
filter,
max: 1,
time: 90000,
});
collector
.on("collect", reaction => {
reaction.users.remove(author);
const emoji = reaction.emoji.name;
if (emoji === this.paginationEmojis[0]) currPage--;
if (emoji === this.paginationEmojis[1]) return collector.stop();
if (emoji === this.paginationEmojis[2]) currPage++;
currPage =
((currPage % contents.length) + contents.length) % contents.length;
const embed = msg.embeds[0]
.setDescription(contents[currPage])
.setFooter(`Page ${currPage + 1} of ${contents.length}`);
msg.edit({ embeds: [embed] });
this.pagination(msg, author, contents, false, currPage);
})
.on("end", (_, reason) => {
if (["time", "user"].includes(reason)) msg.reactions.removeAll();
});
}
}
import { Message, MessageEmbed, User } from "discord.js";
export class Pagination {
constructor() {}
public chunk(arr, size: number) {
const temp = [];
for (let i = 0; i < arr.length; i += size) {
temp.push(arr.slice(i, i + size));
}
return temp;
}
paginationEmojis = ["◀", "⛔", "▶"];
public async pagination(
msg: Message,
author: User,
contents: MessageEmbed,
init = true,
currPage = 0
) {
if (init) for (const emoji of this.paginationEmojis) await msg.react(emoji);
const filter = (reaction, user) => {
return (
this.paginationEmojis.includes(reaction.emoji.name) &&
user.id === author.id
);
};
const collector = msg.createReactionCollector({
filter,
max: 1,
time: 90000,
});
collector
.on("collect", reaction => {
reaction.users.remove(author);
const emoji = reaction.emoji.name;
if (emoji === this.paginationEmojis[0]) currPage--;
if (emoji === this.paginationEmojis[1]) return collector.stop();
if (emoji === this.paginationEmojis[2]) currPage++;
currPage =
((currPage % contents.length) + contents.length) % contents.length;
const embed = msg.embeds[0]
.setDescription(contents[currPage])
.setFooter(`Page ${currPage + 1} of ${contents.length}`);
msg.edit({ embeds: [embed] });
this.pagination(msg, author, contents, false, currPage);
})
.on("end", (_, reason) => {
if (["time", "user"].includes(reason)) msg.reactions.removeAll();
});
}
}

View file

@ -1,8 +1,8 @@
import { CathError } from "../Error/CathError";
/**
* Returns a random number in range
*/
export function randint(max: number, min: number) {
if (!max || !min) throw new CathError("Missing number");
return Math.floor(Math.random() * (max - (min ? min : 0))) + (min ? min : 0);
}
import { CathError } from "../Error/CathError";
/**
* Returns a random number in range
*/
export function randint(max: number, min: number) {
if (!max || !min) throw new CathError("Missing number");
return Math.floor(Math.random() * (max - (min ? min : 0))) + (min ? min : 0);
}

View file

@ -1,13 +1,13 @@
import { CathError } from "../Error/CathError";
/**
* Returns a random ID/String
*/
export function randomID(length: number) {
if (!length) throw new CathError("Missing 'length'");
var result = "";
var c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++) {
result += c.charAt(Math.floor(Math.random() * c.length));
}
return result;
}
import { CathError } from "../Error/CathError";
/**
* Returns a random ID/String
*/
export function randomID(length: number) {
if (!length) throw new CathError("Missing 'length'");
var result = "";
var c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++) {
result += c.charAt(Math.floor(Math.random() * c.length));
}
return result;
}

View file

@ -1,31 +1,31 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
/**
* Sends an embed of reddit
*/
export async function getreddit(sub: string): Promise<RedditObject> {
if (!sub) throw new CathError("Missing Subreddit");
const content = await axios
.get(`https://www.reddit.com/r/${sub}/random/.json`)
.then(res => res.data);
let permalink = content[0].data.children[0].data.permalink;
let memeURL = `https://reddit.com${permalink}`;
let memeImage = content[0].data.children[0].data.url;
let memeTitle = content[0].data.children[0].data.title;
let memeUpvotes = content[0].data.children[0].data.ups;
let memeDownvotes = content[0].data.children[0].data.downs;
let memeNumComments = content[0].data.children[0].data.num_comments;
const obj: RedditObject = {
title: memeTitle,
url: memeURL,
image: memeImage,
footer: ` 👍 ${memeUpvotes} 💬 ${memeNumComments}`,
};
return obj;
}
export interface RedditObject {
title: String;
url: String;
image: String;
footer: String;
}
import axios from "axios";
import { CathError } from "../Error/CathError";
/**
* Sends an embed of reddit
*/
export async function getreddit(sub: string): Promise<RedditObject> {
if (!sub) throw new CathError("Missing Subreddit");
const content = await axios
.get(`https://www.reddit.com/r/${sub}/random/.json`)
.then(res => res.data);
let permalink = content[0].data.children[0].data.permalink;
let memeURL = `https://reddit.com${permalink}`;
let memeImage = content[0].data.children[0].data.url;
let memeTitle = content[0].data.children[0].data.title;
let memeUpvotes = content[0].data.children[0].data.ups;
let memeDownvotes = content[0].data.children[0].data.downs;
let memeNumComments = content[0].data.children[0].data.num_comments;
const obj: RedditObject = {
title: memeTitle,
url: memeURL,
image: memeImage,
footer: ` 👍 ${memeUpvotes} 💬 ${memeNumComments}`,
};
return obj;
}
export interface RedditObject {
title: String;
url: String;
image: String;
footer: String;
}

View file

@ -1,6 +1,6 @@
/**
* Rounds a number to a specified number of decimal places.
*/
export function round(value: number, decimals: number) {
return Number(Math.round(Number(value + "e" + decimals)) + "e-" + decimals);
}
/**
* Rounds a number to a specified number of decimal places.
*/
export function round(value: number, decimals: number) {
return Number(Math.round(Number(value + "e" + decimals)) + "e-" + decimals);
}

View file

@ -1,9 +1,9 @@
import { CathError } from "../Error/CathError";
/**
* Select a random element of the array
*/
export function selectRandom(array = []): any {
if (!array) throw new CathError("Missing 'array'");
if (!array.length) throw new CathError("array length can't be 0");
return array[Math.floor(Math.random() * array.length)];
}
import { CathError } from "../Error/CathError";
/**
* Select a random element of the array
*/
export function selectRandom(array = []): any {
if (!array) throw new CathError("Missing 'array'");
if (!array.length) throw new CathError("array length can't be 0");
return array[Math.floor(Math.random() * array.length)];
}

View file

@ -1,9 +1,9 @@
import { CathError } from "../Error/CathError";
export function sleep(ms: number) {
if (!ms) throw new CathError("Missing 'ms'");
let start = new Date().getTime();
let end = start;
while (end < start + ms) {
end = new Date().getTime();
}
}
import { CathError } from "../Error/CathError";
export function sleep(ms: number) {
if (!ms) throw new CathError("Missing 'ms'");
let start = new Date().getTime();
let end = start;
while (end < start + ms) {
end = new Date().getTime();
}
}

View file

@ -1,16 +1,16 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
/**
* Sends a superscript-ed word
*/
export async function superscript(word: string): Promise<string> {
if (!word) {
throw new CathError("Missing 'word'");
}
const data = await axios
.get(`${config.api}/api/v1/fun/superscript?text=${word}`)
.then(res => res.data);
console.log(data);
return data.text;
}
import axios from "axios";
import { CathError } from "../Error/CathError";
import { config } from "../";
/**
* Sends a superscript-ed word
*/
export async function superscript(word: string): Promise<string> {
if (!word) {
throw new CathError("Missing 'word'");
}
const data = await axios
.get(`${config.api}/api/v1/fun/superscript?text=${word}`)
.then(res => res.data);
console.log(data);
return data.text;
}

View file

@ -1,20 +1,20 @@
import { CathError } from "../Error/CathError";
export function timer(timestamp: number) {
if (!timestamp) throw new CathError("Missing 'timestamp");
const timeLeft = timestamp;
const days = Math.floor(timeLeft / 86400000);
const hours = Math.floor(timeLeft / 3600000) - days * 24;
const minutes = Math.floor(timeLeft / 60000) - days * 1440 - hours * 60;
const seconds =
Math.floor(timeLeft / 1000) - days * 86400 - hours * 3600 - minutes * 60;
const mseconds = timeLeft / 1000 - days * 86400 - hours * 3600 - minutes * 60;
let string = "";
if (days) string = string + `${days} ${days == 1 ? "day " : "days "}`;
if (hours) string = string + `${hours} ${hours == 1 ? "hour " : "hours "}`;
if (minutes)
string = string + `${minutes} ${minutes == 1 ? "minute " : "minutes "}`;
if (seconds)
string = string + `${seconds} ${seconds == 1 ? "second " : "seconds "}`;
if (!string.length) string = `${mseconds.toFixed(1)} second`;
return string;
}
import { CathError } from "../Error/CathError";
export function timer(timestamp: number) {
if (!timestamp) throw new CathError("Missing 'timestamp");
const timeLeft = timestamp;
const days = Math.floor(timeLeft / 86400000);
const hours = Math.floor(timeLeft / 3600000) - days * 24;
const minutes = Math.floor(timeLeft / 60000) - days * 1440 - hours * 60;
const seconds =
Math.floor(timeLeft / 1000) - days * 86400 - hours * 3600 - minutes * 60;
const mseconds = timeLeft / 1000 - days * 86400 - hours * 3600 - minutes * 60;
let string = "";
if (days) string = string + `${days} ${days == 1 ? "day " : "days "}`;
if (hours) string = string + `${hours} ${hours == 1 ? "hour " : "hours "}`;
if (minutes)
string = string + `${minutes} ${minutes == 1 ? "minute " : "minutes "}`;
if (seconds)
string = string + `${seconds} ${seconds == 1 ? "second " : "seconds "}`;
if (!string.length) string = `${mseconds.toFixed(1)} second`;
return string;
}

View file

@ -1,14 +1,14 @@
import { CathError } from "../Error/CathError";
/**
* Trim an array from 10th elemnt
*/
export function trimArray(arr = []) {
if (!arr) throw new CathError("Missing 'arr'");
if (arr.length > 10) {
const length = arr.length - 10;
arr = arr.slice(0, 10);
arr.push(`\n${length} more...`);
}
return arr.join(" **|** ");
}
import { CathError } from "../Error/CathError";
/**
* Trim an array from 10th elemnt
*/
export function trimArray(arr = []) {
if (!arr) throw new CathError("Missing 'arr'");
if (arr.length > 10) {
const length = arr.length - 10;
arr = arr.slice(0, 10);
arr.push(`\n${length} more...`);
}
return arr.join(" **|** ");
}