Beispiel #1
0
        public static EmbedBuilder ToEmbed(ReactionImage img)
        {
            EmbedBuilder embed = new EmbedBuilder();

            string path = $"{AppSettings.ImageUrlPath + "reaction/"}{img.Name}{(img.GuildId > 0 ? "/" + img.GuildId.ToString() : "")}/{img.Id}.{img.ImageFileType}";

            embed.WithImageUrl(path);
            embed.WithFooter($"{img.Name} id: {img.Id}");
            embed.WithColor(BasicUtil.RandomColor());
            return(embed);
        }
Beispiel #2
0
        //Image handlers
        public static async Task UploadReactionImage(ReactionImage img, ISocketMessageChannel ch)
        {
            try
            {
                if (img.Url == null || img.Url == "")
                {
                    return;
                }

                string to   = "reaction";
                string path = Path.Combine(to, img.Name);
                if (img.GuildId > 0)
                {
                    path = Path.Combine(path, img.GuildId.ToString());
                }

                string fileName = $"{img.Id}.{img.ImageFileType}";

                var res = await UploadImage(path, fileName, img.Url);

                if (res != null)
                {
                    await ch.SendMessageAsync($"Failed to upload image to host: `{res}`");
                }
            }
            catch (Exception ex)
            {
                await ch.SendMessageAsync($"{Program.GetClient().GetUser(AppSettings.OwnerId).Mention} Error while uploading image to host.");

                SentrySdk.WithScope(scope =>
                {
                    scope.SetExtras(img.GetProperties());
                    SentrySdk.CaptureException(ex);
                });
            }
        }