New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

devland.js

Package Overview
Dependencies
Maintainers
1
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

devland.js - npm Package Compare versions

Comparing version 1.2.29 to 1.2.30

structures/gateway/events/guildMembersChunk.js

7

index.js

@@ -49,6 +49,7 @@ const Client = require('./structures/client/client')

const ShardClientUtil = require('./structures/sharding/ShardClientUtil')
const {webhookType, ActivityType, guildVerificationLevel, guildMfaLevel, guildDefaultMessageNotifications, guildExplicitContentFilterLevel, guildBoostLevel, guildNsfwLevel, channelType, videoQualityMode, PermissionIdType, stagePrivacyLevel, ComponentsType, ButtonStyle, commandType, commandOptionsType, integrationExpireBehavior, interactionType, textInputStyle, AutoModEventType, AutoModTriggerType, AutoModTriggerPresets, AutoModActionType} = require('./structures/types/enum')
const {webhookType, ActivityType, guildVerificationLevel, guildMfaLevel, guildDefaultMessageNotifications, guildExplicitContentFilterLevel, guildBoostLevel, guildNsfwLevel, channelType, videoQualityMode, PermissionIdType, stagePrivacyLevel, ComponentsType, ButtonStyle, commandType, commandOptionsType, integrationExpireBehavior, interactionType, textInputStyle, AutoModEventType, AutoModTriggerType, AutoModTriggerPresets, AutoModActionType, eventPrivacyLevel, eventEntityType, eventStatus} = require('./structures/types/enum')
const {version} = require('./package.json')
const RESTHandler = require('./structures/rest/RESTHandler')
const clientWebSocket = require('./structures/gateway/webSocket-new')
const ScheduledEvent = require('./structures/models/ScheduledEvent')
module.exports = {

@@ -104,2 +105,3 @@

AutoModRule,
ScheduledEvent,

@@ -144,2 +146,5 @@ /** Shard system */

AutoModActionType,
eventPrivacyLevel,
eventEntityType,
eventStatus,
}

2

package.json

