Options
All
  • Public
  • Public/Protected
  • All
Menu

Class default

The Client Class

description

The client class is the main starting point of your discord bot.

const fuwa = require('fuwa.js'); // Import Fuwa library
const client = new fuwa.Client('?'); // Create and initialize a Client

Hierarchy

Index

Constructors

constructor

Properties

bot

bot: User

cache

cache: { guilds: Map<string, Guild> } = ...

Type declaration

  • guilds: Map<string, Guild>

Protected commands

commands: Map<string, { cb: commandCallback; options: commandOptions }[]> = ...

Protected debugMode

debugMode: boolean

Protected events

events: Map<"READY" | "MSG" | "CMD_NOT_FND" | "ERR", Function> = ...

Protected Optional loop

loop: Timeout

Protected middleware

middleware: commandCallback[] = ...

Protected options

options: clientOptions

Protected prefix

prefix: string | string[] | ((req: default) => string | Promise<string>)

Protected response

response: { events: { emit: <T>(t: T, d: DiscordAPIEvents[T]) => void }; op: { emit: <T>(op: T, d: DiscordAPIOP[T]["d"]) => void } } = ...

Type declaration

  • events: { emit: <T>(t: T, d: DiscordAPIEvents[T]) => void }
    • emit: <T>(t: T, d: DiscordAPIEvents[T]) => void
        • <T>(t: T, d: DiscordAPIEvents[T]): void
        • Type parameters

          • T: "READY" | "GUILD_CREATE" | "CHANNEL_CREATE" | "MESSAGE_CREATE"

          Parameters

          • t: T
          • d: DiscordAPIEvents[T]

          Returns void

  • op: { emit: <T>(op: T, d: DiscordAPIOP[T]["d"]) => void }
    • emit: <T>(op: T, d: DiscordAPIOP[T]["d"]) => void
        • <T>(op: T, d: DiscordAPIOP[T]["d"]): void
        • Type parameters

          • T: 2 | 1 | 3 | 4 | 6 | 8 | 9 | 10

          Parameters

          • op: T
          • d: DiscordAPIOP[T]["d"]

          Returns void

Private sessionId

sessionId: string = ''

Protected status

status: any = ...

token

token: string

The Bot Token

Protected Optional ws

ws: WebSocket

Methods

command

  • Command function

    Parameters

    • name: string | string[]

      Command name(s).

    • cb: commandCallback

      The function that is called when the command is ran.

    • Optional options: commandOptions

      Options for your command.

    Returns default

    client

    cli.command(['ping', 'latency'], (req, res) => {
         res.send('Pong!)
    

    });

Protected connect

  • connect(url: string): void

Protected debug

  • debug(bug: any): void

deleteMessages

  • deleteMessages(amt: number, channelID: string): Promise<void>
  • Parameters

    • amt: number
    • channelID: string

    Returns Promise<void>

Protected event

  • event<T>(e: T, cb: (data: DiscordAPIEvents[T]["d"]) => void): void
  • Type parameters

    • T: "READY" | "GUILD_CREATE" | "CHANNEL_CREATE" | "MESSAGE_CREATE"

    Parameters

    • e: T
    • cb: (data: DiscordAPIEvents[T]["d"]) => void
        • (data: DiscordAPIEvents[T]["d"]): void
        • Parameters

          • data: DiscordAPIEvents[T]["d"]

          Returns void

    Returns void

login

  • login(token: string | Buffer): Promise<void>
  • Log your bot into discord

    Parameters

    • token: string | Buffer

      Your bot token

    Returns Promise<void>

logout

  • logout(end?: boolean): void

on

  • Type parameters

    • T: "READY" | "MSG" | "CMD_NOT_FND" | "ERR"

      The event name

    Parameters

    • event: T
    • cb: Events[T]

      The callback function

      cli.on('ready', () => console.log ('Up and ready to go!'));
      

    Returns default

Protected op

  • op<T>(op: T, cb: (data: DiscordAPIOP[T]["d"]) => void): void
  • Type parameters

    • T: 2 | 1 | 3 | 4 | 6 | 8 | 9 | 10

    Parameters

    • op: T
    • cb: (data: DiscordAPIOP[T]["d"]) => void
        • (data: DiscordAPIOP[T]["d"]): void
        • Parameters

          • data: DiscordAPIOP[T]["d"]

          Returns void

    Returns void

set

setStatus

use

  • a function that is ran before every command

    description
    cli.use((req, res, next) => {
         req.send(`${req.command} has been used!`);
         next(); // call the next middlware/command
    })
    

    Parameters

    Returns default

    A client

Generated using TypeDoc