v1.4.5 with bug fix and word functions

This commit is contained in:
night0721 2021-10-27 08:50:04 +08:00
parent d9d2875560
commit 05100b1169
10 changed files with 70 additions and 13 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "cath", "name": "cath",
"version": "1.4.3", "version": "1.4.5",
"description": "A powerful package that can interact with Cath API", "description": "A powerful package that can interact with Cath API",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View file

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

View file

@ -28,15 +28,15 @@ export async function DiscordActivity(options: DiscordActivityOptions) {
spellcast: "852509694341283871", spellcast: "852509694341283871",
}; };
if (!all[options.application]) { if (!all[options.application]) {
return new CathError( 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" "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) { if (!options.token) {
return new CathError("Missing 'token'"); throw new CathError("Missing 'token'");
} }
if (!options.channel_id) { if (!options.channel_id) {
return new CathError("Missing 'Channel ID'"); throw new CathError("Missing 'Channel ID'");
} }
const data = await axios const data = await axios
.post( .post(

View file

@ -0,0 +1,16 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
import config from "../utils/config.json";
/**
* Sends a 8ball response
*/
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;
}

16
src/functions/fractur.ts Normal file
View file

@ -0,0 +1,16 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
import config from "../utils/config.json";
/**
* 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

@ -0,0 +1,16 @@
import axios from "axios";
import { CathError } from "../Error/CathError";
import config from "../utils/config.json";
/**
* 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

@ -35,3 +35,6 @@ export { cleanText } from "./functions/cleanText";
export { daysAgo } from "./functions/daysAgo"; export { daysAgo } from "./functions/daysAgo";
export { sleep } from "./functions/sleep"; export { sleep } from "./functions/sleep";
export { trimArray } from "./functions/trimArray"; export { trimArray } from "./functions/trimArray";
export { superscript } from "./functions/superscript";
export { doublestruck } from "./functions/doublestruck";
export { fractur } from "./functions/fractur";