Ejemplo n.º 1
0
        internal async Task <string> UpdateSuggestion(GuildSettings gset, ulong id, string status)
        {
            var suggestionChannel = gset.GetChannel(GuildSettings.AssignedChannels.Suggestion);

            if (suggestionChannel == null)
            {
                throw NeitsilliaError.ReplyError("Suggestions are currently deactivated.");
            }
            IUserMessage msg = (IUserMessage)await suggestionChannel.GetMessageAsync(id);

            if (msg == null)
            {
                throw NeitsilliaError.ReplyError("Message not found.");
            }
            else if (msg.Author.Id != Program.clientCopy.CurrentUser.Id)
            {
                throw NeitsilliaError.ReplyError("Message not sent by this bot.");
            }

            IEmbed[] embeds = Enumerable.ToArray(msg.Embeds);
            if (embeds.Length < 1)
            {
                await msg.DeleteAsync();

                throw NeitsilliaError.ReplyError("Message had no embeds and was deleted.");
            }
            EmbedAuthor  a      = (EmbedAuthor)embeds[0].Author;
            string       footer = ((EmbedFooter)embeds[0].Footer).Text;
            EmbedBuilder embed  = DUtils.BuildEmbed(null,
                                                    embeds[0].Description, footer, embeds[0].Color ?? new Color(),
                                                    DUtils.NewField("Reply", status));

            embed.WithAuthor(a.Name, a.IconUrl, a.Url);

            await msg.ModifyAsync(x =>
            {
                x.Embed = embed.Build();
            });

            if (ulong.TryParse(footer, out ulong userId))
            {
                Program.clientCopy.GetUser(userId)?.SendMessageAsync("Your suggestion has a new response.", embed: embed.Build());
            }

            return(msg.GetJumpUrl());
        }