Skip to content

Commit 9de01bf

Browse files
committed
build the lib
1 parent a1848ed commit 9de01bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3057
-0
lines changed

dist/index.d.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import _Client from './lib/Client';
2+
import _Embed from './lib/discord/Embed';
3+
import _Request from './lib/Request';
4+
import _Response from './lib/Response';
5+
export { commandOptions, CommandCallback as commandCallback } from './lib/Command';
6+
export declare const Colors: {
7+
rgb(r: number, g: number, b: number): number;
8+
mind: number;
9+
white: number;
10+
snow: number;
11+
aliceBlue: number;
12+
antiqueWhite: number;
13+
aqua: number;
14+
aquaMarine: number;
15+
azure: number;
16+
beige: number;
17+
bisque: number;
18+
black: number;
19+
blanchedAlmond: number;
20+
blue: number;
21+
blueViolet: number;
22+
brown: number;
23+
lightGreen: number;
24+
orange: number;
25+
pink: number;
26+
red: number;
27+
yellow: number;
28+
};
29+
export declare const Colours: {
30+
rgb(r: number, g: number, b: number): number;
31+
mind: number;
32+
white: number;
33+
snow: number;
34+
aliceBlue: number;
35+
antiqueWhite: number;
36+
aqua: number;
37+
aquaMarine: number;
38+
azure: number;
39+
beige: number;
40+
bisque: number;
41+
black: number;
42+
blanchedAlmond: number;
43+
blue: number;
44+
blueViolet: number;
45+
brown: number;
46+
lightGreen: number;
47+
orange: number;
48+
pink: number;
49+
red: number;
50+
yellow: number;
51+
};
52+
export declare const Client: typeof _Client;
53+
export declare const Embed: typeof _Embed;
54+
export declare let Request: typeof _Request;
55+
export declare let Response: typeof _Response;

dist/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.Response = exports.Request = exports.Embed = exports.Client = exports.Colours = exports.Colors = void 0;
7+
/* eslint-disable @typescript-eslint/ban-ts-comment */
8+
const Client_1 = __importDefault(require("./lib/Client"));
9+
const Embed_1 = __importDefault(require("./lib/discord/Embed"));
10+
const Colors_1 = __importDefault(require("./lib/Colors"));
11+
exports.Colors = Colors_1.default;
12+
exports.Colours = Colors_1.default;
13+
exports.Client = Client_1.default;
14+
exports.Embed = Embed_1.default;

