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

@duxcore/interactive-discord

Package Overview
Dependencies
Maintainers
2
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.1.5 to 1.1.6

5

example/src/index.ts
import Discord, { MessageEmbed } from 'discord.js';
import { config } from 'dotenv';
import InteractiveClient, { ComponentActionRow, ComponentCluster } from '@duxcore/interactive-discord';
import InteractiveClient, { ComponentActionRow, ComponentCluster, SlashCommand } from '@duxcore/interactive-discord';
import { dangerbutton, killerbutton, linkbutton, primarybutton, replacebutton, reviverbutton, secondarybutton, selectionbutton, successbutton, basicselection, multiselection, multiselectbutton, hibutton, byebutton } from './constants';

@@ -14,2 +14,5 @@

console.log('Bot online')
const test = new SlashCommand({ name: 'test', description: 'test command', guilds: ['844279877503025182'] })
interactiveClient.commands.register(test)
})

@@ -16,0 +19,0 @@

2

package.json

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

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

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

@@ -14,6 +14,6 @@ import axios from "axios";

private _axiosOpts: any;
constructor(client: InteractiveClient) {
this._client = client;
this._axiosOpts = {headers: { "Authorization": `Bot ${this._client.bot.token}`}};
this._axiosOpts = { headers: { "Authorization": `Bot ${this._client.bot.token}` } };
}

@@ -42,8 +42,8 @@

public async register(cmd: SlashCommand): Promise<CommandController> {
let cachedCmd = this._commandCache.get(cmd.name);
if (cachedCmd) return (await cachedCmd.update(cmd));
public async register(command: SlashCommand): Promise<CommandController> {
let cachedCmd = this._commandCache.get(command.name);
if (cachedCmd) return (await cachedCmd.update(command));
const registeredData = await registerCommand(cmd, this._client);
const controller = new CommandController(cmd, registeredData, this._client);
const registeredData = await registerCommand(command, this._client);
const controller = new CommandController(command, registeredData, this._client);

@@ -50,0 +50,0 @@ this._commandCache.set(controller.command.name, controller);

@@ -10,6 +10,6 @@ import { InteractiveClient } from "../InteractiveClient";

super(raw, client);
this._customId = raw.data.custom_id
this._customId = raw.data.custom_id || ""
}
get customId(): string { return this._customId; }
}
}

@@ -11,3 +11,3 @@ import { InteractiveClient } from "../InteractiveClient";

super(raw, client);
this._customId = raw.data.custom_id
this._customId = raw.data.custom_id || ""
this._selections = raw.data.values

@@ -18,2 +18,2 @@ }

get selections(): string[] | null | undefined { return this._selections; }
}
}

@@ -11,3 +11,3 @@ import { APIMessageContentResolvable, Client, Collection, DMChannel, MessageAdditions, MessageOptions, NewsChannel, TextChannel } from "discord.js";

import { ButtonListenerCallback } from "./util/types/button";
import { SendComponentsOptions, UniversalComponentType } from "./util/types/components";
import { SendComponentsOptions } from "./util/types/components";
import { Events } from "./util/types/events";

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

}
if (interaction.type == InteractionType.ApplicationCommand) {
console.log(interaction);
}
})

@@ -70,0 +73,0 @@ }

@@ -14,2 +14,6 @@ import { SelectionComponent } from "./selections/SelectionComponent";

addComponent(...components: ComponentTypes[]) {
components.map(comp => this.components.push(comp));
}
compile(asString?: boolean): ComponentObject[] | string {

@@ -16,0 +20,0 @@ let components: ComponentObject[] = [];

import { Snowflake } from "discord.js";
import { ApplicationCommandOption, ApplicationCommandPermissions, NewCommandOptions } from "../util/types/command";
import { ApplicationCommandOption, ApplicationCommandPermissions, SlashCommandOptions } from "../util/types/command";

@@ -13,3 +13,3 @@ export class SlashCommand {

constructor(options: NewCommandOptions) {
constructor(options: SlashCommandOptions) {
this._name = options.name;

@@ -29,7 +29,7 @@ this._description = options.description;

get permissions(): ApplicationCommandPermissions[] { return this._permissions; }
get options(): ApplicationCommandOption[] { return this._options;}
get options(): ApplicationCommandOption[] { return this._options; }
get defaultPermission(): boolean { return this._defaultPermission; }
compile(): NewCommandOptions {
const cmd: NewCommandOptions = {
compile(): SlashCommandOptions {
const cmd: SlashCommandOptions = {
name: this._name,

@@ -36,0 +36,0 @@ description: this._description,

@@ -12,6 +12,6 @@ import axios from "axios";

const isGlobal = (!cmd.guilds || cmd.guilds.length == 0);
if (isGlobal) {
const url = `${appurl}/commands`;
axios.post(url, cmd.compile(), {headers:{'Authorization':`Bot ${client.bot.token}`}}).then((dat) => {
axios.post(url, cmd.compile(), { headers: { 'Authorization': `Bot ${client.bot.token}` } }).then((dat) => {
const data = dat.data;

@@ -23,7 +23,7 @@ return resolve(data);

const guilds = (typeof cmd.guilds == "string" ? [ cmd.guilds ] : cmd.guilds);
const guilds = (typeof cmd.guilds == "string" ? [cmd.guilds] : cmd.guilds);
guilds?.forEach(id => {
const url = `${appurl}/guild/${id}/commands`;
axios.post(url, cmd.compile(), {headers:{'Authorization':`Bot ${client.bot.token}`}}).then((dat) => {
const url = `${appurl}/guilds/${id}/commands`;
axios.post(url, cmd.compile(), { headers: { 'Authorization': `Bot ${client.bot.token}` } }).then((dat) => {
const data = dat.data;

@@ -30,0 +30,0 @@ return resolve(data);

@@ -12,3 +12,3 @@ import { Snowflake } from "discord.js";

ROLE = 8,
MENTIONABLE = 9
MENTIONABLE = 9
}

@@ -21,3 +21,3 @@

export interface NewCommandOptions {
export interface SlashCommandOptions {
name: string;

@@ -24,0 +24,0 @@ description: string;

@@ -74,6 +74,6 @@ import { MessageEmbed } from "discord.js";

options?: (OptionsEntity)[] | null;
name: string;
name?: string;
id: string;
custom_id: string;
component_type: number;
custom_id?: string;
component_type?: number;
values?: string[] | null

@@ -80,0 +80,0 @@ }

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