public async Task <ulong> RepostMessageAsync(ITextChannel chan, IMessage msg, Embed embed = null)
        {
            using (DiscordWebhookClient webhook = await this.TryGetWebhookAsync(chan))
            {
                if (webhook == null)
                {
                    return(0);
                }

                try
                {
                    Embed[] embeds = embed == null ? null : new[] { embed };
                    if (msg.Attachments.Count > 0)
                    {
                        IAttachment attachment = msg.Attachments.First();
                        using (Stream stream = await this.HttpClient.GetStreamAsync(attachment.ProxyUrl))
                            return(await webhook.SendFileAsync(stream, attachment.Filename, msg.Content, false, embeds, msg.Author.Username, msg.Author.GetAvatarUrl()));
                    }
                    else
                    {
                        return(await webhook.SendMessageAsync(msg.Content, false, embeds, msg.Author.Username, msg.Author.GetAvatarUrl()));
                    }
                }
                catch (Exception ex)
                {
                    this.Logger.Nice("Webhook", ConsoleColor.Red, $"Could not send a message: {ex.Message}");
                    return(0);
                }
            }
        }
    internal async Task Init()
    {
        PlatformRacing3Server.StartTime = Stopwatch.StartNew();

        PlatformRacing3Server.ServerConfig = await JsonSerializer.DeserializeAsync <ServerConfig>(File.OpenRead("settings.json"));

        RedisConnection.Init(PlatformRacing3Server.ServerConfig);
        DatabaseConnection.Init(PlatformRacing3Server.ServerConfig);

        await this.serverManager.LoadServersAsync();

        await this.campaignManager.LoadCampaignTimesAsync();

        await this.campaignManager.LoadPrizesAsync();

        if (PlatformRacing3Server.ServerConfig.DiscordChatWebhookId != 0)
        {
            PlatformRacing3Server.DiscordChatWebhook = new DiscordWebhookClient(PlatformRacing3Server.ServerConfig.DiscordChatWebhookId, PlatformRacing3Server.ServerConfig.DiscordChatWebhookToken);
        }

        if (PlatformRacing3Server.ServerConfig.DiscordNotificationsWebhookId != 0)
        {
            PlatformRacing3Server.DiscordNotificationsWebhook = new DiscordWebhookClient(PlatformRacing3Server.ServerConfig.DiscordNotificationsWebhookId, PlatformRacing3Server.ServerConfig.DiscordNotificationsWebhookToken);
        }

        BytePacketManager bytePacketManager = new(this.serviceProvider);

        this.listener = IListener.CreateTcpListener(new IPEndPoint(IPAddress.Parse(PlatformRacing3Server.ServerConfig.BindIp), PlatformRacing3Server.ServerConfig.BindPort), socket =>
        {
            socket.Pipeline.AddHandlerFirst(new SplitPacketHandler(bytePacketManager, new ClientSession(socket)));
            socket.Pipeline.AddHandlerFirst(new FlashSocketPolicyRequestHandler());
        }, this.serviceProvider);

        _ = UpdateStatus();
    }
Example #3
0
        public static async Task BroadcastResultsAsync(List <EndPointHealthResult> epResults, string discordWebhook, ILogger logger,
                                                       bool family = false)
        {
            bool errorDiscordClient     = false;
            DiscordWebhookClient client = null;

            try
            {
                client = new DiscordWebhookClient(discordWebhook);
            } catch (Exception e)
            {
                logger.LogInformation(e.Message);
                errorDiscordClient = true;
            }
            List <Embed> embeds = null;

            if (!family)
            {
                embeds = CreateClassicEmbeds(epResults);
            }
            else
            {
                embeds = CreateFamilyEmbeds(epResults);
            }
            if (!errorDiscordClient)
            {
                await client.SendMessageAsync(embeds : embeds, username : "******");
            }
        }
        public static void PostMessage(string message, Action <string, bool> log, bool error = false)
        {
            using var client = new DiscordWebhookClient(error ? ConfigService.ErrorWebhookURL : ConfigService.WebhookURL);

            client.Log += async arg =>
            {
                log.Invoke(arg.ToString(), false);
                await Task.CompletedTask;
            };

            while (message.Length > 0)
            {
                string tempMessage = null;

                if (message.Length >= 1900)
                {
                    tempMessage = message.Substring(0, 1900);
                    message     = message.Substring(1900);
                }
                else
                {
                    tempMessage = message;
                    message     = string.Empty;
                }

                client.SendMessageAsync(tempMessage).GetAwaiter().GetResult();
            }
        }