@@ -12,3 +12,3 @@ {

"name": "devland.js",
"version": "1.2.29",
"version": "1.2.30",
"description": "A powerful API wrapper for the Discord API designed for modern bots",

@@ -15,0 +15,0 @@ "main": "index.js",

@@ -7,3 +7,3 @@ const { EventEmitter } = require('events')

const { Store } = require('../util/Store/Store')
const { Message, Guild, TextChannel, User, VoiceChannel, CategoryChannel, AnnouncementChannel, StageChannel, DmChannel } = require('../models')
const { Message, Guild, TextChannel, User, VoiceChannel, CategoryChannel, AnnouncementChannel, StageChannel, DmChannel, GuildCommand } = require('../models')
const Thread = require('../models/Thread')

@@ -55,3 +55,4 @@ const ForumChannel = require('../models/ForumChannel')

* @property {number} maxResumeAttempts
* @property {number} invalidCommandValueReturnNull
* @property {boolean} invalidCommandValueReturnNull
* @property {boolean} fetchAllMembers
*/

@@ -115,2 +116,3 @@ /**

COMMANDS: (guildId, commandId) => { return `${this._ENDPOINTS.API}/applications/${this.user.id}/guilds/${guildId}/commands${commandId ? `/${commandId}` : ``}` },
GLOBAL_COMMANDS: (commandId) => { return `${this._ENDPOINTS.API}/applications/${this.user.id}/commands${commandId ? `/${commandId}` : ``}` },
SERVER_CHANNEL: (serverID, channelID) => { return `${DiscordAPI}/guilds/${serverID}/channels${channelID ? `/${channelID}` : ``}`; },

@@ -123,6 +125,7 @@ REACTIONS: (channelID, messageID, emoji, user) => { return `${this._ENDPOINTS.CHANNEL(channelID)}/messages/${messageID}/reactions${emoji ? `/${emoji}${user ? `/${user}` : ``}` : ``}`; },

SERVER_INVITES: (serverID) => { return `${this._ENDPOINTS.SERVERS(serverID)}/invites`; },
INTEGRATIONS: (serverID, integrationID) => { return `${this._ENDPOINTS.SERVERS(serverID)}/integrations${integrationID?`/${integrationID}`:``}`; },
INTEGRATIONS: (serverID, integrationID) => { return `${this._ENDPOINTS.SERVERS(serverID)}/integrations${integrationID ? `/${integrationID}` : ``}`; },
INTERACTIONS: (interactionID, interactionToken) => { return DiscordAPI + '/interactions/' + interactionID + '/' + interactionToken + '/callback'; },
INTERACTIONS_MESSAGE: (interactionID, interactionToken) => { return DiscordAPI + '/interactions/' + interactionID + '/' + interactionToken; },
AUTOMOD: (serverID, ruleID) => { return `${this._ENDPOINTS.SERVERS(serverID)}/auto-moderations/rules${ruleID?`/${ruleID}`:``}`; },
AUTOMOD: (serverID, ruleID) => { return `${this._ENDPOINTS.SERVERS(serverID)}/auto-moderations/rules${ruleID ? `/${ruleID}` : ``}`; },
EVENT: (serverID, eventID) => { return `${this._ENDPOINTS.SERVERS(serverID)}/scheduled-events${eventID ? `/${eventID}` : ``}`; },
}

@@ -166,13 +169,13 @@

if(!this.options.shardId && 'SHARD_ID' in process.env){
if (!this.options.shardId && 'SHARD_ID' in process.env) {
this.options.shardId = Number(process.env.SHARD_ID)
}
if(!this.options.shardCount && 'SHARD_COUNT' in process.env){
if (!this.options.shardCount && 'SHARD_COUNT' in process.env) {
this.options.shardCount = Number(process.env.SHARD_COUNT)
}
if(typeof this.options.shardId !== "number" || isNaN(this.options.shardId)) throw new TypeError("shardId must be a number")
if(typeof this.options.shardCount !== "number" || isNaN(this.options.shardCount)) throw new TypeError("shardCount must be a number")
if(this.options.shardId < 0) throw new RangeError("shardId can't be less than 0")
if(this.options.shardCount < 0) throw new RangeError("shardCount can't be less than 0")
if(this.options.shardId !== 0 && this.options.shardId >= this.options.shardCount) throw new RangeError("shardId must be less than shardCount")
if (typeof this.options.shardId !== "number" || isNaN(this.options.shardId)) throw new TypeError("shardId must be a number")
if (typeof this.options.shardCount !== "number" || isNaN(this.options.shardCount)) throw new TypeError("shardCount must be a number")
if (this.options.shardId < 0) throw new RangeError("shardId can't be less than 0")
if (this.options.shardCount < 0) throw new RangeError("shardCount can't be less than 0")
if (this.options.shardId !== 0 && this.options.shardId >= this.options.shardCount) throw new RangeError("shardId must be less than shardCount")
this.shard = process.env.SHARDING_MANAGER ? ShardClientUtil.singleton(this) : null

@@ -245,6 +248,19 @@

get uptime() {
return this.readyAt ? Date.now()-this.readyAt : 0
return this.readyAt ? Date.now() - this.readyAt : 0
}
static get version() { return require('../../package.json').version }
get allChannels() {
let collect = new Store()
this.textChannels.map(c => collect.set(c.id, c))
this.categoryChannels.map(c => collect.set(c.id, c))
this.voiceChannels.map(c => collect.set(c.id, c))
this.announcementChannels.map(c => collect.set(c.id, c))
this.threadChannels.map(c => collect.set(c.id, c))
this.stageChannels.map(c => collect.set(c.id, c))
this.forumChannels.map(c => collect.set(c.id, c))
return collect
}
/**

@@ -257,3 +273,4 @@ * Connect your bot to the discord gateway

if (token && typeof token === 'string') this.token = token;
if(Array.isArray(this.options.intents)) this.options.intents = parseInt(new IntentFlags(this.options.intents).bitfield)
if (Array.isArray(this.options.intents)) this.options.intents = parseInt(new IntentFlags(this.options.intents).bitfield)
if (this.options.fetchAllMembers && !(new IntentFlags(BigInt(this.options.intents)).has(IntentFlags.FLAGS.GUILD_MEMBERS))) throw new TypeError("You cannot use 'fetchAllMembers' if your bot is not using 'GUILD_MEMBERS' intent")
this.emit('debug', `Trying to attempt login`)

@@ -265,6 +282,6 @@ this.ws._token = this.token

destroy(reopen = false){
this.emit('debug', reopen ? `Reopening a new session after a request`:`Destroying the current session`)
if(!reopen) this.readyAt = 0
if(!reopen) this.ready = false
destroy(reopen = false) {
this.emit('debug', reopen ? `Reopening a new session after a request` : `Destroying the current session`)
if (!reopen) this.readyAt = 0
if (!reopen) this.ready = false
this.ws.disconnect({

@@ -360,2 +377,84 @@ reconnect: reopen ? "auto" : false

async getCommands() {
return new Promise(async (resolve, reject) => {
this.rest.get(this._ENDPOINTS.GLOBAL_COMMANDS()).then(res => {
if (res.length < 1) return resolve([])
else {
let data = []
res.map(com => data.push(new GuildCommand(com)))
return resolve(data)
}
}).catch(e => {
return reject(e)
})
})
}
async deleteCommand(command) {
return new Promise(async (resolve, reject) => {
if (command instanceof GuildCommand) {
if (!command.id) return reject(new TypeError("Invalid command provided, you must provide a GuildCommand class get after using \"getCommands()\""))
this.rest.delete(this._ENDPOINTS.COMMANDS(this.id, command.id)).then(() => {
return resolve(true)
}).catch(e => {
return reject(e)
})
} else if (typeof command === "object") {
if (!command?.id) return reject(new TypeError("Invalid command provided, if you are using a custom object you need to provide the \"<command>.id\""))
this.rest.delete(this._ENDPOINTS.GLOBAL_COMMANDS(command.id)).then(() => {
return resolve(true)
}).catch(e => {
return reject(e)
})
} else return reject(new TypeError("Invalid command provided"))
})
}
async setCommands(...commands) {
return new Promise(async (resolve, reject) => {
if (!commands || (!(commands instanceof Store) && commands?.length < 1) || (commands instanceof Store && commands?.size < 1)) return reject(new TypeError("No command provided"))
if (commands[0] instanceof Store || commands[0] instanceof Map) {
var body = [...commands[0].values()]
body.map(data => {
data.map(command => {
if (command instanceof GuildCommand) {
command = command.pack()
} else if (typeof command == "object") {
command = new GuildCommand(command).pack()
} else return reject(new TypeError("Invalid command format"))
})
})
this.rest.put(this._ENDPOINTS.GLOBAL_COMMANDS(), body).then(() => {
return resolve(true)
}).catch(e => {
return reject(e)
})
} else {
var all = []
commands.map(command => {
if (Array.isArray(command)) {
command.map(cmd => {
if (cmd instanceof GuildCommand) {
all.push(cmd.pack())
} else if (typeof cmd == "object") {
all.push(new GuildCommand(cmd).pack())
} else return reject(new TypeError("Invalid command format"))
})
} else {
if (command instanceof GuildCommand) {
all.push(command.pack())
} else if (typeof command == "object") {
all.push(new GuildCommand(command).pack())
} else return reject(new TypeError("Invalid command format"))
}
})
this.rest.put(this._ENDPOINTS.GLOBAL_COMMANDS(), all).then(() => {
return resolve(true)
}).catch(e => {
return reject(e)
})
}
})
}
}

@@ -6,2 +6,3 @@ const Client = require('../../client/client')

const Role = require('../../models/Role')
const IntentFlags = require('../../util/BitFieldManagement/IntentFlags')
module.exports = {

@@ -179,2 +180,14 @@ name: 'guildCreate',

}))
if(client.options.fetchAllMembers){
let intents;
if (Array.isArray(client.options.intents)) intents = parseInt(new IntentFlags(client.options.intents).bitfield)
intents = new IntentFlags(BigInt(client.options.intents))
client.ws.sendWS(8, {
guild_id: guild.id,
query: "",
limit: 0,
presences: intents.has(IntentFlags.FLAGS.GUILD_PRESENCES)
})
}
/**

@@ -181,0 +194,0 @@ * Emitted whenever the guild data is available

@@ -27,11 +27,3 @@ const Client = require('../client/client')

}
this.hardReset()
/**
this.ws.on("open", this._onWSOpen)
this.ws.on("message", this._onWSMessage)
this.ws.on("error", this._onWSError)
this.ws.on("close", this._onWSClose)
*/
}

