示例#1
0
        public async Task RulesAsync()
        {
            var channel = Context.Channel;
            var user    = Context.User;
            await Context.Message.DeleteAsync();

            TimeSpan last       = Cooldowns.GetRulesLast();
            TimeSpan current    = DateTime.Now.TimeOfDay;
            double   difference = current.TotalSeconds - last.TotalSeconds;

            if (difference >= Cooldowns.GetCommandCooldown() || difference < 0)
            {
                var embed = new EmbedBuilder()
                {
                    Color = Colours.generalCol
                };
                embed.WithAuthor("GTA5Police Rules", References.GetGta5policeLogo());
                embed.Title       = "Click to view all GTA5Police rules.";
                embed.Description = "**Teamspeak IP: gta5police.com**";
                embed.WithUrl(References.GetRulesURL());
                embed.WithThumbnailUrl(References.GetGta5policeLogo());
                embed.WithImageUrl(References.GetHowBanURL());
                embed.WithFooter("Requested by " + Context.User);
                embed.WithCurrentTimestamp();

                var message = await Context.Channel.SendMessageAsync("", false, embed);

                await Delete.DelayDeleteEmbedAsync(message, (int)Cooldowns.GetCommandCooldown());

                await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Commands", "Rules command was used by " + user + "."));

                Cooldowns.SetRulesLast(current);
                Statistics.AddOutgoingMessages();
            }
            else
            {
                await errors.sendErrorTempAsync(channel, user + errorMessage + "\nCooldown " + difference + "/" + Cooldowns.GetCommandCooldown() + " seconds", Colours.errorCol);
            }
        }