Example #5
0
        public static void loaded()
        {
            string desc = "Loaded the following feeds:";

            foreach (RssFeed feed in Program.config.Feeds)
            {
                desc += "\n" + feed.FeedUrl;
            }


            var embed = new EmbedBuilder {
                Title       = "Bot loaded.",
                Description = desc,
                Timestamp   = DateTime.Now
            };

            Embed compiled = embed.Build();

            foreach (DiscordWebhook webhook in Program.config.Webhooks.Values)
            {
                if (webhook.SendDebuggingInfo)
                {
                    using (var client = new DiscordWebhookClient(webhook.Endpoint)) {
                        client.SendMessageAsync(embeds: new Embed[] { compiled }).Wait();
                    }
                }
            }
        }
 public static void SendMessage(List <string> traces, string dpsReportPermalink, WebhookSettings settings)
 {
     if (settings.WebhookURL != null && settings.WebhookURL.Length > 0)
     {
         if (!dpsReportPermalink.Contains("https"))
         {
             traces.Add("Nothing to send to Webhook");
             return;
         }
         try
         {
             var client = new DiscordWebhookClient(settings.WebhookURL);
             try
             {
                 if (settings.Embed == null)
                 {
                     _ = client.SendMessageAsync(text: dpsReportPermalink).Result;
                 }
                 else
                 {
                     _ = client.SendMessageAsync(embeds: new[] { settings.Embed }).Result;
                 }
                 traces.Add("Sent Embed");
             }
             finally
             {
                 client.Dispose();
             }
         }
         catch (Exception e)
         {
             traces.Add("Couldn't send embed: " + e.Message);
         }
     }
 }
Example #7
0
        private async static Task EnviarMensagemDiscord(string mensagem, string urlDiscord, string urlCrowdin)
        {
            Console.WriteLine("Cria a conexão com o webhook");
            var client = new DiscordWebhookClient(urlDiscord);

            var message = new DiscordMessage
                          (
                content: "Atualizações quentinhas saindo do forno para vocês <:kazupray:829517786509869057>",
                username: "******",
                avatarUrl: @"https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png",
                tts: false,
                embeds: new []
            {
                new DiscordMessageEmbed
                (
                    "Novas Atualizações",
                    0,
                    null,
                    urlCrowdin,
                    mensagem,
                    null,
                    null,
                    null,
                    null
                )
            }
                          );

            Console.WriteLine($"Envia a mensagem para o Webhook: {mensagem} - {urlDiscord}");
            await client.SendToDiscord(message);

            Console.WriteLine($"mensagem enviada!");
        }
 public string SendMessage()
 {
     if (_webhookURLValid)
     {
         try
         {
             var client = new DiscordWebhookClient(_webhookURL);
             try
             {
                 if (_embed == null)
                 {
                     _ = client.SendMessageAsync(text: _message).Result;
                 }
                 else
                 {
                     _ = client.SendMessageAsync(embeds: new[] { _embed }).Result;
                 }
             }
             finally
             {
                 client.Dispose();
             }
             return("Sent Embed");
         }
         catch (Exception e)
         {
             return("Couldn't send embed: " + e.Message);
         }
     }
     return("Webhook url invalid");
 }
 public static void DeleteMessage(string webhookURL, ulong id, out string message)
 {
     if (IsWebhookURLValid(webhookURL))
     {
         try
         {
             var client = new DiscordWebhookClient(webhookURL);
             try
             {
                 client.DeleteMessageAsync(id).Wait();
             }
             finally
             {
                 client.Dispose();
             }
             message = "Deleted message";
             return;
         }
         catch (Exception e)
         {
             message = "Couldn't delete message: " + e.Message;
             return;
         }
     }
     message = "Webhook url invalid";
 }
Example #10
0
        private async Task OnMessageReceived(SocketMessage message)
        {
            if (message.Source != MessageSource.User)
            {
                return;
            }
            if (message.Channel.Id != ChannelId)
            {
                return;
            }

            var authorId = message.Author.Id.ToString();

            if (!Config.People.ContainsKey(authorId))
            {
                return;
            }

            string name      = Config.People[authorId].Name;
            string avatarUrl = Config.People[authorId].AvatarUrl;

            using var webhookClient = new DiscordWebhookClient(WebhookUrl);
            await webhookClient.SendMessageAsync(message.Content, username : name, avatarUrl : avatarUrl);

            await message.DeleteAsync(DeleteMessageRequestOptions);
        }
