Пример #1
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);
                }
            }
        }