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

discord-slim

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-slim - npm Package Compare versions

Comparing version 2.2.3 to 2.2.4

12

dist/events.d.ts

@@ -8,5 +8,2 @@ /// <reference types="node" />

RESUMED = "RESUMED",
APPLICATION_COMMAND_CREATE = "APPLICATION_COMMAND_CREATE",
APPLICATION_COMMAND_UPDATE = "APPLICATION_COMMAND_UPDATE",
APPLICATION_COMMAND_DELETE = "APPLICATION_COMMAND_DELETE",
CHANNEL_CREATE = "CHANNEL_CREATE",

@@ -70,11 +67,2 @@ CHANNEL_UPDATE = "CHANNEL_UPDATE",

[Events.RESUMED]: {};
[Events.APPLICATION_COMMAND_CREATE]: types.ApplicationCommand & {
guild_id?: string;
};
[Events.APPLICATION_COMMAND_UPDATE]: types.ApplicationCommand & {
guild_id?: string;
};
[Events.APPLICATION_COMMAND_DELETE]: types.ApplicationCommand & {
guild_id?: string;
};
[Events.CHANNEL_CREATE]: types.Channel;

@@ -81,0 +69,0 @@ [Events.CHANNEL_UPDATE]: types.Channel;

3

dist/events.js

@@ -5,5 +5,2 @@ export var Events;

Events["RESUMED"] = "RESUMED";
Events["APPLICATION_COMMAND_CREATE"] = "APPLICATION_COMMAND_CREATE";
Events["APPLICATION_COMMAND_UPDATE"] = "APPLICATION_COMMAND_UPDATE";
Events["APPLICATION_COMMAND_DELETE"] = "APPLICATION_COMMAND_DELETE";
Events["CHANNEL_CREATE"] = "CHANNEL_CREATE";

@@ -10,0 +7,0 @@ Events["CHANNEL_UPDATE"] = "CHANNEL_UPDATE";

5

dist/helpers.d.ts

@@ -143,5 +143,6 @@ export declare const HOST = "https://discord.com", API: "https://discord.com/api", API_VERSION = 9, API_PATH: "https://discord.com/api/v9", CDN = "https://cdn.discordapp.com";

REPLY = 19,
APPLICATION_COMMAND = 20,
CHAT_INPUT_COMMAND = 20,
THREAD_STARTER_MESSAGE = 21,
GUILD_INVITE_REMINDER = 22
GUILD_INVITE_REMINDER = 22,
CONTEXT_MENU_COMMAND = 23
}

@@ -148,0 +149,0 @@ export declare enum MessageActivityTypes {

@@ -148,5 +148,6 @@ export const HOST = 'https://discord.com', API = `${HOST}/api`, API_VERSION = 9, API_PATH = `${API}/v${API_VERSION}`, CDN = 'https://cdn.discordapp.com';

MessageTypes[MessageTypes["REPLY"] = 19] = "REPLY";
MessageTypes[MessageTypes["APPLICATION_COMMAND"] = 20] = "APPLICATION_COMMAND";
MessageTypes[MessageTypes["CHAT_INPUT_COMMAND"] = 20] = "CHAT_INPUT_COMMAND";
MessageTypes[MessageTypes["THREAD_STARTER_MESSAGE"] = 21] = "THREAD_STARTER_MESSAGE";
MessageTypes[MessageTypes["GUILD_INVITE_REMINDER"] = 22] = "GUILD_INVITE_REMINDER";
MessageTypes[MessageTypes["CONTEXT_MENU_COMMAND"] = 23] = "CONTEXT_MENU_COMMAND";
})(MessageTypes || (MessageTypes = {}));

@@ -153,0 +154,0 @@ export var MessageActivityTypes;

@@ -275,3 +275,3 @@ import type * as helpers from './helpers';