Example #11
0
 static DiscordBot()
 {
     Client                  = new DiscordSocketClient();
     RazChannelWebhook       = new DiscordWebhookClient(BotTools.Settings["raz_channel_webhook"]);
     DJChannelWebhook        = new DiscordWebhookClient(BotTools.Settings["dj_channel_webhook"]);
     DJVettingChannelWebhook = new DiscordWebhookClient(BotTools.Settings["dj_vetting_webhook"]);
 }
Example #12
0
        public static bool SendMessage(string webHookURL, string messageText, string userName = null, string avatarUrl = null)
        {
            DiscordWebhookClient discordWebhookClient = null;

            try
            {
                discordWebhookClient = new DiscordWebhookClient(webHookURL);
            }
            catch (Exception ex)
            {
                throw new DiscordCommunications.Exceptions.DiscordClientInstantiationException("Failed to Instantiate DiscordWebhookClient", ex.InnerException);
            }

            try
            {
                ////But a channel has a 30 msg/60 sec limit for webhooks
                discordWebhookClient.SendMessageAsync(
                    text: messageText,
                    username: userName,
                    avatarUrl: avatarUrl
                    );
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Example #13
0
        public static bool SendMessage(MessageOptions options)
        {
            DiscordWebhookClient discordWebhookClient = null;

            try
            {
                discordWebhookClient = new DiscordWebhookClient(options.WebHookURL);
            }
            catch (Exception ex)
            {
                throw new DiscordCommunications.Exceptions.DiscordClientInstantiationException("Failed to Instantiate DiscordWebhookClient", ex.InnerException);
            }

            try
            {
                ////But a channel has a 30 msg/60 sec limit for webhooks
                discordWebhookClient.SendMessageAsync(
                    text: options.Text,
                    isTTS: options.IsTTS,
                    embeds: options.Embeds,
                    username: options.Username,
                    avatarUrl: options.AvatarUrl,
                    options: options.Options);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Example #14
0
        public static void ConfigureServices(HostBuilderContext context, IServiceCollection services)
        {
            services.AddSingleton <Startup>();
            services.AddHostedService <PinsService>();
            services.AddDbContext <PinsDbContext>(builder =>
            {
                builder.UseSqlite(context.Configuration["Database:ConnectionString"])
                .ConfigureWarnings(c => c.Log((RelationalEventId.CommandExecuting, MSLogLevel.Debug)));
            });

            var discordConfig = new DiscordConfiguration()
            {
                Token = context.Configuration["Discord:Token"], LogLevel = LogLevel.Debug
            };
            var discord = new DiscordClient(discordConfig);

            services.AddSingleton(discord);

            var webhookClient = new DiscordWebhookClient();

            services.AddSingleton(webhookClient);

            var prefixes       = context.Configuration["Discord:Prefixes"].Split(' ', StringSplitOptions.RemoveEmptyEntries);
            var commandsConfig = new CommandsNextConfiguration()
            {
                Services = services.BuildServiceProvider(), StringPrefixes = prefixes
            };
            var cnext = discord.UseCommandsNext(commandsConfig);

            services.AddSingleton(cnext);
        }
        public void TestWebhook_Valid(string webhookurl, ulong expectedId, string expectedToken)
        {
            DiscordWebhookClient.ParseWebhookUrl(webhookurl, out ulong id, out string token);

            Assert.Equal(expectedId, id);
            Assert.Equal(expectedToken, token);
        }
 public static ulong SendMessage(string webhookURL, string embed, out string message)
 {
     if (IsWebhookURLValid(webhookURL))
     {
         try
         {
             var   client = new DiscordWebhookClient(webhookURL);
             ulong id;
             try
             {
                 id = client.SendMessageAsync(text: embed).Result;
             }
             finally
             {
                 client.Dispose();
             }
             message = "Sent Embed";
             return(id);
         }
         catch (Exception e)
         {
             message = "Couldn't send embed: " + e.Message;
             return(0);
         }
     }
     message = "Webhook url invalid";
     return(0);
 }
 public void TestWebhook_Invalid(string webhookurl)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         DiscordWebhookClient.ParseWebhookUrl(webhookurl, out ulong id, out string token);
     });
 }
        public async Task RunAsync(Action <string> logAction = null)
        {
            this.logAction = logAction;

            // 最後に観測した日時をTableから取得する。これより新しいつぶやきのみ通知する。、
            var lastObservedAt = GetLastObservedAt();

            Log($"lastObservedAt ={lastObservedAt }");

            var voiceItems = await GetVoiceItemsAsync();

            var newVoiceItems = voiceItems.Where(x => x.PostTime > lastObservedAt);
            var newComments   = voiceItems
                                .SelectMany(x => x.Response)
                                .Where(x => x.PostTime > lastObservedAt);

            var client = new DiscordWebhookClient(discordWebhookId, discordWebhookToken);

            // 新着ボイスを通知
            await NotifyVoices(newVoiceItems, client);

            // 新着コメントを通知
            await NotifyComments(newComments, client);

            await UpdateLastObservedAtAsync();
        }
Example #19
0
        public async Task SendMessage(DiscordWebhookClient webhook,
                                      Proxy proxy,
                                      string text,
                                      IReadOnlyCollection <IAttachment> attachments)
        {
            var proxyUser = discord.GetUser(proxy.BotUser.DiscordId);
            var username  = $"{proxy.Name} [{proxyUser.Username}]";

            var avatarUrl = proxy.HasAvatar
                ? $"{avatarBaseUrl}/{proxy.AvatarGuid}"
                : proxyUser.GetAvatarUrl();

            if (attachments?.Any() ?? false)
            {
                var first = true;
                foreach (var a in attachments)
                {
                    // TODO: Single multipart request
                    var stream = await new HttpClient().GetStreamAsync(a.Url);
                    await webhook.SendFileAsync(stream, a.Filename, first?text : String.Empty,
                                                username : username,
                                                avatarUrl : avatarUrl);

                    first = false;
                }
            }
            else
            {
                await webhook.SendMessageAsync(text,
                                               username : username,
                                               avatarUrl : avatarUrl);
            }
        }
Example #20
0
 public async Task Upload(string comment, string filepath, string url)
 {
     using (var client = new DiscordWebhookClient(url))
     {
         await client.SendFileAsync(text : comment, filePath : filepath);
     }
 }
Example #21
0
        public async Task Send(Giveaway giveaway, string webhook)
        {
            using (var client = new DiscordWebhookClient(webhook))
            {
                var embed = new EmbedBuilder
                {
                    Title    = giveaway.Title,
                    Color    = Color.Magenta,
                    ImageUrl = giveaway.PhotoUrl,
                    Url      = string.IsNullOrEmpty(giveaway.DirectUrl) ? giveaway.Url : giveaway.DirectUrl,
                    Author   = new EmbedAuthorBuilder().WithName(giveaway.Store)
                };

                try
                {
                    await client.SendMessageAsync(
                        text : $"@everyone \n its free real estate \n add notifier to your [discord server]({MongoConfig.clientUrl})",
                        embeds : new[] { embed.Build() },
                        isTTS : true
                        );
                }
                catch (Exception e)
                {
                    throw new DiscordSendException($"failed to send giveaway {giveaway.ExternalId}", e);
                }
                finally
                {
                    await _giveawayRepository.UpdateStatus(giveaway);
                }
            }
        }
Example #22
0
        public async Task SendPunishmentWebhook(int punishmentId)
        {
            PlayerPunishment punishment = database.GetPunishment(punishmentId);

            if (punishment == null)
            {
                return;
            }

            using (var client = new DiscordWebhookClient(webhookUrl))
            {
                EmbedBuilder eb = new EmbedBuilder();
                eb.WithColor(Color.Blue);
                eb.WithTitle($"{CultureInfo.CurrentCulture.TextInfo.ToTitleCase(punishment.Category)}");
                eb.AddField("Player", $"[{punishment.Player.PlayerName}](https://steamcommunity.com/profiles/{punishment.PlayerId})");
                eb.AddField("Punisher", $"[{punishment.Punisher.PlayerName}](https://steamcommunity.com/profiles/{punishment.PunisherId})");
                eb.AddField("Reason", punishment.Reason == null ? "unkown" : punishment.Reason);
                if (punishment.ExpiryDate.HasValue)
                {
                    eb.AddField("Expires", punishment.ExpiryDate);
                }
                eb.WithTimestamp(punishment.CreateDate);

                await client.SendMessageAsync(embeds : new List <Embed>()
                {
                    eb.Build()
                });
            }
        }
Example #23
0
        public void StartReadEngine()
        {
            if (File.Exists("data/potterhead.garden"))
            {
                Webhook = new DiscordWebhookClient(File.ReadAllText("data/potterhead.garden"));

                if (!Directory.Exists("data/book/"))
                {
                    Directory.CreateDirectory("data/book/");
                }

                if (File.Exists("data/book/lastreadtime.garden"))
                {
                    LastReadTime = DateTime.Parse(File.ReadAllText("data/book/lastreadtime.garden"));
                }
                else
                {
                    LastReadTime = DateTime.UtcNow;
                }
            }
            else
            {
                File.Create("data/potterhead.garden");
                Console.WriteLine("Please paste the PotterHead link in the data/potterhead.garden file!");
            }
        }
Example #24
0
        private static void NotifyNewPosts(RssFeed feed, List <Post> posts)
        {
            for (int i = 0; i < posts.Count; i += 10) //max 10 embeds per webhook push
            {
                List <Embed> embeds = new List <Embed>();
                for (int k = i; k < Math.Min(i + 10, posts.Count); k++)
                {
                    Post p = posts.ElementAt(k);
                    embeds.Add(p.Embed);

                    if (config.OutputToConsole)
                    {
                        Console.WriteLine($"\n{p.Title}");
                        Console.WriteLine($"Posted in /r/{p.Subreddit} by /u/{p.Author}");
                        Console.WriteLine($"Timestamp: {p.PublishDate}");
                        Console.WriteLine($"URL: {p.Url}");
                        if (p.HasImage)
                        {
                            Console.WriteLine($"Image URL: {p.ImageUrl}");
                        }
                    }
                }

                foreach (String target in feed.WebhookTargets)
                {
                    DiscordWebhook webhook = config.Webhooks[target];
                    using (var client = new DiscordWebhookClient(webhook.Endpoint)) {
                        client.SendMessageAsync(text: webhook.PingString.Length > 0 ? webhook.PingString : null, embeds: embeds).Wait();
                    }
                }
            }
        }
Example #25
0
 public static void SendMessage(ParsedLog log, string[] uploadresult)
 {
     if (Properties.Settings.Default.WebhookURL != null && Properties.Settings.Default.WebhookURL.Length > 0)
     {
         if (!uploadresult[0].Contains("https"))
         {
             log.UpdateProgressWithCancellationCheck("Nothing to send to Webhook");
             return;
         }
         try
         {
             var client = new DiscordWebhookClient(Properties.Settings.Default.WebhookURL);
             try
             {
                 if (Properties.Settings.Default.SendSimpleMessageToWebhook)
                 {
                     _ = client.SendMessageAsync(text: uploadresult[0]).Result;
                 }
                 else
                 {
                     _ = client.SendMessageAsync(embeds: new[] { GetEmbed(log, uploadresult) }).Result;
                 }
                 log.UpdateProgressWithCancellationCheck("Sent Embed");
             }
             finally
             {
                 client.Dispose();
             }
         }
         catch (Exception e)
         {
             log.UpdateProgressWithCancellationCheck("Couldn't send embed: " + e.GetFinalException().Message);
         }
     }
 }
Example #26
0
        public static async Task BroadcastErrorAsync(string discordWebhook, ILogger logger)
        {
            bool errorDiscordClient     = false;
            DiscordWebhookClient client = null;

            try
            {
                client = new DiscordWebhookClient(discordWebhook);
            } catch (Exception e)
            {
                logger.LogInformation(e.Message);
                errorDiscordClient = true;
            }
            Color        embedColor = Color.Red;
            EmbedBuilder builder    = new EmbedBuilder();
            var          b          = builder.WithTitle("Latency Alert")
                                      .WithDescription("⚠ There have been a connexion issue, it will restart. If this problem persists, please contact administrator.")
                                      .WithColor(embedColor)
                                      .Build();
            List <Embed> embeds = new List <Embed>()
            {
                b
            };

            if (!errorDiscordClient)
            {
                await client.SendMessageAsync(embeds : embeds, username : "******");
            }
        }
        private async Task SendEmojiWithName(string name)
        {
            string emoji = name switch
            {
                "sans" => "<a:sans:719488632104288286>",
                "thonk" => "<:thonk:718853430969368637>",
                "mindblowing" => "<:mindblowing:719492411369324584>",
                "rotatethink" => "<a:rotatethonk:719491269885427752>",
                "hyper" => "<a:hyper:719494595313926244>",
                "xd" => "<:xd:719510255402352690>",
                "rainbowcat" => "<a:catrainbow1:719513824511656037><a:catrainbow2:719513824553861121>\n<a:catrainbow3:719513824905920603><a:catrainbow4:719513825040400415>",
                "yes" => "<a:yes:719496630902063149>",
                "no" => "<a:no:719496639471157288>",
                "calculated" => "<:calculated:719518217730654218>",
                _ => "unknown"
            };

            var cxt           = base.Context;
            var webhook       = await((ITextChannel)cxt.Channel).CreateWebhookAsync(((IGuildUser)cxt.User).Nickname ?? cxt.User.Username);
            var webhookClient = new DiscordWebhookClient(webhook);

            await cxt.Channel.DeleteMessageAsync(base.Context.Message);

            await webhookClient.SendMessageAsync(emoji, avatarUrl : cxt.User.GetAvatarUrl());

            await webhookClient.DeleteWebhookAsync();
        }
    }
