devland.js
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -40,3 +40,2 @@ const Client = require('./structures/client/client') | ||
const { __exportStar } = require('tslib'); | ||
__exportStar(require('./structures/types/index'), exports) | ||
module.exports = { | ||
@@ -43,0 +42,0 @@ Client, |
@@ -10,3 +10,3 @@ { | ||
"name": "devland.js", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A powerful API wrapper for the Discord API designed for modern bots", | ||
@@ -13,0 +13,0 @@ "main": "index.js", |
@@ -35,3 +35,3 @@ const Permissions = require("../util/Permissions/Permissions") | ||
if (this.options && this.options.length > 25) throw new TypeError("Command max options length is 25") | ||
if (this.options && this.type !== 1) throw new TypeError("Command options are available for CHAT_INPUT type only") | ||
if (this.options && this.options.length > 0 && this.type !== 1) throw new TypeError("Command options are available for CHAT_INPUT type only") | ||
else if (typeof this.options !== "object") this.options = undefined | ||
@@ -38,0 +38,0 @@ if (this.default_member_permissions && this.default_member_permissions instanceof Permissions) { |
@@ -42,3 +42,3 @@ const Client = require('../client/client') | ||
this.values = data?.data?.values | ||
this.isSlashCommand = this.type === 2 | ||
this.isCommand = this.type === 2 | ||
this.isModal = this.type === 5 | ||
@@ -54,2 +54,5 @@ this.isMessageComponent = this.type === 3 | ||
this.isChannelSelect = this.isMessageComponent && this.data.component_type === 8 | ||
this.isSlashCommand = this.isCommand && this.data.type === 1 | ||
this.isUserContext = this.isCommand && this.data.type === 2 | ||
this.isMessageContext = this.isCommand && this.data.type === 3 | ||
this.followUpMessageId = null | ||
@@ -61,3 +64,3 @@ this.deleted = false | ||
return new Promise(async (resolve, reject) => { | ||
if (this.isSlashCommand) return reject(new TypeError("You can't use deferUpdate on a slash command")) | ||
if (this.isCommand) return reject(new TypeError("You can't use deferUpdate on a command")) | ||
if (typeof options !== "object") options = {} | ||
@@ -431,2 +434,12 @@ if (typeof options.ephemeral !== "boolean") options.ephemeral = false | ||
} | ||
getTargetUser(){ | ||
if(!this.isUserContext) throw new TypeError("This function can be used on a user context only") | ||
return new User(this.client, this.data.resolved.users[this.data.target_id]) | ||
} | ||
getTargetMessage(){ | ||
if(!this.isMessageContext) throw new TypeError("This function can be used on a message context only") | ||
return new Message(this.client, this.client.guilds.get(this.guildId)||this.guild, this.channel, this.data.resolved.messages[this.data.target_id]) | ||
} | ||
} |
@@ -28,6 +28,7 @@ const Permissions = require('../util/Permissions/Permissions') | ||
this.data_is_available = true | ||
const User = require('./User') | ||
this.user = data.user ? this.client.users.get(data.user.id) || new User(client, data.user) : null | ||
this.permissions = (this.id === this.guild.ownerId) ? new Permissions("ADMINISTRATOR") : new Permissions(this.roles.map(role_id => { | ||
return this.guild.roles.get(role_id)?.permissions | ||
})) | ||
this.permissions = (this.id === this.guild.ownerId) ? new Permissions("ADMINISTRATOR") : this.roles.length > 0 && this.guild.roles.size > 0 ? new Permissions(this.roles.map(role_id => { | ||
return this.guild.roles.get(role_id)?.permissions.toArray() | ||
})) : new Permissions() | ||
} | ||
@@ -34,0 +35,0 @@ |
@@ -73,4 +73,8 @@ const Client = require('../client/client') | ||
if(data.mentions) data.mentions.map(m => { | ||
m.user = m | ||
if(m.member){ | ||
m.member.user = m | ||
this.memberMentions.set(m.id, new Member(this.client, this.client.guilds.get(this.guildId)||this.guild, m.member)) | ||
} else { | ||
this.memberMentions.set(m.id, new User(this.client, m)) | ||
} | ||
}) | ||
@@ -77,0 +81,0 @@ if(data.mention_roles) data.mention_roles.map(async r_id => { |
@@ -148,3 +148,2 @@ const BitField = require('./BitField'); | ||
MANAGE_THREADS: 1n << 34n, | ||
// TODO: Remove deprecated USE_*_THREADS flags in v14 | ||
USE_PUBLIC_THREADS: 1n << 35n, | ||
@@ -158,2 +157,4 @@ CREATE_PUBLIC_THREADS: 1n << 35n, | ||
MODERATE_MEMBERS: 1n << 40n, | ||
VIEW_CREATOR_MONETIZATION_ANALYTICS: 1n << 41n, | ||
USE_SOUNDBOARD: 1n << 42n, | ||
}; | ||
@@ -160,0 +161,0 @@ |
Sorry, the diff of this file is too big to display
716699
12602