
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Discordial is a framework for building Discord bots. It makes use of the advantages of TypeScript and combines elements of OOP (Object Oriented Programming) and FP (Functional Programming).
Discordial is built uisin the IoC (Inversion of Control) design pattern, and focus on modularity and ease of use. Adding functionality to your bot is as easy as downloading a packaging and writing a single line of code.
Discordial works by registering plugins during your Discordial configuration. Therefore, adding more functionality is as easy as registering more plugins.
import { Discordial } from "discordial";
import { PrefixPlugin } from "./prefix/prefix.plugin";
const token = "your discord bot token";
const discordial = new Discordial(token, {
plugins: [PrefixPlugin] // <= PrefixPlugin is now registered.
});
Now let's take a look at what PrefixPlugin
looks like. A Discordial Plugin is the controller which maps discord events to functions using the @BindEvent()
decorator. A Discordial Plugin takes the @DiscordialPlugin()
decorator at the top.
// src/prefix/prefix.plugin.ts
import { Message } from "discord.js";
import { DiscordialPlugin, BindEvent, DiscordEvents, Inject, Message, SyntheticMessage } from "discordial";
import { PrefixService } from "./prefix.service";
@DiscordialPlugin()
export class PrefixPlugin {
constructor(
// Discordial will instantiate and manage your services for you.
@Inject(PrefixService) private readonly prefixService: PrefixService,
) {}
// `replyWithPong()` will be called on every new message.
@BindEvent(DiscordEvents.MESSAGE)
public replyWithPong(
// You can inject synthetic objects with the help of decorators:
@Message() syntheticMessage: SyntheticMessage,
// Or simply get the default parameters from the listener:
message: Message,
) {
this.prefixService.replyWithPong(syntheticMessage);
}
}
Services can be used to separate concerns and create scalable applications. To declare a service, use the @Injectable()
decorator. Let's take a look at our PrefixService
.
import { Injectable, SyntheticMessage } from "discordial";
@Injectable()
export class PrefixService {
private readonly _prefix = "!";
private isValid(message: SyntheticMessage, command: string): boolean {
if (!message.content.startsWith(this._prefix + command))
return false;
return !message.author.bot;
}
public replyWithPong(message: SyntheticMessage): void {
if (!this.isValid(message, "ping"))
return;
message.reply("pong");
}
}
Built using the IoC design pattern.
Shares similarities with AngularJS and NestJS. If you have experience with any of those frameworks, Discordial becomes that much easier to use.
Synthetic objects: Discordial offers custom interfaces for manipulating the event parameters with improved functionality. Synthetic objects can also be replaced by awesome community made creations. Well, not yet... but that's the plan! :)
FAQs
A Discord framework using IoC architecture.
We found that discordial demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.