Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@duxcore/interactive-discord

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@duxcore/interactive-discord - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

2

package.json

@@ -5,3 +5,3 @@ {

"description": "A package that will allow you to seamlessly integrate discord interactions into your bot.",
"version": "1.0.10",
"version": "1.0.11",
"license": "GPL-3.0",

@@ -8,0 +8,0 @@ "main": "lib/index",

@@ -58,3 +58,2 @@ import axios from 'axios';

.then(dat => {
console.log(dat.data)
resolve()

@@ -61,0 +60,0 @@ })

@@ -1,4 +0,6 @@

import { Client } from "discord.js";
import { Client, Collection } from "discord.js";
import { TypedEmitter } from 'tiny-typed-emitter';
import { ButtonInteractionController } from "./controllers/ButtonInteractionController";
import { ButtonComponent } from "./structures/buttons/ButtonComponent";
import { ButtonListenerCallback } from "./util/types/button";
import { Events } from "./util/types/events";

@@ -11,2 +13,5 @@ import { InteractionType, RawInteractionObject } from "./util/types/interactions";

private _buttonListeners = new Collection<string, ButtonListenerCallback>();
private _singleButtonListeners = new Collection<string, ButtonListenerCallback>();
constructor(bot: Client, applicationId: string) {

@@ -17,3 +22,16 @@ super();

bot.ws.on("INTERACTION_CREATE", (interaction: RawInteractionObject) => {
if (interaction.type == InteractionType.MessageComponent) this.emit("buttonInteraction", new ButtonInteractionController(interaction, this));
if (interaction.type == InteractionType.MessageComponent) {
const btnController = new ButtonInteractionController(interaction, this)
this.emit("buttonInteraction", btnController);
this._buttonListeners.map((cb, key) => {
if (btnController.customId == key) return cb(btnController);
});
this._singleButtonListeners.map((cb, key) => {
if (btnController.customId == key) {
this._singleButtonListeners.delete(key);
return cb(btnController);
}
});
}
})

@@ -24,2 +42,10 @@

}
addButtonListener(button: ButtonComponent, callback: ButtonListenerCallback) {
this._buttonListeners.set(button.customId, callback);
}
addSingleButtonListener(button: ButtonComponent, callback: ButtonListenerCallback) {
this._singleButtonListeners.set(button.customId, callback);
}
}

@@ -0,1 +1,3 @@

import { ButtonInteractionController } from "../../controllers/ButtonInteractionController";
import { InteractiveClient } from "../../InteractiveClient";
import { ButtonStyle, EmojiPartial } from "./components";

@@ -8,2 +10,4 @@

disabled?: boolean
}
}
export type ButtonListenerCallback = (interaction: ButtonInteractionController) => void;
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