Exemple #1
0
        public async Task SendLog(IGuild guild, string title, string description, DateTimeOffset?timeStamp = null,
                                  Server server = null)
        {
            timeStamp = timeStamp ?? DateTimeOffset.Now;
            if (server == null)
            {
                _database.Execute(x => { server = server ?? x.Load <Server>($"{guild.Id}"); });
            }

            if (!server.LogChannelId.HasValue)
            {
                return;
            }

            var channel = await guild.GetTextChannelAsync(server.LogChannelId.Value);

            if (channel == null)
            {
                return;
            }
            var currentUser = await guild.GetCurrentUserAsync();

            if (!currentUser.GetPermissions(channel).SendMessages)
            {
                return;
            }

            var embed = UtilService.NormalizeEmbed(title, description, ColorType.Normal, _random, server);

            embed.WithTimestamp(timeStamp.Value);

            await channel.SendMessageAsync(embed : embed.Build());
        }
Exemple #2
0
 public EmbedBuilder NormalizeEmbed(string title, string description, ColorType colorType = ColorType.Normal,
                                    bool withRequested = false)
 {
     return(UtilService.NormalizeEmbed(title, description, colorType, Random, Server, withRequested, Context));
 }