@@ -69,3 +61,2 @@

} else {
//console.log(this.resumeURL)
this.ws = new ws(`${this.resumeURL}`, this.client.options.ws)

@@ -257,4 +248,3 @@ }

case 0: {
const Events = require('../util/GatewayEvents');
const Events = require('../util/GatewayEvents')
if (packet.t === 'READY') {

@@ -311,3 +301,3 @@ this.connectAttempts = 0

})
if (!Events.hasOwnProperty(packet.t)) return;
if (!Events.hasOwnProperty(packet.t)) return
if (!this.eventFiles.has(Events[packet.t])) return

@@ -314,0 +304,0 @@ this.checkClientReady(packet)

@@ -38,2 +38,3 @@ const ClientUser = require('./ClientUser')

const AutoModRule = require('./AutoModRule')
const ScheduledEvent = require('./ScheduledEvent')
module.exports = {

@@ -77,2 +78,3 @@ ClientUser,

AutoModRule,
ScheduledEvent,
}

@@ -39,2 +39,13 @@ const MemberFlags = require('../util/BitFieldManagement/MemberFlags')

async fetch(){
return new Promise(async(resolve, reject) => {
this.guild.fetchMember(this.id).then(member => {
Object.keys(member).map(k => this[k] = member[k])
return resolve(member)
}).catch(e=>{
return reject(e)
})
})
}
get highestRole() {

@@ -41,0 +52,0 @@ let all = this.guild.roles.toJSON()

@@ -173,2 +173,16 @@ module.exports.webhookType = {

TIMEOUT: 3
}
module.exports.eventPrivacyLevel = {
GUILD_ONLY: 2
}
module.exports.eventEntityType = {
STAGE_INSTANCE: 1,
VOICE: 2,
EXTERNAL: 3
}
module.exports.eventStatus = {
SCHEDULED: 1,
ACTIVE: 2,
COMPLETED: 3,
CANCELED: 4
}

@@ -28,3 +28,3 @@ module.exports = {

'GUILD_MEMBER_REMOVE': 'guildMemberRemove',
'GUILD_MEMBER_CHUNK': 'guildMemberChunk',
'GUILD_MEMBERS_CHUNK': 'guildMembersChunk',
'PRESENCE_UPDATE': 'presenceUpdate',

@@ -57,3 +57,8 @@ 'VOICE_STATE_UPDATE': 'voiceStateUpdate',

'AUTO_MODERATION_RULE_DELETE': 'autoModRuleDelete',
'AUTO_MODERATION_RULE_EXECUTION': 'autoModRuleExecution'
'AUTO_MODERATION_RULE_EXECUTION': 'autoModRuleExecution',
'GUILD_SCHEDULED_EVENT_CREATE': 'guildScheduledEventCreate',
'GUILD_SCHEDULED_EVENT_UPDATE': 'guildScheduledEventUpdate',
'GUILD_SCHEDULED_EVENT_DELETE': 'guildScheduledEventDelete',
'GUILD_SCHEDULED_EVENT_USER_ADD': 'guildScheduledEventUserAdd',
'GUILD_SCHEDULED_EVENT_USER_REMOVE': 'guildScheduledEventUserRemove'
}

@@ -54,2 +54,3 @@ const DataResolver = require('./DateResolver');

invalidCommandValueReturnNull: true,
fetchAllMembers: false,
}

@@ -56,0 +57,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc