mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Add new ESLint rules
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
"node": true
|
"node": true
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"no-await-in-loop": "warn",
|
||||||
|
"no-compare-neg-zero": "error",
|
||||||
"no-extra-parens": ["warn", "all", {
|
"no-extra-parens": ["warn", "all", {
|
||||||
"nestedBinaryExpressions": false
|
"nestedBinaryExpressions": false
|
||||||
}],
|
}],
|
||||||
@@ -53,6 +55,7 @@
|
|||||||
"no-new": "error",
|
"no-new": "error",
|
||||||
"no-octal-escape": "error",
|
"no-octal-escape": "error",
|
||||||
"no-return-assign": "error",
|
"no-return-assign": "error",
|
||||||
|
"no-return-await": "error",
|
||||||
"no-self-compare": "error",
|
"no-self-compare": "error",
|
||||||
"no-sequences": "error",
|
"no-sequences": "error",
|
||||||
"no-throw-literal": "error",
|
"no-throw-literal": "error",
|
||||||
@@ -61,8 +64,11 @@
|
|||||||
"no-useless-call": "error",
|
"no-useless-call": "error",
|
||||||
"no-useless-concat": "error",
|
"no-useless-concat": "error",
|
||||||
"no-useless-escape": "error",
|
"no-useless-escape": "error",
|
||||||
|
"no-useless-return": "error",
|
||||||
"no-void": "error",
|
"no-void": "error",
|
||||||
"no-warning-comments": "warn",
|
"no-warning-comments": "warn",
|
||||||
|
"prefer-promise-reject-errors": "error",
|
||||||
|
"require-await": "warn",
|
||||||
"wrap-iife": "error",
|
"wrap-iife": "error",
|
||||||
"yoda": "error",
|
"yoda": "error",
|
||||||
|
|
||||||
@@ -79,6 +85,7 @@
|
|||||||
"array-bracket-spacing": "error",
|
"array-bracket-spacing": "error",
|
||||||
"block-spacing": "error",
|
"block-spacing": "error",
|
||||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||||
|
"capitalized-comments": ["error", "always", { "ignoreConsecutiveComments": true }],
|
||||||
"comma-dangle": ["error", "always-multiline"],
|
"comma-dangle": ["error", "always-multiline"],
|
||||||
"comma-spacing": "error",
|
"comma-spacing": "error",
|
||||||
"comma-style": "error",
|
"comma-style": "error",
|
||||||
@@ -107,6 +114,7 @@
|
|||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"no-unneeded-ternary": "error",
|
"no-unneeded-ternary": "error",
|
||||||
"no-whitespace-before-property": "error",
|
"no-whitespace-before-property": "error",
|
||||||
|
"nonblock-statement-body-position": "error",
|
||||||
"object-curly-spacing": ["error", "always"],
|
"object-curly-spacing": ["error", "always"],
|
||||||
"operator-assignment": "error",
|
"operator-assignment": "error",
|
||||||
"operator-linebreak": ["error", "after"],
|
"operator-linebreak": ["error", "after"],
|
||||||
@@ -121,6 +129,7 @@
|
|||||||
"space-infix-ops": "error",
|
"space-infix-ops": "error",
|
||||||
"space-unary-ops": "error",
|
"space-unary-ops": "error",
|
||||||
"spaced-comment": "error",
|
"spaced-comment": "error",
|
||||||
|
"template-tag-spacing": "error",
|
||||||
"unicode-bom": "error",
|
"unicode-bom": "error",
|
||||||
|
|
||||||
"arrow-body-style": "error",
|
"arrow-body-style": "error",
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ class GuildDeleteAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (guild.available && data.unavailable) {
|
if (guild.available && data.unavailable) {
|
||||||
// guild is unavailable
|
// Guild is unavailable
|
||||||
guild.available = false;
|
guild.available = false;
|
||||||
client.emit(Constants.Events.GUILD_UNAVAILABLE, guild);
|
client.emit(Constants.Events.GUILD_UNAVAILABLE, guild);
|
||||||
|
|
||||||
// stops the GuildDelete packet thinking a guild was actually deleted,
|
// Stops the GuildDelete packet thinking a guild was actually deleted,
|
||||||
// handles emitting of event itself
|
// handles emitting of event itself
|
||||||
return {
|
return {
|
||||||
guild: null,
|
guild: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete guild
|
// Delete guild
|
||||||
client.guilds.delete(guild.id);
|
client.guilds.delete(guild.id);
|
||||||
this.deleted.set(guild.id, guild);
|
this.deleted.set(guild.id, guild);
|
||||||
this.scheduleForDeletion(guild.id);
|
this.scheduleForDeletion(guild.id);
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ class RESTMethods {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// untested but probably will work
|
// Untested but probably will work
|
||||||
deleteGuild(guild) {
|
deleteGuild(guild) {
|
||||||
return this.rest.makeRequest('del', Constants.Endpoints.guild(guild.id), true).then(() =>
|
return this.rest.makeRequest('del', Constants.Endpoints.guild(guild.id), true).then(() =>
|
||||||
this.client.actions.GuildDelete.handle({ id: guild.id }).guild
|
this.client.actions.GuildDelete.handle({ id: guild.id }).guild
|
||||||
@@ -486,7 +486,7 @@ class RESTMethods {
|
|||||||
if (data.roles) data.roles = data.roles.map(role => role instanceof Role ? role.id : role);
|
if (data.roles) data.roles = data.roles.map(role => role instanceof Role ? role.id : role);
|
||||||
|
|
||||||
let endpoint = Constants.Endpoints.guildMember(member.guild.id, member.id);
|
let endpoint = Constants.Endpoints.guildMember(member.guild.id, member.id);
|
||||||
// fix your endpoints, discord ;-;
|
// Fix your endpoints, discord ;-;
|
||||||
if (member.id === this.client.user.id) {
|
if (member.id === this.client.user.id) {
|
||||||
const keys = Object.keys(data);
|
const keys = Object.keys(data);
|
||||||
if (keys.length === 1 && keys[0] === 'nick') {
|
if (keys.length === 1 && keys[0] === 'nick') {
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ class RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Attempts to get this RequestHandler to process its current queue
|
* Attempts to get this RequestHandler to process its current queue
|
||||||
*/
|
*/
|
||||||
handle() {
|
handle() {} // eslint-disable-line no-empty-function
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RequestHandler;
|
module.exports = RequestHandler;
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ class VoiceBroadcast extends VolumeInterface {
|
|||||||
|
|
||||||
_startPlaying() {
|
_startPlaying() {
|
||||||
if (this.tickInterval) clearInterval(this.tickInterval);
|
if (this.tickInterval) clearInterval(this.tickInterval);
|
||||||
|
// Old code?
|
||||||
// this.tickInterval = this.client.setInterval(this.tick.bind(this), 20);
|
// this.tickInterval = this.client.setInterval(this.tick.bind(this), 20);
|
||||||
this._startTime = Date.now();
|
this._startTime = Date.now();
|
||||||
this._count = 0;
|
this._count = 0;
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ class StreamDispatcher extends VolumeInterface {
|
|||||||
|
|
||||||
if (this.paused) {
|
if (this.paused) {
|
||||||
this.setSpeaking(false);
|
this.setSpeaking(false);
|
||||||
|
// Old code?
|
||||||
// data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
|
// data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
|
||||||
data.pausedTime += data.length * 10;
|
data.pausedTime += data.length * 10;
|
||||||
this.player.voiceConnection.voiceManager.client.setTimeout(() => this.process(), data.length * 10);
|
this.player.voiceConnection.voiceManager.client.setTimeout(() => this.process(), data.length * 10);
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ class BaseOpus {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {} // eslint-disable-line no-empty-function
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = BaseOpus;
|
module.exports = BaseOpus;
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ class VoiceReadable extends Readable {
|
|||||||
this.open = true;
|
this.open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_read() {
|
_read() {} // eslint-disable-line no-empty-function
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_push(d) {
|
_push(d) {
|
||||||
if (this.open) this.push(d);
|
if (this.open) this.push(d);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class VoiceReceiver extends EventEmitter {
|
|||||||
constructor(connection) {
|
constructor(connection) {
|
||||||
super();
|
super();
|
||||||
/*
|
/*
|
||||||
need a queue because we don't get the ssrc of the user speaking until after the first few packets,
|
Need a queue because we don't get the ssrc of the user speaking until after the first few packets,
|
||||||
so we queue up unknown SSRCs until they become known, then empty the queue.
|
so we queue up unknown SSRCs until they become known, then empty the queue.
|
||||||
*/
|
*/
|
||||||
this.queues = new Map();
|
this.queues = new Map();
|
||||||
@@ -68,7 +68,6 @@ class VoiceReceiver extends EventEmitter {
|
|||||||
if (!this.destroyed) return;
|
if (!this.destroyed) return;
|
||||||
this.voiceConnection.sockets.udp.socket.on('message', this._listener);
|
this.voiceConnection.sockets.udp.socket.on('message', this._listener);
|
||||||
this.destroyed = false;
|
this.destroyed = false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ class GuildCreateHandler extends AbstractHandler {
|
|||||||
const guild = client.guilds.get(data.id);
|
const guild = client.guilds.get(data.id);
|
||||||
if (guild) {
|
if (guild) {
|
||||||
if (!guild.available && !data.unavailable) {
|
if (!guild.available && !data.unavailable) {
|
||||||
// a newly available guild
|
// A newly available guild
|
||||||
guild.setup(data);
|
guild.setup(data);
|
||||||
this.packetManager.ws.checkIfReady();
|
this.packetManager.ws.checkIfReady();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// a new guild
|
// A new guild
|
||||||
client.dataManager.newGuild(data);
|
client.dataManager.newGuild(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,22 @@ class GuildEmojisUpdate extends AbstractHandler {
|
|||||||
const deletions = mappify(guild.emojis.entries());
|
const deletions = mappify(guild.emojis.entries());
|
||||||
|
|
||||||
for (const emoji of data.emojis) {
|
for (const emoji of data.emojis) {
|
||||||
// determine type of emoji event
|
// Determine type of emoji event
|
||||||
const cachedEmoji = guild.emojis.get(emoji.id);
|
const cachedEmoji = guild.emojis.get(emoji.id);
|
||||||
if (cachedEmoji) {
|
if (cachedEmoji) {
|
||||||
deletions.delete(emoji.id);
|
deletions.delete(emoji.id);
|
||||||
if (!cachedEmoji.equals(emoji, true)) {
|
if (!cachedEmoji.equals(emoji, true)) {
|
||||||
// emoji updated
|
// Emoji updated
|
||||||
client.actions.GuildEmojiUpdate.handle(cachedEmoji, emoji);
|
client.actions.GuildEmojiUpdate.handle(cachedEmoji, emoji);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// emoji added
|
// Emoji added
|
||||||
client.actions.GuildEmojiCreate.handle(guild, emoji);
|
client.actions.GuildEmojiCreate.handle(guild, emoji);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const emoji of deletions.values()) {
|
for (const emoji of deletions.values()) {
|
||||||
// emoji deleted
|
// Emoji deleted
|
||||||
client.actions.GuildEmojiDelete.handle(emoji);
|
client.actions.GuildEmojiDelete.handle(emoji);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const AbstractHandler = require('./AbstractHandler');
|
const AbstractHandler = require('./AbstractHandler');
|
||||||
const Constants = require('../../../../util/Constants');
|
const Constants = require('../../../../util/Constants');
|
||||||
// uncomment in v12
|
// Uncomment in v12
|
||||||
// const Collection = require('../../../../util/Collection');
|
// const Collection = require('../../../../util/Collection');
|
||||||
|
|
||||||
class GuildMembersChunkHandler extends AbstractHandler {
|
class GuildMembersChunkHandler extends AbstractHandler {
|
||||||
@@ -10,7 +10,7 @@ class GuildMembersChunkHandler extends AbstractHandler {
|
|||||||
const guild = client.guilds.get(data.guild_id);
|
const guild = client.guilds.get(data.guild_id);
|
||||||
if (!guild) return;
|
if (!guild) return;
|
||||||
|
|
||||||
// uncomment in v12
|
// Uncomment in v12
|
||||||
// const members = new Collection();
|
// const members = new Collection();
|
||||||
//
|
//
|
||||||
// for (const member of data.members) members.set(member.id, guild._addMember(member, false));
|
// for (const member of data.members) members.set(member.id, guild._addMember(member, false));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class PresenceUpdateHandler extends AbstractHandler {
|
|||||||
let user = client.users.get(data.user.id);
|
let user = client.users.get(data.user.id);
|
||||||
const guild = client.guilds.get(data.guild_id);
|
const guild = client.guilds.get(data.guild_id);
|
||||||
|
|
||||||
// step 1
|
// Step 1
|
||||||
if (!user) {
|
if (!user) {
|
||||||
if (data.user.username) {
|
if (data.user.username) {
|
||||||
user = client.dataManager.newUser(data.user);
|
user = client.dataManager.newUser(data.user);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class VoiceStateUpdateHandler extends AbstractHandler {
|
|||||||
member.voiceChannel.members.delete(oldVoiceChannelMember.id);
|
member.voiceChannel.members.delete(oldVoiceChannelMember.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the member left the voice channel, unset their speaking property
|
// If the member left the voice channel, unset their speaking property
|
||||||
if (!data.channel_id) member.speaking = null;
|
if (!data.channel_id) member.speaking = null;
|
||||||
|
|
||||||
if (member.user.id === client.user.id && data.channel_id) {
|
if (member.user.id === client.user.id && data.channel_id) {
|
||||||
|
|||||||
@@ -37,25 +37,26 @@ class DMChannel extends Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||||
send() { return; }
|
/* eslint-disable no-empty-function */
|
||||||
sendMessage() { return; }
|
send() {}
|
||||||
sendEmbed() { return; }
|
sendMessage() {}
|
||||||
sendFile() { return; }
|
sendEmbed() {}
|
||||||
sendFiles() { return; }
|
sendFile() {}
|
||||||
sendCode() { return; }
|
sendFiles() {}
|
||||||
fetchMessage() { return; }
|
sendCode() {}
|
||||||
fetchMessages() { return; }
|
fetchMessage() {}
|
||||||
fetchPinnedMessages() { return; }
|
fetchMessages() {}
|
||||||
search() { return; }
|
fetchPinnedMessages() {}
|
||||||
startTyping() { return; }
|
search() {}
|
||||||
stopTyping() { return; }
|
startTyping() {}
|
||||||
get typing() { return; }
|
stopTyping() {}
|
||||||
get typingCount() { return; }
|
get typing() {}
|
||||||
createCollector() { return; }
|
get typingCount() {}
|
||||||
awaitMessages() { return; }
|
createCollector() {}
|
||||||
// doesn't work on DM channels; bulkDelete() { return; }
|
awaitMessages() {}
|
||||||
acknowledge() { return; }
|
// Doesn't work on DM channels; bulkDelete() {}
|
||||||
_cacheMessage() { return; }
|
acknowledge() {}
|
||||||
|
_cacheMessage() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(DMChannel, true, ['bulkDelete']);
|
TextBasedChannel.applyToClass(DMChannel, true, ['bulkDelete']);
|
||||||
|
|||||||
@@ -153,25 +153,26 @@ class GroupDMChannel extends Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||||
send() { return; }
|
/* eslint-disable no-empty-function */
|
||||||
sendMessage() { return; }
|
send() {}
|
||||||
sendEmbed() { return; }
|
sendMessage() {}
|
||||||
sendFile() { return; }
|
sendEmbed() {}
|
||||||
sendFiles() { return; }
|
sendFile() {}
|
||||||
sendCode() { return; }
|
sendFiles() {}
|
||||||
fetchMessage() { return; }
|
sendCode() {}
|
||||||
fetchMessages() { return; }
|
fetchMessage() {}
|
||||||
fetchPinnedMessages() { return; }
|
fetchMessages() {}
|
||||||
search() { return; }
|
fetchPinnedMessages() {}
|
||||||
startTyping() { return; }
|
search() {}
|
||||||
stopTyping() { return; }
|
startTyping() {}
|
||||||
get typing() { return; }
|
stopTyping() {}
|
||||||
get typingCount() { return; }
|
get typing() {}
|
||||||
createCollector() { return; }
|
get typingCount() {}
|
||||||
awaitMessages() { return; }
|
createCollector() {}
|
||||||
// doesn't work on group DMs; bulkDelete() { return; }
|
awaitMessages() {}
|
||||||
acknowledge() { return; }
|
// Doesn't work on group DMs; bulkDelete() {}
|
||||||
_cacheMessage() { return; }
|
acknowledge() {}
|
||||||
|
_cacheMessage() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(GroupDMChannel, true, ['bulkDelete']);
|
TextBasedChannel.applyToClass(GroupDMChannel, true, ['bulkDelete']);
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ class Guild {
|
|||||||
fetchMembers(query = '', limit = 0) {
|
fetchMembers(query = '', limit = 0) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.memberCount === this.members.size) {
|
if (this.memberCount === this.members.size) {
|
||||||
// uncomment in v12
|
// Uncomment in v12
|
||||||
// resolve(this.members)
|
// resolve(this.members)
|
||||||
resolve(this);
|
resolve(this);
|
||||||
return;
|
return;
|
||||||
@@ -388,10 +388,9 @@ class Guild {
|
|||||||
if (guild.id !== this.id) return;
|
if (guild.id !== this.id) return;
|
||||||
if (this.memberCount === this.members.size || members.length < 1000) {
|
if (this.memberCount === this.members.size || members.length < 1000) {
|
||||||
this.client.removeListener(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
|
this.client.removeListener(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
|
||||||
// uncomment in v12
|
// Uncomment in v12
|
||||||
// resolve(this.members)
|
// resolve(this.members)
|
||||||
resolve(this);
|
resolve(this);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.client.on(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
|
this.client.on(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
|
||||||
|
|||||||
@@ -501,11 +501,12 @@ class GuildMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||||
send() { return; }
|
/* eslint-disable no-empty-function */
|
||||||
sendMessage() { return; }
|
send() {}
|
||||||
sendEmbed() { return; }
|
sendMessage() {}
|
||||||
sendFile() { return; }
|
sendEmbed() {}
|
||||||
sendCode() { return; }
|
sendFile() {}
|
||||||
|
sendCode() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(GuildMember);
|
TextBasedChannel.applyToClass(GuildMember);
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class MessageCollector extends EventEmitter {
|
|||||||
|
|
||||||
const onEnd = (...args) => {
|
const onEnd = (...args) => {
|
||||||
cleanup();
|
cleanup();
|
||||||
reject(...args);
|
reject(...args); // eslint-disable-line prefer-promise-reject-errors
|
||||||
};
|
};
|
||||||
|
|
||||||
this.once('message', onMessage);
|
this.once('message', onMessage);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class MessageReaction {
|
|||||||
*/
|
*/
|
||||||
get emoji() {
|
get emoji() {
|
||||||
if (this._emoji instanceof Emoji) return this._emoji;
|
if (this._emoji instanceof Emoji) return this._emoji;
|
||||||
// check to see if the emoji has become known to the client
|
// Check to see if the emoji has become known to the client
|
||||||
if (this._emoji.id) {
|
if (this._emoji.id) {
|
||||||
const emojis = this.message.client.emojis;
|
const emojis = this.message.client.emojis;
|
||||||
if (emojis.has(this._emoji.id)) {
|
if (emojis.has(this._emoji.id)) {
|
||||||
@@ -62,7 +62,7 @@ class MessageReaction {
|
|||||||
remove(user = this.message.client.user) {
|
remove(user = this.message.client.user) {
|
||||||
const message = this.message;
|
const message = this.message;
|
||||||
user = this.message.client.resolver.resolveUserID(user);
|
user = this.message.client.resolver.resolveUserID(user);
|
||||||
if (!user) return Promise.reject('Couldn\'t resolve the user ID to remove from the reaction.');
|
if (!user) return Promise.reject(new Error('Couldn\'t resolve the user ID to remove from the reaction.'));
|
||||||
return message.client.rest.methods.removeMessageReaction(
|
return message.client.rest.methods.removeMessageReaction(
|
||||||
message, this.emoji.identifier, user
|
message, this.emoji.identifier, user
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class OAuth2Application {
|
|||||||
this.flags = data.flags;
|
this.flags = data.flags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* oauth2 secret for the app
|
* OAuth2 secret for the application
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.secret = data.secret;
|
this.secret = data.secret;
|
||||||
|
|||||||
@@ -73,25 +73,26 @@ class TextChannel extends GuildChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||||
send() { return; }
|
/* eslint-disable no-empty-function */
|
||||||
sendMessage() { return; }
|
send() {}
|
||||||
sendEmbed() { return; }
|
sendMessage() {}
|
||||||
sendFile() { return; }
|
sendEmbed() {}
|
||||||
sendFiles() { return; }
|
sendFile() {}
|
||||||
sendCode() { return; }
|
sendFiles() {}
|
||||||
fetchMessage() { return; }
|
sendCode() {}
|
||||||
fetchMessages() { return; }
|
fetchMessage() {}
|
||||||
fetchPinnedMessages() { return; }
|
fetchMessages() {}
|
||||||
search() { return; }
|
fetchPinnedMessages() {}
|
||||||
startTyping() { return; }
|
search() {}
|
||||||
stopTyping() { return; }
|
startTyping() {}
|
||||||
get typing() { return; }
|
stopTyping() {}
|
||||||
get typingCount() { return; }
|
get typing() {}
|
||||||
createCollector() { return; }
|
get typingCount() {}
|
||||||
awaitMessages() { return; }
|
createCollector() {}
|
||||||
bulkDelete() { return; }
|
awaitMessages() {}
|
||||||
acknowledge() { return; }
|
bulkDelete() {}
|
||||||
_cacheMessage() { return; }
|
acknowledge() {}
|
||||||
|
_cacheMessage() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(TextChannel, true);
|
TextBasedChannel.applyToClass(TextChannel, true);
|
||||||
|
|||||||
@@ -280,11 +280,12 @@ class User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||||
send() { return; }
|
/* eslint-disable no-empty-function */
|
||||||
sendMessage() { return; }
|
send() {}
|
||||||
sendEmbed() { return; }
|
sendMessage() {}
|
||||||
sendFile() { return; }
|
sendEmbed() {}
|
||||||
sendCode() { return; }
|
sendFile() {}
|
||||||
|
sendCode() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(User);
|
TextBasedChannel.applyToClass(User);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class UserConnection {
|
|||||||
this.revoked = data.revoked;
|
this.revoked = data.revoked;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* an array of partial server integrations (not yet implemented in this lib)
|
* Partial server integrations (not yet implemented)
|
||||||
* @type {Object[]}
|
* @type {Object[]}
|
||||||
*/
|
*/
|
||||||
this.integrations = data.integrations;
|
this.integrations = data.integrations;
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ class TextBasedChannel {
|
|||||||
|
|
||||||
if (options.embed && options.embed.file) options.file = options.embed.file;
|
if (options.embed && options.embed.file) options.file = options.embed.file;
|
||||||
|
|
||||||
// backward compat
|
|
||||||
if (options.file) {
|
if (options.file) {
|
||||||
if (options.files) options.files.push(options.file);
|
if (options.files) options.files.push(options.file);
|
||||||
else options.files = [options.file];
|
else options.files = [options.file];
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ const PROTOCOL_VERSION = exports.PROTOCOL_VERSION = 6;
|
|||||||
const HOST = exports.HOST = `https://discordapp.com`;
|
const HOST = exports.HOST = `https://discordapp.com`;
|
||||||
const API = exports.API = `${HOST}/api/v${PROTOCOL_VERSION}`;
|
const API = exports.API = `${HOST}/api/v${PROTOCOL_VERSION}`;
|
||||||
const Endpoints = exports.Endpoints = {
|
const Endpoints = exports.Endpoints = {
|
||||||
// general
|
// General
|
||||||
login: `${API}/auth/login`,
|
login: `${API}/auth/login`,
|
||||||
logout: `${API}/auth/logout`,
|
logout: `${API}/auth/logout`,
|
||||||
gateway: `${API}/gateway`,
|
gateway: `${API}/gateway`,
|
||||||
@@ -92,7 +92,7 @@ const Endpoints = exports.Endpoints = {
|
|||||||
assets: asset => `${HOST}/assets/${asset}`,
|
assets: asset => `${HOST}/assets/${asset}`,
|
||||||
CDN: 'https://cdn.discordapp.com',
|
CDN: 'https://cdn.discordapp.com',
|
||||||
|
|
||||||
// users
|
// Users
|
||||||
user: userID => `${API}/users/${userID}`,
|
user: userID => `${API}/users/${userID}`,
|
||||||
userChannels: userID => `${Endpoints.user(userID)}/channels`,
|
userChannels: userID => `${Endpoints.user(userID)}/channels`,
|
||||||
userProfile: userID => `${Endpoints.user(userID)}/profile`,
|
userProfile: userID => `${Endpoints.user(userID)}/profile`,
|
||||||
@@ -110,7 +110,7 @@ const Endpoints = exports.Endpoints = {
|
|||||||
|
|
||||||
voiceRegions: `${API}/voice/regions`,
|
voiceRegions: `${API}/voice/regions`,
|
||||||
|
|
||||||
// guilds
|
// Guilds
|
||||||
guilds: `${API}/guilds`,
|
guilds: `${API}/guilds`,
|
||||||
guild: guildID => `${Endpoints.guilds}/${guildID}`,
|
guild: guildID => `${Endpoints.guilds}/${guildID}`,
|
||||||
guildIcon: (guildID, hash) => `${Endpoints.CDN}/icons/${guildID}/${hash}.jpg`,
|
guildIcon: (guildID, hash) => `${Endpoints.CDN}/icons/${guildID}/${hash}.jpg`,
|
||||||
@@ -132,7 +132,7 @@ const Endpoints = exports.Endpoints = {
|
|||||||
guildSearch: guildID => `${Endpoints.guild(guildID)}/messages/search`,
|
guildSearch: guildID => `${Endpoints.guild(guildID)}/messages/search`,
|
||||||
guildVoiceRegions: guildID => `${Endpoints.guild(guildID)}/regions`,
|
guildVoiceRegions: guildID => `${Endpoints.guild(guildID)}/regions`,
|
||||||
|
|
||||||
// channels
|
// Channels
|
||||||
channels: `${API}/channels`,
|
channels: `${API}/channels`,
|
||||||
channel: channelID => `${Endpoints.channels}/${channelID}`,
|
channel: channelID => `${Endpoints.channels}/${channelID}`,
|
||||||
channelMessages: channelID => `${Endpoints.channel(channelID)}/messages`,
|
channelMessages: channelID => `${Endpoints.channel(channelID)}/messages`,
|
||||||
@@ -145,7 +145,7 @@ const Endpoints = exports.Endpoints = {
|
|||||||
|
|
||||||
dmChannelRecipient: (channelID, recipientID) => `${Endpoints.channel(channelID)}/recipients/${recipientID}`,
|
dmChannelRecipient: (channelID, recipientID) => `${Endpoints.channel(channelID)}/recipients/${recipientID}`,
|
||||||
|
|
||||||
// message reactions
|
// Message reactions
|
||||||
messageReactions: (channelID, messageID) => `${Endpoints.channelMessage(channelID, messageID)}/reactions`,
|
messageReactions: (channelID, messageID) => `${Endpoints.channelMessage(channelID, messageID)}/reactions`,
|
||||||
messageReaction:
|
messageReaction:
|
||||||
(channel, msg, emoji, limit) =>
|
(channel, msg, emoji, limit) =>
|
||||||
@@ -156,14 +156,14 @@ const Endpoints = exports.Endpoints = {
|
|||||||
userMessageReaction: (channel, msg, emoji, limit, id) =>
|
userMessageReaction: (channel, msg, emoji, limit, id) =>
|
||||||
`${Endpoints.messageReaction(channel, msg, emoji, limit)}/${id}`,
|
`${Endpoints.messageReaction(channel, msg, emoji, limit)}/${id}`,
|
||||||
|
|
||||||
// webhooks
|
// Webhooks
|
||||||
webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`,
|
webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`,
|
||||||
|
|
||||||
// oauth
|
// OAuth
|
||||||
oauth2Application: appID => `${API}/oauth2/applications/${appID}`,
|
oauth2Application: appID => `${API}/oauth2/applications/${appID}`,
|
||||||
getApp: id => `${API}/oauth2/authorize?client_id=${id}`,
|
getApp: id => `${API}/oauth2/authorize?client_id=${id}`,
|
||||||
|
|
||||||
// emoji
|
// Emoji
|
||||||
emoji: emojiID => `${Endpoints.CDN}/emojis/${emojiID}.png`,
|
emoji: emojiID => `${Endpoints.CDN}/emojis/${emojiID}.png`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user