├── .gitattributes ├── LICENSE ├── README.md ├── index.js ├── node_modules ├── async-limiter │ ├── .eslintignore │ ├── .nycrc │ ├── .travis.yml │ ├── LICENSE │ ├── index.js │ ├── package.json │ └── readme.md ├── discord.js │ ├── .tern-project │ ├── LICENSE │ ├── README.md │ ├── browser.js │ ├── package.json │ ├── src │ │ ├── client │ │ │ ├── Client.js │ │ │ ├── ClientDataManager.js │ │ │ ├── ClientDataResolver.js │ │ │ ├── ClientManager.js │ │ │ ├── WebhookClient.js │ │ │ ├── actions │ │ │ │ ├── Action.js │ │ │ │ ├── ActionsManager.js │ │ │ │ ├── ChannelCreate.js │ │ │ │ ├── ChannelDelete.js │ │ │ │ ├── ChannelUpdate.js │ │ │ │ ├── GuildBanRemove.js │ │ │ │ ├── GuildChannelsPositionUpdate.js │ │ │ │ ├── GuildDelete.js │ │ │ │ ├── GuildEmojiCreate.js │ │ │ │ ├── GuildEmojiDelete.js │ │ │ │ ├── GuildEmojiUpdate.js │ │ │ │ ├── GuildEmojisUpdate.js │ │ │ │ ├── GuildMemberGet.js │ │ │ │ ├── GuildMemberRemove.js │ │ │ │ ├── GuildRoleCreate.js │ │ │ │ ├── GuildRoleDelete.js │ │ │ │ ├── GuildRoleUpdate.js │ │ │ │ ├── GuildRolesPositionUpdate.js │ │ │ │ ├── GuildSync.js │ │ │ │ ├── GuildUpdate.js │ │ │ │ ├── MessageCreate.js │ │ │ │ ├── MessageDelete.js │ │ │ │ ├── MessageDeleteBulk.js │ │ │ │ ├── MessageReactionAdd.js │ │ │ │ ├── MessageReactionRemove.js │ │ │ │ ├── MessageReactionRemoveAll.js │ │ │ │ ├── MessageUpdate.js │ │ │ │ ├── UserGet.js │ │ │ │ ├── UserNoteUpdate.js │ │ │ │ └── UserUpdate.js │ │ │ ├── rest │ │ │ │ ├── APIRequest.js │ │ │ │ ├── DiscordAPIError.js │ │ │ │ ├── RESTManager.js │ │ │ │ ├── RESTMethods.js │ │ │ │ ├── RequestHandlers │ │ │ │ │ ├── Burst.js │ │ │ │ │ ├── RequestHandler.js │ │ │ │ │ └── Sequential.js │ │ │ │ └── UserAgentManager.js │ │ │ ├── voice │ │ │ │ ├── ClientVoiceManager.js │ │ │ │ ├── VoiceBroadcast.js │ │ │ │ ├── VoiceConnection.js │ │ │ │ ├── VoiceUDPClient.js │ │ │ │ ├── VoiceWebSocket.js │ │ │ │ ├── dispatcher │ │ │ │ │ └── StreamDispatcher.js │ │ │ │ ├── opus │ │ │ │ │ ├── BaseOpusEngine.js │ │ │ │ │ ├── NodeOpusEngine.js │ │ │ │ │ ├── OpusEngineList.js │ │ │ │ │ └── OpusScriptEngine.js │ │ │ │ ├── player │ │ │ │ │ └── AudioPlayer.js │ │ │ │ ├── receiver │ │ │ │ │ ├── VoiceReadable.js │ │ │ │ │ └── VoiceReceiver.js │ │ │ │ └── util │ │ │ │ │ ├── SecretKey.js │ │ │ │ │ ├── Secretbox.js │ │ │ │ │ └── VolumeInterface.js │ │ │ └── websocket │ │ │ │ ├── WebSocketConnection.js │ │ │ │ ├── WebSocketManager.js │ │ │ │ └── packets │ │ │ │ ├── WebSocketPacketManager.js │ │ │ │ └── handlers │ │ │ │ ├── AbstractHandler.js │ │ │ │ ├── ChannelCreate.js │ │ │ │ ├── ChannelDelete.js │ │ │ │ ├── ChannelPinsUpdate.js │ │ │ │ ├── ChannelUpdate.js │ │ │ │ ├── GuildBanAdd.js │ │ │ │ ├── GuildBanRemove.js │ │ │ │ ├── GuildCreate.js │ │ │ │ ├── GuildDelete.js │ │ │ │ ├── GuildEmojisUpdate.js │ │ │ │ ├── GuildIntegrationsUpdate.js │ │ │ │ ├── GuildMemberAdd.js │ │ │ │ ├── GuildMemberRemove.js │ │ │ │ ├── GuildMemberUpdate.js │ │ │ │ ├── GuildMembersChunk.js │ │ │ │ ├── GuildRoleCreate.js │ │ │ │ ├── GuildRoleDelete.js │ │ │ │ ├── GuildRoleUpdate.js │ │ │ │ ├── GuildSync.js │ │ │ │ ├── GuildUpdate.js │ │ │ │ ├── MessageCreate.js │ │ │ │ ├── MessageDelete.js │ │ │ │ ├── MessageDeleteBulk.js │ │ │ │ ├── MessageReactionAdd.js │ │ │ │ ├── MessageReactionRemove.js │ │ │ │ ├── MessageReactionRemoveAll.js │ │ │ │ ├── MessageUpdate.js │ │ │ │ ├── PresenceUpdate.js │ │ │ │ ├── Ready.js │ │ │ │ ├── RelationshipAdd.js │ │ │ │ ├── RelationshipRemove.js │ │ │ │ ├── Resumed.js │ │ │ │ ├── TypingStart.js │ │ │ │ ├── UserGuildSettingsUpdate.js │ │ │ │ ├── UserNoteUpdate.js │ │ │ │ ├── UserSettingsUpdate.js │ │ │ │ ├── UserUpdate.js │ │ │ │ ├── VoiceServerUpdate.js │ │ │ │ ├── VoiceStateUpdate.js │ │ │ │ └── WebhooksUpdate.js │ │ ├── index.js │ │ ├── sharding │ │ │ ├── Shard.js │ │ │ ├── ShardClientUtil.js │ │ │ └── ShardingManager.js │ │ ├── structures │ │ │ ├── Attachment.js │ │ │ ├── CategoryChannel.js │ │ │ ├── Channel.js │ │ │ ├── ClientUser.js │ │ │ ├── ClientUserChannelOverride.js │ │ │ ├── ClientUserGuildSettings.js │ │ │ ├── ClientUserSettings.js │ │ │ ├── DMChannel.js │ │ │ ├── Emoji.js │ │ │ ├── GroupDMChannel.js │ │ │ ├── Guild.js │ │ │ ├── GuildAuditLogs.js │ │ │ ├── GuildChannel.js │ │ │ ├── GuildMember.js │ │ │ ├── Invite.js │ │ │ ├── Message.js │ │ │ ├── MessageAttachment.js │ │ │ ├── MessageCollector.js │ │ │ ├── MessageEmbed.js │ │ │ ├── MessageMentions.js │ │ │ ├── MessageReaction.js │ │ │ ├── NewsChannel.js │ │ │ ├── OAuth2Application.js │ │ │ ├── PartialGuild.js │ │ │ ├── PartialGuildChannel.js │ │ │ ├── PermissionOverwrites.js │ │ │ ├── Presence.js │ │ │ ├── ReactionCollector.js │ │ │ ├── ReactionEmoji.js │ │ │ ├── RichEmbed.js │ │ │ ├── Role.js │ │ │ ├── StoreChannel.js │ │ │ ├── TextChannel.js │ │ │ ├── User.js │ │ │ ├── UserConnection.js │ │ │ ├── UserProfile.js │ │ │ ├── VoiceChannel.js │ │ │ ├── VoiceRegion.js │ │ │ ├── Webhook.js │ │ │ ├── interfaces │ │ │ │ ├── Collector.js │ │ │ │ └── TextBasedChannel.js │ │ │ └── shared │ │ │ │ └── resolvePermissions.js │ │ └── util │ │ │ ├── Collection.js │ │ │ ├── Constants.js │ │ │ ├── Permissions.js │ │ │ ├── Snowflake.js │ │ │ └── Util.js │ └── typings │ │ ├── discord.js-test.ts │ │ └── index.d.ts ├── long │ ├── LICENSE │ ├── README.md │ ├── dist │ │ ├── long.js │ │ └── long.js.map │ ├── index.js │ ├── package.json │ └── src │ │ └── long.js ├── prism-media │ ├── .eslintrc.json │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── output.opus │ ├── package.json │ ├── src │ │ ├── Prism.js │ │ ├── index.js │ │ ├── opus │ │ │ └── OggOpus.js │ │ ├── transcoders │ │ │ ├── MediaTranscoder.js │ │ │ └── ffmpeg │ │ │ │ ├── Ffmpeg.js │ │ │ │ └── FfmpegProcess.js │ │ └── util │ │ │ └── Constants.js │ └── test │ │ ├── main.js │ │ └── test.js ├── snekfetch │ ├── .eslintrc.json │ ├── .github │ │ ├── ISSUE_TEMPLATE.md │ │ └── PULL_REQUEST_TEMPLATE.md │ ├── .travis.yml │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── browser.js │ ├── docs.js │ ├── esm.mjs │ ├── index.js │ ├── package.json │ ├── scripts │ │ ├── travis-deploy.sh │ │ └── travis-test.sh │ ├── src │ │ ├── browser.js │ │ ├── index.js │ │ ├── node │ │ │ ├── FormData.js │ │ │ ├── index.js │ │ │ ├── mime.js │ │ │ ├── mimeOfBuffer.js │ │ │ ├── mimes.json │ │ │ └── transports │ │ │ │ ├── ResponseStream.js │ │ │ │ ├── file.js │ │ │ │ └── http2.js │ │ └── qs_mock.js │ ├── sync.js │ ├── test │ │ ├── .eslintrc.json │ │ ├── browser │ │ │ ├── http1.test.js │ │ │ ├── http2.test.js │ │ │ └── main.js │ │ ├── interop.js │ │ ├── main.js │ │ ├── node │ │ │ ├── file.test.js │ │ │ ├── http1.test.js │ │ │ ├── http2.test.js.disabled │ │ │ ├── main.js │ │ │ ├── sync.test.js │ │ │ └── util.test.js │ │ └── server.js │ └── webpack.config.js ├── tweetnacl │ ├── AUTHORS.md │ ├── CHANGELOG.md │ ├── LICENSE │ ├── PULL_REQUEST_TEMPLATE.md │ ├── README.md │ ├── nacl-fast.js │ ├── nacl-fast.min.js │ ├── nacl.d.ts │ ├── nacl.js │ ├── nacl.min.js │ └── package.json └── ws │ ├── LICENSE │ ├── README.md │ ├── browser.js │ ├── index.js │ ├── lib │ ├── buffer-util.js │ ├── constants.js │ ├── event-target.js │ ├── extension.js │ ├── permessage-deflate.js │ ├── receiver.js │ ├── sender.js │ ├── validation.js │ ├── websocket-server.js │ └── websocket.js │ └── package.json ├── package-lock.json └── package.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 asterDis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord Gen Bot Tutorial 2 | This is a tutorial on how to create a gen bot, this code is open source and free for anyone to use. Enjoy making your gen bot. If there are any problems contact me on discord: Aster#2763 3 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const Discord = require('discord.js'); 2 | const client = new Discord.Client(); 3 | 4 | const token = 'NjIwNDA2MzY1MTQ3NjI3NTIz.XXaygw.klPIAqXszSjSVP3vJ6Qwe6riB9U'; 5 | usedCommandRecently4 = new Set(); 6 | 7 | client.on('ready', () =>{ 8 | console.log('gen bot is now online') 9 | client.user.setPresence({ game: { name: `${client.guilds.size} Servers`, type: "WATCHING"}}); 10 | }); 11 | client.on('message', message =>{ 12 | if (message.content === 'hello'){ 13 | message.author.send('hi'); 14 | }; 15 | }); 16 | client.on('message', message =>{ 17 | if (!message.guild) return; 18 | if (message.content === '=test'){ 19 | if (usedCommandRecently4.has(message.author.id)){ 20 | message.channel.send('Cooldown Message') 21 | } else{ 22 | usedCommandRecently4.add(message.author.id); 23 | setTimeout(() =>{ 24 | usedCommandRecently4.delete(message.author.id); 25 | }, 10000) 26 | var string = `test1 27 | test2 28 | test3 29 | test4 30 | test5` 31 | var words = string.split('\n'); 32 | let random = words[Math.floor(Math.random()*words.length)]; 33 | message.author.send(`${random}`); 34 | }; 35 | }; 36 | }); 37 | client.login(token); 38 | -------------------------------------------------------------------------------- /node_modules/async-limiter/.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | .nyc_output -------------------------------------------------------------------------------- /node_modules/async-limiter/.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "check-coverage": false, 3 | "lines": 99, 4 | "statements": 99, 5 | "functions": 99, 6 | "branches": 99, 7 | "include": [ 8 | "index.js" 9 | ] 10 | } -------------------------------------------------------------------------------- /node_modules/async-limiter/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | - "8" 5 | - "10" 6 | - "node" 7 | script: npm run travis 8 | cache: 9 | yarn: true 10 | -------------------------------------------------------------------------------- /node_modules/async-limiter/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2017 Samuel Reed 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /node_modules/async-limiter/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function Queue(options) { 4 | if (!(this instanceof Queue)) { 5 | return new Queue(options); 6 | } 7 | 8 | options = options || {}; 9 | this.concurrency = options.concurrency || Infinity; 10 | this.pending = 0; 11 | this.jobs = []; 12 | this.cbs = []; 13 | this._done = done.bind(this); 14 | } 15 | 16 | var arrayAddMethods = [ 17 | 'push', 18 | 'unshift', 19 | 'splice' 20 | ]; 21 | 22 | arrayAddMethods.forEach(function(method) { 23 | Queue.prototype[method] = function() { 24 | var methodResult = Array.prototype[method].apply(this.jobs, arguments); 25 | this._run(); 26 | return methodResult; 27 | }; 28 | }); 29 | 30 | Object.defineProperty(Queue.prototype, 'length', { 31 | get: function() { 32 | return this.pending + this.jobs.length; 33 | } 34 | }); 35 | 36 | Queue.prototype._run = function() { 37 | if (this.pending === this.concurrency) { 38 | return; 39 | } 40 | if (this.jobs.length) { 41 | var job = this.jobs.shift(); 42 | this.pending++; 43 | job(this._done); 44 | this._run(); 45 | } 46 | 47 | if (this.pending === 0) { 48 | while (this.cbs.length !== 0) { 49 | var cb = this.cbs.pop(); 50 | process.nextTick(cb); 51 | } 52 | } 53 | }; 54 | 55 | Queue.prototype.onDone = function(cb) { 56 | if (typeof cb === 'function') { 57 | this.cbs.push(cb); 58 | this._run(); 59 | } 60 | }; 61 | 62 | function done() { 63 | this.pending--; 64 | this._run(); 65 | } 66 | 67 | module.exports = Queue; 68 | -------------------------------------------------------------------------------- /node_modules/async-limiter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "async-limiter@~1.0.0", 3 | "_id": "async-limiter@1.0.1", 4 | "_inBundle": false, 5 | "_integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", 6 | "_location": "/async-limiter", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "async-limiter@~1.0.0", 12 | "name": "async-limiter", 13 | "escapedName": "async-limiter", 14 | "rawSpec": "~1.0.0", 15 | "saveSpec": null, 16 | "fetchSpec": "~1.0.0" 17 | }, 18 | "_requiredBy": [ 19 | "/ws" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", 22 | "_shasum": "dd379e94f0db8310b08291f9d64c3209766617fd", 23 | "_spec": "async-limiter@~1.0.0", 24 | "_where": "C:\\Users\\Chris\\Desktop\\GenBot\\node_modules\\ws", 25 | "author": { 26 | "name": "Samuel Reed" 27 | }, 28 | "bugs": { 29 | "url": "https://github.com/strml/async-limiter/issues" 30 | }, 31 | "bundleDependencies": false, 32 | "dependencies": {}, 33 | "deprecated": false, 34 | "description": "asynchronous function queue with adjustable concurrency", 35 | "devDependencies": { 36 | "coveralls": "^3.0.3", 37 | "eslint": "^5.16.0", 38 | "eslint-plugin-mocha": "^5.3.0", 39 | "intelli-espower-loader": "^1.0.1", 40 | "mocha": "^6.1.4", 41 | "nyc": "^14.1.1", 42 | "power-assert": "^1.6.1" 43 | }, 44 | "homepage": "https://github.com/strml/async-limiter#readme", 45 | "keywords": [ 46 | "throttle", 47 | "async", 48 | "limiter", 49 | "asynchronous", 50 | "job", 51 | "task", 52 | "concurrency", 53 | "concurrent" 54 | ], 55 | "license": "MIT", 56 | "name": "async-limiter", 57 | "repository": { 58 | "type": "git", 59 | "url": "git+https://github.com/strml/async-limiter.git" 60 | }, 61 | "scripts": { 62 | "coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls", 63 | "example": "node example", 64 | "lint": "eslint .", 65 | "test": "mocha --require intelli-espower-loader test/", 66 | "travis": "npm run lint && npm run test" 67 | }, 68 | "version": "1.0.1" 69 | } 70 | -------------------------------------------------------------------------------- /node_modules/discord.js/.tern-project: -------------------------------------------------------------------------------- 1 | { 2 | "ecmaVersion": 7, 3 | "libs": [], 4 | "loadEagerly": [ 5 | "./src/*.js" 6 | ], 7 | "dontLoad": [ 8 | "node_modules/**" 9 | ], 10 | "plugins": { 11 | "es_modules": {}, 12 | "node": {}, 13 | "doc_comment": { 14 | "fullDocs": true, 15 | "strong": true 16 | }, 17 | "webpack": { 18 | "configPath": "./webpack.config.js", 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /node_modules/discord.js/browser.js: -------------------------------------------------------------------------------- 1 | const browser = typeof window !== 'undefined'; 2 | const webpack = !!process.env.__DISCORD_WEBPACK__; 3 | 4 | const Discord = require('./'); 5 | 6 | module.exports = Discord; 7 | if (browser && webpack) window.Discord = Discord; // eslint-disable-line no-undef 8 | // eslint-disable-next-line no-console 9 | else if (!browser) console.warn('Warning: Attempting to use browser version of Discord.js in a non-browser environment!'); 10 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/ClientManager.js: -------------------------------------------------------------------------------- 1 | const Constants = require('../util/Constants'); 2 | const WebSocketConnection = require('./websocket/WebSocketConnection'); 3 | 4 | /** 5 | * Manages the state and background tasks of the client. 6 | * @private 7 | */ 8 | class ClientManager { 9 | constructor(client) { 10 | /** 11 | * The client that instantiated this Manager 12 | * @type {Client} 13 | */ 14 | this.client = client; 15 | 16 | /** 17 | * The heartbeat interval 18 | * @type {?number} 19 | */ 20 | this.heartbeatInterval = null; 21 | } 22 | 23 | /** 24 | * The status of the client 25 | * @type {number} 26 | */ 27 | get status() { 28 | return this.connection ? this.connection.status : Constants.Status.IDLE; 29 | } 30 | 31 | /** 32 | * Connects the client to the WebSocket. 33 | * @param {string} token The authorization token 34 | * @param {Function} resolve Function to run when connection is successful 35 | * @param {Function} reject Function to run when connection fails 36 | */ 37 | connectToWebSocket(token, resolve, reject) { 38 | this.client.emit(Constants.Events.DEBUG, `Authenticated using token ${token}`); 39 | this.client.token = token; 40 | const timeout = this.client.setTimeout(() => reject(new Error(Constants.Errors.TOOK_TOO_LONG)), 1000 * 300); 41 | this.client.rest.methods.getGateway().then(res => { 42 | const protocolVersion = Constants.DefaultOptions.ws.version; 43 | const gateway = `${res.url}/?v=${protocolVersion}&encoding=${WebSocketConnection.ENCODING}`; 44 | this.client.emit(Constants.Events.DEBUG, `Using gateway ${gateway}`); 45 | this.client.ws.connect(gateway); 46 | this.client.ws.connection.once('error', reject); 47 | this.client.ws.connection.once('close', event => { 48 | if (event.code === 4004) reject(new Error(Constants.Errors.BAD_LOGIN)); 49 | if (event.code === 4010) reject(new Error(Constants.Errors.INVALID_SHARD)); 50 | if (event.code === 4011) reject(new Error(Constants.Errors.SHARDING_REQUIRED)); 51 | }); 52 | this.client.once(Constants.Events.READY, () => { 53 | resolve(token); 54 | this.client.clearTimeout(timeout); 55 | }); 56 | }, reject); 57 | } 58 | 59 | destroy() { 60 | this.client.ws.destroy(); 61 | this.client.rest.destroy(); 62 | if (!this.client.user) return Promise.resolve(); 63 | if (this.client.user.bot) { 64 | this.client.token = null; 65 | return Promise.resolve(); 66 | } else { 67 | return this.client.rest.methods.logout().then(() => { 68 | this.client.token = null; 69 | }); 70 | } 71 | } 72 | } 73 | 74 | module.exports = ClientManager; 75 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/Action.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | ABOUT ACTIONS 4 | 5 | Actions are similar to WebSocket Packet Handlers, but since introducing 6 | the REST API methods, in order to prevent rewriting code to handle data, 7 | "actions" have been introduced. They're basically what Packet Handlers 8 | used to be but they're strictly for manipulating data and making sure 9 | that WebSocket events don't clash with REST methods. 10 | 11 | */ 12 | 13 | class GenericAction { 14 | constructor(client) { 15 | this.client = client; 16 | } 17 | 18 | handle(data) { 19 | return data; 20 | } 21 | } 22 | 23 | module.exports = GenericAction; 24 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/ActionsManager.js: -------------------------------------------------------------------------------- 1 | class ActionsManager { 2 | constructor(client) { 3 | this.client = client; 4 | 5 | this.register(require('./MessageCreate')); 6 | this.register(require('./MessageDelete')); 7 | this.register(require('./MessageDeleteBulk')); 8 | this.register(require('./MessageUpdate')); 9 | this.register(require('./MessageReactionAdd')); 10 | this.register(require('./MessageReactionRemove')); 11 | this.register(require('./MessageReactionRemoveAll')); 12 | this.register(require('./ChannelCreate')); 13 | this.register(require('./ChannelDelete')); 14 | this.register(require('./ChannelUpdate')); 15 | this.register(require('./GuildDelete')); 16 | this.register(require('./GuildUpdate')); 17 | this.register(require('./GuildMemberGet')); 18 | this.register(require('./GuildMemberRemove')); 19 | this.register(require('./GuildBanRemove')); 20 | this.register(require('./GuildRoleCreate')); 21 | this.register(require('./GuildRoleDelete')); 22 | this.register(require('./GuildRoleUpdate')); 23 | this.register(require('./UserGet')); 24 | this.register(require('./UserUpdate')); 25 | this.register(require('./UserNoteUpdate')); 26 | this.register(require('./GuildSync')); 27 | this.register(require('./GuildEmojiCreate')); 28 | this.register(require('./GuildEmojiDelete')); 29 | this.register(require('./GuildEmojiUpdate')); 30 | this.register(require('./GuildEmojisUpdate')); 31 | this.register(require('./GuildRolesPositionUpdate')); 32 | this.register(require('./GuildChannelsPositionUpdate')); 33 | } 34 | 35 | register(Action) { 36 | this[Action.name.replace(/Action$/, '')] = new Action(this.client); 37 | } 38 | } 39 | 40 | module.exports = ActionsManager; 41 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/ChannelCreate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class ChannelCreateAction extends Action { 4 | handle(data) { 5 | const client = this.client; 6 | const channel = client.dataManager.newChannel(data); 7 | return { channel }; 8 | } 9 | } 10 | 11 | module.exports = ChannelCreateAction; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/ChannelDelete.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class ChannelDeleteAction extends Action { 4 | constructor(client) { 5 | super(client); 6 | this.deleted = new Map(); 7 | } 8 | 9 | handle(data) { 10 | const client = this.client; 11 | 12 | let channel = client.channels.get(data.id); 13 | if (channel) { 14 | client.dataManager.killChannel(channel); 15 | this.deleted.set(channel.id, channel); 16 | this.scheduleForDeletion(channel.id); 17 | } else { 18 | channel = this.deleted.get(data.id) || null; 19 | } 20 | if (channel) channel.deleted = true; 21 | 22 | return { channel }; 23 | } 24 | 25 | scheduleForDeletion(id) { 26 | this.client.setTimeout(() => this.deleted.delete(id), this.client.options.restWsBridgeTimeout); 27 | } 28 | } 29 | 30 | module.exports = ChannelDeleteAction; 31 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/ChannelUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const TextChannel = require('../../structures/TextChannel'); 3 | const VoiceChannel = require('../../structures/VoiceChannel'); 4 | const CategoryChannel = require('../../structures/CategoryChannel'); 5 | const NewsChannel = require('../../structures/NewsChannel'); 6 | const StoreChannel = require('../../structures/StoreChannel'); 7 | const Constants = require('../../util/Constants'); 8 | const ChannelTypes = Constants.ChannelTypes; 9 | const Util = require('../../util/Util'); 10 | 11 | class ChannelUpdateAction extends Action { 12 | handle(data) { 13 | const client = this.client; 14 | 15 | let channel = client.channels.get(data.id); 16 | if (channel) { 17 | const oldChannel = Util.cloneObject(channel); 18 | 19 | // If the channel is changing types, we need to follow a different process 20 | if (ChannelTypes[channel.type.toUpperCase()] !== data.type) { 21 | // Determine which channel class we're changing to 22 | let channelClass; 23 | switch (data.type) { 24 | case ChannelTypes.TEXT: 25 | channelClass = TextChannel; 26 | break; 27 | case ChannelTypes.VOICE: 28 | channelClass = VoiceChannel; 29 | break; 30 | case ChannelTypes.CATEGORY: 31 | channelClass = CategoryChannel; 32 | break; 33 | case ChannelTypes.NEWS: 34 | channelClass = NewsChannel; 35 | break; 36 | case ChannelTypes.STORE: 37 | channelClass = StoreChannel; 38 | break; 39 | } 40 | 41 | // Create the new channel instance and copy over cached data 42 | const newChannel = new channelClass(channel.guild, data); 43 | if (channel.messages && newChannel.messages) { 44 | for (const [id, message] of channel.messages) newChannel.messages.set(id, message); 45 | } 46 | 47 | channel = newChannel; 48 | this.client.channels.set(channel.id, channel); 49 | } else { 50 | channel.setup(data); 51 | } 52 | 53 | client.emit(Constants.Events.CHANNEL_UPDATE, oldChannel, channel); 54 | return { 55 | old: oldChannel, 56 | updated: channel, 57 | }; 58 | } 59 | 60 | return { 61 | old: null, 62 | updated: null, 63 | }; 64 | } 65 | } 66 | 67 | /** 68 | * Emitted whenever a channel is updated - e.g. name change, topic change. 69 | * @event Client#channelUpdate 70 | * @param {Channel} oldChannel The channel before the update 71 | * @param {Channel} newChannel The channel after the update 72 | */ 73 | 74 | module.exports = ChannelUpdateAction; 75 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildBanRemove.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class GuildBanRemove extends Action { 5 | handle(data) { 6 | const client = this.client; 7 | const guild = client.guilds.get(data.guild_id); 8 | const user = client.dataManager.newUser(data.user); 9 | if (guild && user) client.emit(Constants.Events.GUILD_BAN_REMOVE, guild, user); 10 | } 11 | } 12 | 13 | module.exports = GuildBanRemove; 14 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildChannelsPositionUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class GuildChannelsPositionUpdate extends Action { 4 | handle(data) { 5 | const client = this.client; 6 | 7 | const guild = client.guilds.get(data.guild_id); 8 | if (guild) { 9 | for (const partialChannel of data.channels) { 10 | const channel = guild.channels.get(partialChannel.id); 11 | if (channel) channel.position = partialChannel.position; 12 | } 13 | } 14 | 15 | return { guild }; 16 | } 17 | } 18 | 19 | module.exports = GuildChannelsPositionUpdate; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildDelete.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class GuildDeleteAction extends Action { 5 | constructor(client) { 6 | super(client); 7 | this.deleted = new Map(); 8 | } 9 | 10 | handle(data) { 11 | const client = this.client; 12 | 13 | let guild = client.guilds.get(data.id); 14 | if (guild) { 15 | for (const channel of guild.channels.values()) { 16 | if (channel.type === 'text') channel.stopTyping(true); 17 | } 18 | 19 | if (guild.available && data.unavailable) { 20 | // Guild is unavailable 21 | guild.available = false; 22 | client.emit(Constants.Events.GUILD_UNAVAILABLE, guild); 23 | 24 | // Stops the GuildDelete packet thinking a guild was actually deleted, 25 | // handles emitting of event itself 26 | return { 27 | guild: null, 28 | }; 29 | } 30 | 31 | for (const channel of guild.channels.values()) this.client.channels.delete(channel.id); 32 | if (guild.voiceConnection) guild.voiceConnection.disconnect(); 33 | 34 | // Delete guild 35 | client.guilds.delete(guild.id); 36 | this.deleted.set(guild.id, guild); 37 | this.scheduleForDeletion(guild.id); 38 | } else { 39 | guild = this.deleted.get(data.id) || null; 40 | } 41 | if (guild) guild.deleted = true; 42 | 43 | return { guild }; 44 | } 45 | 46 | scheduleForDeletion(id) { 47 | this.client.setTimeout(() => this.deleted.delete(id), this.client.options.restWsBridgeTimeout); 48 | } 49 | } 50 | 51 | /** 52 | * Emitted whenever a guild becomes unavailable, likely due to a server outage. 53 | * @event Client#guildUnavailable 54 | * @param {Guild} guild The guild that has become unavailable 55 | */ 56 | 57 | module.exports = GuildDeleteAction; 58 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildEmojiCreate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class GuildEmojiCreateAction extends Action { 4 | handle(guild, createdEmoji) { 5 | const client = this.client; 6 | const emoji = client.dataManager.newEmoji(createdEmoji, guild); 7 | return { emoji }; 8 | } 9 | } 10 | 11 | /** 12 | * Emitted whenever a custom emoji is created in a guild. 13 | * @event Client#emojiCreate 14 | * @param {Emoji} emoji The emoji that was created 15 | */ 16 | 17 | module.exports = GuildEmojiCreateAction; 18 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildEmojiDelete.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class GuildEmojiDeleteAction extends Action { 4 | handle(emoji) { 5 | const client = this.client; 6 | client.dataManager.killEmoji(emoji); 7 | emoji.deleted = true; 8 | return { emoji }; 9 | } 10 | } 11 | 12 | /** 13 | * Emitted whenever a custom guild emoji is deleted. 14 | * @event Client#emojiDelete 15 | * @param {Emoji} emoji The emoji that was deleted 16 | */ 17 | 18 | module.exports = GuildEmojiDeleteAction; 19 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildEmojiUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class GuildEmojiUpdateAction extends Action { 4 | handle(oldEmoji, newEmoji) { 5 | const emoji = this.client.dataManager.updateEmoji(oldEmoji, newEmoji); 6 | return { emoji }; 7 | } 8 | } 9 | 10 | /** 11 | * Emitted whenever a custom guild emoji is updated. 12 | * @event Client#emojiUpdate 13 | * @param {Emoji} oldEmoji The old emoji 14 | * @param {Emoji} newEmoji The new emoji 15 | */ 16 | 17 | module.exports = GuildEmojiUpdateAction; 18 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildEmojisUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | function mappify(iterable) { 4 | const map = new Map(); 5 | for (const x of iterable) map.set(...x); 6 | return map; 7 | } 8 | 9 | class GuildEmojisUpdateAction extends Action { 10 | handle(data) { 11 | const guild = this.client.guilds.get(data.guild_id); 12 | if (!guild || !guild.emojis) return; 13 | 14 | const deletions = mappify(guild.emojis.entries()); 15 | 16 | for (const emoji of data.emojis) { 17 | // Determine type of emoji event 18 | const cachedEmoji = guild.emojis.get(emoji.id); 19 | if (cachedEmoji) { 20 | deletions.delete(emoji.id); 21 | if (!cachedEmoji.equals(emoji, true)) { 22 | // Emoji updated 23 | this.client.actions.GuildEmojiUpdate.handle(cachedEmoji, emoji); 24 | } 25 | } else { 26 | // Emoji added 27 | this.client.actions.GuildEmojiCreate.handle(guild, emoji); 28 | } 29 | } 30 | 31 | for (const emoji of deletions.values()) { 32 | // Emoji deleted 33 | this.client.actions.GuildEmojiDelete.handle(emoji); 34 | } 35 | } 36 | } 37 | 38 | module.exports = GuildEmojisUpdateAction; 39 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildMemberGet.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class GuildMemberGetAction extends Action { 4 | handle(guild, data) { 5 | const member = guild._addMember(data, false); 6 | return { member }; 7 | } 8 | } 9 | 10 | module.exports = GuildMemberGetAction; 11 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildMemberRemove.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class GuildMemberRemoveAction extends Action { 5 | constructor(client) { 6 | super(client); 7 | this.deleted = new Map(); 8 | } 9 | 10 | handle(data) { 11 | const client = this.client; 12 | const guild = client.guilds.get(data.guild_id); 13 | let member = null; 14 | if (guild) { 15 | member = guild.members.get(data.user.id); 16 | guild.memberCount--; 17 | if (member) { 18 | guild._removeMember(member); 19 | this.deleted.set(guild.id + data.user.id, member); 20 | if (client.status === Constants.Status.READY) client.emit(Constants.Events.GUILD_MEMBER_REMOVE, member); 21 | this.scheduleForDeletion(guild.id, data.user.id); 22 | } else { 23 | member = this.deleted.get(guild.id + data.user.id) || null; 24 | } 25 | if (member) member.deleted = true; 26 | } 27 | return { guild, member }; 28 | } 29 | 30 | scheduleForDeletion(guildID, userID) { 31 | this.client.setTimeout(() => this.deleted.delete(guildID + userID), this.client.options.restWsBridgeTimeout); 32 | } 33 | } 34 | 35 | /** 36 | * Emitted whenever a member leaves a guild, or is kicked. 37 | * @event Client#guildMemberRemove 38 | * @param {GuildMember} member The member that has left/been kicked from the guild 39 | */ 40 | 41 | module.exports = GuildMemberRemoveAction; 42 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildRoleCreate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | const Role = require('../../structures/Role'); 4 | 5 | class GuildRoleCreate extends Action { 6 | handle(data) { 7 | const client = this.client; 8 | const guild = client.guilds.get(data.guild_id); 9 | let role; 10 | if (guild) { 11 | const already = guild.roles.has(data.role.id); 12 | role = new Role(guild, data.role); 13 | guild.roles.set(role.id, role); 14 | if (!already) client.emit(Constants.Events.GUILD_ROLE_CREATE, role); 15 | } 16 | return { role }; 17 | } 18 | } 19 | 20 | /** 21 | * Emitted whenever a role is created. 22 | * @event Client#roleCreate 23 | * @param {Role} role The role that was created 24 | */ 25 | 26 | module.exports = GuildRoleCreate; 27 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildRoleDelete.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class GuildRoleDeleteAction extends Action { 5 | constructor(client) { 6 | super(client); 7 | this.deleted = new Map(); 8 | } 9 | 10 | handle(data) { 11 | const client = this.client; 12 | const guild = client.guilds.get(data.guild_id); 13 | let role; 14 | 15 | if (guild) { 16 | role = guild.roles.get(data.role_id); 17 | if (role) { 18 | guild.roles.delete(data.role_id); 19 | this.deleted.set(guild.id + data.role_id, role); 20 | this.scheduleForDeletion(guild.id, data.role_id); 21 | client.emit(Constants.Events.GUILD_ROLE_DELETE, role); 22 | } else { 23 | role = this.deleted.get(guild.id + data.role_id) || null; 24 | } 25 | if (role) role.deleted = true; 26 | } 27 | 28 | return { role }; 29 | } 30 | 31 | scheduleForDeletion(guildID, roleID) { 32 | this.client.setTimeout(() => this.deleted.delete(guildID + roleID), this.client.options.restWsBridgeTimeout); 33 | } 34 | } 35 | 36 | /** 37 | * Emitted whenever a guild role is deleted. 38 | * @event Client#roleDelete 39 | * @param {Role} role The role that was deleted 40 | */ 41 | 42 | module.exports = GuildRoleDeleteAction; 43 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildRoleUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | const Util = require('../../util/Util'); 4 | 5 | class GuildRoleUpdateAction extends Action { 6 | handle(data) { 7 | const client = this.client; 8 | const guild = client.guilds.get(data.guild_id); 9 | 10 | if (guild) { 11 | const roleData = data.role; 12 | let oldRole = null; 13 | 14 | const role = guild.roles.get(roleData.id); 15 | if (role) { 16 | oldRole = Util.cloneObject(role); 17 | role.setup(data.role); 18 | client.emit(Constants.Events.GUILD_ROLE_UPDATE, oldRole, role); 19 | } 20 | 21 | return { 22 | old: oldRole, 23 | updated: role, 24 | }; 25 | } 26 | 27 | return { 28 | old: null, 29 | updated: null, 30 | }; 31 | } 32 | } 33 | 34 | /** 35 | * Emitted whenever a guild role is updated. 36 | * @event Client#roleUpdate 37 | * @param {Role} oldRole The role before the update 38 | * @param {Role} newRole The role after the update 39 | */ 40 | 41 | module.exports = GuildRoleUpdateAction; 42 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildRolesPositionUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class GuildRolesPositionUpdate extends Action { 4 | handle(data) { 5 | const client = this.client; 6 | 7 | const guild = client.guilds.get(data.guild_id); 8 | if (guild) { 9 | for (const partialRole of data.roles) { 10 | const role = guild.roles.get(partialRole.id); 11 | if (role) role.position = partialRole.position; 12 | } 13 | } 14 | 15 | return { guild }; 16 | } 17 | } 18 | 19 | module.exports = GuildRolesPositionUpdate; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildSync.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class GuildSync extends Action { 4 | handle(data) { 5 | const client = this.client; 6 | 7 | const guild = client.guilds.get(data.id); 8 | if (guild) { 9 | if (data.presences) { 10 | for (const presence of data.presences) guild._setPresence(presence.user.id, presence); 11 | } 12 | 13 | if (data.members) { 14 | for (const syncMember of data.members) { 15 | const member = guild.members.get(syncMember.user.id); 16 | if (member) { 17 | guild._updateMember(member, syncMember); 18 | } else { 19 | guild._addMember(syncMember, false); 20 | } 21 | } 22 | } 23 | 24 | if ('large' in data) guild.large = data.large; 25 | } 26 | } 27 | } 28 | 29 | module.exports = GuildSync; 30 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/GuildUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | const Util = require('../../util/Util'); 4 | 5 | class GuildUpdateAction extends Action { 6 | handle(data) { 7 | const client = this.client; 8 | 9 | const guild = client.guilds.get(data.id); 10 | if (guild) { 11 | const oldGuild = Util.cloneObject(guild); 12 | guild.setup(data); 13 | client.emit(Constants.Events.GUILD_UPDATE, oldGuild, guild); 14 | return { 15 | old: oldGuild, 16 | updated: guild, 17 | }; 18 | } 19 | 20 | return { 21 | old: null, 22 | updated: null, 23 | }; 24 | } 25 | } 26 | 27 | /** 28 | * Emitted whenever a guild is updated - e.g. name change. 29 | * @event Client#guildUpdate 30 | * @param {Guild} oldGuild The guild before the update 31 | * @param {Guild} newGuild The guild after the update 32 | */ 33 | 34 | module.exports = GuildUpdateAction; 35 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/MessageCreate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Message = require('../../structures/Message'); 3 | 4 | class MessageCreateAction extends Action { 5 | handle(data) { 6 | const client = this.client; 7 | 8 | const channel = client.channels.get((data instanceof Array ? data[0] : data).channel_id); 9 | const user = client.users.get((data instanceof Array ? data[0] : data).author.id); 10 | if (channel) { 11 | const member = channel.guild ? channel.guild.member(user) : null; 12 | if (data instanceof Array) { 13 | const messages = new Array(data.length); 14 | for (let i = 0; i < data.length; i++) { 15 | messages[i] = channel._cacheMessage(new Message(channel, data[i], client)); 16 | } 17 | const lastMessage = messages[messages.length - 1]; 18 | channel.lastMessageID = lastMessage.id; 19 | if (user) { 20 | user.lastMessageID = lastMessage.id; 21 | user.lastMessage = lastMessage; 22 | } 23 | if (member) { 24 | member.lastMessageID = lastMessage.id; 25 | member.lastMessage = lastMessage; 26 | } 27 | return { 28 | messages, 29 | }; 30 | } else { 31 | const message = channel._cacheMessage(new Message(channel, data, client)); 32 | channel.lastMessageID = data.id; 33 | if (user) { 34 | user.lastMessageID = data.id; 35 | user.lastMessage = message; 36 | } 37 | if (member) { 38 | member.lastMessageID = data.id; 39 | member.lastMessage = message; 40 | } 41 | return { 42 | message, 43 | }; 44 | } 45 | } 46 | 47 | return { 48 | message: null, 49 | }; 50 | } 51 | } 52 | 53 | module.exports = MessageCreateAction; 54 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/MessageDelete.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class MessageDeleteAction extends Action { 4 | constructor(client) { 5 | super(client); 6 | this.deleted = new Map(); 7 | } 8 | 9 | handle(data) { 10 | const client = this.client; 11 | const channel = client.channels.get(data.channel_id); 12 | let message; 13 | 14 | if (channel) { 15 | message = channel.messages.get(data.id); 16 | if (message) { 17 | channel.messages.delete(message.id); 18 | this.deleted.set(channel.id + message.id, message); 19 | this.scheduleForDeletion(channel.id, message.id); 20 | } else { 21 | message = this.deleted.get(channel.id + data.id) || null; 22 | } 23 | if (message) message.deleted = true; 24 | } 25 | 26 | return { message }; 27 | } 28 | 29 | scheduleForDeletion(channelID, messageID) { 30 | this.client.setTimeout(() => this.deleted.delete(channelID + messageID), 31 | this.client.options.restWsBridgeTimeout); 32 | } 33 | } 34 | 35 | module.exports = MessageDeleteAction; 36 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/MessageDeleteBulk.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Collection = require('../../util/Collection'); 3 | const Constants = require('../../util/Constants'); 4 | 5 | class MessageDeleteBulkAction extends Action { 6 | handle(data) { 7 | const messages = new Collection(); 8 | const channel = this.client.channels.get(data.channel_id); 9 | 10 | if (channel) { 11 | for (const id of data.ids) { 12 | const message = channel.messages.get(id); 13 | if (message) { 14 | message.deleted = true; 15 | messages.set(message.id, message); 16 | channel.messages.delete(id); 17 | } 18 | } 19 | } 20 | 21 | if (messages.size > 0) this.client.emit(Constants.Events.MESSAGE_BULK_DELETE, messages); 22 | return { messages }; 23 | } 24 | } 25 | 26 | module.exports = MessageDeleteBulkAction; 27 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/MessageReactionAdd.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | /* 5 | { user_id: 'id', 6 | message_id: 'id', 7 | emoji: { name: '�', id: null }, 8 | channel_id: 'id' } } 9 | */ 10 | 11 | class MessageReactionAdd extends Action { 12 | handle(data) { 13 | const user = this.client.users.get(data.user_id); 14 | if (!user) return false; 15 | // Verify channel 16 | const channel = this.client.channels.get(data.channel_id); 17 | if (!channel || channel.type === 'voice') return false; 18 | // Verify message 19 | const message = channel.messages.get(data.message_id); 20 | if (!message) return false; 21 | if (!data.emoji) return false; 22 | // Verify reaction 23 | const reaction = message._addReaction(data.emoji, user); 24 | if (reaction) this.client.emit(Constants.Events.MESSAGE_REACTION_ADD, reaction, user); 25 | 26 | return { message, reaction, user }; 27 | } 28 | } 29 | 30 | /** 31 | * Emitted whenever a reaction is added to a cached message. 32 | * @event Client#messageReactionAdd 33 | * @param {MessageReaction} messageReaction The reaction object 34 | * @param {User} user The user that applied the emoji or reaction emoji 35 | */ 36 | 37 | module.exports = MessageReactionAdd; 38 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/MessageReactionRemove.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | /* 5 | { user_id: 'id', 6 | message_id: 'id', 7 | emoji: { name: '�', id: null }, 8 | channel_id: 'id' } } 9 | */ 10 | 11 | class MessageReactionRemove extends Action { 12 | handle(data) { 13 | const user = this.client.users.get(data.user_id); 14 | if (!user) return false; 15 | // Verify channel 16 | const channel = this.client.channels.get(data.channel_id); 17 | if (!channel || channel.type === 'voice') return false; 18 | // Verify message 19 | const message = channel.messages.get(data.message_id); 20 | if (!message) return false; 21 | if (!data.emoji) return false; 22 | // Verify reaction 23 | const reaction = message._removeReaction(data.emoji, user); 24 | if (reaction) this.client.emit(Constants.Events.MESSAGE_REACTION_REMOVE, reaction, user); 25 | 26 | return { message, reaction, user }; 27 | } 28 | } 29 | 30 | /** 31 | * Emitted whenever a reaction is removed from a cached message. 32 | * @event Client#messageReactionRemove 33 | * @param {MessageReaction} messageReaction The reaction object 34 | * @param {User} user The user whose emoji or reaction emoji was removed 35 | */ 36 | 37 | module.exports = MessageReactionRemove; 38 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/MessageReactionRemoveAll.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class MessageReactionRemoveAll extends Action { 5 | handle(data) { 6 | const channel = this.client.channels.get(data.channel_id); 7 | if (!channel || channel.type === 'voice') return false; 8 | 9 | const message = channel.messages.get(data.message_id); 10 | if (!message) return false; 11 | 12 | message._clearReactions(); 13 | this.client.emit(Constants.Events.MESSAGE_REACTION_REMOVE_ALL, message); 14 | 15 | return { message }; 16 | } 17 | } 18 | 19 | /** 20 | * Emitted whenever all reactions are removed from a cached message. 21 | * @event Client#messageReactionRemoveAll 22 | * @param {Message} message The message the reactions were removed from 23 | */ 24 | 25 | module.exports = MessageReactionRemoveAll; 26 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/MessageUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class MessageUpdateAction extends Action { 5 | handle(data) { 6 | const client = this.client; 7 | 8 | const channel = client.channels.get(data.channel_id); 9 | if (channel) { 10 | const message = channel.messages.get(data.id); 11 | if (message) { 12 | message.patch(data); 13 | client.emit(Constants.Events.MESSAGE_UPDATE, message._edits[0], message); 14 | return { 15 | old: message._edits[0], 16 | updated: message, 17 | }; 18 | } 19 | 20 | return { 21 | old: message, 22 | updated: message, 23 | }; 24 | } 25 | 26 | return { 27 | old: null, 28 | updated: null, 29 | }; 30 | } 31 | } 32 | 33 | /** 34 | * Emitted whenever a message is updated - e.g. embed or content change. 35 | * @event Client#messageUpdate 36 | * @param {Message} oldMessage The message before the update 37 | * @param {Message} newMessage The message after the update 38 | */ 39 | 40 | module.exports = MessageUpdateAction; 41 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/UserGet.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | 3 | class UserGetAction extends Action { 4 | handle(data) { 5 | const client = this.client; 6 | const user = client.dataManager.newUser(data); 7 | return { user }; 8 | } 9 | } 10 | 11 | module.exports = UserGetAction; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/UserNoteUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class UserNoteUpdateAction extends Action { 5 | handle(data) { 6 | const client = this.client; 7 | 8 | const oldNote = client.user.notes.get(data.id); 9 | const note = data.note.length ? data.note : null; 10 | 11 | client.user.notes.set(data.id, note); 12 | 13 | client.emit(Constants.Events.USER_NOTE_UPDATE, data.id, oldNote, note); 14 | 15 | return { 16 | old: oldNote, 17 | updated: note, 18 | }; 19 | } 20 | } 21 | 22 | /** 23 | * Emitted whenever a note is updated. 24 | * @event Client#userNoteUpdate 25 | * @param {User} user The user the note belongs to 26 | * @param {string} oldNote The note content before the update 27 | * @param {string} newNote The note content after the update 28 | */ 29 | 30 | module.exports = UserNoteUpdateAction; 31 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/actions/UserUpdate.js: -------------------------------------------------------------------------------- 1 | const Action = require('./Action'); 2 | const Constants = require('../../util/Constants'); 3 | const Util = require('../../util/Util'); 4 | 5 | class UserUpdateAction extends Action { 6 | handle(data) { 7 | const client = this.client; 8 | 9 | if (client.user) { 10 | if (client.user.equals(data)) { 11 | return { 12 | old: client.user, 13 | updated: client.user, 14 | }; 15 | } 16 | 17 | const oldUser = Util.cloneObject(client.user); 18 | client.user.patch(data); 19 | client.emit(Constants.Events.USER_UPDATE, oldUser, client.user); 20 | return { 21 | old: oldUser, 22 | updated: client.user, 23 | }; 24 | } 25 | 26 | return { 27 | old: null, 28 | updated: null, 29 | }; 30 | } 31 | } 32 | 33 | module.exports = UserUpdateAction; 34 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/rest/APIRequest.js: -------------------------------------------------------------------------------- 1 | const snekfetch = require('snekfetch'); 2 | const Constants = require('../../util/Constants'); 3 | 4 | class APIRequest { 5 | constructor(rest, method, path, auth, data, files, reason) { 6 | this.rest = rest; 7 | this.client = rest.client; 8 | this.method = method; 9 | this.path = path.toString(); 10 | this.auth = auth; 11 | this.data = data; 12 | this.files = files; 13 | this.route = this.getRoute(this.path); 14 | this.reason = reason; 15 | } 16 | 17 | getRoute(url) { 18 | let route = url.split('?')[0]; 19 | if (route.includes('/channels/') || route.includes('/guilds/')) { 20 | const startInd = route.includes('/channels/') ? route.indexOf('/channels/') : route.indexOf('/guilds/'); 21 | const majorID = route.substring(startInd).split('/')[2]; 22 | route = route.replace(/(\d{8,})/g, ':id').replace(':id', majorID); 23 | } 24 | return route; 25 | } 26 | 27 | getAuth() { 28 | if (this.client.token && this.client.user && this.client.user.bot) { 29 | return `Bot ${this.client.token}`; 30 | } else if (this.client.token) { 31 | return this.client.token; 32 | } 33 | throw new Error(Constants.Errors.NO_TOKEN); 34 | } 35 | 36 | gen() { 37 | const API = `${this.client.options.http.host}/api/v${this.client.options.http.version}`; 38 | const request = snekfetch[this.method](`${API}${this.path}`); 39 | if (this.auth) request.set('Authorization', this.getAuth()); 40 | if (this.reason) request.set('X-Audit-Log-Reason', encodeURIComponent(this.reason)); 41 | if (!this.rest.client.browser) request.set('User-Agent', this.rest.userAgentManager.userAgent); 42 | if (this.files) { 43 | for (const file of this.files) if (file && file.file) request.attach(file.name, file.file, file.name); 44 | if (typeof this.data !== 'undefined') request.attach('payload_json', JSON.stringify(this.data)); 45 | } else if (this.data) { 46 | request.send(this.data); 47 | } 48 | return request; 49 | } 50 | } 51 | 52 | module.exports = APIRequest; 53 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/rest/DiscordAPIError.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents an error from the Discord API. 3 | * @extends Error 4 | */ 5 | class DiscordAPIError extends Error { 6 | constructor(path, error, method) { 7 | super(); 8 | const flattened = this.constructor.flattenErrors(error.errors || error).join('\n'); 9 | this.name = 'DiscordAPIError'; 10 | this.message = error.message && flattened ? `${error.message}\n${flattened}` : error.message || flattened; 11 | 12 | /** 13 | * The path of the request relative to the HTTP endpoint 14 | * @type {string} 15 | */ 16 | this.path = path; 17 | 18 | /** 19 | * HTTP error code returned by Discord 20 | * @type {number} 21 | */ 22 | this.code = error.code; 23 | 24 | /** 25 | * The HTTP method used for the request 26 | * @type {string} 27 | */ 28 | this.method = method; 29 | } 30 | 31 | /** 32 | * Flattens an errors object returned from the API into an array. 33 | * @param {Object} obj Discord errors object 34 | * @param {string} [key] Used internally to determine key names of nested fields 35 | * @returns {string[]} 36 | * @private 37 | */ 38 | static flattenErrors(obj, key = '') { 39 | let messages = []; 40 | 41 | for (const k of Object.keys(obj)) { 42 | if (k === 'message') continue; 43 | const newKey = key ? isNaN(k) ? `${key}.${k}` : `${key}[${k}]` : k; 44 | 45 | if (obj[k]._errors) { 46 | messages.push(`${newKey}: ${obj[k]._errors.map(e => e.message).join(' ')}`); 47 | } else if (obj[k].code || obj[k].message) { 48 | messages.push(`${obj[k].code ? `${obj[k].code}: ` : ''}: ${obj[k].message}`.trim()); 49 | } else if (typeof obj[k] === 'string') { 50 | messages.push(obj[k]); 51 | } else { 52 | messages = messages.concat(this.flattenErrors(obj[k], newKey)); 53 | } 54 | } 55 | 56 | return messages; 57 | } 58 | } 59 | 60 | module.exports = DiscordAPIError; 61 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/rest/RESTManager.js: -------------------------------------------------------------------------------- 1 | const UserAgentManager = require('./UserAgentManager'); 2 | const RESTMethods = require('./RESTMethods'); 3 | const SequentialRequestHandler = require('./RequestHandlers/Sequential'); 4 | const BurstRequestHandler = require('./RequestHandlers/Burst'); 5 | const APIRequest = require('./APIRequest'); 6 | const Constants = require('../../util/Constants'); 7 | 8 | class RESTManager { 9 | constructor(client) { 10 | this.client = client; 11 | this.handlers = {}; 12 | this.userAgentManager = new UserAgentManager(this); 13 | this.methods = new RESTMethods(this); 14 | this.rateLimitedEndpoints = {}; 15 | this.globallyRateLimited = false; 16 | } 17 | 18 | destroy() { 19 | for (const handlerKey of Object.keys(this.handlers)) { 20 | const handler = this.handlers[handlerKey]; 21 | if (handler.destroy) handler.destroy(); 22 | } 23 | } 24 | 25 | push(handler, apiRequest) { 26 | return new Promise((resolve, reject) => { 27 | handler.push({ 28 | request: apiRequest, 29 | resolve, 30 | reject, 31 | retries: 0, 32 | }); 33 | }); 34 | } 35 | 36 | getRequestHandler() { 37 | switch (this.client.options.apiRequestMethod) { 38 | case 'sequential': 39 | return SequentialRequestHandler; 40 | case 'burst': 41 | return BurstRequestHandler; 42 | default: 43 | throw new Error(Constants.Errors.INVALID_RATE_LIMIT_METHOD); 44 | } 45 | } 46 | 47 | makeRequest(method, url, auth, data, file, reason) { 48 | const apiRequest = new APIRequest(this, method, url, auth, data, file, reason); 49 | if (!this.handlers[apiRequest.route]) { 50 | const RequestHandlerType = this.getRequestHandler(); 51 | this.handlers[apiRequest.route] = new RequestHandlerType(this, apiRequest.route); 52 | } 53 | 54 | return this.push(this.handlers[apiRequest.route], apiRequest); 55 | } 56 | } 57 | 58 | module.exports = RESTManager; 59 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/rest/RequestHandlers/Burst.js: -------------------------------------------------------------------------------- 1 | const RequestHandler = require('./RequestHandler'); 2 | const DiscordAPIError = require('../DiscordAPIError'); 3 | const { Events: { RATE_LIMIT } } = require('../../../util/Constants'); 4 | 5 | class BurstRequestHandler extends RequestHandler { 6 | constructor(restManager, endpoint) { 7 | super(restManager, endpoint); 8 | 9 | this.client = restManager.client; 10 | 11 | this.limit = Infinity; 12 | this.resetTime = null; 13 | this.remaining = 1; 14 | this.timeDifference = 0; 15 | 16 | this.resetTimeout = null; 17 | } 18 | 19 | push(request) { 20 | super.push(request); 21 | this.handle(); 22 | } 23 | 24 | execute(item) { 25 | if (!item) return; 26 | item.request.gen().end((err, res) => { 27 | if (res && res.headers) { 28 | this.limit = Number(res.headers['x-ratelimit-limit']); 29 | this.resetTime = Number(res.headers['x-ratelimit-reset']) * 1000; 30 | this.remaining = Number(res.headers['x-ratelimit-remaining']); 31 | this.timeDifference = Date.now() - new Date(res.headers.date).getTime(); 32 | } 33 | if (err) { 34 | if (err.status === 429) { 35 | this.queue.unshift(item); 36 | if (res.headers['x-ratelimit-global']) this.globalLimit = true; 37 | if (this.resetTimeout) return; 38 | this.resetTimeout = this.client.setTimeout(() => { 39 | this.remaining = this.limit; 40 | this.globalLimit = false; 41 | this.handle(); 42 | this.resetTimeout = null; 43 | }, Number(res.headers['retry-after']) + this.client.options.restTimeOffset); 44 | } else if (err.status >= 500 && err.status < 600) { 45 | if (item.retries === this.client.options.retryLimit) { 46 | item.reject(err); 47 | this.handle(); 48 | } else { 49 | item.retries++; 50 | this.queue.unshift(item); 51 | this.resetTimeout = this.client.setTimeout(() => { 52 | this.handle(); 53 | this.resetTimeout = null; 54 | }, 1e3 + this.client.options.restTimeOffset); 55 | } 56 | } else { 57 | item.reject(err.status >= 400 && err.status < 500 ? 58 | new DiscordAPIError(res.request.path, res.body, res.request.method) : err); 59 | this.handle(); 60 | } 61 | } else { 62 | if (this.remaining === 0) { 63 | if (this.client.listenerCount(RATE_LIMIT)) { 64 | this.client.emit(RATE_LIMIT, { 65 | limit: this.limit, 66 | timeDifference: this.timeDifference, 67 | path: item.request.path, 68 | method: item.request.method, 69 | }); 70 | } 71 | } 72 | this.globalLimit = false; 73 | const data = res && res.body ? res.body : {}; 74 | item.resolve(data); 75 | this.handle(); 76 | } 77 | }); 78 | } 79 | 80 | handle() { 81 | super.handle(); 82 | if (this.queue.length === 0) return; 83 | if ((this.remaining <= 0 || this.globalLimit) && Date.now() - this.timeDifference < this.resetTime) return; 84 | this.execute(this.queue.shift()); 85 | this.remaining--; 86 | this.handle(); 87 | } 88 | } 89 | 90 | module.exports = BurstRequestHandler; 91 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/rest/RequestHandlers/RequestHandler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A base class for different types of rate limiting handlers for the REST API. 3 | * @private 4 | */ 5 | class RequestHandler { 6 | /** 7 | * @param {RESTManager} restManager The REST manager to use 8 | */ 9 | constructor(restManager) { 10 | /** 11 | * The RESTManager that instantiated this RequestHandler 12 | * @type {RESTManager} 13 | */ 14 | this.restManager = restManager; 15 | 16 | /** 17 | * A list of requests that have yet to be processed 18 | * @type {APIRequest[]} 19 | */ 20 | this.queue = []; 21 | } 22 | 23 | /** 24 | * Whether or not the client is being rate limited on every endpoint 25 | * @type {boolean} 26 | * @readonly 27 | */ 28 | get globalLimit() { 29 | return this.restManager.globallyRateLimited; 30 | } 31 | 32 | set globalLimit(value) { 33 | this.restManager.globallyRateLimited = value; 34 | } 35 | 36 | /** 37 | * Push a new API request into this bucket. 38 | * @param {APIRequest} request The new request to push into the queue 39 | */ 40 | push(request) { 41 | this.queue.push(request); 42 | } 43 | 44 | /** 45 | * Attempts to get this RequestHandler to process its current queue. 46 | */ 47 | handle() {} // eslint-disable-line no-empty-function 48 | 49 | destroy() { 50 | this.queue = []; 51 | } 52 | } 53 | 54 | module.exports = RequestHandler; 55 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/rest/UserAgentManager.js: -------------------------------------------------------------------------------- 1 | const Constants = require('../../util/Constants'); 2 | 3 | class UserAgentManager { 4 | constructor() { 5 | this.build(this.constructor.DEFAULT); 6 | } 7 | 8 | set({ url, version } = {}) { 9 | this.build({ 10 | url: url || this.constructor.DFEAULT.url, 11 | version: version || this.constructor.DEFAULT.version, 12 | }); 13 | } 14 | 15 | build(ua) { 16 | this.userAgent = `DiscordBot (${ua.url}, ${ua.version}) Node.js/${process.version}`; 17 | } 18 | } 19 | 20 | UserAgentManager.DEFAULT = { 21 | url: Constants.Package.homepage.split('#')[0], 22 | version: Constants.Package.version, 23 | }; 24 | 25 | module.exports = UserAgentManager; 26 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/ClientVoiceManager.js: -------------------------------------------------------------------------------- 1 | const Collection = require('../../util/Collection'); 2 | const VoiceConnection = require('./VoiceConnection'); 3 | 4 | /** 5 | * Manages all the voice stuff for the client. 6 | * @private 7 | */ 8 | class ClientVoiceManager { 9 | constructor(client) { 10 | /** 11 | * The client that instantiated this voice manager 12 | * @type {Client} 13 | */ 14 | this.client = client; 15 | 16 | /** 17 | * A collection mapping connection IDs to the Connection objects 18 | * @type {Collection} 19 | */ 20 | this.connections = new Collection(); 21 | 22 | this.client.on('self.voiceServer', this.onVoiceServer.bind(this)); 23 | this.client.on('self.voiceStateUpdate', this.onVoiceStateUpdate.bind(this)); 24 | } 25 | 26 | onVoiceServer({ guild_id, token, endpoint }) { 27 | const connection = this.connections.get(guild_id); 28 | if (connection) connection.setTokenAndEndpoint(token, endpoint); 29 | } 30 | 31 | onVoiceStateUpdate({ guild_id, session_id, channel_id }) { 32 | const connection = this.connections.get(guild_id); 33 | if (connection) { 34 | connection.channel = this.client.channels.get(channel_id); 35 | connection.setSessionID(session_id); 36 | } 37 | } 38 | 39 | /** 40 | * Sets up a request to join a voice channel. 41 | * @param {VoiceChannel} channel The voice channel to join 42 | * @returns {Promise} 43 | */ 44 | joinChannel(channel) { 45 | return new Promise((resolve, reject) => { 46 | if (!channel.joinable) { 47 | if (channel.full) { 48 | throw new Error('You do not have permission to join this voice channel; it is full.'); 49 | } else { 50 | throw new Error('You do not have permission to join this voice channel.'); 51 | } 52 | } 53 | 54 | let connection = this.connections.get(channel.guild.id); 55 | 56 | if (connection) { 57 | if (connection.channel.id !== channel.id) { 58 | this.connections.get(channel.guild.id).updateChannel(channel); 59 | } 60 | resolve(connection); 61 | return; 62 | } else { 63 | connection = new VoiceConnection(this, channel); 64 | this.connections.set(channel.guild.id, connection); 65 | } 66 | 67 | connection.once('failed', reason => { 68 | this.connections.delete(channel.guild.id); 69 | reject(reason); 70 | }); 71 | 72 | connection.once('authenticated', () => { 73 | connection.once('ready', () => resolve(connection)); 74 | connection.once('error', reject); 75 | connection.once('disconnect', () => this.connections.delete(channel.guild.id)); 76 | }); 77 | }); 78 | } 79 | } 80 | 81 | module.exports = ClientVoiceManager; 82 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/opus/BaseOpusEngine.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The base opus encoding engine. 3 | * @private 4 | */ 5 | class BaseOpus { 6 | /** 7 | * @param {Object} [options] The options to apply to the Opus engine 8 | * @param {number} [options.bitrate=48] The desired bitrate (kbps) 9 | * @param {boolean} [options.fec=false] Whether to enable forward error correction 10 | * @param {number} [options.plp=0] The expected packet loss percentage 11 | */ 12 | constructor({ bitrate = 48, fec = false, plp = 0 } = {}) { 13 | this.ctl = { 14 | BITRATE: 4002, 15 | FEC: 4012, 16 | PLP: 4014, 17 | }; 18 | 19 | this.samplingRate = 48000; 20 | this.channels = 2; 21 | 22 | /** 23 | * The desired bitrate (kbps) 24 | * @type {number} 25 | */ 26 | this.bitrate = bitrate; 27 | 28 | /** 29 | * Miscellaneous Opus options 30 | * @type {Object} 31 | */ 32 | this.options = { fec, plp }; 33 | } 34 | 35 | init() { 36 | try { 37 | this.setBitrate(this.bitrate); 38 | 39 | // Set FEC (forward error correction) 40 | if (this.options.fec) this.setFEC(this.options.fec); 41 | 42 | // Set PLP (expected packet loss percentage) 43 | if (this.options.plp) this.setPLP(this.options.plp); 44 | } catch (err) { 45 | // Opus engine likely has no support for libopus CTL 46 | } 47 | } 48 | 49 | encode(buffer) { 50 | return buffer; 51 | } 52 | 53 | decode(buffer) { 54 | return buffer; 55 | } 56 | 57 | destroy() {} // eslint-disable-line no-empty-function 58 | } 59 | 60 | module.exports = BaseOpus; 61 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/opus/NodeOpusEngine.js: -------------------------------------------------------------------------------- 1 | const OpusEngine = require('./BaseOpusEngine'); 2 | 3 | let opus; 4 | 5 | class NodeOpusEngine extends OpusEngine { 6 | constructor(player) { 7 | super(player); 8 | try { 9 | opus = require('node-opus'); 10 | } catch (err) { 11 | throw err; 12 | } 13 | this.encoder = new opus.OpusEncoder(this.samplingRate, this.channels); 14 | super.init(); 15 | } 16 | 17 | setBitrate(bitrate) { 18 | this.encoder.applyEncoderCTL(this.ctl.BITRATE, Math.min(128, Math.max(16, bitrate)) * 1000); 19 | } 20 | 21 | setFEC(enabled) { 22 | this.encoder.applyEncoderCTL(this.ctl.FEC, enabled ? 1 : 0); 23 | } 24 | 25 | setPLP(percent) { 26 | this.encoder.applyEncoderCTL(this.ctl.PLP, Math.min(100, Math.max(0, percent * 100))); 27 | } 28 | 29 | encode(buffer) { 30 | super.encode(buffer); 31 | return this.encoder.encode(buffer, 1920); 32 | } 33 | 34 | decode(buffer) { 35 | super.decode(buffer); 36 | return this.encoder.decode(buffer, 1920); 37 | } 38 | } 39 | 40 | module.exports = NodeOpusEngine; 41 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/opus/OpusEngineList.js: -------------------------------------------------------------------------------- 1 | const list = [ 2 | require('./NodeOpusEngine'), 3 | require('./OpusScriptEngine'), 4 | ]; 5 | 6 | function fetch(Encoder, engineOptions) { 7 | try { 8 | return new Encoder(engineOptions); 9 | } catch (err) { 10 | if (err.message.includes('Cannot find module')) return null; 11 | 12 | // The Opus engine exists, but another error occurred. 13 | throw err; 14 | } 15 | } 16 | 17 | exports.add = encoder => { 18 | list.push(encoder); 19 | }; 20 | 21 | exports.fetch = engineOptions => { 22 | for (const encoder of list) { 23 | const fetched = fetch(encoder, engineOptions); 24 | if (fetched) return fetched; 25 | } 26 | 27 | throw new Error('Couldn\'t find an Opus engine.'); 28 | }; 29 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/opus/OpusScriptEngine.js: -------------------------------------------------------------------------------- 1 | const OpusEngine = require('./BaseOpusEngine'); 2 | 3 | let OpusScript; 4 | 5 | class OpusScriptEngine extends OpusEngine { 6 | constructor(player) { 7 | super(player); 8 | try { 9 | OpusScript = require('opusscript'); 10 | } catch (err) { 11 | throw err; 12 | } 13 | this.encoder = new OpusScript(this.samplingRate, this.channels); 14 | super.init(); 15 | } 16 | 17 | setBitrate(bitrate) { 18 | this.encoder.encoderCTL(this.ctl.BITRATE, Math.min(128, Math.max(16, bitrate)) * 1000); 19 | } 20 | 21 | setFEC(enabled) { 22 | this.encoder.encoderCTL(this.ctl.FEC, enabled ? 1 : 0); 23 | } 24 | 25 | setPLP(percent) { 26 | this.encoder.encoderCTL(this.ctl.PLP, Math.min(100, Math.max(0, percent * 100))); 27 | } 28 | 29 | encode(buffer) { 30 | super.encode(buffer); 31 | return this.encoder.encode(buffer, 960); 32 | } 33 | 34 | decode(buffer) { 35 | super.decode(buffer); 36 | return this.encoder.decode(buffer); 37 | } 38 | 39 | destroy() { 40 | super.destroy(); 41 | this.encoder.delete(); 42 | } 43 | } 44 | 45 | module.exports = OpusScriptEngine; 46 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/receiver/VoiceReadable.js: -------------------------------------------------------------------------------- 1 | const Readable = require('stream').Readable; 2 | 3 | class VoiceReadable extends Readable { 4 | constructor() { 5 | super(); 6 | this._packets = []; 7 | this.open = true; 8 | } 9 | 10 | _read() {} // eslint-disable-line no-empty-function 11 | 12 | _push(d) { 13 | if (this.open) this.push(d); 14 | } 15 | } 16 | 17 | module.exports = VoiceReadable; 18 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/util/SecretKey.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a Secret Key used in encryption over voice. 3 | * @private 4 | */ 5 | class SecretKey { 6 | constructor(key) { 7 | /** 8 | * The key used for encryption 9 | * @type {Uint8Array} 10 | */ 11 | this.key = new Uint8Array(new ArrayBuffer(key.length)); 12 | for (const index in key) this.key[index] = key[index]; 13 | } 14 | } 15 | 16 | module.exports = SecretKey; 17 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/util/Secretbox.js: -------------------------------------------------------------------------------- 1 | const libs = { 2 | sodium: sodium => ({ 3 | open: sodium.api.crypto_secretbox_open_easy, 4 | close: sodium.api.crypto_secretbox_easy, 5 | }), 6 | 'libsodium-wrappers': sodium => ({ 7 | open: sodium.crypto_secretbox_open_easy, 8 | close: sodium.crypto_secretbox_easy, 9 | }), 10 | tweetnacl: tweetnacl => ({ 11 | open: tweetnacl.secretbox.open, 12 | close: tweetnacl.secretbox, 13 | }), 14 | }; 15 | 16 | exports.methods = {}; 17 | 18 | for (const libName of Object.keys(libs)) { 19 | try { 20 | const lib = require(libName); 21 | if (libName === 'libsodium-wrappers' && lib.ready) { 22 | lib.ready.then(() => { 23 | exports.methods = libs[libName](lib); 24 | }).catch(() => { 25 | const tweetnacl = require('tweetnacl'); 26 | exports.methods = libs.tweetnacl(tweetnacl); 27 | }).catch(() => undefined); 28 | } else { 29 | exports.methods = libs[libName](lib); 30 | } 31 | break; 32 | } catch (err) {} // eslint-disable-line no-empty 33 | } 34 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/voice/util/VolumeInterface.js: -------------------------------------------------------------------------------- 1 | const EventEmitter = require('events'); 2 | 3 | /** 4 | * An interface class for volume transformation. 5 | * @extends {EventEmitter} 6 | */ 7 | class VolumeInterface extends EventEmitter { 8 | constructor({ volume = 1 } = {}) { 9 | super(); 10 | this.setVolume(volume); 11 | } 12 | 13 | /** 14 | * The current volume of the broadcast 15 | * @readonly 16 | * @type {number} 17 | */ 18 | get volume() { 19 | return this._volume; 20 | } 21 | 22 | /** 23 | * The current volume of the broadcast in decibels 24 | * @readonly 25 | * @type {number} 26 | */ 27 | get volumeDecibels() { 28 | return Math.log10(this._volume) * 20; 29 | } 30 | 31 | /** 32 | * The current volume of the broadcast from a logarithmic scale 33 | * @readonly 34 | * @type {number} 35 | */ 36 | get volumeLogarithmic() { 37 | return Math.pow(this._volume, 1 / 1.660964); 38 | } 39 | 40 | applyVolume(buffer, volume) { 41 | volume = volume || this._volume; 42 | if (volume === 1) return buffer; 43 | 44 | const out = Buffer.alloc(buffer.length); 45 | for (let i = 0; i < buffer.length; i += 2) { 46 | if (i >= buffer.length - 1) break; 47 | const uint = Math.min(32767, Math.max(-32767, Math.floor(volume * buffer.readInt16LE(i)))); 48 | out.writeInt16LE(uint, i); 49 | } 50 | 51 | return out; 52 | } 53 | 54 | /** 55 | * Sets the volume relative to the input stream - i.e. 1 is normal, 0.5 is half, 2 is double. 56 | * @param {number} volume The volume that you want to set 57 | */ 58 | setVolume(volume) { 59 | /** 60 | * Emitted when the volume of this interface changes. 61 | * @event VolumeInterface#volumeChange 62 | * @param {number} oldVolume The old volume of this interface 63 | * @param {number} newVolume The new volume of this interface 64 | */ 65 | this.emit('volumeChange', this._volume, volume); 66 | this._volume = volume; 67 | } 68 | 69 | /** 70 | * Set the volume in decibels. 71 | * @param {number} db The decibels 72 | */ 73 | setVolumeDecibels(db) { 74 | this.setVolume(Math.pow(10, db / 20)); 75 | } 76 | 77 | /** 78 | * Set the volume so that a perceived value of 0.5 is half the perceived volume etc. 79 | * @param {number} value The value for the volume 80 | */ 81 | setVolumeLogarithmic(value) { 82 | this.setVolume(Math.pow(value, 1.660964)); 83 | } 84 | } 85 | 86 | module.exports = VolumeInterface; 87 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/WebSocketManager.js: -------------------------------------------------------------------------------- 1 | const EventEmitter = require('events').EventEmitter; 2 | const Constants = require('../../util/Constants'); 3 | const WebSocketConnection = require('./WebSocketConnection'); 4 | 5 | /** 6 | * WebSocket Manager of the client. 7 | * @private 8 | */ 9 | class WebSocketManager extends EventEmitter { 10 | constructor(client) { 11 | super(); 12 | /** 13 | * The client that instantiated this WebSocketManager 14 | * @type {Client} 15 | */ 16 | this.client = client; 17 | 18 | /** 19 | * The WebSocket connection of this manager 20 | * @type {?WebSocketConnection} 21 | */ 22 | this.connection = null; 23 | } 24 | 25 | /** 26 | * Sends a heartbeat on the available connection. 27 | * @returns {void} 28 | */ 29 | heartbeat() { 30 | if (!this.connection) return this.debug('No connection to heartbeat'); 31 | return this.connection.heartbeat(); 32 | } 33 | 34 | /** 35 | * Emits a debug event. 36 | * @param {string} message Debug message 37 | * @returns {void} 38 | */ 39 | debug(message) { 40 | return this.client.emit('debug', `[ws] ${message}`); 41 | } 42 | 43 | /** 44 | * Destroy the client. 45 | * @returns {void} Whether or not destruction was successful 46 | */ 47 | destroy() { 48 | if (!this.connection) { 49 | this.debug('Attempted to destroy WebSocket but no connection exists!'); 50 | return false; 51 | } 52 | return this.connection.destroy(); 53 | } 54 | 55 | /** 56 | * Send a packet on the available WebSocket. 57 | * @param {Object} packet Packet to send 58 | * @returns {void} 59 | */ 60 | send(packet) { 61 | if (!this.connection) { 62 | this.debug('No connection to websocket'); 63 | return; 64 | } 65 | this.connection.send(packet); 66 | } 67 | 68 | /** 69 | * Connects the client to a gateway. 70 | * @param {string} gateway The gateway to connect to 71 | * @returns {boolean} 72 | */ 73 | connect(gateway) { 74 | if (!this.connection) { 75 | this.connection = new WebSocketConnection(this, gateway); 76 | return true; 77 | } 78 | switch (this.connection.status) { 79 | case Constants.Status.IDLE: 80 | case Constants.Status.DISCONNECTED: 81 | this.connection.connect(gateway, 5500); 82 | return true; 83 | default: 84 | this.debug(`Couldn't connect to ${gateway} as the websocket is at state ${this.connection.status}`); 85 | return false; 86 | } 87 | } 88 | } 89 | 90 | module.exports = WebSocketManager; 91 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/AbstractHandler.js: -------------------------------------------------------------------------------- 1 | class AbstractHandler { 2 | constructor(packetManager) { 3 | this.packetManager = packetManager; 4 | } 5 | 6 | handle(packet) { 7 | return packet; 8 | } 9 | } 10 | 11 | module.exports = AbstractHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/ChannelCreate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class ChannelCreateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.ChannelCreate.handle(data); 8 | } 9 | } 10 | 11 | /** 12 | * Emitted whenever a channel is created. 13 | * @event Client#channelCreate 14 | * @param {Channel} channel The channel that was created 15 | */ 16 | 17 | module.exports = ChannelCreateHandler; 18 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/ChannelDelete.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | const Constants = require('../../../../util/Constants'); 4 | 5 | class ChannelDeleteHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const data = packet.d; 9 | const response = client.actions.ChannelDelete.handle(data); 10 | if (response.channel) client.emit(Constants.Events.CHANNEL_DELETE, response.channel); 11 | } 12 | } 13 | 14 | /** 15 | * Emitted whenever a channel is deleted. 16 | * @event Client#channelDelete 17 | * @param {Channel} channel The channel that was deleted 18 | */ 19 | 20 | module.exports = ChannelDeleteHandler; 21 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/ChannelPinsUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | 4 | /* 5 | { t: 'CHANNEL_PINS_UPDATE', 6 | s: 666, 7 | op: 0, 8 | d: 9 | { last_pin_timestamp: '2016-08-28T17:37:13.171774+00:00', 10 | channel_id: '314866471639044027' } } 11 | */ 12 | 13 | class ChannelPinsUpdate extends AbstractHandler { 14 | handle(packet) { 15 | const client = this.packetManager.client; 16 | const data = packet.d; 17 | const channel = client.channels.get(data.channel_id); 18 | const time = new Date(data.last_pin_timestamp); 19 | if (channel && time) { 20 | // Discord sends null for last_pin_timestamp if the last pinned message was removed 21 | channel.lastPinTimestamp = time.getTime() || null; 22 | 23 | client.emit(Constants.Events.CHANNEL_PINS_UPDATE, channel, time); 24 | } 25 | } 26 | } 27 | 28 | /** 29 | * Emitted whenever the pins of a channel are updated. Due to the nature of the WebSocket event, not much information 30 | * can be provided easily here - you need to manually check the pins yourself. 31 | * The `time` parameter will be a Unix Epoch Date object when there are no pins left. 32 | * @event Client#channelPinsUpdate 33 | * @param {Channel} channel The channel that the pins update occured in 34 | * @param {Date} time The time when the last pinned message was pinned 35 | */ 36 | 37 | module.exports = ChannelPinsUpdate; 38 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/ChannelUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class ChannelUpdateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.ChannelUpdate.handle(data); 8 | } 9 | } 10 | 11 | module.exports = ChannelUpdateHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildBanAdd.js: -------------------------------------------------------------------------------- 1 | // ##untested handler## 2 | 3 | const AbstractHandler = require('./AbstractHandler'); 4 | const Constants = require('../../../../util/Constants'); 5 | 6 | class GuildBanAddHandler extends AbstractHandler { 7 | handle(packet) { 8 | const client = this.packetManager.client; 9 | const data = packet.d; 10 | const guild = client.guilds.get(data.guild_id); 11 | const user = client.users.get(data.user.id); 12 | if (guild && user) client.emit(Constants.Events.GUILD_BAN_ADD, guild, user); 13 | } 14 | } 15 | 16 | /** 17 | * Emitted whenever a member is banned from a guild. 18 | * @event Client#guildBanAdd 19 | * @param {Guild} guild The guild that the ban occurred in 20 | * @param {User} user The user that was banned 21 | */ 22 | 23 | module.exports = GuildBanAddHandler; 24 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildBanRemove.js: -------------------------------------------------------------------------------- 1 | // ##untested handler## 2 | 3 | const AbstractHandler = require('./AbstractHandler'); 4 | 5 | class GuildBanRemoveHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const data = packet.d; 9 | client.actions.GuildBanRemove.handle(data); 10 | } 11 | } 12 | 13 | /** 14 | * Emitted whenever a member is unbanned from a guild. 15 | * @event Client#guildBanRemove 16 | * @param {Guild} guild The guild that the unban occurred in 17 | * @param {User} user The user that was unbanned 18 | */ 19 | 20 | module.exports = GuildBanRemoveHandler; 21 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildCreate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class GuildCreateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | 8 | const guild = client.guilds.get(data.id); 9 | if (guild) { 10 | if (!guild.available && !data.unavailable) { 11 | // A newly available guild 12 | guild.setup(data); 13 | this.packetManager.ws.checkIfReady(); 14 | } 15 | } else { 16 | // A new guild 17 | client.dataManager.newGuild(data); 18 | } 19 | } 20 | } 21 | 22 | module.exports = GuildCreateHandler; 23 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildDelete.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | 4 | class GuildDeleteHandler extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | const data = packet.d; 8 | const response = client.actions.GuildDelete.handle(data); 9 | if (response.guild) client.emit(Constants.Events.GUILD_DELETE, response.guild); 10 | } 11 | } 12 | 13 | /** 14 | * Emitted whenever a guild is deleted/left. 15 | * @event Client#guildDelete 16 | * @param {Guild} guild The guild that was deleted 17 | */ 18 | 19 | module.exports = GuildDeleteHandler; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildEmojisUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class GuildEmojisUpdate extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.GuildEmojisUpdate.handle(data); 8 | } 9 | } 10 | 11 | module.exports = GuildEmojisUpdate; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildIntegrationsUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const { Events } = require('../../../../util/Constants'); 3 | 4 | class GuildIntegrationsHandler extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | const data = packet.d; 8 | const guild = client.guilds.get(data.guild_id); 9 | if (guild) client.emit(Events.GUILD_INTEGRATIONS_UPDATE, guild); 10 | } 11 | } 12 | 13 | module.exports = GuildIntegrationsHandler; 14 | 15 | /** 16 | * Emitted whenever a guild integration is updated 17 | * @event Client#guildIntegrationsUpdate 18 | * @param {Guild} guild The guild whose integrations were updated 19 | */ 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildMemberAdd.js: -------------------------------------------------------------------------------- 1 | // ##untested handler## 2 | 3 | const AbstractHandler = require('./AbstractHandler'); 4 | 5 | class GuildMemberAddHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const data = packet.d; 9 | const guild = client.guilds.get(data.guild_id); 10 | if (guild) { 11 | guild.memberCount++; 12 | guild._addMember(data); 13 | } 14 | } 15 | } 16 | 17 | module.exports = GuildMemberAddHandler; 18 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildMemberRemove.js: -------------------------------------------------------------------------------- 1 | // ##untested handler## 2 | 3 | const AbstractHandler = require('./AbstractHandler'); 4 | 5 | class GuildMemberRemoveHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const data = packet.d; 9 | client.actions.GuildMemberRemove.handle(data); 10 | } 11 | } 12 | 13 | module.exports = GuildMemberRemoveHandler; 14 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildMemberUpdate.js: -------------------------------------------------------------------------------- 1 | // ##untested handler## 2 | 3 | const AbstractHandler = require('./AbstractHandler'); 4 | 5 | class GuildMemberUpdateHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const data = packet.d; 9 | 10 | const guild = client.guilds.get(data.guild_id); 11 | if (guild) { 12 | const member = guild.members.get(data.user.id); 13 | if (member) guild._updateMember(member, data); 14 | } 15 | } 16 | } 17 | 18 | module.exports = GuildMemberUpdateHandler; 19 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildMembersChunk.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | // Uncomment in v12 4 | // const Collection = require('../../../../util/Collection'); 5 | 6 | class GuildMembersChunkHandler extends AbstractHandler { 7 | handle(packet) { 8 | const client = this.packetManager.client; 9 | const data = packet.d; 10 | const guild = client.guilds.get(data.guild_id); 11 | if (!guild) return; 12 | 13 | // Uncomment in v12 14 | // const members = new Collection(); 15 | // 16 | // for (const member of data.members) members.set(member.id, guild._addMember(member, false)); 17 | 18 | const members = data.members.map(member => guild._addMember(member, false)); 19 | 20 | client.emit(Constants.Events.GUILD_MEMBERS_CHUNK, members, guild); 21 | 22 | client.ws.lastHeartbeatAck = true; 23 | } 24 | } 25 | 26 | /** 27 | * Emitted whenever a chunk of guild members is received (all members come from the same guild). 28 | * @event Client#guildMembersChunk 29 | * @param {GuildMember[]} members The members in the chunk 30 | * @param {Guild} guild The guild related to the member chunk 31 | */ 32 | 33 | module.exports = GuildMembersChunkHandler; 34 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildRoleCreate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class GuildRoleCreateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.GuildRoleCreate.handle(data); 8 | } 9 | } 10 | 11 | module.exports = GuildRoleCreateHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildRoleDelete.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class GuildRoleDeleteHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.GuildRoleDelete.handle(data); 8 | } 9 | } 10 | 11 | module.exports = GuildRoleDeleteHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildRoleUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class GuildRoleUpdateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.GuildRoleUpdate.handle(data); 8 | } 9 | } 10 | 11 | module.exports = GuildRoleUpdateHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildSync.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class GuildSyncHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.GuildSync.handle(data); 8 | } 9 | } 10 | 11 | module.exports = GuildSyncHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/GuildUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class GuildUpdateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.GuildUpdate.handle(data); 8 | } 9 | } 10 | 11 | module.exports = GuildUpdateHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | 4 | class MessageCreateHandler extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | const data = packet.d; 8 | const response = client.actions.MessageCreate.handle(data); 9 | if (response.message) client.emit(Constants.Events.MESSAGE_CREATE, response.message); 10 | } 11 | } 12 | 13 | /** 14 | * Emitted whenever a message is created. 15 | * @event Client#message 16 | * @param {Message} message The created message 17 | */ 18 | 19 | module.exports = MessageCreateHandler; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/MessageDelete.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | 4 | class MessageDeleteHandler extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | const data = packet.d; 8 | const response = client.actions.MessageDelete.handle(data); 9 | if (response.message) client.emit(Constants.Events.MESSAGE_DELETE, response.message); 10 | } 11 | } 12 | 13 | /** 14 | * Emitted whenever a message is deleted. 15 | * @event Client#messageDelete 16 | * @param {Message} message The deleted message 17 | */ 18 | 19 | module.exports = MessageDeleteHandler; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/MessageDeleteBulk.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class MessageDeleteBulkHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.MessageDeleteBulk.handle(data); 8 | } 9 | } 10 | 11 | /** 12 | * Emitted whenever messages are deleted in bulk. 13 | * @event Client#messageDeleteBulk 14 | * @param {Collection} messages The deleted messages, mapped by their ID 15 | */ 16 | 17 | module.exports = MessageDeleteBulkHandler; 18 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/MessageReactionAdd.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class MessageReactionAddHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.MessageReactionAdd.handle(data); 8 | } 9 | } 10 | 11 | module.exports = MessageReactionAddHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/MessageReactionRemove.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class MessageReactionRemove extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.MessageReactionRemove.handle(data); 8 | } 9 | } 10 | 11 | module.exports = MessageReactionRemove; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/MessageReactionRemoveAll.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class MessageReactionRemoveAll extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.MessageReactionRemoveAll.handle(data); 8 | } 9 | } 10 | 11 | module.exports = MessageReactionRemoveAll; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/MessageUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class MessageUpdateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.MessageUpdate.handle(data); 8 | } 9 | } 10 | 11 | module.exports = MessageUpdateHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/PresenceUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | const Util = require('../../../../util/Util'); 4 | 5 | class PresenceUpdateHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const data = packet.d; 9 | let user = client.users.get(data.user.id); 10 | const guild = client.guilds.get(data.guild_id); 11 | 12 | // Step 1 13 | if (!user) { 14 | if (data.user.username) { 15 | user = client.dataManager.newUser(data.user); 16 | } else { 17 | return; 18 | } 19 | } 20 | 21 | const oldUser = Util.cloneObject(user); 22 | user.patch(data.user); 23 | if (!user.equals(oldUser)) { 24 | client.emit(Constants.Events.USER_UPDATE, oldUser, user); 25 | } 26 | 27 | if (guild) { 28 | let member = guild.members.get(user.id); 29 | if (!member && data.status !== 'offline') { 30 | member = guild._addMember({ 31 | user, 32 | roles: data.roles, 33 | deaf: false, 34 | mute: false, 35 | }, false); 36 | client.emit(Constants.Events.GUILD_MEMBER_AVAILABLE, member); 37 | } 38 | if (member) { 39 | if (client.listenerCount(Constants.Events.PRESENCE_UPDATE) === 0) { 40 | guild._setPresence(user.id, data); 41 | return; 42 | } 43 | const oldMember = Util.cloneObject(member); 44 | if (member.presence) { 45 | oldMember.frozenPresence = Util.cloneObject(member.presence); 46 | } 47 | guild._setPresence(user.id, data); 48 | client.emit(Constants.Events.PRESENCE_UPDATE, oldMember, member); 49 | } else { 50 | guild._setPresence(user.id, data); 51 | } 52 | } 53 | } 54 | } 55 | 56 | /** 57 | * Emitted whenever a guild member's presence changes, or they change one of their details. 58 | * @event Client#presenceUpdate 59 | * @param {GuildMember} oldMember The member before the presence update 60 | * @param {GuildMember} newMember The member after the presence update 61 | */ 62 | 63 | /** 64 | * Emitted whenever a user's details (e.g. username) are changed. 65 | * @event Client#userUpdate 66 | * @param {User} oldUser The user before the update 67 | * @param {User} newUser The user after the update 68 | */ 69 | 70 | /** 71 | * Emitted whenever a member becomes available in a large guild. 72 | * @event Client#guildMemberAvailable 73 | * @param {GuildMember} member The member that became available 74 | */ 75 | 76 | module.exports = PresenceUpdateHandler; 77 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/Ready.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | const ClientUser = require('../../../../structures/ClientUser'); 4 | 5 | class ReadyHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const data = packet.d; 9 | 10 | client.ws.heartbeat(); 11 | 12 | data.user.user_settings = data.user_settings; 13 | data.user.user_guild_settings = data.user_guild_settings; 14 | 15 | const clientUser = new ClientUser(client, data.user); 16 | client.user = clientUser; 17 | client.readyAt = new Date(); 18 | client.users.set(clientUser.id, clientUser); 19 | 20 | for (const guild of data.guilds) if (!client.guilds.has(guild.id)) client.dataManager.newGuild(guild); 21 | for (const privateDM of data.private_channels) client.dataManager.newChannel(privateDM); 22 | 23 | for (const relation of data.relationships) { 24 | const user = client.dataManager.newUser(relation.user); 25 | if (relation.type === 1) { 26 | client.user.friends.set(user.id, user); 27 | } else if (relation.type === 2) { 28 | client.user.blocked.set(user.id, user); 29 | } 30 | } 31 | 32 | data.presences = data.presences || []; 33 | for (const presence of data.presences) { 34 | client.dataManager.newUser(presence.user); 35 | client._setPresence(presence.user.id, presence); 36 | } 37 | 38 | if (data.notes) { 39 | for (const user in data.notes) { 40 | let note = data.notes[user]; 41 | if (!note.length) note = null; 42 | 43 | client.user.notes.set(user, note); 44 | } 45 | } 46 | 47 | if (!client.user.bot && client.options.sync) client.setInterval(client.syncGuilds.bind(client), 30000); 48 | 49 | if (!client.users.has('1')) { 50 | client.dataManager.newUser({ 51 | id: '1', 52 | username: 'Clyde', 53 | discriminator: '0000', 54 | avatar: 'https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png', 55 | bot: true, 56 | status: 'online', 57 | game: null, 58 | verified: true, 59 | }); 60 | } 61 | 62 | const t = client.setTimeout(() => { 63 | client.ws.connection.triggerReady(); 64 | }, 1200 * data.guilds.length); 65 | 66 | client.setMaxListeners(data.guilds.length + 10); 67 | 68 | client.once('ready', () => { 69 | client.syncGuilds(); 70 | client.setMaxListeners(10); 71 | client.clearTimeout(t); 72 | }); 73 | 74 | const ws = this.packetManager.ws; 75 | 76 | ws.sessionID = data.session_id; 77 | ws._trace = data._trace; 78 | client.emit('debug', `READY ${ws._trace.join(' -> ')} ${ws.sessionID}`); 79 | ws.checkIfReady(); 80 | } 81 | } 82 | 83 | module.exports = ReadyHandler; 84 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/RelationshipAdd.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class RelationshipAddHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | if (data.type === 1) { 8 | client.fetchUser(data.id).then(user => { 9 | client.user.friends.set(user.id, user); 10 | }); 11 | } else if (data.type === 2) { 12 | client.fetchUser(data.id).then(user => { 13 | client.user.blocked.set(user.id, user); 14 | }); 15 | } 16 | } 17 | } 18 | 19 | module.exports = RelationshipAddHandler; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/RelationshipRemove.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class RelationshipRemoveHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | if (data.type === 2) { 8 | if (client.user.blocked.has(data.id)) { 9 | client.user.blocked.delete(data.id); 10 | } 11 | } else if (data.type === 1) { 12 | if (client.user.friends.has(data.id)) { 13 | client.user.friends.delete(data.id); 14 | } 15 | } 16 | } 17 | } 18 | 19 | module.exports = RelationshipRemoveHandler; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/Resumed.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | 4 | class ResumedHandler extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | const ws = client.ws.connection; 8 | 9 | ws._trace = packet.d._trace; 10 | 11 | ws.status = Constants.Status.READY; 12 | this.packetManager.handleQueue(); 13 | 14 | const replayed = ws.sequence - ws.closeSequence; 15 | 16 | ws.debug(`RESUMED ${ws._trace.join(' -> ')} | replayed ${replayed} events.`); 17 | client.emit(Constants.Events.RESUME, replayed); 18 | ws.heartbeat(); 19 | } 20 | } 21 | 22 | /** 23 | * Emitted whenever a WebSocket resumes. 24 | * @event Client#resume 25 | * @param {number} replayed The number of events that were replayed 26 | */ 27 | 28 | module.exports = ResumedHandler; 29 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/TypingStart.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | 4 | class TypingStartHandler extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | const data = packet.d; 8 | const channel = client.channels.get(data.channel_id); 9 | const user = client.users.get(data.user_id); 10 | const timestamp = new Date(data.timestamp * 1000); 11 | 12 | if (channel && user) { 13 | if (channel.type === 'voice') { 14 | client.emit(Constants.Events.WARN, `Discord sent a typing packet to voice channel ${channel.id}`); 15 | return; 16 | } 17 | if (channel._typing.has(user.id)) { 18 | const typing = channel._typing.get(user.id); 19 | typing.lastTimestamp = timestamp; 20 | typing.resetTimeout(tooLate(channel, user)); 21 | } else { 22 | channel._typing.set(user.id, new TypingData(client, timestamp, timestamp, tooLate(channel, user))); 23 | client.emit(Constants.Events.TYPING_START, channel, user); 24 | } 25 | } 26 | } 27 | } 28 | 29 | class TypingData { 30 | constructor(client, since, lastTimestamp, _timeout) { 31 | this.client = client; 32 | this.since = since; 33 | this.lastTimestamp = lastTimestamp; 34 | this._timeout = _timeout; 35 | } 36 | 37 | resetTimeout(_timeout) { 38 | this.client.clearTimeout(this._timeout); 39 | this._timeout = _timeout; 40 | } 41 | 42 | get elapsedTime() { 43 | return Date.now() - this.since; 44 | } 45 | } 46 | 47 | function tooLate(channel, user) { 48 | return channel.client.setTimeout(() => { 49 | channel.client.emit(Constants.Events.TYPING_STOP, channel, user, channel._typing.get(user.id)); 50 | channel._typing.delete(user.id); 51 | }, 6000); 52 | } 53 | 54 | /** 55 | * Emitted whenever a user starts typing in a channel. 56 | * @event Client#typingStart 57 | * @param {Channel} channel The channel the user started typing in 58 | * @param {User} user The user that started typing 59 | */ 60 | 61 | /** 62 | * Emitted whenever a user stops typing in a channel. 63 | * @event Client#typingStop 64 | * @param {Channel} channel The channel the user stopped typing in 65 | * @param {User} user The user that stopped typing 66 | */ 67 | 68 | module.exports = TypingStartHandler; 69 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/UserGuildSettingsUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | const ClientUserGuildSettings = require('../../../../structures/ClientUserGuildSettings'); 4 | 5 | class UserGuildSettingsUpdateHandler extends AbstractHandler { 6 | handle(packet) { 7 | const client = this.packetManager.client; 8 | const settings = client.user.guildSettings.get(packet.d.guild_id); 9 | if (settings) settings.patch(packet.d); 10 | else client.user.guildSettings.set(packet.d.guild_id, new ClientUserGuildSettings(packet.d, client)); 11 | client.emit(Constants.Events.USER_GUILD_SETTINGS_UPDATE, client.user.guildSettings.get(packet.d.guild_id)); 12 | } 13 | } 14 | 15 | /** 16 | * Emitted whenever the client user's settings update. 17 | * @event Client#clientUserGuildSettingsUpdate 18 | * @param {ClientUserGuildSettings} clientUserGuildSettings The new client user guild settings 19 | */ 20 | 21 | module.exports = UserGuildSettingsUpdateHandler; 22 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/UserNoteUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class UserNoteUpdateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | 8 | client.actions.UserNoteUpdate.handle(data); 9 | } 10 | } 11 | 12 | module.exports = UserNoteUpdateHandler; 13 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/UserSettingsUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const Constants = require('../../../../util/Constants'); 3 | 4 | class UserSettingsUpdateHandler extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | client.user.settings.patch(packet.d); 8 | client.emit(Constants.Events.USER_SETTINGS_UPDATE, client.user.settings); 9 | } 10 | } 11 | 12 | /** 13 | * Emitted when the client user's settings update. 14 | * @event Client#clientUserSettingsUpdate 15 | * @param {ClientUserSettings} clientUserSettings The new client user settings 16 | */ 17 | 18 | module.exports = UserSettingsUpdateHandler; 19 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/UserUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | class UserUpdateHandler extends AbstractHandler { 4 | handle(packet) { 5 | const client = this.packetManager.client; 6 | const data = packet.d; 7 | client.actions.UserUpdate.handle(data); 8 | } 9 | } 10 | 11 | module.exports = UserUpdateHandler; 12 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/VoiceServerUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | /* 4 | { 5 | "token": "my_token", 6 | "guild_id": "41771983423143937", 7 | "endpoint": "smart.loyal.discord.gg" 8 | } 9 | */ 10 | 11 | class VoiceServerUpdate extends AbstractHandler { 12 | handle(packet) { 13 | const client = this.packetManager.client; 14 | const data = packet.d; 15 | client.emit('self.voiceServer', data); 16 | } 17 | } 18 | 19 | module.exports = VoiceServerUpdate; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/VoiceStateUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | 3 | const Constants = require('../../../../util/Constants'); 4 | const Util = require('../../../../util/Util'); 5 | 6 | class VoiceStateUpdateHandler extends AbstractHandler { 7 | handle(packet) { 8 | const client = this.packetManager.client; 9 | const data = packet.d; 10 | 11 | const guild = client.guilds.get(data.guild_id); 12 | if (guild) { 13 | const member = guild.members.get(data.user_id); 14 | if (member) { 15 | const oldVoiceChannelMember = Util.cloneObject(member); 16 | if (member.voiceChannel && member.voiceChannel.id !== data.channel_id) { 17 | member.voiceChannel.members.delete(oldVoiceChannelMember.id); 18 | } 19 | 20 | // If the member left the voice channel, unset their speaking property 21 | if (!data.channel_id) member.speaking = null; 22 | 23 | if (member.user.id === client.user.id && data.channel_id) { 24 | client.emit('self.voiceStateUpdate', data); 25 | } 26 | 27 | const newChannel = client.channels.get(data.channel_id); 28 | if (newChannel) { 29 | newChannel.members.set(member.id, member); 30 | member.guild.channels.set(data.channel_id, newChannel); 31 | } 32 | 33 | member.serverMute = data.mute; 34 | member.serverDeaf = data.deaf; 35 | member.selfMute = data.self_mute; 36 | member.selfDeaf = data.self_deaf; 37 | member.voiceSessionID = data.session_id; 38 | member.voiceChannelID = data.channel_id; 39 | client.emit(Constants.Events.VOICE_STATE_UPDATE, oldVoiceChannelMember, member); 40 | } 41 | } 42 | } 43 | } 44 | 45 | /** 46 | * Emitted whenever a user changes voice state - e.g. joins/leaves a channel, mutes/unmutes. 47 | * @event Client#voiceStateUpdate 48 | * @param {GuildMember} oldMember The member before the voice state update 49 | * @param {GuildMember} newMember The member after the voice state update 50 | */ 51 | 52 | module.exports = VoiceStateUpdateHandler; 53 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/client/websocket/packets/handlers/WebhooksUpdate.js: -------------------------------------------------------------------------------- 1 | const AbstractHandler = require('./AbstractHandler'); 2 | const { Events } = require('../../../../util/Constants'); 3 | 4 | class WebhooksUpdate extends AbstractHandler { 5 | handle(packet) { 6 | const client = this.packetManager.client; 7 | const data = packet.d; 8 | const channel = client.channels.get(data.channel_id); 9 | if (channel) client.emit(Events.WEBHOOKS_UPDATE, channel); 10 | } 11 | } 12 | 13 | /** 14 | * Emitted whenever a guild text channel has its webhooks changed. 15 | * @event Client#webhookUpdate 16 | * @param {TextChannel} channel The channel that had a webhook update 17 | */ 18 | 19 | module.exports = WebhooksUpdate; 20 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/index.js: -------------------------------------------------------------------------------- 1 | const Util = require('./util/Util'); 2 | 3 | module.exports = { 4 | // "Root" classes (starting points) 5 | Client: require('./client/Client'), 6 | Shard: require('./sharding/Shard'), 7 | ShardClientUtil: require('./sharding/ShardClientUtil'), 8 | ShardingManager: require('./sharding/ShardingManager'), 9 | WebhookClient: require('./client/WebhookClient'), 10 | 11 | // Utilities 12 | Collection: require('./util/Collection'), 13 | Constants: require('./util/Constants'), 14 | DiscordAPIError: require('./client/rest/DiscordAPIError'), 15 | EvaluatedPermissions: require('./util/Permissions'), 16 | Permissions: require('./util/Permissions'), 17 | Snowflake: require('./util/Snowflake'), 18 | SnowflakeUtil: require('./util/Snowflake'), 19 | Util: Util, 20 | util: Util, 21 | version: require('../package').version, 22 | 23 | // Shortcuts to Util methods 24 | escapeMarkdown: Util.escapeMarkdown, 25 | fetchRecommendedShards: Util.fetchRecommendedShards, 26 | splitMessage: Util.splitMessage, 27 | 28 | // Structures 29 | Attachment: require('./structures/Attachment'), 30 | CategoryChannel: require('./structures/CategoryChannel'), 31 | Channel: require('./structures/Channel'), 32 | ClientUser: require('./structures/ClientUser'), 33 | ClientUserSettings: require('./structures/ClientUserSettings'), 34 | Collector: require('./structures/interfaces/Collector'), 35 | DMChannel: require('./structures/DMChannel'), 36 | Emoji: require('./structures/Emoji'), 37 | Game: require('./structures/Presence').Game, 38 | GroupDMChannel: require('./structures/GroupDMChannel'), 39 | Guild: require('./structures/Guild'), 40 | GuildAuditLogs: require('./structures/GuildAuditLogs'), 41 | GuildChannel: require('./structures/GuildChannel'), 42 | GuildMember: require('./structures/GuildMember'), 43 | Invite: require('./structures/Invite'), 44 | Message: require('./structures/Message'), 45 | MessageAttachment: require('./structures/MessageAttachment'), 46 | MessageCollector: require('./structures/MessageCollector'), 47 | MessageEmbed: require('./structures/MessageEmbed'), 48 | MessageMentions: require('./structures/MessageMentions'), 49 | MessageReaction: require('./structures/MessageReaction'), 50 | NewsChannel: require('./structures/NewsChannel'), 51 | OAuth2Application: require('./structures/OAuth2Application'), 52 | ClientOAuth2Application: require('./structures/OAuth2Application'), 53 | PartialGuild: require('./structures/PartialGuild'), 54 | PartialGuildChannel: require('./structures/PartialGuildChannel'), 55 | PermissionOverwrites: require('./structures/PermissionOverwrites'), 56 | Presence: require('./structures/Presence').Presence, 57 | ReactionEmoji: require('./structures/ReactionEmoji'), 58 | ReactionCollector: require('./structures/ReactionCollector'), 59 | RichEmbed: require('./structures/RichEmbed'), 60 | Role: require('./structures/Role'), 61 | StoreChannel: require('./structures/StoreChannel'), 62 | TextChannel: require('./structures/TextChannel'), 63 | User: require('./structures/User'), 64 | VoiceChannel: require('./structures/VoiceChannel'), 65 | Webhook: require('./structures/Webhook'), 66 | }; 67 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/Attachment.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents an attachment in a message. 3 | * @param {BufferResolvable|Stream} file The file 4 | * @param {string} [name] The name of the file, if any 5 | */ 6 | class Attachment { 7 | constructor(file, name) { 8 | this.file = null; 9 | if (name) this.setAttachment(file, name); 10 | else this._attach(file); 11 | } 12 | 13 | /** 14 | * The name of the file 15 | * @type {?string} 16 | * @readonly 17 | */ 18 | get name() { 19 | return this.file.name; 20 | } 21 | 22 | /** 23 | * The file 24 | * @type {?BufferResolvable|Stream} 25 | * @readonly 26 | */ 27 | get attachment() { 28 | return this.file.attachment; 29 | } 30 | 31 | /** 32 | * Set the file of this attachment. 33 | * @param {BufferResolvable|Stream} file The file 34 | * @param {string} name The name of the file 35 | * @returns {Attachment} This attachment 36 | */ 37 | setAttachment(file, name) { 38 | this.file = { attachment: file, name }; 39 | return this; 40 | } 41 | 42 | /** 43 | * Set the file of this attachment. 44 | * @param {BufferResolvable|Stream} attachment The file 45 | * @returns {Attachment} This attachment 46 | */ 47 | setFile(attachment) { 48 | this.file = { attachment }; 49 | return this; 50 | } 51 | 52 | /** 53 | * Set the name of this attachment. 54 | * @param {string} name The name of the image 55 | * @returns {Attachment} This attachment 56 | */ 57 | setName(name) { 58 | this.file.name = name; 59 | return this; 60 | } 61 | 62 | /** 63 | * Set the file of this attachment. 64 | * @param {BufferResolvable|Stream} file The file 65 | * @param {string} name The name of the file 66 | * @returns {void} 67 | * @private 68 | */ 69 | _attach(file, name) { 70 | if (typeof file === 'string') this.file = file; 71 | else this.setAttachment(file, name); 72 | } 73 | } 74 | 75 | module.exports = Attachment; 76 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/CategoryChannel.js: -------------------------------------------------------------------------------- 1 | const GuildChannel = require('./GuildChannel'); 2 | 3 | /** 4 | * Represents a guild category channel on Discord. 5 | * @extends {GuildChannel} 6 | */ 7 | class CategoryChannel extends GuildChannel { 8 | constructor(guild, data) { 9 | super(guild, data); 10 | this.type = 'category'; 11 | } 12 | /** 13 | * The channels that are part of this category 14 | * @type {?Collection} 15 | * @readonly 16 | */ 17 | get children() { 18 | return this.guild.channels.filter(c => c.parentID === this.id); 19 | } 20 | } 21 | 22 | module.exports = CategoryChannel; 23 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/Channel.js: -------------------------------------------------------------------------------- 1 | const Snowflake = require('../util/Snowflake'); 2 | 3 | /** 4 | * Represents any channel on Discord. 5 | */ 6 | class Channel { 7 | constructor(client, data) { 8 | /** 9 | * The client that instantiated the Channel 10 | * @name Channel#client 11 | * @type {Client} 12 | * @readonly 13 | */ 14 | Object.defineProperty(this, 'client', { value: client }); 15 | 16 | /** 17 | * The type of the channel, either: 18 | * * `dm` - a DM channel 19 | * * `group` - a Group DM channel 20 | * * `text` - a guild text channel 21 | * * `voice` - a guild voice channel 22 | * * `category` - a guild category channel 23 | * * `news` - a guild news channel 24 | * * `store` - a guild store channel 25 | * @type {string} 26 | */ 27 | this.type = null; 28 | 29 | /** 30 | * Whether the channel has been deleted 31 | * @type {boolean} 32 | */ 33 | this.deleted = false; 34 | 35 | if (data) this.setup(data); 36 | } 37 | 38 | setup(data) { 39 | /** 40 | * The unique ID of the channel 41 | * @type {Snowflake} 42 | */ 43 | this.id = data.id; 44 | } 45 | 46 | /** 47 | * The timestamp the channel was created at 48 | * @type {number} 49 | * @readonly 50 | */ 51 | get createdTimestamp() { 52 | return Snowflake.deconstruct(this.id).timestamp; 53 | } 54 | 55 | /** 56 | * The time the channel was created 57 | * @type {Date} 58 | * @readonly 59 | */ 60 | get createdAt() { 61 | return new Date(this.createdTimestamp); 62 | } 63 | 64 | /** 65 | * Deletes the channel. 66 | * @returns {Promise} 67 | * @example 68 | * // Delete the channel 69 | * channel.delete() 70 | * .then(console.log) 71 | * .catch(console.error); 72 | */ 73 | delete() { 74 | return this.client.rest.methods.deleteChannel(this); 75 | } 76 | } 77 | 78 | module.exports = Channel; 79 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/ClientUserChannelOverride.js: -------------------------------------------------------------------------------- 1 | const Constants = require('../util/Constants'); 2 | 3 | /** 4 | * A wrapper around the ClientUser's channel overrides. 5 | */ 6 | class ClientUserChannelOverride { 7 | constructor(data) { 8 | this.patch(data); 9 | } 10 | 11 | /** 12 | * Patch the data contained in this class with new partial data. 13 | * @param {Object} data Data to patch this with 14 | * @returns {void} 15 | * @private 16 | */ 17 | patch(data) { 18 | for (const key of Object.keys(Constants.UserChannelOverrideMap)) { 19 | const value = Constants.UserChannelOverrideMap[key]; 20 | if (!data.hasOwnProperty(key)) continue; 21 | if (typeof value === 'function') { 22 | this[value.name] = value(data[key]); 23 | } else { 24 | this[value] = data[key]; 25 | } 26 | } 27 | } 28 | } 29 | 30 | module.exports = ClientUserChannelOverride; 31 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/ClientUserGuildSettings.js: -------------------------------------------------------------------------------- 1 | const Constants = require('../util/Constants'); 2 | const Collection = require('../util/Collection'); 3 | const ClientUserChannelOverride = require('./ClientUserChannelOverride'); 4 | 5 | /** 6 | * A wrapper around the ClientUser's guild settings. 7 | */ 8 | class ClientUserGuildSettings { 9 | constructor(data, client) { 10 | /** 11 | * The client that created the instance of the ClientUserGuildSettings 12 | * @name ClientUserGuildSettings#client 13 | * @type {Client} 14 | * @readonly 15 | */ 16 | Object.defineProperty(this, 'client', { value: client }); 17 | /** 18 | * The ID of the guild this settings are for 19 | * @type {Snowflake} 20 | */ 21 | this.guildID = data.guild_id; 22 | this.channelOverrides = new Collection(); 23 | this.patch(data); 24 | } 25 | 26 | /** 27 | * Patch the data contained in this class with new partial data. 28 | * @param {Object} data Data to patch this with 29 | * @returns {void} 30 | * @private 31 | */ 32 | patch(data) { 33 | for (const key of Object.keys(Constants.UserGuildSettingsMap)) { 34 | const value = Constants.UserGuildSettingsMap[key]; 35 | if (!data.hasOwnProperty(key)) continue; 36 | if (key === 'channel_overrides') { 37 | for (const channel of data[key]) { 38 | this.channelOverrides.set(channel.channel_id, 39 | new ClientUserChannelOverride(channel)); 40 | } 41 | } else if (typeof value === 'function') { 42 | this[value.name] = value(data[key]); 43 | } else { 44 | this[value] = data[key]; 45 | } 46 | } 47 | } 48 | 49 | /** 50 | * Update a specific property of the guild settings. 51 | * @param {string} name Name of property 52 | * @param {value} value Value to patch 53 | * @returns {Promise} 54 | */ 55 | update(name, value) { 56 | return this.client.rest.methods.patchClientUserGuildSettings(this.guildID, { [name]: value }); 57 | } 58 | } 59 | 60 | module.exports = ClientUserGuildSettings; 61 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/ClientUserSettings.js: -------------------------------------------------------------------------------- 1 | const Constants = require('../util/Constants'); 2 | const Util = require('../util/Util'); 3 | 4 | /** 5 | * A wrapper around the ClientUser's settings. 6 | */ 7 | class ClientUserSettings { 8 | constructor(user, data) { 9 | this.user = user; 10 | this.patch(data); 11 | } 12 | 13 | /** 14 | * Patch the data contained in this class with new partial data. 15 | * @param {Object} data Data to patch this with 16 | * @returns {void} 17 | * @private 18 | */ 19 | patch(data) { 20 | for (const key of Object.keys(Constants.UserSettingsMap)) { 21 | const value = Constants.UserSettingsMap[key]; 22 | if (!data.hasOwnProperty(key)) continue; 23 | if (typeof value === 'function') { 24 | this[value.name] = value(data[key]); 25 | } else { 26 | this[value] = data[key]; 27 | } 28 | } 29 | } 30 | 31 | /** 32 | * Update a specific property of of user settings. 33 | * @param {string} name Name of property 34 | * @param {*} value Value to patch 35 | * @returns {Promise} 36 | */ 37 | update(name, value) { 38 | return this.user.client.rest.methods.patchUserSettings({ [name]: value }); 39 | } 40 | 41 | /** 42 | * Sets the position at which this guild will appear in the Discord client. 43 | * @param {Guild} guild The guild to move 44 | * @param {number} position Absolute or relative position 45 | * @param {boolean} [relative=false] Whether to position relatively or absolutely 46 | * @returns {Promise} 47 | */ 48 | setGuildPosition(guild, position, relative) { 49 | const temp = Object.assign([], this.guildPositions); 50 | Util.moveElementInArray(temp, guild.id, position, relative); 51 | return this.update('guild_positions', temp).then(() => guild); 52 | } 53 | 54 | /** 55 | * Add a guild to the list of restricted guilds. 56 | * @param {Guild} guild The guild to add 57 | * @returns {Promise} 58 | */ 59 | addRestrictedGuild(guild) { 60 | const temp = Object.assign([], this.restrictedGuilds); 61 | if (temp.includes(guild.id)) return Promise.reject(new Error('Guild is already restricted')); 62 | temp.push(guild.id); 63 | return this.update('restricted_guilds', temp).then(() => guild); 64 | } 65 | 66 | /** 67 | * Remove a guild from the list of restricted guilds. 68 | * @param {Guild} guild The guild to remove 69 | * @returns {Promise} 70 | */ 71 | removeRestrictedGuild(guild) { 72 | const temp = Object.assign([], this.restrictedGuilds); 73 | const index = temp.indexOf(guild.id); 74 | if (index < 0) return Promise.reject(new Error('Guild is not restricted')); 75 | temp.splice(index, 1); 76 | return this.update('restricted_guilds', temp).then(() => guild); 77 | } 78 | } 79 | 80 | module.exports = ClientUserSettings; 81 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/DMChannel.js: -------------------------------------------------------------------------------- 1 | const Channel = require('./Channel'); 2 | const TextBasedChannel = require('./interfaces/TextBasedChannel'); 3 | const Collection = require('../util/Collection'); 4 | 5 | /** 6 | * Represents a direct message channel between two users. 7 | * @extends {Channel} 8 | * @implements {TextBasedChannel} 9 | */ 10 | class DMChannel extends Channel { 11 | constructor(client, data) { 12 | super(client, data); 13 | this.type = 'dm'; 14 | this.messages = new Collection(); 15 | this._typing = new Map(); 16 | } 17 | 18 | setup(data) { 19 | super.setup(data); 20 | 21 | /** 22 | * The recipient on the other end of the DM 23 | * @type {User} 24 | */ 25 | this.recipient = this.client.dataManager.newUser(data.recipients[0]); 26 | 27 | /** 28 | * The ID of the last message in the channel, if one was sent 29 | * @type {?Snowflake} 30 | */ 31 | this.lastMessageID = data.last_message_id; 32 | 33 | /** 34 | * The timestamp when the last pinned message was pinned, if there was one 35 | * @type {?number} 36 | */ 37 | this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null; 38 | } 39 | 40 | /** 41 | * When concatenated with a string, this automatically concatenates the recipient's mention instead of the 42 | * DM channel object. 43 | * @returns {string} 44 | */ 45 | toString() { 46 | return this.recipient.toString(); 47 | } 48 | 49 | // These are here only for documentation purposes - they are implemented by TextBasedChannel 50 | /* eslint-disable no-empty-function */ 51 | get lastPinAt() {} 52 | send() {} 53 | sendMessage() {} 54 | sendEmbed() {} 55 | sendFile() {} 56 | sendFiles() {} 57 | sendCode() {} 58 | fetchMessage() {} 59 | fetchMessages() {} 60 | fetchPinnedMessages() {} 61 | search() {} 62 | startTyping() {} 63 | stopTyping() {} 64 | get typing() {} 65 | get typingCount() {} 66 | createCollector() {} 67 | createMessageCollector() {} 68 | awaitMessages() {} 69 | // Doesn't work on DM channels; bulkDelete() {} 70 | acknowledge() {} 71 | _cacheMessage() {} 72 | } 73 | 74 | TextBasedChannel.applyToClass(DMChannel, true, ['bulkDelete']); 75 | 76 | module.exports = DMChannel; 77 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/MessageAttachment.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents an attachment in a message. 3 | */ 4 | class MessageAttachment { 5 | constructor(message, data) { 6 | /** 7 | * The client that instantiated this MessageAttachment 8 | * @name MessageAttachment#client 9 | * @type {Client} 10 | * @readonly 11 | */ 12 | Object.defineProperty(this, 'client', { value: message.client }); 13 | 14 | /** 15 | * The message this attachment is part of 16 | * @type {Message} 17 | */ 18 | this.message = message; 19 | 20 | this.setup(data); 21 | } 22 | 23 | setup(data) { 24 | /** 25 | * The ID of this attachment 26 | * @type {Snowflake} 27 | */ 28 | this.id = data.id; 29 | 30 | /** 31 | * The file name of this attachment 32 | * @type {string} 33 | */ 34 | this.filename = data.filename; 35 | 36 | /** 37 | * The size of this attachment in bytes 38 | * @type {number} 39 | */ 40 | this.filesize = data.size; 41 | 42 | /** 43 | * The URL to this attachment 44 | * @type {string} 45 | */ 46 | this.url = data.url; 47 | 48 | /** 49 | * The Proxy URL to this attachment 50 | * @type {string} 51 | */ 52 | this.proxyURL = data.proxy_url; 53 | 54 | /** 55 | * The height of this attachment (if an image) 56 | * @type {?number} 57 | */ 58 | this.height = data.height; 59 | 60 | /** 61 | * The width of this attachment (if an image) 62 | * @type {?number} 63 | */ 64 | this.width = data.width; 65 | } 66 | } 67 | 68 | module.exports = MessageAttachment; 69 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/MessageCollector.js: -------------------------------------------------------------------------------- 1 | const Collector = require('./interfaces/Collector'); 2 | const util = require('util'); 3 | 4 | /** 5 | * @typedef {CollectorOptions} MessageCollectorOptions 6 | * @property {number} max The maximum amount of messages to process 7 | * @property {number} maxMatches The maximum amount of messages to collect 8 | */ 9 | 10 | /** 11 | * Collects messages on a channel. 12 | * @extends {Collector} 13 | */ 14 | class MessageCollector extends Collector { 15 | /** 16 | * @param {TextChannel|DMChannel|GroupDMChannel} channel The channel 17 | * @param {CollectorFilter} filter The filter to be applied to this collector 18 | * @param {MessageCollectorOptions} options The options to be applied to this collector 19 | * @emits MessageCollector#message 20 | */ 21 | constructor(channel, filter, options = {}) { 22 | super(channel.client, filter, options); 23 | 24 | /** 25 | * The channel 26 | * @type {TextBasedChannel} 27 | */ 28 | this.channel = channel; 29 | 30 | /** 31 | * Total number of messages that were received in the channel during message collection 32 | * @type {number} 33 | */ 34 | this.received = 0; 35 | 36 | this.client.setMaxListeners(this.client.getMaxListeners() + 1); 37 | this.client.on('message', this.listener); 38 | 39 | // For backwards compatibility (remove in v12) 40 | if (this.options.max) this.options.maxProcessed = this.options.max; 41 | if (this.options.maxMatches) this.options.max = this.options.maxMatches; 42 | this._reEmitter = message => { 43 | /** 44 | * Emitted when the collector receives a message. 45 | * @event MessageCollector#message 46 | * @param {Message} message The message 47 | * @deprecated 48 | */ 49 | this.emit('message', message); 50 | }; 51 | this.on('collect', this._reEmitter); 52 | } 53 | 54 | // Remove in v12 55 | on(eventName, listener) { 56 | if (eventName === 'message') { 57 | listener = util.deprecate(listener, 'MessageCollector will soon no longer emit "message", use "collect" instead'); 58 | } 59 | super.on(eventName, listener); 60 | } 61 | 62 | /** 63 | * Handle an incoming message for possible collection. 64 | * @param {Message} message The message that could be collected 65 | * @returns {?{key: Snowflake, value: Message}} 66 | * @private 67 | */ 68 | handle(message) { 69 | if (message.channel.id !== this.channel.id) return null; 70 | this.received++; 71 | return { 72 | key: message.id, 73 | value: message, 74 | }; 75 | } 76 | 77 | /** 78 | * Check after collection to see if the collector is done. 79 | * @returns {?string} Reason to end the collector, if any 80 | * @private 81 | */ 82 | postCheck() { 83 | // Consider changing the end reasons for v12 84 | if (this.options.maxMatches && this.collected.size >= this.options.max) return 'matchesLimit'; 85 | if (this.options.max && this.received >= this.options.maxProcessed) return 'limit'; 86 | return null; 87 | } 88 | 89 | /** 90 | * Removes event listeners. 91 | * @private 92 | */ 93 | cleanup() { 94 | this.removeListener('collect', this._reEmitter); 95 | this.client.removeListener('message', this.listener); 96 | this.client.setMaxListeners(this.client.getMaxListeners() - 1); 97 | } 98 | } 99 | 100 | module.exports = MessageCollector; 101 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/NewsChannel.js: -------------------------------------------------------------------------------- 1 | const TextChannel = require('./TextChannel'); 2 | 3 | /** 4 | * Represents a guild news channel on Discord. 5 | * @extends {TextChannel} 6 | */ 7 | class NewsChannel extends TextChannel { 8 | constructor(guild, data) { 9 | super(guild, data); 10 | this.type = 'news'; 11 | } 12 | 13 | setup(data) { 14 | super.setup(data); 15 | 16 | /** 17 | * The ratelimit per user for this channel (always 0) 18 | * @type {number} 19 | */ 20 | this.rateLimitPerUser = 0; 21 | } 22 | } 23 | 24 | module.exports = NewsChannel; 25 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/PartialGuild.js: -------------------------------------------------------------------------------- 1 | /* 2 | { splash: null, 3 | id: '123123123', 4 | icon: '123123123', 5 | name: 'name' } 6 | */ 7 | 8 | /** 9 | * Represents a guild that the client only has limited information for - e.g. from invites. 10 | */ 11 | class PartialGuild { 12 | constructor(client, data) { 13 | /** 14 | * The client that instantiated this PartialGuild 15 | * @name PartialGuild#client 16 | * @type {Client} 17 | * @readonly 18 | */ 19 | Object.defineProperty(this, 'client', { value: client }); 20 | 21 | this.setup(data); 22 | } 23 | 24 | setup(data) { 25 | /** 26 | * The ID of this guild 27 | * @type {Snowflake} 28 | */ 29 | this.id = data.id; 30 | 31 | /** 32 | * The name of this guild 33 | * @type {string} 34 | */ 35 | this.name = data.name; 36 | 37 | /** 38 | * The hash of this guild's icon 39 | * @type {?string} 40 | */ 41 | this.icon = data.icon; 42 | 43 | /** 44 | * The hash of the guild splash image (VIP only) 45 | * @type {?string} 46 | */ 47 | this.splash = data.splash; 48 | } 49 | } 50 | 51 | module.exports = PartialGuild; 52 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/PartialGuildChannel.js: -------------------------------------------------------------------------------- 1 | const Constants = require('../util/Constants'); 2 | 3 | /* 4 | { type: 0, id: '123123', name: 'heavy-testing' } } 5 | */ 6 | 7 | /** 8 | * Represents a guild channel that the client only has limited information for - e.g. from invites. 9 | */ 10 | class PartialGuildChannel { 11 | constructor(client, data) { 12 | /** 13 | * The client that instantiated this PartialGuildChannel 14 | * @name PartialGuildChannel#client 15 | * @type {Client} 16 | * @readonly 17 | */ 18 | Object.defineProperty(this, 'client', { value: client }); 19 | 20 | this.setup(data); 21 | } 22 | 23 | setup(data) { 24 | /** 25 | * The ID of this guild channel 26 | * @type {Snowflake} 27 | */ 28 | this.id = data.id; 29 | 30 | /** 31 | * The name of this guild channel 32 | * @type {string} 33 | */ 34 | this.name = data.name; 35 | 36 | /** 37 | * The type of this guild channel - `text` or `voice` 38 | * @type {string} 39 | */ 40 | this.type = Constants.ChannelTypes.TEXT === data.type ? 'text' : 'voice'; 41 | } 42 | } 43 | 44 | module.exports = PartialGuildChannel; 45 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/PermissionOverwrites.js: -------------------------------------------------------------------------------- 1 | const Permissions = require('../util/Permissions'); 2 | 3 | /** 4 | * Represents a permission overwrite for a role or member in a guild channel. 5 | */ 6 | class PermissionOverwrites { 7 | constructor(guildChannel, data) { 8 | /** 9 | * The GuildChannel this overwrite is for 10 | * @name PermissionOverwrites#channel 11 | * @type {GuildChannel} 12 | * @readonly 13 | */ 14 | Object.defineProperty(this, 'channel', { value: guildChannel }); 15 | 16 | if (data) this.setup(data); 17 | } 18 | 19 | setup(data) { 20 | /** 21 | * The ID of this overwrite, either a user ID or a role ID 22 | * @type {Snowflake} 23 | */ 24 | this.id = data.id; 25 | 26 | /** 27 | * The type of this overwrite 28 | * @type {string} 29 | */ 30 | this.type = data.type; 31 | 32 | /** 33 | * The permissions that are denied for the user or role as a bitfield. 34 | * @type {number} 35 | */ 36 | this.deny = data.deny; 37 | 38 | /** 39 | * The permissions that are allowed for the user or role as a bitfield. 40 | * @type {number} 41 | */ 42 | this.allow = data.allow; 43 | 44 | /** 45 | * The permissions that are denied for the user or role. 46 | * @type {Permissions} 47 | * @deprecated 48 | */ 49 | this.denied = new Permissions(data.deny).freeze(); 50 | 51 | /** 52 | * The permissions that are allowed for the user or role. 53 | * @type {Permissions} 54 | * @deprecated 55 | */ 56 | this.allowed = new Permissions(data.allow).freeze(); 57 | } 58 | 59 | /** 60 | * Delete this Permission Overwrite. 61 | * @param {string} [reason] Reason for deleting this overwrite 62 | * @returns {Promise} 63 | */ 64 | delete(reason) { 65 | return this.channel.client.rest.methods.deletePermissionOverwrites(this, reason); 66 | } 67 | } 68 | 69 | module.exports = PermissionOverwrites; 70 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/ReactionCollector.js: -------------------------------------------------------------------------------- 1 | const Collector = require('./interfaces/Collector'); 2 | const Collection = require('../util/Collection'); 3 | 4 | /** 5 | * @typedef {CollectorOptions} ReactionCollectorOptions 6 | * @property {number} max The maximum total amount of reactions to collect 7 | * @property {number} maxEmojis The maximum number of emojis to collect 8 | * @property {number} maxUsers The maximum number of users to react 9 | */ 10 | 11 | /** 12 | * Collects reactions on messages. 13 | * @extends {Collector} 14 | */ 15 | class ReactionCollector extends Collector { 16 | /** 17 | * @param {Message} message The message upon which to collect reactions 18 | * @param {CollectorFilter} filter The filter to apply to this collector 19 | * @param {ReactionCollectorOptions} [options={}] The options to apply to this collector 20 | */ 21 | constructor(message, filter, options = {}) { 22 | super(message.client, filter, options); 23 | 24 | /** 25 | * The message 26 | * @type {Message} 27 | */ 28 | this.message = message; 29 | 30 | /** 31 | * The users which have reacted 32 | * @type {Collection} 33 | */ 34 | this.users = new Collection(); 35 | 36 | /** 37 | * The total number of reactions collected 38 | * @type {number} 39 | */ 40 | this.total = 0; 41 | 42 | this.client.setMaxListeners(this.client.getMaxListeners() + 1); 43 | this.client.on('messageReactionAdd', this.listener); 44 | } 45 | 46 | /** 47 | * Handle an incoming reaction for possible collection. 48 | * @param {MessageReaction} reaction The reaction to possibly collect 49 | * @returns {?{key: Snowflake, value: MessageReaction}} 50 | * @private 51 | */ 52 | handle(reaction) { 53 | if (reaction.message.id !== this.message.id) return null; 54 | return { 55 | key: reaction.emoji.id || reaction.emoji.name, 56 | value: reaction, 57 | }; 58 | } 59 | 60 | /** 61 | * Check after collection to see if the collector is done. 62 | * @param {MessageReaction} reaction The reaction that was collected 63 | * @param {User} user The user that reacted 64 | * @returns {?string} Reason to end the collector, if any 65 | * @private 66 | */ 67 | postCheck(reaction, user) { 68 | this.users.set(user.id, user); 69 | if (this.options.max && ++this.total >= this.options.max) return 'limit'; 70 | if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit'; 71 | if (this.options.maxUsers && this.users.size >= this.options.maxUsers) return 'userLimit'; 72 | return null; 73 | } 74 | 75 | /** 76 | * Remove event listeners. 77 | * @private 78 | */ 79 | cleanup() { 80 | this.client.removeListener('messageReactionAdd', this.listener); 81 | this.client.setMaxListeners(this.client.getMaxListeners() - 1); 82 | } 83 | } 84 | 85 | module.exports = ReactionCollector; 86 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/ReactionEmoji.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a limited emoji set used for both custom and unicode emojis. Custom emojis 3 | * will use this class opposed to the Emoji class when the client doesn't know enough 4 | * information about them. 5 | */ 6 | class ReactionEmoji { 7 | constructor(reaction, name, id) { 8 | /** 9 | * The message reaction this emoji refers to 10 | * @type {MessageReaction} 11 | */ 12 | this.reaction = reaction; 13 | 14 | /** 15 | * The name of this reaction emoji 16 | * @type {string} 17 | */ 18 | this.name = name; 19 | 20 | /** 21 | * The ID of this reaction emoji 22 | * @type {?Snowflake} 23 | */ 24 | this.id = id; 25 | } 26 | 27 | /** 28 | * The identifier of this emoji, used for message reactions 29 | * @type {string} 30 | * @readonly 31 | */ 32 | get identifier() { 33 | if (this.id) return `${this.name}:${this.id}`; 34 | return encodeURIComponent(this.name); 35 | } 36 | 37 | /** 38 | * Creates the text required to form a graphical emoji on Discord. 39 | * @example 40 | * // Send the emoji used in a reaction to the channel the reaction is part of 41 | * reaction.message.channel.send(`The emoji used is ${reaction.emoji}`); 42 | * @returns {string} 43 | */ 44 | toString() { 45 | return this.id ? `<:${this.name}:${this.id}>` : this.name; 46 | } 47 | } 48 | 49 | module.exports = ReactionEmoji; 50 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/StoreChannel.js: -------------------------------------------------------------------------------- 1 | const GuildChannel = require('./GuildChannel'); 2 | 3 | /** 4 | * Represents a guild store channel on Discord. 5 | * @extends {GuildChannel} 6 | */ 7 | class StoreChannel extends GuildChannel { 8 | constructor(guild, data) { 9 | super(guild, data); 10 | this.type = 'store'; 11 | } 12 | 13 | setup(data) { 14 | super.setup(data); 15 | 16 | /** 17 | * If the guild considers this channel NSFW 18 | * @type {boolean} 19 | * @readonly 20 | */ 21 | this.nsfw = data.nsfw; 22 | } 23 | } 24 | 25 | module.exports = StoreChannel; 26 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/UserConnection.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a user connection (or "platform identity"). 3 | */ 4 | class UserConnection { 5 | constructor(user, data) { 6 | /** 7 | * The user that owns the connection 8 | * @type {User} 9 | */ 10 | this.user = user; 11 | 12 | this.setup(data); 13 | } 14 | 15 | setup(data) { 16 | /** 17 | * The type of the connection 18 | * @type {string} 19 | */ 20 | this.type = data.type; 21 | 22 | /** 23 | * The username of the connection account 24 | * @type {string} 25 | */ 26 | this.name = data.name; 27 | 28 | /** 29 | * The id of the connection account 30 | * @type {string} 31 | */ 32 | this.id = data.id; 33 | 34 | /** 35 | * Whether the connection is revoked 36 | * @type {boolean} 37 | */ 38 | this.revoked = data.revoked; 39 | 40 | /** 41 | * Partial server integrations (not yet implemented) 42 | * @type {Object[]} 43 | */ 44 | this.integrations = data.integrations; 45 | } 46 | } 47 | 48 | module.exports = UserConnection; 49 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/UserProfile.js: -------------------------------------------------------------------------------- 1 | const Collection = require('../util/Collection'); 2 | const UserConnection = require('./UserConnection'); 3 | 4 | /** 5 | * Represents a user's profile on Discord. 6 | */ 7 | class UserProfile { 8 | constructor(user, data) { 9 | /** 10 | * The owner of the profile 11 | * @type {User} 12 | */ 13 | this.user = user; 14 | 15 | /** 16 | * The client that created the instance of the UserProfile 17 | * @name UserProfile#client 18 | * @type {Client} 19 | * @readonly 20 | */ 21 | Object.defineProperty(this, 'client', { value: user.client }); 22 | 23 | /** 24 | * The guilds that the client user and the user share 25 | * @type {Collection} 26 | */ 27 | this.mutualGuilds = new Collection(); 28 | 29 | /** 30 | * The user's connections 31 | * @type {Collection} 32 | */ 33 | this.connections = new Collection(); 34 | 35 | this.setup(data); 36 | } 37 | 38 | setup(data) { 39 | /** 40 | * If the user has Discord Premium 41 | * @type {boolean} 42 | */ 43 | this.premium = data.premium; 44 | 45 | /** 46 | * The date since which the user has had Discord Premium 47 | * @type {?Date} 48 | */ 49 | this.premiumSince = data.premium_since ? new Date(data.premium_since) : null; 50 | 51 | for (const guild of data.mutual_guilds) { 52 | if (this.client.guilds.has(guild.id)) { 53 | this.mutualGuilds.set(guild.id, this.client.guilds.get(guild.id)); 54 | } 55 | } 56 | for (const connection of data.connected_accounts) { 57 | this.connections.set(connection.id, new UserConnection(this.user, connection)); 58 | } 59 | } 60 | } 61 | 62 | module.exports = UserProfile; 63 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/VoiceRegion.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a Discord voice region for guilds. 3 | */ 4 | class VoiceRegion { 5 | constructor(data) { 6 | /** 7 | * The ID of the region 8 | * @type {string} 9 | */ 10 | this.id = data.id; 11 | 12 | /** 13 | * Name of the region 14 | * @type {string} 15 | */ 16 | this.name = data.name; 17 | 18 | /** 19 | * Whether the region is VIP-only 20 | * @type {boolean} 21 | */ 22 | this.vip = data.vip; 23 | 24 | /** 25 | * Whether the region is deprecated 26 | * @type {boolean} 27 | */ 28 | this.deprecated = data.deprecated; 29 | 30 | /** 31 | * Whether the region is optimal 32 | * @type {boolean} 33 | */ 34 | this.optimal = data.optimal; 35 | 36 | /** 37 | * Whether the region is custom 38 | * @type {boolean} 39 | */ 40 | this.custom = data.custom; 41 | 42 | /** 43 | * A sample hostname for what a connection might look like 44 | * @type {string} 45 | */ 46 | this.sampleHostname = data.sample_hostname; 47 | } 48 | } 49 | 50 | module.exports = VoiceRegion; 51 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/structures/shared/resolvePermissions.js: -------------------------------------------------------------------------------- 1 | const Permissions = require('../../util/Permissions'); 2 | const Collection = require('../../util/Collection'); 3 | 4 | module.exports = function resolvePermissions(overwrites, guild) { 5 | if (overwrites instanceof Collection || overwrites instanceof Array) { 6 | overwrites = overwrites.map(overwrite => { 7 | const role = this.client.resolver.resolveRole(guild, overwrite.id); 8 | if (role) { 9 | overwrite.id = role.id; 10 | overwrite.type = 'role'; 11 | } else { 12 | overwrite.id = this.client.resolver.resolveUserID(overwrite.id); 13 | overwrite.type = 'member'; 14 | } 15 | 16 | return { 17 | allow: Permissions.resolve(overwrite.allow || overwrite.allowed || 0), 18 | deny: Permissions.resolve(overwrite.deny || overwrite.denied || 0), 19 | type: overwrite.type, 20 | id: overwrite.id, 21 | }; 22 | }); 23 | } 24 | 25 | return overwrites; 26 | }; 27 | -------------------------------------------------------------------------------- /node_modules/discord.js/src/util/Snowflake.js: -------------------------------------------------------------------------------- 1 | const Long = require('long'); 2 | 3 | // Discord epoch (2015-01-01T00:00:00.000Z) 4 | const EPOCH = 1420070400000; 5 | let INCREMENT = 0; 6 | 7 | /** 8 | * A container for useful snowflake-related methods. 9 | */ 10 | class SnowflakeUtil { 11 | constructor() { 12 | throw new Error(`The ${this.constructor.name} class may not be instantiated.`); 13 | } 14 | 15 | /** 16 | * A Twitter snowflake, except the epoch is 2015-01-01T00:00:00.000Z 17 | * ``` 18 | * If we have a snowflake '266241948824764416' we can represent it as binary: 19 | * 20 | * 64 22 17 12 0 21 | * 000000111011000111100001101001000101000000 00001 00000 000000000000 22 | * number of ms since Discord epoch worker pid increment 23 | * ``` 24 | * @typedef {string} Snowflake 25 | */ 26 | 27 | /** 28 | * Generates a Discord snowflake. 29 | * This hardcodes the worker ID as 1 and the process ID as 0. 30 | * @param {number|Date} [timestamp=Date.now()] Timestamp or date of the snowflake to generate 31 | * @returns {Snowflake} The generated snowflake 32 | */ 33 | static generate(timestamp = Date.now()) { 34 | if (timestamp instanceof Date) timestamp = timestamp.getTime(); 35 | if (typeof timestamp !== 'number' || isNaN(timestamp)) { 36 | throw new TypeError( 37 | `"timestamp" argument must be a number (received ${isNaN(timestamp) ? 'NaN' : typeof timestamp})` 38 | ); 39 | } 40 | if (INCREMENT >= 4095) INCREMENT = 0; 41 | const BINARY = `${pad((timestamp - EPOCH).toString(2), 42)}0000100000${pad((INCREMENT++).toString(2), 12)}`; 42 | return Long.fromString(BINARY, 2).toString(); 43 | } 44 | 45 | /** 46 | * A deconstructed snowflake. 47 | * @typedef {Object} DeconstructedSnowflake 48 | * @property {number} timestamp Timestamp the snowflake was created 49 | * @property {Date} date Date the snowflake was created 50 | * @property {number} workerID Worker ID in the snowflake 51 | * @property {number} processID Process ID in the snowflake 52 | * @property {number} increment Increment in the snowflake 53 | * @property {string} binary Binary representation of the snowflake 54 | */ 55 | 56 | /** 57 | * Deconstructs a Discord snowflake. 58 | * @param {Snowflake} snowflake Snowflake to deconstruct 59 | * @returns {DeconstructedSnowflake} Deconstructed snowflake 60 | */ 61 | static deconstruct(snowflake) { 62 | const BINARY = pad(Long.fromString(snowflake).toString(2), 64); 63 | const res = { 64 | timestamp: parseInt(BINARY.substring(0, 42), 2) + EPOCH, 65 | workerID: parseInt(BINARY.substring(42, 47), 2), 66 | processID: parseInt(BINARY.substring(47, 52), 2), 67 | increment: parseInt(BINARY.substring(52, 64), 2), 68 | binary: BINARY, 69 | }; 70 | Object.defineProperty(res, 'date', { 71 | get: function get() { return new Date(this.timestamp); }, 72 | enumerable: true, 73 | }); 74 | return res; 75 | } 76 | } 77 | 78 | function pad(v, n, c = '0') { 79 | return String(v).length >= n ? String(v) : (String(c).repeat(n) + v).slice(-n); 80 | } 81 | 82 | module.exports = SnowflakeUtil; 83 | -------------------------------------------------------------------------------- /node_modules/discord.js/typings/discord.js-test.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import { Collector, Message, CollectorFilter, Client, CollectorHandler, MessageReaction, Collection, User, ReactionCollectorOptions, Snowflake } from 'discord.js'; 4 | 5 | const client = new Client({ 6 | disableEveryone: false, 7 | disabledEvents: ['GUILD_MEMBER_ADD'] 8 | }); 9 | 10 | client.on('message', (message) => { 11 | if (message.content === 'hello') { 12 | message.channel.sendMessage('o/'); 13 | } 14 | 15 | const collector: ReactionCollector = new ReactionCollector(message, 16 | (reaction: MessageReaction) => reaction.emoji.toString() === '👌', 17 | { time: 30e3 }); 18 | collector.on('end', collected => console.log(collected)); 19 | }); 20 | 21 | client.login('dsfsd754.4fds4f68d4f6sd46f4s.7878easfdsgdfFDSIJIO'); 22 | 23 | export class TestCollector extends Collector { 24 | public filter: CollectorFilter; 25 | public constructor(client: Client, filter: CollectorFilter) { 26 | super(client, filter); 27 | } 28 | 29 | public handle(message: Message): CollectorHandler { 30 | return { key: message.id, value: message }; 31 | } 32 | 33 | public cleanup(): void {} 34 | public postCheck(): null { return null; } 35 | } 36 | 37 | class ReactionCollector extends Collector { 38 | public message: Message; 39 | public users: Collection; 40 | public total: number; 41 | public options: ReactionCollectorOptions; 42 | public constructor(message: Message, filter: CollectorFilter, options?: ReactionCollectorOptions) { 43 | super(message.client, filter, options || {}); 44 | this.message = message; 45 | this.users = new Collection(); 46 | this.total = 0; 47 | this.client.on('messageReactionAdd', this.listener); 48 | } 49 | 50 | public handle(reaction: MessageReaction): CollectorHandler { 51 | if (reaction.message.id !== this.message.id) { return null; } 52 | return { 53 | key: reaction.emoji.id || reaction.emoji.name, 54 | value: reaction 55 | }; 56 | } 57 | 58 | public postCheck(reaction: MessageReaction, user: User): string { 59 | this.users.set(user.id, user); 60 | if (this.options.max && ++this.total >= this.options.max) { return 'limit'; } 61 | if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) { return 'emojiLimit'; } 62 | if (this.options.maxUsers && this.users.size >= this.options.maxUsers) { return 'userLimit'; } 63 | return null; 64 | } 65 | 66 | public cleanup(): void { 67 | this.client.removeListener('messageReactionAdd', this.listener as any); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /node_modules/long/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require("./src/long"); 2 | -------------------------------------------------------------------------------- /node_modules/long/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "long@^4.0.0", 3 | "_id": "long@4.0.0", 4 | "_inBundle": false, 5 | "_integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", 6 | "_location": "/long", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "long@^4.0.0", 12 | "name": "long", 13 | "escapedName": "long", 14 | "rawSpec": "^4.0.0", 15 | "saveSpec": null, 16 | "fetchSpec": "^4.0.0" 17 | }, 18 | "_requiredBy": [ 19 | "/discord.js" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", 22 | "_shasum": "9a7b71cfb7d361a194ea555241c92f7468d5bf28", 23 | "_spec": "long@^4.0.0", 24 | "_where": "C:\\Users\\Chris\\Desktop\\GenBot\\node_modules\\discord.js", 25 | "author": { 26 | "name": "Daniel Wirtz", 27 | "email": "dcode@dcode.io" 28 | }, 29 | "bugs": { 30 | "url": "https://github.com/dcodeIO/long.js/issues" 31 | }, 32 | "bundleDependencies": false, 33 | "dependencies": {}, 34 | "deprecated": false, 35 | "description": "A Long class for representing a 64-bit two's-complement integer value.", 36 | "devDependencies": { 37 | "webpack": "^3.10.0" 38 | }, 39 | "files": [ 40 | "index.js", 41 | "LICENSE", 42 | "README.md", 43 | "src/long.js", 44 | "dist/long.js", 45 | "dist/long.js.map" 46 | ], 47 | "homepage": "https://github.com/dcodeIO/long.js#readme", 48 | "keywords": [ 49 | "math" 50 | ], 51 | "license": "Apache-2.0", 52 | "main": "src/long.js", 53 | "name": "long", 54 | "repository": { 55 | "type": "git", 56 | "url": "git+https://github.com/dcodeIO/long.js.git" 57 | }, 58 | "scripts": { 59 | "build": "webpack", 60 | "test": "node tests" 61 | }, 62 | "version": "4.0.0" 63 | } 64 | -------------------------------------------------------------------------------- /node_modules/prism-media/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - node 4 | cache: 5 | directories: 6 | - node_modules -------------------------------------------------------------------------------- /node_modules/prism-media/README.md: -------------------------------------------------------------------------------- 1 | # prism-media 2 | [![Build Status](https://travis-ci.org/hydrabolt/prism-media.svg?branch=master)](https://travis-ci.org/hydrabolt/prism-media) 3 | [![dependencies](https://david-dm.org/hydrabolt/prism-media/status.svg)](https://david-dm.org/hydrabolt/prism-media) 4 | [![devDependencies](https://david-dm.org/hydrabolt/prism-media/dev-status.svg)](https://david-dm.org/hydrabolt/prism-media?type=dev) 5 | 6 | Makes programmatically transcoding media easier 7 | 8 | `npm install --save hydrabolt/prism-media` 9 | 10 | ```js 11 | const Prism = require('prism-media'); 12 | const fs = require('fs'); 13 | 14 | const prism = new Prism(); 15 | 16 | const transcoder = prism.transcode({ 17 | type: 'ffmpeg', 18 | media: './test/test.mp3', 19 | ffmpegArguments: [ 20 | '-analyzeduration', '0', 21 | '-loglevel', '0', 22 | '-f', 's16le', 23 | '-ar', '48000', 24 | '-ac', '2', 25 | ], 26 | }); 27 | 28 | transcoder.output.pipe(fs.createWriteStream('./test/test.pcm')); 29 | ``` -------------------------------------------------------------------------------- /node_modules/prism-media/output.opus: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Talus/GenBot-Tutorial/e39abcb556564aba3ec53910653b88e44feefad5/node_modules/prism-media/output.opus -------------------------------------------------------------------------------- /node_modules/prism-media/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "prism-media@^0.0.3", 3 | "_id": "prism-media@0.0.3", 4 | "_inBundle": false, 5 | "_integrity": "sha512-c9KkNifSMU/iXT8FFTaBwBMr+rdVcN+H/uNv1o+CuFeTThNZNTOrQ+RgXA1yL/DeLk098duAeRPP3QNPNbhxYQ==", 6 | "_location": "/prism-media", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "prism-media@^0.0.3", 12 | "name": "prism-media", 13 | "escapedName": "prism-media", 14 | "rawSpec": "^0.0.3", 15 | "saveSpec": null, 16 | "fetchSpec": "^0.0.3" 17 | }, 18 | "_requiredBy": [ 19 | "/discord.js" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.0.3.tgz", 22 | "_shasum": "8842d4fae804f099d3b48a9a38e3c2bab6f4855b", 23 | "_spec": "prism-media@^0.0.3", 24 | "_where": "C:\\Users\\Chris\\Desktop\\GenBot\\node_modules\\discord.js", 25 | "author": { 26 | "name": "Amish Shah", 27 | "email": "amishshah.2k@gmail.com" 28 | }, 29 | "bugs": { 30 | "url": "https://github.com/hydrabolt/prism-media/issues" 31 | }, 32 | "bundleDependencies": false, 33 | "deprecated": false, 34 | "description": "Makes transcoding media easier", 35 | "devDependencies": { 36 | "eslint": "^3.12.2" 37 | }, 38 | "homepage": "https://github.com/hydrabolt/prism-media#readme", 39 | "keywords": [ 40 | "audio", 41 | "media", 42 | "ffmpeg" 43 | ], 44 | "license": "Apache-2.0", 45 | "main": "src/index.js", 46 | "name": "prism-media", 47 | "repository": { 48 | "type": "git", 49 | "url": "git+https://github.com/hydrabolt/prism-media.git" 50 | }, 51 | "scripts": { 52 | "lint": "eslint src && eslint test", 53 | "test": "npm run lint" 54 | }, 55 | "version": "0.0.3" 56 | } 57 | -------------------------------------------------------------------------------- /node_modules/prism-media/src/Prism.js: -------------------------------------------------------------------------------- 1 | const MediaTranscoder = require('./transcoders/MediaTranscoder'); 2 | 3 | class Prism { 4 | constructor() { 5 | this.transcoder = new MediaTranscoder(this); 6 | } 7 | 8 | createTranscoder(...args) { 9 | return this.transcode(...args); 10 | } 11 | 12 | transcode(...args) { 13 | return this.transcoder.transcode(...args); 14 | } 15 | } 16 | 17 | module.exports = Prism; 18 | -------------------------------------------------------------------------------- /node_modules/prism-media/src/index.js: -------------------------------------------------------------------------------- 1 | const Prism = require('./Prism'); 2 | const MediaTranscoder = require('./transcoders/MediaTranscoder'); 3 | 4 | Prism.MediaTranscoder = MediaTranscoder; 5 | 6 | module.exports = Prism; 7 | -------------------------------------------------------------------------------- /node_modules/prism-media/src/opus/OggOpus.js: -------------------------------------------------------------------------------- 1 | const { Transform } = require('stream'); 2 | 3 | const OGG_PAGE_HEADER_SIZE = 26; 4 | const STREAM_STRUCTURE_VERSION = 0; 5 | 6 | const OGGS_HEADER = Buffer.from('OggS'.split('').map(x => x.charCodeAt(0))); 7 | const OPUS_HEAD = Buffer.from('OpusHead'.split('').map(x => x.charCodeAt(0))); 8 | const OPUS_TAGS = Buffer.from('OpusTags'.split('').map(x => x.charCodeAt(0))); 9 | 10 | class OggOpusTransform extends Transform { 11 | constructor() { 12 | super(); 13 | this._remainder = null; 14 | this._head = null; 15 | } 16 | 17 | _transform(chunk, encoding, done) { 18 | if (this._remainder) { 19 | chunk = Buffer.concat([this._remainder, chunk]); 20 | this._remainder = null; 21 | } 22 | 23 | while (chunk) { 24 | try { 25 | const result = this.readPage(chunk); 26 | if (result) chunk = result; 27 | else break; 28 | } catch (err) { 29 | this.emit('error', err); 30 | } 31 | } 32 | this._remainder = chunk; 33 | done(); 34 | } 35 | 36 | /** 37 | * Reads a page from a buffer 38 | * @param {Buffer} chunk The chunk containing the page 39 | * @returns {boolean|Buffer} 40 | */ 41 | readPage(chunk) { 42 | if (chunk.length < OGG_PAGE_HEADER_SIZE) { 43 | return false; 44 | } 45 | if (!chunk.slice(0, 4).equals(OGGS_HEADER)) { 46 | throw Error(`capture_pattern is not ${OGGS_HEADER}`); 47 | } 48 | if (chunk.readUInt8(4) !== STREAM_STRUCTURE_VERSION) { 49 | throw Error(`stream_structure_version is not ${STREAM_STRUCTURE_VERSION}`); 50 | } 51 | 52 | const pageSegments = chunk.readUInt8(26), 53 | table = chunk.slice(27, 27 + pageSegments); 54 | 55 | let sizes = [], totalSize = 0; 56 | 57 | for (let i = 0; i < pageSegments;) { 58 | let size = 0, x = 255; 59 | while (x === 255) { 60 | x = table.readUInt8(i); 61 | i++; 62 | size += x; 63 | } 64 | sizes.push(size); 65 | totalSize += size; 66 | } 67 | 68 | if (chunk.length < 27 + pageSegments + totalSize) { 69 | return false; 70 | } 71 | 72 | let start = 27 + pageSegments; 73 | for (const size of sizes) { 74 | const segment = chunk.slice(start, start + size); 75 | const header = segment.slice(0, 8); 76 | if (this._head) { 77 | if (header.equals(OPUS_TAGS)) this.emit('opusTags', segment); 78 | else this.push(segment); 79 | } else if (header.equals(OPUS_HEAD)) { 80 | this._head = segment; 81 | } else { 82 | throw Error(`Invalid segment ${segment}`); 83 | } 84 | start += size; 85 | } 86 | return chunk.slice(start); 87 | } 88 | } 89 | 90 | module.exports = OggOpusTransform; 91 | -------------------------------------------------------------------------------- /node_modules/prism-media/src/transcoders/MediaTranscoder.js: -------------------------------------------------------------------------------- 1 | const Ffmpeg = require('./ffmpeg/Ffmpeg'); 2 | 3 | const transcoders = [ 4 | 'ffmpeg', 5 | ]; 6 | 7 | class MediaTranscoder { 8 | constructor(prism) { 9 | this.prism = prism; 10 | this.ffmpeg = new Ffmpeg(this); 11 | } 12 | 13 | static verifyOptions(options) { 14 | if (!options) throw new Error('Options must be passed to MediaTranscoder.transcode()'); 15 | if (!options.type) throw new Error('Options.type must be passed to MediaTranscoder.transcode()'); 16 | if (!transcoders.includes(options.type)) throw new Error(`Options.type must be: ${transcoders.join(' ')}`); 17 | return options; 18 | } 19 | 20 | /** 21 | * Transcodes a media stream based on specified options 22 | * @param {Object} options the options to use when transcoding 23 | * @returns {ReadableStream} the transcodeed stream 24 | */ 25 | transcode(options) { 26 | options = MediaTranscoder.verifyOptions(options); 27 | return this[options.type].transcode(options); 28 | } 29 | } 30 | 31 | module.exports = MediaTranscoder; 32 | -------------------------------------------------------------------------------- /node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js: -------------------------------------------------------------------------------- 1 | const ChildProcess = require('child_process'); 2 | const FfmpegProcess = require('./FfmpegProcess'); 3 | 4 | class FfmpegTranscoder { 5 | constructor(mediaTranscoder) { 6 | this.mediaTranscoder = mediaTranscoder; 7 | this.command = FfmpegTranscoder.selectFfmpegCommand(); 8 | this.processes = []; 9 | } 10 | 11 | static verifyOptions(options) { 12 | if (!options) throw new Error('Options not provided!'); 13 | if (!options.media) throw new Error('Media must be provided'); 14 | if (!options.ffmpegArguments || !(options.ffmpegArguments instanceof Array)) { 15 | throw new Error('FFMPEG Arguments must be an array'); 16 | } 17 | if (options.ffmpegArguments.includes('-i')) return options; 18 | if (typeof options.media === 'string') { 19 | options.ffmpegArguments = ['-i', `${options.media}`].concat(options.ffmpegArguments).concat(['pipe:1']); 20 | } else { 21 | options.ffmpegArguments = ['-i', '-'].concat(options.ffmpegArguments).concat(['pipe:1']); 22 | } 23 | return options; 24 | } 25 | 26 | /** 27 | * Transcodes an input using FFMPEG 28 | * @param {FfmpegTranscoderOptions} options the options to use 29 | * @returns {FfmpegProcess} the created FFMPEG process 30 | * @throws {FFMPEGOptionsError} 31 | */ 32 | transcode(options) { 33 | if (!this.command) this.command = FfmpegTranscoder.selectFfmpegCommand(); 34 | const proc = new FfmpegProcess(this, FfmpegTranscoder.verifyOptions(options)); 35 | this.processes.push(proc); 36 | return proc; 37 | } 38 | 39 | static selectFfmpegCommand() { 40 | try { 41 | return require('ffmpeg-binaries'); 42 | } catch (err) { 43 | for (const command of ['ffmpeg', 'avconv', './ffmpeg', './avconv']) { 44 | if (!ChildProcess.spawnSync(command, ['-h']).error) return command; 45 | } 46 | throw new Error('FFMPEG not found'); 47 | } 48 | } 49 | } 50 | 51 | module.exports = FfmpegTranscoder; 52 | -------------------------------------------------------------------------------- /node_modules/prism-media/src/transcoders/ffmpeg/FfmpegProcess.js: -------------------------------------------------------------------------------- 1 | const EventEmitter = require('events').EventEmitter; 2 | const ChildProcess = require('child_process'); 3 | 4 | /** 5 | * A spawned FFMPEG process 6 | */ 7 | class FfmpegProcess extends EventEmitter { 8 | constructor(ffmpegTranscoder, options) { 9 | super(); 10 | /** 11 | * The ffmpeg process 12 | * @type {ChildProcess} 13 | */ 14 | this.process = ChildProcess.spawn(ffmpegTranscoder.command, options.ffmpegArguments); 15 | /** 16 | * The FFMPEG transcoder that created this process 17 | * @type {FfmpegTranscoder} 18 | */ 19 | this.transcoder = ffmpegTranscoder; 20 | /** 21 | * The input media 22 | * @type {?ReadableStream|string} 23 | */ 24 | this.inputMedia = options.media; 25 | 26 | if (typeof this.inputMedia !== 'string') { 27 | try { 28 | this.connectStream(this.inputMedia); 29 | } catch (e) { 30 | this.emit('error', e, 'instantiation'); 31 | } 32 | } else { 33 | this.attachErrorHandlers(); 34 | } 35 | 36 | this.on('error', this.kill.bind(this)); 37 | this.once('end', this.kill.bind(this)); 38 | } 39 | 40 | /** 41 | * The ffmpeg output stream 42 | * @type {?ReadableStream} 43 | */ 44 | get output() { 45 | return this.process ? this.process.stdout : null; 46 | } 47 | 48 | attachErrorHandlers() { 49 | this.process.stdin.on('error', e => { 50 | // if not killed 51 | if (this.process) { 52 | this.emit('error', e, 'ffmpegProcess.stdin'); 53 | } 54 | }); 55 | this.process.stdout.on('error', e => { 56 | // if not killed 57 | if (this.process) { 58 | this.emit('error', e, 'ffmpegProcess.stdout'); 59 | } 60 | }); 61 | this.process.on('error', e => this.emit('error', e, 'ffmpegProcess')); 62 | this.process.stdout.on('end', () => this.emit('end')); 63 | } 64 | 65 | /** 66 | * Connects an input stream to the ffmpeg process 67 | * @param {ReadableStream} inputMedia the stream to pass to ffmpeg 68 | * @returns {ReadableStream} the ffmpeg output stream 69 | */ 70 | connectStream(inputMedia) { 71 | if (!this.process) throw new Error('No FFMPEG process available'); 72 | this.inputMedia = inputMedia; 73 | this.inputMedia.pipe(this.process.stdin, { end: false }); 74 | 75 | inputMedia.on('error', e => this.emit('error', e, 'inputstream', inputMedia)); 76 | 77 | this.attachErrorHandlers(); 78 | 79 | return this.process.stdout; 80 | } 81 | 82 | /** 83 | * Kills the ffmpeg process 84 | */ 85 | kill() { 86 | if (!this.process) return; 87 | if (this.inputMedia && this.inputMedia.unpipe) { 88 | this.inputMedia.unpipe(this.process.stdin); 89 | } 90 | this.process.kill('SIGKILL'); 91 | this.process = null; 92 | } 93 | } 94 | 95 | module.exports = FfmpegProcess; 96 | -------------------------------------------------------------------------------- /node_modules/prism-media/src/util/Constants.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Talus/GenBot-Tutorial/e39abcb556564aba3ec53910653b88e44feefad5/node_modules/prism-media/src/util/Constants.js -------------------------------------------------------------------------------- /node_modules/prism-media/test/main.js: -------------------------------------------------------------------------------- 1 | /* eslint no-console: 0 */ 2 | const Prism = require('../'); 3 | const fs = require('fs'); 4 | 5 | const prism = new Prism(); 6 | 7 | const transcoder = prism.transcode({ 8 | type: 'ffmpeg', 9 | media: './test/test.mp3', 10 | ffmpegArguments: [ 11 | '-analyzeduration', '0', 12 | '-loglevel', '0', 13 | '-f', 's16le', 14 | '-ar', '48000', 15 | '-ac', '2', 16 | ], 17 | }); 18 | 19 | transcoder.output.pipe(fs.createWriteStream('./test/test.pcm')); 20 | -------------------------------------------------------------------------------- /node_modules/prism-media/test/test.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const OggOpusTransform = require('../src/opus/OggOpus'); 3 | const opus = require('node-opus'); 4 | 5 | const decoder = new opus.Decoder(48000, 2, 1920); 6 | 7 | const transformer = new OggOpusTransform(); 8 | 9 | fs.createReadStream('./test/ts.ogg') 10 | .pipe(transformer) 11 | .pipe(decoder) 12 | .pipe(fs.createWriteStream('./output.opus')); 13 | -------------------------------------------------------------------------------- /node_modules/snekfetch/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Snekfetch version or commit hash: 2 | 3 | 4 | Explaination of issue: 5 | 6 | 7 | Example code to reproduce: 8 | ```js 9 | // code here 10 | ``` 11 | 12 | 13 | - [ ] Issue occurs in browser 14 | - [ ] Issue occurs in node 15 | -------------------------------------------------------------------------------- /node_modules/snekfetch/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | if your pr is about typescript go away 2 | -------------------------------------------------------------------------------- /node_modules/snekfetch/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | install: npm install 5 | jobs: 6 | include: 7 | - stage: test 8 | script: bash ./scripts/travis-test.sh 9 | - stage: deploy 10 | script: bash ./scripts/travis-deploy.sh 11 | cache: 12 | directories: 13 | - node_modules 14 | notifications: 15 | email: false 16 | -------------------------------------------------------------------------------- /node_modules/snekfetch/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at me@gus.host. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /node_modules/snekfetch/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | don't break stuff when you pr 2 | -------------------------------------------------------------------------------- /node_modules/snekfetch/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Gus Caplan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /node_modules/snekfetch/README.md: -------------------------------------------------------------------------------- 1 | [![npm][download-badge]][npm] 2 | [![David][dep-badge]][dep-link] 3 | [![Coverage Status][coverage-badge]][coverage-link] 4 | [![Build Status][build-badge]][build-link] 5 | 6 | [![NPM][large-badge]][stats-link] 7 | 8 | # snekfetch [![Version Badge][version-badge]][npm] 9 | 10 | Snekfetch is a fast, efficient, and user-friendly library for making HTTP requests. 11 | 12 | The API was inspired by superagent, however it is much smaller and faster. 13 | In fact, in browser, it is a mere 4.4kb. 14 | 15 | Documentation is available at https://snekfetch.js.org/ 16 | 17 | ## Some examples 18 | 19 | ```javascript 20 | const request = require('snekfetch'); 21 | 22 | request.post('https://httpbin.org/post') 23 | .send({ usingGoodRequestLibrary: true }) 24 | .then(r => console.log(r.body)); // r.body is object from json response 25 | 26 | request.get('https://s.gc.gy/o-SNAKES.jpg') 27 | .then(r => fs.writeFile('download.jpg', r.body)); // r.body is buffer 28 | 29 | request.get('https://s.gc.gy/o-SNAKES.jpg') 30 | .pipe(fs.createWriteStream('download.jpg')); // pipes 31 | ``` 32 | 33 | Available for browser as UMD from [unpkg][unpkg-link] 34 | ```html 35 | 36 | ``` 37 | 38 | [npm]: https://npmjs.org/package/snekfetch 39 | [large-badge]: https://nodei.co/npm/snekfetch.png?downloads=true&downloadRank=true&stars=true 40 | [stats-link]: https://nodei.co/npm/snekfetch/ 41 | [version-badge]: https://versionbadge.now.sh/snekfetch.svg 42 | [download-badge]: https://img.shields.io/npm/dt/snekfetch.svg?maxAge=3600 43 | [build-badge]: https://api.travis-ci.org/devsnek/snekfetch.svg?branch=master 44 | [build-link]: https://travis-ci.org/devsnek/snekfetch 45 | [dep-badge]: https://david-dm.org/devsnek/snekfetch.svg 46 | [dep-link]: https://david-dm.org/devsnek/snekfetch 47 | [coverage-badge]: https://coveralls.io/repos/github/devsnek/snekfetch/badge.svg?branch=master 48 | [coverage-link]: https://coveralls.io/github/devsnek/snekfetch?branch=master 49 | [unpkg-link]: https://unpkg.com/ 50 | -------------------------------------------------------------------------------- /node_modules/snekfetch/docs.js: -------------------------------------------------------------------------------- 1 | const Docma = require('docma'); 2 | const Package = require('./package'); 3 | 4 | Docma.create() 5 | .build({ 6 | app: { 7 | title: Package.name, 8 | base: '/', 9 | entrance: 'content:readme', 10 | routing: 'query', 11 | server: Docma.ServerType.GITHUB, 12 | }, 13 | markdown: { 14 | gfm: true, 15 | tables: true, 16 | breaks: false, 17 | pedantic: false, 18 | sanitize: false, 19 | smartLists: false, 20 | smartypants: false, 21 | tasks: false, 22 | emoji: true, 23 | }, 24 | src: [ 25 | { readme: './README.md' }, 26 | { snekfetch: './src/index.js' }, 27 | ], 28 | dest: './docs', 29 | jsdoc: { 30 | plugins: ['jsdoc-dynamic'], 31 | }, 32 | template: { 33 | options: { 34 | title: Package.name, 35 | navItems: [ 36 | { 37 | label: 'Readme', 38 | href: '?content=readme', 39 | }, 40 | { 41 | label: 'Documentation', 42 | href: '?api=snekfetch', 43 | iconClass: 'ico-book', 44 | }, 45 | { 46 | label: 'GitHub', 47 | href: Package.homepage, 48 | target: '_blank', 49 | iconClass: 'ico-md ico-github', 50 | }, 51 | ], 52 | }, 53 | }, 54 | }) 55 | .catch(console.error); // eslint-disable-line no-console 56 | -------------------------------------------------------------------------------- /node_modules/snekfetch/esm.mjs: -------------------------------------------------------------------------------- 1 | import Snekfetch from './index.js'; 2 | 3 | export default Snekfetch; 4 | 5 | export const version = Snekfetch.version; 6 | export const METHODS = Snekfetch.METHODS; 7 | 8 | export const acl = Snekfetch.acl; 9 | export const bind = Snekfetch.bind; 10 | export const checkout = Snekfetch.checkout; 11 | export const connect = Snekfetch.connect; 12 | export const copy = Snekfetch.copy; 13 | const _delete = Snekfetch.delete; 14 | export { _delete as delete }; 15 | export const get = Snekfetch.get; 16 | export const head = Snekfetch.head; 17 | export const link = Snekfetch.link; 18 | export const lock = Snekfetch.lock; 19 | export const merge = Snekfetch.merge; 20 | export const mkactivity = Snekfetch.mkactivity; 21 | export const mkcalendar = Snekfetch.mkcalendar; 22 | export const mkcol = Snekfetch.mkcol; 23 | export const move = Snekfetch.move; 24 | export const notify = Snekfetch.notify; 25 | export const options = Snekfetch.options; 26 | export const patch = Snekfetch.patch; 27 | export const post = Snekfetch.post; 28 | export const propfind = Snekfetch.propfind; 29 | export const proppatch = Snekfetch.proppatch; 30 | export const purge = Snekfetch.purge; 31 | export const put = Snekfetch.put; 32 | export const rebind = Snekfetch.rebind; 33 | export const report = Snekfetch.report; 34 | export const search = Snekfetch.search; 35 | export const subscribe = Snekfetch.subscribe; 36 | export const trace = Snekfetch.trace; 37 | export const unbind = Snekfetch.unbind; 38 | export const unlink = Snekfetch.unlink; 39 | export const unlock = Snekfetch.unlock; 40 | export const unsubscribe = Snekfetch.unsubscribe; 41 | export const brew = Snekfetch.brew; 42 | -------------------------------------------------------------------------------- /node_modules/snekfetch/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./src'); 2 | -------------------------------------------------------------------------------- /node_modules/snekfetch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "snekfetch@^3.6.4", 3 | "_id": "snekfetch@3.6.4", 4 | "_inBundle": false, 5 | "_integrity": "sha512-NjxjITIj04Ffqid5lqr7XdgwM7X61c/Dns073Ly170bPQHLm6jkmelye/eglS++1nfTWktpP6Y2bFXjdPlQqdw==", 6 | "_location": "/snekfetch", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "snekfetch@^3.6.4", 12 | "name": "snekfetch", 13 | "escapedName": "snekfetch", 14 | "rawSpec": "^3.6.4", 15 | "saveSpec": null, 16 | "fetchSpec": "^3.6.4" 17 | }, 18 | "_requiredBy": [ 19 | "/discord.js" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz", 22 | "_shasum": "d13e80a616d892f3d38daae4289f4d258a645120", 23 | "_spec": "snekfetch@^3.6.4", 24 | "_where": "C:\\Users\\Chris\\Desktop\\GenBot\\node_modules\\discord.js", 25 | "author": { 26 | "name": "Gus Caplan", 27 | "email": "me@gus.host" 28 | }, 29 | "browser": { 30 | "./src/node/index.js": false, 31 | "./src/meta.js": false 32 | }, 33 | "bugs": { 34 | "url": "https://github.com/devsnek/snekfetch/issues" 35 | }, 36 | "bundleDependencies": false, 37 | "dependencies": {}, 38 | "deprecated": "use node-fetch instead", 39 | "description": "Just do http requests without all that weird nastiness from other libs", 40 | "devDependencies": { 41 | "@snek/syncify": "0.0.6", 42 | "coveralls": "^3.0.0", 43 | "docma": "^1.5.1", 44 | "eslint": "^4.8.0", 45 | "jest": "^21.2.1", 46 | "jsdoc-dynamic": "^1.0.4", 47 | "json-filter-loader": "^1.0.0", 48 | "node-fetch": "github:bitinn/node-fetch", 49 | "uglifyjs-webpack-plugin": "^1.0.0-beta.2", 50 | "webpack": "^3.8.1" 51 | }, 52 | "homepage": "https://snekfetch.js.org/", 53 | "jest": { 54 | "collectCoverage": true, 55 | "collectCoverageFrom": [ 56 | "src/**/*.js", 57 | "!src/qs_mock.js", 58 | "!src/node/mimeOfBuffer.js", 59 | "!src/node/transports/http2.js" 60 | ], 61 | "verbose": true 62 | }, 63 | "jsdelivr": "browser.js", 64 | "license": "MIT", 65 | "main": "index.js", 66 | "module": "esm.mjs", 67 | "name": "snekfetch", 68 | "repository": { 69 | "type": "git", 70 | "url": "git+https://github.com/devsnek/snekfetch.git" 71 | }, 72 | "scripts": { 73 | "build:browser": "webpack", 74 | "docs": "node docs.js", 75 | "lint": "eslint **/*.js", 76 | "prepublishOnly": "npm run build:browser", 77 | "test": "node ./node_modules/.bin/jest", 78 | "test:coveralls": "cat ./coverage/lcov.info | coveralls" 79 | }, 80 | "unpkg": "browser.js", 81 | "version": "3.6.4" 82 | } 83 | -------------------------------------------------------------------------------- /node_modules/snekfetch/scripts/travis-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Based on https://github.com/hydrabolt/discord.js-site/blob/master/deploy/deploy.sh 3 | 4 | set -e 5 | 6 | if [ "$TRAVIS_BRANCH" != "master" -o -n "$TRAVIS_TAG" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then 7 | echo -e "Not building for a non master branch push - building without deploying." 8 | npm run docs 9 | exit 0 10 | fi 11 | 12 | echo -e "Building for a master branch push - building and deploying." 13 | 14 | REPO=$(git config remote.origin.url) 15 | SHA=$(git rev-parse --verify HEAD) 16 | 17 | TARGET_BRANCH="gh-pages" 18 | git clone $REPO dist -b $TARGET_BRANCH 19 | 20 | npm run docs 21 | 22 | rsync -vau docs/ dist/ 23 | 24 | cd dist 25 | git add --all . 26 | git config user.name "Travis CI" 27 | git config user.email "${COMMIT_EMAIL}" 28 | git commit -m "Docs build: ${SHA}" || true 29 | git push "https://${GH_TOKEN}@${GH_REF}" $TARGET_BRANCH 30 | -------------------------------------------------------------------------------- /node_modules/snekfetch/scripts/travis-test.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | npm run lint 4 | 5 | npm run test 6 | 7 | if [ "$TRAVIS_BRANCH" != "master" -o -n "$TRAVIS_TAG" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then 8 | echo -e "Not sending coverage for a non master branch push - covering without sending." 9 | exit 0 10 | fi 11 | 12 | echo -e "Generating Coverage for a master branch push - covering and sending." 13 | 14 | npm run test:coveralls 15 | -------------------------------------------------------------------------------- /node_modules/snekfetch/src/browser.js: -------------------------------------------------------------------------------- 1 | function buildRequest(method, url) { 2 | return { 3 | method, 4 | path: url, 5 | redirect: this.options.followRedirects ? 'follow' : 'manual', 6 | headers: {}, 7 | setHeader(name, value) { 8 | this.headers[name.toLowerCase()] = value; 9 | }, 10 | getHeader(name) { 11 | return this.headers[name.toLowerCase()]; 12 | }, 13 | }; 14 | } 15 | 16 | function finalizeRequest() { 17 | this._finalizeRequest(); 18 | if (this.data) 19 | this.request.body = this.data; 20 | return window.fetch(this.request.path, this.request) 21 | .then((r) => r.text().then((t) => { 22 | const headers = {}; 23 | for (const [k, v] of r.headers.entries()) 24 | headers[k.toLowerCase()] = v; 25 | return { response: r, raw: t, headers }; 26 | })); 27 | } 28 | 29 | module.exports = { 30 | buildRequest, finalizeRequest, 31 | shouldSendRaw: () => false, 32 | METHODS: ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH'], 33 | STATUS_CODES: {}, 34 | Extension: Object, 35 | FormData: window.FormData, 36 | }; 37 | -------------------------------------------------------------------------------- /node_modules/snekfetch/src/node/FormData.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const mime = require('./mime'); 3 | 4 | class FormData { 5 | constructor() { 6 | this.boundary = `--snekfetch--${Math.random().toString().slice(2, 7)}`; 7 | this.buffers = []; 8 | } 9 | 10 | append(name, data, filename) { 11 | if (typeof data === 'undefined') 12 | return; 13 | let str = `\r\n--${this.boundary}\r\nContent-Disposition: form-data; name="${name}"`; 14 | let mimetype = null; 15 | if (filename) { 16 | str += `; filename="${filename}"`; 17 | mimetype = 'application/octet-stream'; 18 | const extname = path.extname(filename).slice(1); 19 | if (extname) 20 | mimetype = mime.lookup(extname); 21 | } 22 | 23 | if (data instanceof Buffer) { 24 | mimetype = mime.buffer(data); 25 | } else if (typeof data === 'object') { 26 | mimetype = 'application/json'; 27 | data = Buffer.from(JSON.stringify(data)); 28 | } else { 29 | data = Buffer.from(String(data)); 30 | } 31 | 32 | if (mimetype) 33 | str += `\r\nContent-Type: ${mimetype}`; 34 | this.buffers.push(Buffer.from(`${str}\r\n\r\n`)); 35 | this.buffers.push(data); 36 | } 37 | 38 | getBoundary() { 39 | return this.boundary; 40 | } 41 | 42 | end() { 43 | return Buffer.concat([...this.buffers, Buffer.from(`\r\n--${this.boundary}--`)]); 44 | } 45 | 46 | get length() { 47 | return this.buffers.reduce((sum, b) => sum + Buffer.byteLength(b), 0); 48 | } 49 | } 50 | 51 | module.exports = FormData; 52 | -------------------------------------------------------------------------------- /node_modules/snekfetch/src/node/mime.js: -------------------------------------------------------------------------------- 1 | const mimes = require('./mimes.json'); 2 | const mimeOfBuffer = require('./mimeOfBuffer.js'); 3 | 4 | function lookupMime(ext) { 5 | return mimes[ext.replace(/^\./, '')] || mimes.bin; 6 | } 7 | 8 | function lookupBuffer(buffer) { 9 | const ret = mimeOfBuffer(buffer); 10 | return ret ? ret.mime : mimes.bin; 11 | } 12 | 13 | module.exports = { 14 | buffer: lookupBuffer, 15 | lookup: lookupMime, 16 | }; 17 | -------------------------------------------------------------------------------- /node_modules/snekfetch/src/node/transports/ResponseStream.js: -------------------------------------------------------------------------------- 1 | const Stream = require('stream'); 2 | 3 | class ResponseStream extends Stream.Readable { 4 | constructor() { 5 | super(); 6 | this.statusCode = 200; 7 | this.status = 'OK'; 8 | } 9 | 10 | error(code, message) { 11 | this.statusCode = code; 12 | this.status = message; 13 | return this; 14 | } 15 | 16 | on(event, handler) { 17 | if (['end', 'open'].includes(event)) 18 | handler(); 19 | } 20 | 21 | _read() {} // eslint-disable-line no-empty-function 22 | } 23 | 24 | module.exports = ResponseStream; 25 | -------------------------------------------------------------------------------- /node_modules/snekfetch/src/node/transports/file.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const mime = require('../mime'); 4 | const EventEmitter = require('events'); 5 | const ResponseStream = require('./ResponseStream'); 6 | 7 | const methods = { 8 | GET: (filename, req) => { 9 | req.end = () => { 10 | const stream = should404(filename) ? 11 | new ResponseStream().error(404, `ENOENT: no such file or directory, open '${filename}'`) : 12 | fs.createReadStream(filename); 13 | req.res = stream; 14 | stream.headers = { 15 | 'content-length': 0, 16 | 'content-type': mime.lookup(path.extname(filename)), 17 | }; 18 | stream.on('open', () => { 19 | req.emit('response', stream); 20 | }); 21 | if (stream instanceof ResponseStream) 22 | return; 23 | stream.statusCode = 200; 24 | stream.on('end', () => { 25 | stream.headers['content-length'] = stream.bytesRead; 26 | }); 27 | /* istanbul ignore next */ 28 | stream.on('error', (err) => { 29 | stream.statusCode = 400; 30 | stream.status = err.message; 31 | }); 32 | }; 33 | }, 34 | POST: (filename, req) => { 35 | const chunks = []; 36 | /* istanbul ignore next */ 37 | req.write = (data) => { 38 | chunks.push(data); 39 | }; 40 | req.end = (data) => { 41 | chunks.push(data); 42 | const stream = fs.createWriteStream(filename); 43 | const standin = new ResponseStream(); 44 | req.res = standin; 45 | standin.headers = { 46 | 'content-length': 0, 47 | 'content-type': mime.lookup(path.extname(filename)), 48 | }; 49 | stream.on('finish', () => { 50 | req.emit('response', standin); 51 | }); 52 | stream.on('open', () => { 53 | (function write() { 54 | const chunk = chunks.shift(); 55 | if (!chunk) 56 | return; 57 | /* istanbul ignore next */ 58 | if (!stream.write(chunk)) 59 | stream.once('drain', write); 60 | else 61 | write(); 62 | }()); 63 | stream.end(); 64 | }); 65 | }; 66 | }, 67 | DELETE: (filename, req) => { 68 | req.end = () => { 69 | const stream = new ResponseStream(); 70 | req.res = stream; 71 | stream.headers = { 72 | 'content-length': 0, 73 | 'content-type': mime.lookup(path.extname(filename)), 74 | }; 75 | fs.unlink(filename, (err) => { 76 | req.emit('response', err ? stream.error(400, err.message) : stream); 77 | }); 78 | }; 79 | }, 80 | }; 81 | 82 | class Req extends EventEmitter { 83 | constructor() { 84 | super(); 85 | this._headers = {}; 86 | } 87 | 88 | setHeader() {} // eslint-disable-line no-empty-function 89 | getHeader() {} // eslint-disable-line no-empty-function 90 | } 91 | 92 | function request(options) { 93 | const method = methods[options.method]; 94 | if (!method) 95 | throw new Error(`Invalid request method for file: "${options.method}"`); 96 | const filename = options.href.replace('file://', ''); 97 | 98 | const req = new Req(); 99 | method(filename, req, options); 100 | return req; 101 | } 102 | 103 | function should404(p) { 104 | try { 105 | return fs.lstatSync(p).isDirectory(); 106 | } catch (err) { 107 | return true; 108 | } 109 | } 110 | 111 | module.exports = { 112 | request, 113 | }; 114 | -------------------------------------------------------------------------------- /node_modules/snekfetch/src/node/transports/http2.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const Stream = require('stream'); 3 | const EventEmitter = require('events'); 4 | const http2 = (() => { 5 | try { 6 | const h2 = require('http2'); 7 | if (!h2.constants) 8 | throw new Error('DAMN_YOU_NPM_HTTP2'); 9 | return h2; 10 | } catch (err) { 11 | return { 12 | constants: {}, 13 | connect: () => { 14 | throw new Error('Please run node with --expose-http2 to use the http2 request transport'); 15 | }, 16 | }; 17 | } 18 | })(); 19 | 20 | const { 21 | HTTP2_HEADER_PATH, 22 | HTTP2_HEADER_METHOD, 23 | HTTP2_HEADER_STATUS, 24 | } = http2.constants; 25 | 26 | class Http2Request extends EventEmitter { 27 | constructor(options) { 28 | super(); 29 | this.options = options; 30 | this._headers = { 31 | [HTTP2_HEADER_PATH]: options.pathname, 32 | [HTTP2_HEADER_METHOD]: options.method.toUpperCase(), 33 | }; 34 | } 35 | 36 | setHeader(name, value) { 37 | this._headers[name.toLowerCase()] = value; 38 | } 39 | 40 | getHeader(name) { 41 | return this._headers[name]; 42 | } 43 | 44 | getHeaders() { 45 | return this._headers; 46 | } 47 | 48 | get path() { 49 | return this._headers[HTTP2_HEADER_PATH]; 50 | } 51 | 52 | set path(path) { 53 | this._headers[HTTP2_HEADER_PATH] = path; 54 | } 55 | 56 | end(data) { 57 | const options = this.options; 58 | const client = http2.connect(`${options.protocol}//${options.hostname}`); 59 | const req = client.request(this._headers); 60 | const stream = new Stream.PassThrough(); 61 | 62 | client.once('error', (e) => this.emit('error', e)); 63 | client.once('frameError', (e) => this.emit('error', e)); 64 | 65 | req.once('error', (e) => this.emit('error', e)); 66 | 67 | req.once('response', (headers) => { 68 | stream.headers = headers; 69 | stream.statusCode = headers[HTTP2_HEADER_STATUS]; 70 | stream.status = http.STATUS_CODES[stream.statusCode]; 71 | 72 | this.emit('response', stream); 73 | this.response = stream; 74 | 75 | req.on('data', (chunk) => { 76 | if (!stream.push(chunk)) 77 | req.pause(); 78 | }); 79 | 80 | req.once('end', () => { 81 | stream.push(null); 82 | client.destroy(); 83 | }); 84 | 85 | stream.once('error', (err) => { 86 | stream.statusCode = 400; 87 | stream.status = err.message; 88 | }); 89 | }); 90 | 91 | req.end(data); 92 | 93 | return req; 94 | } 95 | } 96 | 97 | 98 | function request(options) { 99 | return new Http2Request(options); 100 | } 101 | 102 | module.exports = { request }; 103 | -------------------------------------------------------------------------------- /node_modules/snekfetch/src/qs_mock.js: -------------------------------------------------------------------------------- 1 | exports = { 2 | parse: (str) => { 3 | const parsed = {}; 4 | for (const [k, v] of new Window.URLSearchParams(str).entries()) 5 | parsed[k] = v; 6 | return parsed; 7 | }, 8 | stringify: (obj) => new window.URLSearchParams(obj).toString(), 9 | }; 10 | -------------------------------------------------------------------------------- /node_modules/snekfetch/sync.js: -------------------------------------------------------------------------------- 1 | try { 2 | var syncify = require('@snek/syncify'); 3 | } catch (err) { 4 | throw new Error('Using sync requires @snek/syncify (npm install @snek/syncify)'); 5 | } 6 | 7 | const Snekfetch = require('.'); 8 | 9 | class SnekfetchSync extends Snekfetch { 10 | end() { 11 | return syncify(super.end()); 12 | } 13 | } 14 | 15 | module.exports = SnekfetchSync; 16 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../.eslintrc.json"], 3 | "env": { "jest": true } 4 | } 5 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/browser/http1.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @jest-environment jsdom 3 | */ 4 | 5 | global.HTTP_VERSION = 1; 6 | 7 | require('./main'); 8 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/browser/http2.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @jest-environment jsdom 3 | */ 4 | 5 | global.HTTP_VERSION = 2; 6 | 7 | require('./main'); 8 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/browser/main.js: -------------------------------------------------------------------------------- 1 | window.fetch = require('node-fetch'); 2 | window.URLSearchParams = require('url').URLSearchParams; 3 | window.FormData = require('form-data'); 4 | 5 | require('../main'); 6 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/interop.js: -------------------------------------------------------------------------------- 1 | function makeProxy(fetch) { 2 | return new Proxy(fetch, { 3 | get(target, prop) { 4 | const p = target[prop]; 5 | if (typeof p === 'function') { 6 | return (url, options = {}) => 7 | p.call(target, url, Object.assign(options, { version: global.HTTP_VERSION })); 8 | } 9 | return p; 10 | }, 11 | }); 12 | } 13 | 14 | exports.Snekfetch = makeProxy(require('../')); 15 | try { 16 | exports.SnekfetchSync = makeProxy(require('../sync')); 17 | } catch (err) {} // eslint-disable-line no-empty 18 | 19 | exports.TestRoot = global.HTTP_VERSION === 2 ? 20 | 'https://nghttp2.org/httpbin' : 21 | 'https://httpbin.org'; 22 | 23 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/node/file.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @jest-environment node 3 | */ 4 | 5 | const fs = require('fs'); 6 | const { Snekfetch } = require('../interop'); 7 | 8 | const resolve = (x) => require.resolve(x); 9 | 10 | test('node/file get', () => { 11 | const original = fs.readFileSync(resolve('../../package.json')).toString(); 12 | return Snekfetch.get(`file://${resolve('../../package.json')}`) 13 | .then((res) => { 14 | expect(res.text).toBe(original); 15 | }); 16 | }); 17 | 18 | test('node/file post', () => { 19 | const content = 'wow this is a\n\ntest!!'; 20 | const file = './test_file_post.txt'; 21 | return Snekfetch.post(`file://${file}`) 22 | .send(content) 23 | .then(() => Snekfetch.get(`file://${file}`)) 24 | .then((res) => { 25 | expect(res.text).toBe(content); 26 | }) 27 | .then(() => { 28 | fs.unlinkSync(file); 29 | }); 30 | }); 31 | 32 | test('node/file delete', () => { 33 | const file = './test_file_delete.txt'; 34 | fs.closeSync(fs.openSync(file, 'w')); 35 | expect(fs.existsSync(file)).toBe(true); 36 | return Snekfetch.delete(`file://${file}`) 37 | .then(() => { 38 | expect(fs.existsSync(file)).toBe(false); 39 | }); 40 | }); 41 | 42 | 43 | test('node/file invalid method', () => { 44 | expect(() => { 45 | Snekfetch.options('file:///dev/urandom'); 46 | }).toThrow(/Invalid request method for file:/); 47 | }); 48 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/node/http1.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @jest-environment node 3 | */ 4 | 5 | global.HTTP_VERSION = 1; 6 | 7 | require('./main'); 8 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/node/http2.test.js.disabled: -------------------------------------------------------------------------------- 1 | /** 2 | * @jest-environment node 3 | */ 4 | 5 | global.HTTP_VERSION = 2; 6 | 7 | require('./main'); 8 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/node/main.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | const { Snekfetch, TestRoot } = require('../interop'); 4 | 5 | require('../main'); 6 | 7 | test('node/pipe get', (done) => { 8 | Snekfetch.get(`${TestRoot}/get`) 9 | .pipe(fs.createWriteStream('/dev/null')) 10 | .on('finish', done); 11 | }); 12 | 13 | 14 | test('node/FormData json works', () => 15 | Snekfetch.post(`${TestRoot}/post`) 16 | .attach('object', { a: 1 }) 17 | .then((res) => { 18 | const { form } = res.body; 19 | expect(form.object).toBe('{"a":1}'); 20 | }) 21 | ); 22 | 23 | test('node/rawsend post', () => 24 | Snekfetch.post(`${TestRoot}/post`) 25 | .send(Buffer.from('memes')).end() 26 | ); 27 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/node/sync.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @jest-environment node 3 | */ 4 | 5 | const { SnekfetchSync, TestRoot } = require('../interop'); 6 | 7 | test('sync get', SnekfetchSync && (() => { 8 | const res = SnekfetchSync.get(`${TestRoot}/get`).end(); 9 | expect(res.body).not.toBeUndefined(); 10 | })); 11 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/node/util.test.js: -------------------------------------------------------------------------------- 1 | const FormData = require('../../src/node/FormData'); 2 | const mime = require('../../src/node/mime'); 3 | 4 | test('node/FormData behaves predictably', () => { 5 | const f = new FormData(); 6 | f.append('hello'); 7 | f.append('hello', 'world'); 8 | expect(f.length).toBe(77); 9 | f.append('meme', 'dream', 'name'); 10 | expect(f.length).toBe(210); 11 | }); 12 | 13 | test('node/mimes behaves predictably', () => { 14 | expect(mime.lookup('js')).toBe('application/javascript'); 15 | expect(mime.lookup('nope')).toBe('application/octet-stream'); 16 | expect(mime.buffer([0xFF, 0xD8, 0xFF])).toBe('image/jpeg'); 17 | }); 18 | -------------------------------------------------------------------------------- /node_modules/snekfetch/test/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | 3 | const ref = require.main === module; 4 | 5 | const server = http.createServer((req, res) => { 6 | if (!ref) 7 | req.connection.unref(); 8 | switch (req.url) { 9 | case '/invalid-json': 10 | res.setHeader('Content-Type', 'application/json'); 11 | res.end('{ "a": 1'); 12 | break; 13 | case '/form-urlencoded': 14 | res.setHeader('Content-Type', 'application/x-www-form-urlencoded'); 15 | res.end('test=1&hello=world'); 16 | break; 17 | case '/echo': { 18 | let body = ''; 19 | req.on('data', (c) => { body += c; }); 20 | req.on('end', () => { 21 | res.end(body); 22 | }); 23 | break; 24 | } 25 | default: 26 | res.end(); 27 | break; 28 | } 29 | }); 30 | 31 | server.on('connection', (socket) => { 32 | if (!ref) 33 | socket.unref(); 34 | }); 35 | 36 | server.listen(0); 37 | 38 | exports.port = server.address().port; 39 | 40 | if (ref) 41 | console.log(exports.port); // eslint-disable-line no-console 42 | -------------------------------------------------------------------------------- /node_modules/snekfetch/webpack.config.js: -------------------------------------------------------------------------------- 1 | const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); 2 | 3 | module.exports = { 4 | entry: require.resolve('.'), 5 | output: { 6 | filename: 'browser.js', 7 | library: 'Snekfetch', 8 | libraryTarget: 'umd', 9 | }, 10 | plugins: [ 11 | new UglifyJSPlugin(), 12 | ], 13 | resolve: { 14 | alias: { 15 | querystring: require.resolve('./src/qs_mock'), 16 | }, 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /node_modules/tweetnacl/AUTHORS.md: -------------------------------------------------------------------------------- 1 | List of TweetNaCl.js authors 2 | ============================ 3 | 4 | Format: Name (GitHub username or URL) 5 | 6 | * Dmitry Chestnykh (@dchest) 7 | * Devi Mandiri (@devi) 8 | * AndSDev (@AndSDev) 9 | 10 | List of authors of third-party public domain code from which TweetNaCl.js code was derived 11 | ========================================================================================== 12 | 13 | [TweetNaCl](http://tweetnacl.cr.yp.to/) 14 | -------------------------------------- 15 | 16 | * Bernard van Gastel 17 | * Daniel J. Bernstein 18 | * Peter Schwabe 19 | * Sjaak Smetsers 20 | * Tanja Lange 21 | * Wesley Janssen 22 | 23 | 24 | [Poly1305-donna](https://github.com/floodyberry/poly1305-donna) 25 | -------------------------------------------------------------- 26 | 27 | * Andrew Moon (@floodyberry) 28 | -------------------------------------------------------------------------------- /node_modules/tweetnacl/LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Important! 2 | 3 | If your contribution is not trivial (not a typo fix, etc.), we can only accept 4 | it if you dedicate your copyright for the contribution to the public domain. 5 | Make sure you understand what it means (see http://unlicense.org/)! If you 6 | agree, please add yourself to AUTHORS.md file, and include the following text 7 | to your pull request description or a comment in it: 8 | 9 | ------------------------------------------------------------------------------ 10 | 11 | I dedicate any and all copyright interest in this software to the 12 | public domain. I make this dedication for the benefit of the public at 13 | large and to the detriment of my heirs and successors. I intend this 14 | dedication to be an overt act of relinquishment in perpetuity of all 15 | present and future rights to this software under copyright law. 16 | 17 | Anyone is free to copy, modify, publish, use, compile, sell, or 18 | distribute this software, either in source code form or as a compiled 19 | binary, for any purpose, commercial or non-commercial, and by any 20 | means. 21 | -------------------------------------------------------------------------------- /node_modules/tweetnacl/nacl.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for TweetNaCl.js 2 | 3 | export as namespace nacl; 4 | 5 | declare var nacl: nacl; 6 | export = nacl; 7 | 8 | declare namespace nacl { 9 | export interface BoxKeyPair { 10 | publicKey: Uint8Array; 11 | secretKey: Uint8Array; 12 | } 13 | 14 | export interface SignKeyPair { 15 | publicKey: Uint8Array; 16 | secretKey: Uint8Array; 17 | } 18 | 19 | export interface secretbox { 20 | (msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array; 21 | open(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null; 22 | readonly keyLength: number; 23 | readonly nonceLength: number; 24 | readonly overheadLength: number; 25 | } 26 | 27 | export interface scalarMult { 28 | (n: Uint8Array, p: Uint8Array): Uint8Array; 29 | base(n: Uint8Array): Uint8Array; 30 | readonly scalarLength: number; 31 | readonly groupElementLength: number; 32 | } 33 | 34 | namespace boxProps { 35 | export interface open { 36 | (msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array | null; 37 | after(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null; 38 | } 39 | 40 | export interface keyPair { 41 | (): BoxKeyPair; 42 | fromSecretKey(secretKey: Uint8Array): BoxKeyPair; 43 | } 44 | } 45 | 46 | export interface box { 47 | (msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; 48 | before(publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; 49 | after(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array; 50 | open: boxProps.open; 51 | keyPair: boxProps.keyPair; 52 | readonly publicKeyLength: number; 53 | readonly secretKeyLength: number; 54 | readonly sharedKeyLength: number; 55 | readonly nonceLength: number; 56 | readonly overheadLength: number; 57 | } 58 | 59 | namespace signProps { 60 | export interface detached { 61 | (msg: Uint8Array, secretKey: Uint8Array): Uint8Array; 62 | verify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean; 63 | } 64 | 65 | export interface keyPair { 66 | (): SignKeyPair; 67 | fromSecretKey(secretKey: Uint8Array): SignKeyPair; 68 | fromSeed(secretKey: Uint8Array): SignKeyPair; 69 | } 70 | } 71 | 72 | export interface sign { 73 | (msg: Uint8Array, secretKey: Uint8Array): Uint8Array; 74 | open(signedMsg: Uint8Array, publicKey: Uint8Array): Uint8Array | null; 75 | detached: signProps.detached; 76 | keyPair: signProps.keyPair; 77 | readonly publicKeyLength: number; 78 | readonly secretKeyLength: number; 79 | readonly seedLength: number; 80 | readonly signatureLength: number; 81 | } 82 | 83 | export interface hash { 84 | (msg: Uint8Array): Uint8Array; 85 | readonly hashLength: number; 86 | } 87 | } 88 | 89 | declare interface nacl { 90 | randomBytes(n: number): Uint8Array; 91 | secretbox: nacl.secretbox; 92 | scalarMult: nacl.scalarMult; 93 | box: nacl.box; 94 | sign: nacl.sign; 95 | hash: nacl.hash; 96 | verify(x: Uint8Array, y: Uint8Array): boolean; 97 | setPRNG(fn: (x: Uint8Array, n: number) => void): void; 98 | } 99 | -------------------------------------------------------------------------------- /node_modules/tweetnacl/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "tweetnacl@^1.0.0", 3 | "_id": "tweetnacl@1.0.1", 4 | "_inBundle": false, 5 | "_integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==", 6 | "_location": "/tweetnacl", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "tweetnacl@^1.0.0", 12 | "name": "tweetnacl", 13 | "escapedName": "tweetnacl", 14 | "rawSpec": "^1.0.0", 15 | "saveSpec": null, 16 | "fetchSpec": "^1.0.0" 17 | }, 18 | "_requiredBy": [ 19 | "/discord.js" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz", 22 | "_shasum": "2594d42da73cd036bd0d2a54683dd35a6b55ca17", 23 | "_spec": "tweetnacl@^1.0.0", 24 | "_where": "C:\\Users\\Chris\\Desktop\\GenBot\\node_modules\\discord.js", 25 | "author": { 26 | "name": "TweetNaCl-js contributors" 27 | }, 28 | "browser": { 29 | "buffer": false, 30 | "crypto": false 31 | }, 32 | "bugs": { 33 | "url": "https://github.com/dchest/tweetnacl-js/issues" 34 | }, 35 | "bundleDependencies": false, 36 | "deprecated": false, 37 | "description": "Port of TweetNaCl cryptographic library to JavaScript", 38 | "devDependencies": { 39 | "browserify": "^13.1.1", 40 | "eslint": "^3.12.1", 41 | "faucet": "^0.0.1", 42 | "tap-browser-color": "^0.1.2", 43 | "tape": "^4.6.3", 44 | "tweetnacl-util": "^0.13.5", 45 | "uglify-js": "^2.7.5" 46 | }, 47 | "directories": { 48 | "test": "test" 49 | }, 50 | "homepage": "https://tweetnacl.js.org", 51 | "keywords": [ 52 | "crypto", 53 | "cryptography", 54 | "curve25519", 55 | "ed25519", 56 | "encrypt", 57 | "hash", 58 | "key", 59 | "nacl", 60 | "poly1305", 61 | "public", 62 | "salsa20", 63 | "signatures" 64 | ], 65 | "license": "Unlicense", 66 | "main": "nacl-fast.js", 67 | "name": "tweetnacl", 68 | "repository": { 69 | "type": "git", 70 | "url": "git+https://github.com/dchest/tweetnacl-js.git" 71 | }, 72 | "scripts": { 73 | "bench": "node test/benchmark/bench.js", 74 | "build": "uglifyjs nacl.js -c -m -o nacl.min.js && uglifyjs nacl-fast.js -c -m -o nacl-fast.min.js", 75 | "build-test-browser": "browserify test/browser/init.js test/*.js | uglifyjs -c -m -o test/browser/_bundle.js 2>/dev/null && browserify test/browser/init.js test/*.quick.js | uglifyjs -c -m -o test/browser/_bundle-quick.js 2>/dev/null", 76 | "lint": "eslint nacl.js nacl-fast.js test/*.js test/benchmark/*.js", 77 | "test": "npm run test-node-all", 78 | "test-node": "tape test/*.js | faucet", 79 | "test-node-all": "make -C test/c && tape test/*.js test/c/*.js | faucet" 80 | }, 81 | "types": "nacl.d.ts", 82 | "version": "1.0.1" 83 | } 84 | -------------------------------------------------------------------------------- /node_modules/ws/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011 Einar Otto Stangvik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /node_modules/ws/browser.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function() { 4 | throw new Error( 5 | 'ws does not work in the browser. Browser clients must use the native ' + 6 | 'WebSocket object' 7 | ); 8 | }; 9 | -------------------------------------------------------------------------------- /node_modules/ws/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WebSocket = require('./lib/websocket'); 4 | 5 | WebSocket.Server = require('./lib/websocket-server'); 6 | WebSocket.Receiver = require('./lib/receiver'); 7 | WebSocket.Sender = require('./lib/sender'); 8 | 9 | module.exports = WebSocket; 10 | -------------------------------------------------------------------------------- /node_modules/ws/lib/constants.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | BINARY_TYPES: ['nodebuffer', 'arraybuffer', 'fragments'], 5 | GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', 6 | kStatusCode: Symbol('status-code'), 7 | kWebSocket: Symbol('websocket'), 8 | EMPTY_BUFFER: Buffer.alloc(0), 9 | NOOP: () => {} 10 | }; 11 | -------------------------------------------------------------------------------- /node_modules/ws/lib/validation.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | try { 4 | const isValidUTF8 = require('utf-8-validate'); 5 | 6 | exports.isValidUTF8 = 7 | typeof isValidUTF8 === 'object' 8 | ? isValidUTF8.Validation.isValidUTF8 // utf-8-validate@<3.0.0 9 | : isValidUTF8; 10 | } catch (e) /* istanbul ignore next */ { 11 | exports.isValidUTF8 = () => true; 12 | } 13 | 14 | /** 15 | * Checks if a status code is allowed in a close frame. 16 | * 17 | * @param {Number} code The status code 18 | * @return {Boolean} `true` if the status code is valid, else `false` 19 | * @public 20 | */ 21 | exports.isValidStatusCode = (code) => { 22 | return ( 23 | (code >= 1000 && 24 | code <= 1013 && 25 | code !== 1004 && 26 | code !== 1005 && 27 | code !== 1006) || 28 | (code >= 3000 && code <= 4999) 29 | ); 30 | }; 31 | -------------------------------------------------------------------------------- /node_modules/ws/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "ws@^6.0.0", 3 | "_id": "ws@6.2.1", 4 | "_inBundle": false, 5 | "_integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", 6 | "_location": "/ws", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "ws@^6.0.0", 12 | "name": "ws", 13 | "escapedName": "ws", 14 | "rawSpec": "^6.0.0", 15 | "saveSpec": null, 16 | "fetchSpec": "^6.0.0" 17 | }, 18 | "_requiredBy": [ 19 | "/discord.js" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", 22 | "_shasum": "442fdf0a47ed64f59b6a5d8ff130f4748ed524fb", 23 | "_spec": "ws@^6.0.0", 24 | "_where": "C:\\Users\\Chris\\Desktop\\GenBot\\node_modules\\discord.js", 25 | "author": { 26 | "name": "Einar Otto Stangvik", 27 | "email": "einaros@gmail.com", 28 | "url": "http://2x.io" 29 | }, 30 | "browser": "browser.js", 31 | "bugs": { 32 | "url": "https://github.com/websockets/ws/issues" 33 | }, 34 | "bundleDependencies": false, 35 | "dependencies": { 36 | "async-limiter": "~1.0.0" 37 | }, 38 | "deprecated": false, 39 | "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js", 40 | "devDependencies": { 41 | "benchmark": "~2.1.4", 42 | "bufferutil": "~4.0.0", 43 | "coveralls": "~3.0.3", 44 | "eslint": "~5.15.0", 45 | "eslint-config-prettier": "~4.1.0", 46 | "eslint-plugin-prettier": "~3.0.0", 47 | "mocha": "~6.0.0", 48 | "nyc": "~13.3.0", 49 | "prettier": "~1.16.1", 50 | "utf-8-validate": "~5.0.0" 51 | }, 52 | "files": [ 53 | "browser.js", 54 | "index.js", 55 | "lib/*.js" 56 | ], 57 | "homepage": "https://github.com/websockets/ws", 58 | "keywords": [ 59 | "HyBi", 60 | "Push", 61 | "RFC-6455", 62 | "WebSocket", 63 | "WebSockets", 64 | "real-time" 65 | ], 66 | "license": "MIT", 67 | "main": "index.js", 68 | "name": "ws", 69 | "repository": { 70 | "type": "git", 71 | "url": "git+https://github.com/websockets/ws.git" 72 | }, 73 | "scripts": { 74 | "integration": "npm run lint && mocha test/*.integration.js", 75 | "lint": "eslint --ignore-path .gitignore . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yml}\"", 76 | "test": "npm run lint && nyc --reporter=html --reporter=text mocha test/*.test.js" 77 | }, 78 | "version": "6.2.1" 79 | } 80 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "genbot", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "async-limiter": { 8 | "version": "1.0.1", 9 | "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", 10 | "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" 11 | }, 12 | "discord.js": { 13 | "version": "11.5.1", 14 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-11.5.1.tgz", 15 | "integrity": "sha512-tGhV5xaZXE3Z+4uXJb3hYM6gQ1NmnSxp9PClcsSAYFVRzH6AJH74040mO3afPDMWEAlj8XsoPXXTJHTxesqcGw==", 16 | "requires": { 17 | "long": "^4.0.0", 18 | "prism-media": "^0.0.3", 19 | "snekfetch": "^3.6.4", 20 | "tweetnacl": "^1.0.0", 21 | "ws": "^6.0.0" 22 | } 23 | }, 24 | "long": { 25 | "version": "4.0.0", 26 | "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", 27 | "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" 28 | }, 29 | "prism-media": { 30 | "version": "0.0.3", 31 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.0.3.tgz", 32 | "integrity": "sha512-c9KkNifSMU/iXT8FFTaBwBMr+rdVcN+H/uNv1o+CuFeTThNZNTOrQ+RgXA1yL/DeLk098duAeRPP3QNPNbhxYQ==" 33 | }, 34 | "snekfetch": { 35 | "version": "3.6.4", 36 | "resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz", 37 | "integrity": "sha512-NjxjITIj04Ffqid5lqr7XdgwM7X61c/Dns073Ly170bPQHLm6jkmelye/eglS++1nfTWktpP6Y2bFXjdPlQqdw==" 38 | }, 39 | "tweetnacl": { 40 | "version": "1.0.1", 41 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz", 42 | "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==" 43 | }, 44 | "ws": { 45 | "version": "6.2.2", 46 | "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", 47 | "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", 48 | "requires": { 49 | "async-limiter": "~1.0.0" 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "genbot", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Aster", 10 | "license": "ISC", 11 | "dependencies": { 12 | "discord.js": "^11.5.1" 13 | } 14 | } 15 | --------------------------------------------------------------------------------