dist/lib/Client.d.ts

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
/******************************************************************************
2+
* @file src/lib/Client.ts
3+
* @fileoverview Exports the Client class - the main class in Fuwa.JS - alongside other
4+
* helper functions, interfaces, types, etc.
5+
*****************************************************************************/
6+
/// <reference types="node" />
7+
import Request from './Request';
8+
import Cache from './_Cache';
9+
import Debug from './_Debug';
10+
import { UserStatus, ActivityType } from './_DiscordAPI';
11+
import User from './discord/User';
12+
import Response from './Response';
13+
import Emitter from './Emitter';
14+
import { CommandCallback, commandOptions } from './Command';
15+
import Reaction from './discord/Reaction';
16+
export declare type statusType = 'playing' | 'listening' | 'streaming' | 'competing';
17+
/**
18+
* status options for bot
19+
*/
20+
export interface StatusOptions {
21+
/**
22+
* The status message to be displayed
23+
*/
24+
name: string;
25+
/**
26+
* The available status types are playing, listening, streaming, and
27+
* competing.
28+
*/
29+
type?: ActivityType;
30+
/**
31+
* The URL of a stream
32+
*/
33+
url?: string;
34+
/**
35+
* The status of your bot. Online by default
36+
*/
37+
status?: UserStatus;
38+
/**
39+
* Whether or not the bot is afk.
40+
*/
41+
afk?: boolean;
42+
}
43+
export interface Events {
44+
ready(): void | Promise<void>;
45+
message(req: Request, res: Response): void | Promise<void>;
46+
commandNotFound(req: Request, cmd: CommandCallback): void | Promise<void>;
47+
reaction(reaction: Reaction): any;
48+
}
49+
export interface clientOptions {
50+
/**
51+
* The owners' discord ID
52+
*/
53+
owners?: string[] | string;
54+
/**
55+
* To turn on the debug mode, not recommed to turn this on unless your debugging
56+
* the library.
57+
*/
58+
debug?: boolean;
59+
/**
60+
* If this is turned on (true) When someone mentions your bot it will behave
61+
* as a prefix.
62+
*/
63+
useMentionPrefix?: boolean;
64+
/**
65+
*
66+
*/
67+
builtinCommands?: {
68+
help?: {
69+
embedColor?: string | number;
70+
} | false;
71+
};
72+
/**
73+
* @see GatewayIntents
74+
*/
75+
intents: number;
76+
/**
77+
* If the bot should cache guilds/channels/users or not.
78+
* It's suggested to keep this on for smaller bots
79+
* but for larger ones turn this off,
80+
* caching increases the speed of sending messages, but takes up memory.
81+
* meaning caching on = faster guild replies
82+
* caching off = more memory for other tasks
83+
*/
84+
cache?: true;
85+
/**
86+
* Settings for caching
87+
*/
88+
cachingSettings?: {
89+
/**
90+
* Clear the cache after a certain amount of time (in ms)
91+
* If this is false then the cache will never be cleared
92+
*/
93+
clearAfter?: number | false;
94+
cacheOptions?: {
95+
guilds: boolean;
96+
channels: boolean;
97+
users: boolean;
98+
};
99+
/**
100+
* Maximum amount of items to cache at once. Set this to 0 if you want
101+
* an unlimited cache size
102+
*/
103+
maxSize?: number;
104+
};
105+
}
106+
/**
107+
* The Client Class
108+
* @description The client class is the main starting point of your discord bot.
109+
* ```typescript
110+
* const fuwa = require('fuwa.js'); // Import Fuwa library
111+
* const client = new fuwa.Client('?'); // Create and initialize a Client
112+
* ```
113+
*/
114+
declare class Client extends Emitter {
115+
bot: User;
116+
protected debug: Debug;
117+
private sessionId;
118+
cache: Cache;
119+
protected status: any;
120+
protected events: Map<keyof Events, Function>;
121+
protected prefix: string | string[] | ((req: Request) => Promise<string> | string);
122+
protected options: clientOptions;
123+
protected loop?: NodeJS.Timeout;
124+
protected commands: Map<string, {
125+
cb: CommandCallback;
126+
options: commandOptions;
127+
}[]>;
128+
protected middleware: CommandCallback[];
129+
/**
130+
* The Bot Token
131+
*/
132+
token: string;
133+
/**
134+
* @param prefix The prefix for your bot
135+
*/
136+
constructor(prefix: string | string[] | ((req: Request) => Promise<string> | string), options?: clientOptions);
137+
/**
138+
* Command function
139+
* @param name Command name(s).
140+
* @param cb The function that is called when the command is ran.
141+
* @param options Options for your command.
142+
* @returns Command Options
143+
* @example
144+
* ```typescript
145+
* cli.command(['ping', 'latency'], (req, res) => {
146+
* res.send('Pong!');
147+
*
148+
* });
149+
* ```
150+
*/
151+
command(name: string | string[], cb: CommandCallback, options?: commandOptions): {
152+
addAlias: (...aliases: string[]) => any;
153+
addArgument: <T>(name: string, desc: string, defaultVal?: T) => any;
154+
};
155+
/**
156+
* @typeParam T The event name
157+
* @param cb The callback function
158+
* ```typescript
159+
* cli.on('ready', () => console.log ('Up and ready to go!'));
160+
* ```
161+
*/
162+
on<T extends keyof Events>(event: T, cb: Events[T]): this;
163+
/**
164+
* @description A function that is ran before every command
165+
* @param cb Your middleware function
166+
* @returns A **client** so you can *chain* methods.
167+
* @example
168+
* ```typescript
169+
* cli.use((req, res, next) => {
170+
* req.send(`${req.command} has been used!`);
171+
* next(); // call the next middlware/command
172+
* })
173+
* ```
174+
*/
175+
use(cb: CommandCallback): this;
176+
/**
177+
* options for bot status
178+
*/
179+
/**
180+
* @description Log your bot into discord
181+
* @param token Your bot token
182+
* @param status Your Bot Status Options
183+
*/
184+
login(token: string | Buffer): Promise<void>;
185+
logout(end?: boolean): void;
186+
set<T extends keyof clientOptions>(key: T, val: clientOptions[T]): this;
187+
setStatus(status: StatusOptions): void;
188+
deleteMessages(amt: number, channelID: string): Promise<void>;
189+
}
190+
export default Client;

0 commit comments

Comments
 (0)