Example #28
0
        private async void bSend_Click(object sender, EventArgs e)
        {
            var match = regexWebhook.Match(tbFullWebhook.Text);

            if (!match.Success)
            {
                return;
            }
            var hook = new DiscordWebhookClient(ulong.Parse(match.Groups[1].Value), match.Groups[2].Value);

            var embed = new EmbedBuilder();

            embed.WithDescription(tbBodyMessage.Text);
            var cnt = 0;

            if (cbUseColor.Checked && ++cnt > 0)
            {
                embed.WithColor(new Color(pColor.BackColor.R, pColor.BackColor.G, pColor.BackColor.B));
            }
            if (!string.IsNullOrEmpty(tbTitle.Text) && ++cnt > 0)
            {
                embed.WithTitle(tbTitle.Text);
            }
            if (!string.IsNullOrEmpty(tbThumbnailUrl.Text) && ++cnt > 0)
            {
                embed.WithThumbnailUrl(tbThumbnailUrl.Text);
            }
            if (!string.IsNullOrEmpty(tbImageUrl.Text) && ++cnt > 0)
            {
                embed.WithImageUrl(tbImageUrl.Text);
            }
            if (!string.IsNullOrEmpty(tbLink.Text) && ++cnt > 0)
            {
                embed.WithUrl(tbLink.Text);
            }
            if (dtpTimestamp.Checked && ++cnt > 0)
            {
                embed.WithTimestamp(new DateTimeOffset(dtpTimestamp.Value.ToUniversalTime()));
            }
            if (!string.IsNullOrEmpty(tbAuthorName.Text) && ++cnt > 0)
            {
                embed.WithAuthor(tbAuthorName.Text
                                 , !string.IsNullOrEmpty(tbAuthorAvatarUrl.Text) ? tbAuthorAvatarUrl.Text : null
                                 , !string.IsNullOrEmpty(tbAuthorLink.Text) ? tbAuthorLink.Text : null);
            }
            if (!string.IsNullOrEmpty(tbFooterText.Text) && ++cnt > 0)
            {
                embed.WithFooter(tbFooterText.Text
                                 , !string.IsNullOrEmpty(tbFooterIconUrl.Text) ? tbFooterIconUrl.Text : null);
            }
            if (cnt > 0)
            {
                await hook.SendMessageAsync("", false, new[] { embed.Build() }, tbSenderName.Text,
                                            tbSenderAvatarUrl.Text);
            }
            else
            {
                await hook.SendMessageAsync(tbBodyMessage.Text, false, null, tbSenderName.Text, tbSenderAvatarUrl.Text);
            }
        }
 private void Test(object sender, RoutedEventArgs e)
 {
     try {
         DiscordWebhookClient s = new DiscordWebhookClient(hook.Text);
         var embed = new EmbedBuilder
         {
             Title       = "Zen Aio Webhook Test Results",
             Description = "Testing.."
         };
         embed.AddField("Product",
                        "Yeezy 350 V2")
         .WithFooter(footer => footer.Text = "Zen Aio")
         //.WithFooter(footer => )
         .WithColor(Discord.Color.Blue)
         .WithCurrentTimestamp()
         .WithImageUrl("https://www.flightclub.com/media/catalog/product/cache/1/image/1600x1140/9df78eab33525d08d6e5fb8d27136e95/2/0/201519_1.jpg")
         .Build();
         embed.Footer.IconUrl = "https://cdn.discordapp.com/attachments/561322271935823893/580919251670663168/Zen.jpg";
         s.SendMessageAsync(text: "COPPED!", embeds: new[] { embed.Build() });
     }
     catch
     {
         MessageBox.Show("Error on the webhook");
     }
 }
Example #30
0
 private DiscordWebhookClient GetWebhook()
 {
     if (webhook == null)
     {
         webhook = new DiscordWebhookClient(this.Id, this.Token);
     }
     return(webhook);
 }