devland.js
Advanced tools
Comparing version 1.2.35 to 1.2.37
@@ -12,3 +12,3 @@ { | ||
"name": "devland.js", | ||
"version": "1.2.35", | ||
"version": "1.2.37", | ||
"description": "A powerful API wrapper for the Discord API designed for modern bots", | ||
@@ -15,0 +15,0 @@ "main": "index.js", |
const Client = require('../../client/client') | ||
const { Guild, TextChannel, Message, DmChannel, Member } = require('../../models') | ||
const { default: Store } = require('../../util/Store/Store') | ||
module.exports = { | ||
@@ -38,3 +39,11 @@ name: 'guildMemberRemove', | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
if (client.guilds.filter(g => g.members.has(data.user.id)).size < 1) client.users.delete(data.user.id) | ||
let allGuilds = new Store() | ||
if (client.options.guildsLifeTime) client.guilds.map(g => allGuilds.set(g.id, g)) | ||
else await Promise.all(client.guildsIds.map(async id => { | ||
let guild = await client.rest.get(client._ENDPOINTS.SERVERS(id)).catch(e => { }) | ||
if (!guild) return | ||
else return allGuilds.set(guild.id, guild) | ||
})) | ||
if (client.options.guildsLifeTime && client.guilds.filter(g => g.members.has(data.user.id)).size < 1) client.users.delete(data.user.id) | ||
else if (allGuilds.filter(g => g.members.find(m => m.user.id === data.user.id)).length < 1) client.users.delete(data.user.id) | ||
} | ||
@@ -41,0 +50,0 @@ } |
@@ -22,4 +22,7 @@ const Client = require('../../client/client') | ||
client.emit('guildScheduledEventUserAdd', event, user) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
} | ||
} |
@@ -19,6 +19,10 @@ const Client = require('../../client/client') | ||
let user = client.users.get(data.user_id) || await client.rest.get(client._ENDPOINTS.USER(data.user_id)) | ||
if (!user) return | ||
if (!(user instanceof User)) user = new User(client, user) | ||
client.emit('guildScheduledEventUserRemove', event, user) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
} | ||
} |
@@ -36,4 +36,7 @@ const Client = require('../../client/client') | ||
client.emit('interaction', interaction) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
} | ||
} |
@@ -69,2 +69,5 @@ const Client = require('../../client/client') | ||
} | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
@@ -71,0 +74,0 @@ async function fetchMentionsRoles() { |
@@ -34,2 +34,5 @@ const Client = require('../../client/client') | ||
client.emit('messageReactionAdd', { guild: guild, channel: channel, message: message, user: user, member: member, emoji: emoji }) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
@@ -36,0 +39,0 @@ |
@@ -29,2 +29,5 @@ const Client = require('../../client/client') | ||
client.emit('messageReactionAllRemove', guild, channel, message) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
@@ -31,0 +34,0 @@ |
@@ -30,4 +30,7 @@ const Client = require('../../client/client') | ||
client.emit('messageReactionRemove', { guild: guild, channel: channel, message: message, user: user, emoji: emoji }) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
} | ||
} |
@@ -34,2 +34,5 @@ const Client = require('../../client/client') | ||
let message = new Message(client, guild, dm_channel, data) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(channel.user.id, channel.user) | ||
} | ||
@@ -93,2 +96,5 @@ if (oldMessage) { | ||
} | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
@@ -95,0 +101,0 @@ } else { |
@@ -34,4 +34,7 @@ const Client = require('../../client/client') | ||
} | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
} | ||
} |
@@ -13,3 +13,3 @@ const Client = require('../../client/client') | ||
const data = d.d | ||
data.user.tag = data.user.username + '#' + data.user.discriminator | ||
@@ -34,6 +34,3 @@ client.user = new Models.ClientUser(client, data.user) | ||
} else { | ||
if (client.guilds.filter(g => g.ready === true).size < client.guilds.size) return// console.log('waiting ready') | ||
if (client.options.waitCacheBeforeReady && client.options.membersLifeTime && client.guilds.filter(g => g.members.size < g.totalMembersCount-15).size > 0) return //console.log(client.guilds.filter(g => g.members.size < g.totalMembersCount).map(g => `${g.totalMembersCount}/${g.members.size} ${g.name}`)) | ||
if (client.options.waitCacheBeforeReady && client.options.presencesLifeTime && client.guilds.filter(g => g.presences.size < g.totalMembersCount-15).size > 0) return// console.log('waiting presences') | ||
if (client.options.waitCacheBeforeReady && client.options.voicesLifeTime && client.guilds.filter(g => g.voicesStates.size < g.totalMembersCount-15).size > 0) return //console.log('waiting voices') | ||
if (client.options.waitCacheBeforeReady && client.guilds.filter(g => g.ready === true).size < client.guilds.size) return | ||
clearInterval(checkGuilds) | ||
@@ -40,0 +37,0 @@ client.ready = true |
@@ -31,4 +31,7 @@ const Client = require('../../client/client') | ||
client.emit('userTypingStart', guild, channel, user, member, data.timestamp) | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
} | ||
} |
@@ -48,4 +48,7 @@ const Client = require('../../client/client') | ||
} | ||
if (typeof client.options.usersLifeTime === "number" && client.options.usersLifeTime > 0) { | ||
client.users.set(user.id, user) | ||
} | ||
} catch (err) { client.emit('errordev', d.t, err) } | ||
} | ||
} |
@@ -47,3 +47,3 @@ /*class APIError { | ||
this.options = res.req.options; | ||
switch(this.code) { | ||
switch (this.code) { | ||
case 204: this.message = "The server returned no content"; break; | ||
@@ -54,3 +54,40 @@ case 304: this.message = "No action was taken"; break; | ||
case 403: this.message = "Missing Permissions"; break; | ||
case 404: this.message = "Ressource not found, probably deleted or invalid"; break; | ||
case 404: { | ||
if (this.path.includes("/interactions/")) | ||
this.message = "Unknow interaction, probably deleted or invalid" | ||
else if (this.path.includes("/pins")) | ||
this.message = "Unknow pin, probably unpined or invalid" | ||
else if (this.path.includes("/reactions")) | ||
this.message = "Unknow reaction, probably removed or invalid" | ||
else if (this.path.includes("messages/")) | ||
this.message = "Unknow message, probably deleted or invalid" | ||
else if (this.path.includes("channels/")) | ||
this.message = "Unknow channel, probably deleted or invalid" | ||
else if (this.path.includes("/users")) | ||
this.message = "Unknow user, probably invalid" | ||
else if (this.path.includes("/webhooks")) | ||
this.message = "Unknow webhook, probably deleted or invalid" | ||
else if (this.path.includes("/emojis")) | ||
this.message = "Unknow emoji, probably deleted or invalid" | ||
else if (this.path.includes("/commands")) | ||
this.message = "Unknow command, probably deleted or invalid" | ||
else if (this.path.includes("/invites")) | ||
this.message = "Unknow invite, problably deleted or invalid" | ||
else if (this.path.includes("/auto-moderations/")) | ||
this.message = "Unknow auto-mod rule, probably deleted or invalid" | ||
else if (this.path.includes("scheduled-events")) | ||
this.message = "Unknow event, probably deleted or invalid" | ||
else if (this.path.includes("/integrations")) | ||
this.message = "Unknow integration, probably deleted or invalid" | ||
else if (this.path.includes("/members")) | ||
this.message = "Unknow member, probably deleted or invalid" | ||
else if (this.path.includes("/roles")) | ||
this.message = "Unknow role, probably deleted or invalid" | ||
else if (this.path.includes("/bans")) | ||
this.message = "Unknow ban, probably revoked or invalid" | ||
else if (this.path.includes("/guilds")) | ||
this.message = "Unknow guild, probably invalid" | ||
else | ||
this.message = "Ressource not found, probably deleted or invalid" | ||
} break; | ||
case 405: this.message = "Method not allowed, contact the developer"; break; | ||
@@ -57,0 +94,0 @@ case 429: this.message = "Too many requests"; break; |
1706794
18570