mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
User settings (#1337)
* user settings bruh * remove development dump * emit stuff * i am so done * Update ClientUserSettings.js * modularize * Update ClientUserSettings.js * Update Constants.js * Update ClientUserSettings.js * Update RESTMethods.js * Update ClientUserSettings.js * <.<
This commit is contained in:
@@ -301,6 +301,17 @@ class Guild {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of this guild
|
||||
* <warn>This is only available when using a user account.</warn>
|
||||
* @type {?number}
|
||||
*/
|
||||
get position() {
|
||||
if (this.client.user.bot) return null;
|
||||
if (!this.client.user.settings.guildPositions) return null;
|
||||
return this.client.user.settings.guildPositions.indexOf(this.id);
|
||||
}
|
||||
|
||||
/*
|
||||
* The `@everyone` Role of the guild.
|
||||
* @type {Role}
|
||||
* @readonly
|
||||
@@ -786,6 +797,29 @@ class Guild {
|
||||
return this.client.rest.methods.ackGuild(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} position Absolute or relative position
|
||||
* @param {boolean} [relative=false] Whether to position relatively or absolutely
|
||||
* @returns {Promise<Guild>}
|
||||
*/
|
||||
setPosition(position, relative) {
|
||||
if (this.client.user.bot) {
|
||||
return Promise.reject(new Error('Setting guild position is only available for user accounts'));
|
||||
}
|
||||
return this.client.user.settings.setGuildPosition(this, position, relative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow direct messages from guild members
|
||||
* @param {boolean} allow Whether to allow direct messages
|
||||
* @returns {Promise<Guild>}
|
||||
*/
|
||||
allowDMs(allow) {
|
||||
const settings = this.client.user.settings;
|
||||
if (allow) return settings.removeRestrictedGuild(this);
|
||||
else return settings.addRestrictedGuild(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this Guild equals another Guild. It compares all properties, so for most operations
|
||||
* it is advisable to just compare `guild.id === guild2.id` as it is much faster and is often
|
||||
|
||||
Reference in New Issue
Block a user