Add user_guild_settings support (#1365)

* user guild settings

* Use direct collection

* I'm a goof

* double goof

* Structure properties

* Forgot to register listener

* wrong class names

* No more get in docs

* avoid waterfalls, bot checks

* trycatch

wow i thought i already did this :notlikecat:

* 👀

* Update ClientUser.js

* Update ClientUserGuildSettings.js

* Update UserGuildSettingsUpdate.js

* Update ClientUserChannelOverride.js

* Update ClientUserGuildSettings.js
This commit is contained in:
stupid cat
2017-07-31 20:28:15 -06:00
committed by Crawl
parent 4f5d1bffaf
commit b8034525e3
9 changed files with 259 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ const Invite = require('./Invite');
const PermissionOverwrites = require('./PermissionOverwrites');
const Permissions = require('../util/Permissions');
const Collection = require('../util/Collection');
const Constants = require('../util/Constants');
const { TypeError } = require('../errors');
/**
@@ -363,6 +364,35 @@ class GuildChannel extends Channel {
return this.client.api.channels(this.id).delete({ reason }).then(() => this);
}
/**
* Whether the channel is muted
* <warn>This is only available when using a user account.</warn>
* @type {boolean}
*/
get muted() {
if (this.client.user.bot) return null;
try {
return this.client.user.guildSettings.get(this.guild.id).channelOverrides.get(this.id).muted;
} catch (err) {
return false;
}
}
/**
* The type of message that should notify you
* one of `EVERYTHING`, `MENTIONS`, `NOTHING`, `INHERIT`
* <warn>This is only available when using a user account.</warn>
* @type {string}
*/
get messageNotifications() {
if (this.client.user.bot) return null;
try {
return this.client.user.guildSettings.get(this.guild.id).channelOverrides.get(this.id).messageNotifications;
} catch (err) {
return Constants.MessageNotificationTypes[3];
}
}
/**
* When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
* @returns {string}