Skip to content

Commit 11d7f30

Browse files
committed
Add GATEWAY_INTENTS_ALL_UNPRIVILEGED
- Add `GATEWAY_INTENTS_ALL_UNPRIVILEGED` -> This is the default intents on the gateway connection now - Sending in '*' as the intents will do nothing now -> Changed to 'ALL' - Added support for sending in 'ALL' and 'ALL_UNPRIVILEGED' as the intents
1 parent eac892f commit 11d7f30

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "detritus-client-socket",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"description": "A TypeScript NodeJS library to interact with Discord's Gateway",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/constants.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const Package = Object.freeze({
22
URL: 'https://github.com/detritusjs/client-socket',
3-
VERSION: '0.7.0',
3+
VERSION: '0.7.1',
44
});
55

66

@@ -187,7 +187,23 @@ export const GATEWAY_INTENTS_ALL = [
187187
GatewayIntents.DIRECT_MESSAGE_TYPING,
188188
].reduce((x, total) => total | x);
189189

190-
export const GATEWAY_INTENTS_DIRECT_MESSAGES = [
190+
export const GATEWAY_INTENTS_ALL_UNPRIVILEGED = [
191+
GatewayIntents.GUILDS,
192+
GatewayIntents.GUILD_BANS,
193+
GatewayIntents.GUILD_EMOJIS,
194+
GatewayIntents.GUILD_INTEGRATIONS,
195+
GatewayIntents.GUILD_WEBHOOKS,
196+
GatewayIntents.GUILD_INVITES,
197+
GatewayIntents.GUILD_VOICE_STATES,
198+
GatewayIntents.GUILD_MESSAGES,
199+
GatewayIntents.GUILD_MESSAGE_REACTIONS,
200+
GatewayIntents.GUILD_MESSAGE_TYPING,
201+
GatewayIntents.DIRECT_MESSAGES,
202+
GatewayIntents.DIRECT_MESSAGE_REACTIONS,
203+
GatewayIntents.DIRECT_MESSAGE_TYPING,
204+
].reduce((x, total) => total | x);
205+
206+
export const GATEWAY_INTENTS_ALL_DIRECT_MESSAGES = [
191207
GatewayIntents.DIRECT_MESSAGES,
192208
GatewayIntents.DIRECT_MESSAGE_REACTIONS,
193209
GatewayIntents.DIRECT_MESSAGE_TYPING,
@@ -208,6 +224,7 @@ export const GATEWAY_INTENTS_ALL_GUILD = [
208224
GatewayIntents.GUILD_MESSAGE_TYPING,
209225
].reduce((x, total) => total | x);
210226

227+
211228
export enum GatewayOpCodes {
212229
DISPATCH = 0,
213230
HEARTBEAT = 1,

src/gateway.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
DEFAULT_SHARD_LAUNCH_DELAY,
3232
DEFAULT_VOICE_TIMEOUT,
3333
GATEWAY_INTENTS_ALL,
34+
GATEWAY_INTENTS_ALL_UNPRIVILEGED,
3435
} from './constants';
3536

3637

@@ -111,7 +112,7 @@ export class Socket extends EventSpewer {
111112
encoding: EncodingTypes;
112113
guildSubscriptions: boolean;
113114
identifyProperties: IdentifyDataProperties = Object.assign({}, IdentifyProperties);
114-
intents: number = GATEWAY_INTENTS_ALL;
115+
intents: number = GATEWAY_INTENTS_ALL_UNPRIVILEGED;
115116
killed: boolean = false;
116117
largeThreshold: number;
117118
mediaGateways = new BaseCollection<string, MediaSocket>();
@@ -133,7 +134,7 @@ export class Socket extends EventSpewer {
133134

134135
constructor(
135136
token: string,
136-
options: SocketOptions = {intents: GATEWAY_INTENTS_ALL},
137+
options: SocketOptions = {intents: GATEWAY_INTENTS_ALL_UNPRIVILEGED},
137138
) {
138139
super();
139140

@@ -207,8 +208,10 @@ export class Socket extends EventSpewer {
207208

208209
if (options.intents !== undefined) {
209210
this.intents = 0;
210-
if (options.intents === '*') {
211+
if (options.intents === 'ALL') {
211212
this.intents = GATEWAY_INTENTS_ALL;
213+
} else if (options.intents === 'ALL_UNPRIVILEGED') {
214+
this.intents = GATEWAY_INTENTS_ALL_UNPRIVILEGED;
212215
} else {
213216
const intents = (Array.isArray(options.intents)) ? options.intents : [options.intents];
214217
for (let intent of intents) {

0 commit comments

Comments
 (0)