Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user_guild_settings support #1365

Merged
merged 22 commits into from
Aug 1, 2017
Merged

Conversation

Ratismal
Copy link
Contributor

In the ready event, discord sends two properties specific to ClientUsers - UserSettings and UserGuildSettings. UserSettings has already been wrapped, so this PR aims to wrap UserGuildSettings.

This is accomplished by create two new structures: ClientUserGuildSettings and ClientUserChannelOverrides. These contain wrappings for the user guild settings, and the former contains a Collection of the latter.

Additionally, the Guild and GuildChannel classes both have new properties obtained from these wraps.

I didn't implement the actions required to modify these settings, and will look into doing that in the future (I didn't implement because I wasn't sure how to do it).

I also didn't know the best way to accomplish this, so feel free to give feedback or suggestions on reimplementation.

Thank you for your time.

@devsnek
Copy link
Member

devsnek commented Apr 24, 2017

you could replace these waterfalls with try/catch

get muted() {
  if (this.client.user.bot) return null;
  if (!this.client.user.guildSettings) return null;
  if (!this.client.user.guildSettings.get(this.guild.id)) return null;
  if (!this.client.user.guildSettings.get(this.guild.id).channelOverrides) return false;
  if (!this.client.user.guildSettings.get(this.guild.id).channelOverrides.get(this.id)) return false;
  return this.client.user.guildSettings.get(this.guild.id).channelOverrides.get(this.id).muted;
}

to

get messageNotifications() {
  try {
    return this.client.user.guildSettings.get(this.guild.id).channelOverrides.get(this.id).muted;
  } catch (err) {
    return false;
  }
}

@aemino
Copy link
Contributor

aemino commented Apr 28, 2017

This needs a rebase.

@Ratismal
Copy link
Contributor Author

As requested by @GusCaplan, switched waterfalls to try/catches

Also did some if bot return null checks

@amishshah amishshah force-pushed the master branch 4 times, most recently from 260b09e to 5b2ca32 Compare April 29, 2017 18:45
@devsnek
Copy link
Member

devsnek commented Apr 29, 2017

@Ratismal this needs a rebase

@devsnek
Copy link
Member

devsnek commented Jun 17, 2017

@Ratismal is this ready to merge

if (this.client.user.bot) return null;
if (!this.client.user.guildSettings) return null;
if (!this.client.user.guildSettings.get(this.id)) return null;
return this.client.user.guildSettings.get(this.id).suppressEveryone;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/catch

iCrawl and others added 2 commits July 29, 2017 22:43
wow i thought i already did this :notlikecat:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants