Esempio n. 1
0
        public async Task Ping()
        {
            var t   = MiXLib.tick();
            var msg = await ReplyAsync("", false, MiXLib.GetEmbed("Pinging..."));

            await msg.ModifyAsync(x =>
            {
                x.Embed = MiXLib.GetEmbed($"Pong! **{((int)((MiXLib.tick() - t) * 1000)).ToString()}ms**");
            });
        }
Esempio n. 2
0
        public async Task Warn(SocketUser user, [Remainder] string reason = "Unspecified Reason")
        {
            if (await MiXLib.GetRank(user.Id, Context.Guild) > 0)
            {
                await ReplyAsync("", false, MiXLib.GetEmbed("**Error:** User is a staff member, cannot warn.", color: new Color(200, 0, 0)));

                return;
            }
            var w = new Warn(user.Id, Context.User.Id, reason, MiXLib.tick(), MiXLib.tick() + 18000);
            await Core.Guilds[Context.Guild.Id].AddWarnAsync(w);

            await ReplyAsync("", false, MiXLib.GetEmbed("Successfully warned user.", color: new Color(255, 140, 0)));
        }
Esempio n. 3
0
        public async Task TestCommand(string time = null)
        {
            //var time = "";
            var reason      = "";
            var IsPermanent = false;
            var EndTime     = MiXLib.tick();

            if (time == null)
            {
                EndTime += 604800;
            }
            else if (time == "inf" || time == "perm" || time == "permanent" || time == "forever" || time == "0" || time == "-1")
            {
                IsPermanent = true;
                EndTime     = -1;
            }
            else
            {
                double length = 0;
                try { length = Convert.ToDouble(time.Substring(0, time.Length - 1)); } catch (Exception ex) { length = Convert.ToDouble(time); }
                var suf = "";
                try { suf = time.Substring(time.Length - 1); } catch (Exception ex) { suf = "m"; }
                if (suf == "y")
                {
                    length = (((length * 60) * 60) * 24) * 365;
                }
                else if (suf == "d")
                {
                    length = ((length * 60) * 60) * 24;
                }
                else if (suf == "h")
                {
                    length = (length * 60) * 60;
                }
                else if (suf == "m")
                {
                    length = length * 60;
                }
                else if (suf == "s")
                {
                    length = length;
                }
                if (length <= 0)
                {
                    IsPermanent = true;
                    EndTime     = -1;
                }
                else
                {
                    EndTime += length;
                }
            }
            var LengthString = MiXLib.FormatTime(Convert.ToInt32(EndTime - MiXLib.tick()));

            if (IsPermanent)
            {
                LengthString = "**forever**";
            }
            if (reason == null)
            {
                reason = "";
            }
            await ReplyAsync("", false, MiXLib.GetEmbed(LengthString));
        }
Esempio n. 4
0
        public async Task Ban(SocketUser user, string duration = "-1", [Remainder] string reason = "Unspecified Reason")
        {
            if (await MiXLib.GetRank(user.Id, Context.Guild) >= await MiXLib.GetRank(Context.User.Id, Context.Guild))
            {
                await ReplyAsync("", false, MiXLib.GetEmbed("**Error:** You do not outrank this user.", color: new Color(200, 0, 0)));

                return;
            }
            else if (Context.Guild.GetUser(user.Id).Hierarchy > Context.Guild.GetUser(Context.Client.CurrentUser.Id).Hierarchy || Context.Guild.OwnerId == user.Id)
            {
                await ReplyAsync("", false, MiXLib.GetEmbed("**Error:** User outranks bot, no permissions.", color: new Color(200, 0, 0)));

                return;
            }
            var IsPermanent = false;
            var EndTime     = MiXLib.tick();

            if (duration == null)
            {
                EndTime += 604800;
            }
            else if (duration == "inf" || duration == "perm" || duration == "permanent" || duration == "forever" || duration == "0" || duration == "-1")
            {
                IsPermanent = true;
                EndTime     = -1;
            }
            else
            {
                double length = 0;
                try { length = Convert.ToDouble(duration.Substring(0, duration.Length - 1)); } catch (Exception ex) { length = Convert.ToDouble(duration); }
                var suf = "";
                try { suf = duration.Substring(duration.Length - 1); } catch (Exception ex) { suf = "m"; }
                try { Convert.ToDouble(suf); length = Convert.ToDouble(duration); suf = "m"; } catch (Exception ex) { }
                if (suf == "y")
                {
                    length = (((length * 60) * 60) * 24) * 365;
                }
                else if (suf == "d")
                {
                    length = ((length * 60) * 60) * 24;
                }
                else if (suf == "h")
                {
                    length = (length * 60) * 60;
                }
                else if (suf == "m")
                {
                    length = length * 60;
                }
                else if (suf == "s")
                {
                    length = length;
                }
                if (length <= 0)
                {
                    IsPermanent = true;
                    EndTime     = -1;
                }
                else
                {
                    EndTime += length;
                }
            }

            /*var LengthString = MiXLib.FormatTime(Convert.ToInt32(EndTime - MiXLib.tick()));
             * if (IsPermanent)
             * {
             *  LengthString = "forever";
             * }*/
            var b = new Ban(user.Id, Context.User.Id, reason, MiXLib.tick(), EndTime, IsPermanent);
            await Core.Guilds[Context.Guild.Id].AddBanAsync(b);

            await ReplyAsync("", false, MiXLib.GetEmbed("Successfully banned user.", color: new Color(1, 1, 1)));
        }
Esempio n. 5
0
        public async Task GetWarns(SocketUser user)
        {
            var Guild = Core.Guilds[Context.Guild.Id];

            if (!Guild.Warns.ContainsKey(user.Id) || Guild.Warns[user.Id].Count <= 0)
            {
                await ReplyAsync("", false, MiXLib.GetEmbed("User has no active warnings!", color: new Color(255, 140, 0)));

                return;
            }
            var Warns = Guild.Warns[user.Id];
            var str   = "";

            foreach (Warn w in Warns)
            {
                var DateTimeFormat = @"MM\/dd\/yyyy  hh:mm tt";
                var Issuer         = Context.Guild.GetUser(w.Issuer);
                str = str +
                      $"{MiXLib.UnixTimeStampToDateTime(Convert.ToInt64(w.Starts)).ToString(DateTimeFormat)}\n" +
                      $"  Reason: **{w.Reason}**\n" +
                      $"  Issuer: **{Issuer.Username}#{Issuer.Discriminator}** ({Issuer.Id})\n" +
                      $"  Expired: **{MiXLib.BoolToYesNo(w.Expired)}**\n" +
                      $"  Expires: **{MiXLib.UnixTimeStampToDateTime(Convert.ToInt64(w.Ends)).ToString(DateTimeFormat)}** (in **{MiXLib.FormatTime(Convert.ToInt32(w.Ends - MiXLib.tick()))}**)\n\n";
            }
            await ReplyAsync("", false, MiXLib.GetEmbed(str, $"Warnings for {user.Username}#{user.Discriminator}", new Color(255, 140, 0)));
        }