public async Task Channelmod( [Summary("The user to cmod")][Remainder] SocketGuildUser user) { CollectionReference channelCollection = GranularPermissionsStorage.Db.Document(Convert.ToString(this.Context.Guild.Id)).Collection("channels"); DocumentReference channelDoc = channelCollection.Document(Convert.ToString(this.Context.Channel.Id)); Dictionary <string, object> update = new Dictionary <string, object>(); List <ulong> mods = await GranularPermissionsStorage.GetChannelmodsFor(this.Context.Guild.Id, this.Context.Channel); if (!mods.Contains(user.Id)) { mods.Add(user.Id); update["mods"] = mods; await channelDoc.SetAsync(update, SetOptions.MergeAll); if (this.Context.Channel is SocketGuildChannel sgc) { await sgc.AddPermissionOverwriteAsync(user, new OverwritePermissions(readMessages : PermValue.Allow, sendMessages : PermValue.Allow, manageMessages : PermValue.Allow)); } await this.Context.Message.AddReactionAsync(new Emoji("👌")); } else { mods.RemoveAll(x => x == user.Id); update["mods"] = mods; await channelDoc.SetAsync(update, SetOptions.MergeAll); await this.Context.Channel.SendMessageAsync("Removed a channelmod. (Their Discord permissions were not changed.)"); } }
public async Task RemoveFromChannel( [Summary("The user to remove")] SocketGuildUser user, [Summary("The channel to add to")] SocketGuildChannel channel) { List <ulong> mods = await GranularPermissionsStorage.GetChannelmodsFor(this.Context.Guild.Id, channel as ISocketMessageChannel); if (!mods.Contains(this.Context.User.Id)) { await this.Context.Channel.SendMessageAsync("You're not a channelmod of this channel: **" + channel.Name + "**"); return; } await channel.AddPermissionOverwriteAsync(user, new OverwritePermissions(readMessages : PermValue.Deny, sendMessages : PermValue.Deny)); await this.Context.Message.AddReactionAsync(new Emoji("👌")); }