export declare type EmbedThumbnail = {
url?: string;
url: string;
proxy_url?: string;

@@ -282,3 +282,3 @@ height?: number;

export declare type EmbedVideo = {
url?: string;
url: string;
proxy_url?: string;

@@ -289,3 +289,3 @@ height?: number;

export declare type EmbedImage = {
url?: string;
url: string;
proxy_url?: string;

@@ -300,3 +300,3 @@ height?: number;

export declare type EmbedAuthor = {
name?: string;
name: string;
url?: string;

@@ -303,0 +303,0 @@ icon_url?: string;

{
"name": "discord-slim",
"version": "2.2.3",
"version": "2.2.4",
"description": "Lightweight Discord API library for Node.js.",

@@ -5,0 +5,0 @@ "author": "Hanabishi",

@@ -40,2 +40,3 @@ # Discord Slim

// You probably want to use such code for every bot.
const client = new Client();

@@ -52,5 +53,8 @@ client.on(ClientEvents.CONNECT, () => console.log('Connection established.'));

// Request options for actions.
// By design every action can use it's own options. But for convinience you сan set default options globally for all actions.
// Default options can be overridden in any time by passing `requestOptions` argument to individual action.
// By design every action can use its own options.
// But for convinience you сan set default options globally for all actions.
// Default options can be overridden by passing `requestOptions` argument.
Actions.setDefaultRequestOptions({
// Include authorization, it is required for most actions.

@@ -62,9 +66,13 @@ authorization,

rateLimit: {
// Set how many attempts to make due to the rate limit. Default: 5.
// This includes the first try, so values 1 and below will be treated as "no retries".
retryCount: 5,
// Rate limit hit callback
// Rate limit hit callback.
callback: (response, attempts) =>
console.log(`${response.message} Global: ${response.global}. Cooldown: ${response.retry_after} sec. Attempt: ${attempts}.`),
},
});

@@ -82,9 +90,12 @@

client.events.on(Events.MESSAGE_CREATE, (message) => {
// Filter out own messages
// Filter out own messages.
if(message.author.id == client.user.id) return;
// Check that the message contains phrases like "hello bot" or "hi bot"
if(message.content.search(/(^|\s)h(ello|i)(\s|\s.*\s)bot($|\s)/i) < 0) return;
// Using both reply and mention just for demo
// Check that the message contains "hello" word.
if(message.content.search(/(^|\s)hello($|\s)/i) < 0) return;
// Using both reply and mention just for demo.
Actions.Message.Create(message.channel_id, {
content: `Hi, ${Tools.Mentions.User(message.author.id)}!`,
content: `Hi, ${Tools.Mentions.User(message.author)}!`,
message_reference: {

@@ -95,2 +106,3 @@ channel_id: message.channel_id,

});
});

@@ -102,2 +114,3 @@ ```

client.events.on(Events.READY, () => {
client.UpdatePresence({

@@ -109,2 +122,3 @@ status: Helpers.StatusTypes.ONLINE,

});
});

@@ -116,15 +130,19 @@ ```

client.events.on(Events.READY, async (data) => {
// Log all application global commands
// Log all the global application commands.
console.log(await Actions.Application.GetGlobalCommands(data.user.id));
});
```
### Using slash commands
Note: slash commands requires `applications.commands` scope. Read details in [docs](https://discord.com/developers/docs/interactions/slash-commands).
### Using application commands
Note: application commands require `applications.commands` scope. Read details in [docs](https://discord.com/developers/docs/interactions/application-commands#authorizing-your-application).
```js
// Create a command in your guild(s).
client.events.on(Events.GUILD_CREATE, (guild) => {
// Create a command in your guild(s).
// This example represents a simple command that just echoing the text back.
Actions.Application.CreateGuildCommand(client.user.id, guild.id, {
name: 'echo',
description: 'Test slash command.',
description: 'Test application command.',
options: [

@@ -139,2 +157,3 @@ {

});
});

@@ -144,10 +163,20 @@

client.events.on(Events.INTERACTION_CREATE, (interaction) => {
// Check the command by name.
if(interaction.data?.name != 'echo') return;
// Make a response.
Actions.Application.CreateInteractionResponse(interaction.id, interaction.token, {
type: Helpers.InteractionCallbackTypes.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
content: interaction.data.options[0].value.toString(),
// Just echoing the content.
content: interaction.data.options[0].value,
// "EPHEMERAL" flag means that the response will be visible only by the caller.
flags: Helpers.InteractionCallbackDataFlags.EPHEMERAL,
},
});
});

@@ -154,0 +183,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