-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1848ed
commit 9de01bf
Showing
42 changed files
with
3,057 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import _Client from './lib/Client'; | ||
import _Embed from './lib/discord/Embed'; | ||
import _Request from './lib/Request'; | ||
import _Response from './lib/Response'; | ||
export { commandOptions, CommandCallback as commandCallback } from './lib/Command'; | ||
export declare const Colors: { | ||
rgb(r: number, g: number, b: number): number; | ||
mind: number; | ||
white: number; | ||
snow: number; | ||
aliceBlue: number; | ||
antiqueWhite: number; | ||
aqua: number; | ||
aquaMarine: number; | ||
azure: number; | ||
beige: number; | ||
bisque: number; | ||
black: number; | ||
blanchedAlmond: number; | ||
blue: number; | ||
blueViolet: number; | ||
brown: number; | ||
lightGreen: number; | ||
orange: number; | ||
pink: number; | ||
red: number; | ||
yellow: number; | ||
}; | ||
export declare const Colours: { | ||
rgb(r: number, g: number, b: number): number; | ||
mind: number; | ||
white: number; | ||
snow: number; | ||
aliceBlue: number; | ||
antiqueWhite: number; | ||
aqua: number; | ||
aquaMarine: number; | ||
azure: number; | ||
beige: number; | ||
bisque: number; | ||
black: number; | ||
blanchedAlmond: number; | ||
blue: number; | ||
blueViolet: number; | ||
brown: number; | ||
lightGreen: number; | ||
orange: number; | ||
pink: number; | ||
red: number; | ||
yellow: number; | ||
}; | ||
export declare const Client: typeof _Client; | ||
export declare const Embed: typeof _Embed; | ||
export declare let Request: typeof _Request; | ||
export declare let Response: typeof _Response; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Response = exports.Request = exports.Embed = exports.Client = exports.Colours = exports.Colors = void 0; | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
const Client_1 = __importDefault(require("./lib/Client")); | ||
const Embed_1 = __importDefault(require("./lib/discord/Embed")); | ||
const Colors_1 = __importDefault(require("./lib/Colors")); | ||
exports.Colors = Colors_1.default; | ||
exports.Colours = Colors_1.default; | ||
exports.Client = Client_1.default; | ||
exports.Embed = Embed_1.default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
/****************************************************************************** | ||
* @file src/lib/Client.ts | ||
* @fileoverview Exports the Client class - the main class in Fuwa.JS - alongside other | ||
* helper functions, interfaces, types, etc. | ||
*****************************************************************************/ | ||
/// <reference types="node" /> | ||
import Request from './Request'; | ||
import Cache from './_Cache'; | ||
import Debug from './_Debug'; | ||
import { UserStatus, ActivityType } from './_DiscordAPI'; | ||
import User from './discord/User'; | ||
import Response from './Response'; | ||
import Emitter from './Emitter'; | ||
import { CommandCallback, commandOptions } from './Command'; | ||
import Reaction from './discord/Reaction'; | ||
export declare type statusType = 'playing' | 'listening' | 'streaming' | 'competing'; | ||
/** | ||
* status options for bot | ||
*/ | ||
export interface StatusOptions { | ||
/** | ||
* The status message to be displayed | ||
*/ | ||
name: string; | ||
/** | ||
* The available status types are playing, listening, streaming, and | ||
* competing. | ||
*/ | ||
type?: ActivityType; | ||
/** | ||
* The URL of a stream | ||
*/ | ||
url?: string; | ||
/** | ||
* The status of your bot. Online by default | ||
*/ | ||
status?: UserStatus; | ||
/** | ||
* Whether or not the bot is afk. | ||
*/ | ||
afk?: boolean; | ||
} | ||
export interface Events { | ||
ready(): void | Promise<void>; | ||
message(req: Request, res: Response): void | Promise<void>; | ||
commandNotFound(req: Request, cmd: CommandCallback): void | Promise<void>; | ||
reaction(reaction: Reaction): any; | ||
} | ||
export interface clientOptions { | ||
/** | ||
* The owners' discord ID | ||
*/ | ||
owners?: string[] | string; | ||
/** | ||
* To turn on the debug mode, not recommed to turn this on unless your debugging | ||
* the library. | ||
*/ | ||
debug?: boolean; | ||
/** | ||
* If this is turned on (true) When someone mentions your bot it will behave | ||
* as a prefix. | ||
*/ | ||
useMentionPrefix?: boolean; | ||
/** | ||
* | ||
*/ | ||
builtinCommands?: { | ||
help?: { | ||
embedColor?: string | number; | ||
} | false; | ||
}; | ||
/** | ||
* @see GatewayIntents | ||
*/ | ||
intents: number; | ||
/** | ||
* If the bot should cache guilds/channels/users or not. | ||
* It's suggested to keep this on for smaller bots | ||
* but for larger ones turn this off, | ||
* caching increases the speed of sending messages, but takes up memory. | ||
* meaning caching on = faster guild replies | ||
* caching off = more memory for other tasks | ||
*/ | ||
cache?: true; | ||
/** | ||
* Settings for caching | ||
*/ | ||
cachingSettings?: { | ||
/** | ||
* Clear the cache after a certain amount of time (in ms) | ||
* If this is false then the cache will never be cleared | ||
*/ | ||
clearAfter?: number | false; | ||
cacheOptions?: { | ||
guilds: boolean; | ||
channels: boolean; | ||
users: boolean; | ||
}; | ||
/** | ||
* Maximum amount of items to cache at once. Set this to 0 if you want | ||
* an unlimited cache size | ||
*/ | ||
maxSize?: number; | ||
}; | ||
} | ||
/** | ||
* The Client Class | ||
* @description The client class is the main starting point of your discord bot. | ||
* ```typescript | ||
* const fuwa = require('fuwa.js'); // Import Fuwa library | ||
* const client = new fuwa.Client('?'); // Create and initialize a Client | ||
* ``` | ||
*/ | ||
declare class Client extends Emitter { | ||
bot: User; | ||
protected debug: Debug; | ||
private sessionId; | ||
cache: Cache; | ||
protected status: any; | ||
protected events: Map<keyof Events, Function>; | ||
protected prefix: string | string[] | ((req: Request) => Promise<string> | string); | ||
protected options: clientOptions; | ||
protected loop?: NodeJS.Timeout; | ||
protected commands: Map<string, { | ||
cb: CommandCallback; | ||
options: commandOptions; | ||
}[]>; | ||
protected middleware: CommandCallback[]; | ||
/** | ||
* The Bot Token | ||
*/ | ||
token: string; | ||
/** | ||
* @param prefix The prefix for your bot | ||
*/ | ||
constructor(prefix: string | string[] | ((req: Request) => Promise<string> | string), options?: clientOptions); | ||
/** | ||
* Command function | ||
* @param name Command name(s). | ||
* @param cb The function that is called when the command is ran. | ||
* @param options Options for your command. | ||
* @returns Command Options | ||
* @example | ||
* ```typescript | ||
* cli.command(['ping', 'latency'], (req, res) => { | ||
* res.send('Pong!'); | ||
* | ||
* }); | ||
* ``` | ||
*/ | ||
command(name: string | string[], cb: CommandCallback, options?: commandOptions): { | ||
addAlias: (...aliases: string[]) => any; | ||
addArgument: <T>(name: string, desc: string, defaultVal?: T) => any; | ||
}; | ||
/** | ||
* @typeParam T The event name | ||
* @param cb The callback function | ||
* ```typescript | ||
* cli.on('ready', () => console.log ('Up and ready to go!')); | ||
* ``` | ||
*/ | ||
on<T extends keyof Events>(event: T, cb: Events[T]): this; | ||
/** | ||
* @description A function that is ran before every command | ||
* @param cb Your middleware function | ||
* @returns A **client** so you can *chain* methods. | ||
* @example | ||
* ```typescript | ||
* cli.use((req, res, next) => { | ||
* req.send(`${req.command} has been used!`); | ||
* next(); // call the next middlware/command | ||
* }) | ||
* ``` | ||
*/ | ||
use(cb: CommandCallback): this; | ||
/** | ||
* options for bot status | ||
*/ | ||
/** | ||
* @description Log your bot into discord | ||
* @param token Your bot token | ||
* @param status Your Bot Status Options | ||
*/ | ||
login(token: string | Buffer): Promise<void>; | ||
logout(end?: boolean): void; | ||
set<T extends keyof clientOptions>(key: T, val: clientOptions[T]): this; | ||
setStatus(status: StatusOptions): void; | ||
deleteMessages(amt: number, channelID: string): Promise<void>; | ||
} | ||
export default Client; |
Oops, something went wrong.