Esempio n. 1
0
        private async Task UpdateSelfRoleMessage(RoleMenu rm, string list)
        {
            IUserMessage message = await GetSelfRoleMessage(rm);

            if (message != null)
            {
                EmbedBuilder embedBuilder = CreateEmbed(EmbedColor.SalmonPink);

                StringBuilder sb        = new StringBuilder();
                List <IEmote> reactions = new List <IEmote>();
                foreach (string key in rm.SelfRoles.Keys)
                {
                    sb.AppendLine($"{key} - {Context.Guild.GetRole(rm.SelfRoles[key]).Mention}\n");
                    reactions.Add(GetEmote(key));
                }
                if (rm.SelfRoles.Keys.Count > 0)
                {
                    string title = list ?? "Self Roles";
                    embedBuilder.AddField($"**{title}**", sb.ToString());
                }
                else
                {
                    embedBuilder.AddField($"**There are no roles in {list ?? "default"} self role menu**", "ごめんね");
                }

                await message.ModifyAsync(x => x.Embed = embedBuilder.Build());

                //Get the difference set of the message reactions set minus the final reactions set
                List <IEmote> toDelete = new List <IEmote>(message.Reactions.Keys.Except <IEmote>(reactions));
                foreach (IEmote emote in toDelete)
                {
                    await DiscordAPIHelper.DeleteAllReactionsWithEmote(message, emote);                     //Making this was :CoconaSweat:
                }

                //Get the difference set of the final reactions set minus the message reactions set
                List <IEmote> toAdd = new List <IEmote>(reactions.Except <IEmote>(message.Reactions.Keys));
                await message.AddReactionsAsync(toAdd.ToArray());

                //Just because of pride, if the Discord API improves in the future, leave this shit here.
            }
        }