Socket
Socket
Sign inDemoInstall

discordx

Package Overview
Dependencies
Maintainers
1
Versions
617
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discordx - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

8

build/decorators/classes/DCommand.d.ts

@@ -24,4 +24,4 @@ import { ApplicationCommandPermissionData, Snowflake } from "discord.js";

set guilds(value: `${bigint}`[]);
get argSplitter(): string;
set argSplitter(value: string);
get argSplitter(): string | RegExp;
set argSplitter(value: string | RegExp);
get directMessage(): boolean;

@@ -37,5 +37,5 @@ set directMessage(value: boolean);

set options(value: DCommandOption[]);
protected constructor(name: string, description?: string, argSplitter?: string, directMessage?: boolean, defaultPermission?: boolean, guilds?: Snowflake[], botIds?: string[], aliases?: string[]);
static create(name: string, description?: string, argSplitter?: string, directMessage?: boolean, defaultPermission?: boolean, guilds?: Snowflake[], botIds?: string[], aliases?: string[]): DCommand;
protected constructor(name: string, description?: string, argSplitter?: string | RegExp, directMessage?: boolean, defaultPermission?: boolean, guilds?: Snowflake[], botIds?: string[], aliases?: string[]);
static create(name: string, description?: string, argSplitter?: string | RegExp, directMessage?: boolean, defaultPermission?: boolean, guilds?: Snowflake[], botIds?: string[], aliases?: string[]): DCommand;
parseParams(message: CommandMessage): (string | number | boolean | undefined)[];
}
import { Snowflake } from "discord.js";
export interface CommandParams {
argSplitter?: string;
argSplitter?: string | RegExp;
description?: string;

@@ -5,0 +5,0 @@ directMessage?: boolean;

{
"name": "discordx",
"version": "5.2.0",
"version": "5.2.1",
"description": "Create your discord bot by using TypeScript and decorators!",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -36,3 +36,3 @@ # Why discordx?

<p align="center">
discord.ts (discordx or @typeit/discord)
discord.ts (discordx)
</p>

@@ -93,2 +93,105 @@ </h1>

# 📟 @Button - Discord button interaction handler
add button interaction handler for your bot using `@Button` decorator
```ts
@Discord()
class buttonExample {
@Slash("hello")
async hello(interaction: CommandInteraction) {
const helloBtn = new MessageButton()
.setLabel("Hello")
.setEmoji("👋")
.setStyle("PRIMARY")
.setCustomId("hello-btn");
const row = new MessageActionRow().addComponents(helloBtn);
interaction.reply({
content: "Say hello to bot",
components: [row],
});
}
@Button("hello-btn")
mybtn(interaction: ButtonInteraction) {
interaction.reply(`👋 ${interaction.member}`);
}
}
```
# 📟 @SelectMenu - Discord menu interaction handler
add menu interaction handler for your bot using `@SelectMenu` decorator
```ts
const roles = [
{ label: "Principal", value: "principal" },
{ label: "Teacher", value: "teacher" },
{ label: "Student", value: "student" },
];
@Discord()
class buttons {
@SelectMenu("role-menu")
async handle(interaction: SelectMenuInteraction) {
await interaction.defer();
// extract selected value by member
const roleValue = interaction.values?.[0];
// if value not found
if (!roleValue)
return await interaction.followUp("invalid role id, select again");
await interaction.followUp(
`you have selected role: ${
roles.find((r) => r.value === roleValue).label
}`
);
return;
}
@Slash("roles", { description: "role selector menu" })
async myroles(interaction: CommandInteraction): Promise<unknown> {
await interaction.defer();
// create menu for roels
const menu = new MessageSelectMenu()
.addOptions(roles)
.setCustomId("role-menu");
// create a row for meessage actions
const buttonRow = new MessageActionRow().addComponents(menu);
// send it
interaction.editReply({
content: "select your role!",
components: [buttonRow],
});
return;
}
}
```
# 📟 @Command - Command Processor
Create a simple command handler for messages using `@Command`. Example `!hello world`
```ts
@Discord()
class commandTest {
@Command("permcheck", { aliases: ["ptest"] })
@DefaultPermission(false)
@Permission({
id: "462341082919731200" as Snowflake,
type: "USER",
permission: true,
})
async permFunc(message: CommandMessage) {
message.reply("access granted");
}
}
```
# 💡@On / @Once - Discord events

@@ -138,4 +241,3 @@

@Guard(
NotBot, // You can use multiple guard functions, they are excuted in the same order!
Prefix("!")
NotBot // You can use multiple guard functions, they are excuted in the same order!
)

@@ -142,0 +244,0 @@ async onMessage([message]: ArgsOf<"messageCreate">) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc