Socket
Book a DemoInstallSign in
Socket

core-discord

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-discord

### TS-Use only. ## Initialising Client & Start ``` import { Client } from "core-discord";

2.0.5
latest
Source
npmnpm
Version published
Weekly downloads
12
Maintainers
1
Weekly downloads
 
Created
Source

Discord Core Documentation

TS-Use only.

Initialising Client & Start

import { Client } from "core-discord";

const client = new Client({
    token: "YOUR_TOKEN",
    prefix: "PREFIX",
    intents: [],
    partials?: [],
    paths: {
        commands: "./commands",
        events: "./events"
    },
    color: "RED",
    footer: {text: "", iconURL?: ""}
});

client.start();

Registering Events

Create a new file under the events path

import { Client, Event } from "core-discord"

export default class Ready extends Event {
    constructor() {
        super("ready");
    }

    public run(client: Client) {
        client.logger.info(`Logged in as ${client.user.tag}!`);
    }
}

Registering Commands

Create a new file under the commands path

import { TextChannel, GuildMember, Message } from "discord.js";
import { Client, Command } from "core-discord";

export default class Ping extends Command {
    constructor() {
        super("ping", "Pong!", "ping", ["GUILDS"], ["ROLEIDS"], true);
    }

    async run(client: Client, channel: TextChannel, member: GuildMember, message: Message<boolean>, args: string[]): Promise<void> {
        const ping = Date.now() - message.createdTimestamp;
        channel.send({
            embeds: [client.util.generateEmbed({
                title: "Pong!",
                description: `${ping}ms`,
            })]
        });
    }
}

Utils

{Client}.util.{Function}

Functions include:

  • generateEmbed
  • getMessage
  • getChannel
  • getMember

Logging

The core uses the Consola logging package, which provides info debug and success logs.

That's it! Enjoy!

FAQs

Package last updated on 25 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.