示例#1
0
        private async Task UsersAsync()
        {
            await Context.Message.DeleteAsync();

            var bot    = LCommandHandler.GetBot();
            int guilds = bot.Guilds.Count;
            int users  = (await Context.Guild.GetUsersAsync()).Count;
            int total  = 0;

            foreach (var guild in bot.Guilds)
            {
                total += guild.Users.Count;
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Lori's Angels Statistics",
                Color       = Color.DarkPurple,
                Description = $"Out of the {guilds} guilds I am watching {total} total users, {users} of which are from this guild!",
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Id}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#2
0
        private async Task AvatarAsync(ulong userid)
        {
            await Context.Message.DeleteAsync();

            IUser user = (await Context.Guild.GetUserAsync(userid) as IUser);

            if (user == null)
            {
                foreach (var guild in CommandHandler.GetBot().Guilds)
                {
                    if (await(guild as IGuild).GetUserAsync(userid) as IUser != null)
                    {
                        user = await(guild as IGuild).GetUserAsync(userid) as IUser;
                    }
                }
            }

            if (user == null)
            {
                user = (Context.User as IUser);
            }

            string       avatar = user.GetAvatarUrl(size: 2048);
            EmbedBuilder embed  = new EmbedBuilder()
            {
                Title    = $"{user.Username}#{user.Discriminator}",
                Color    = Color.DarkPurple,
                ImageUrl = avatar,
                Footer   = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                },
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#3
0
        private async Task UptimeAsync()
        {
            await Context.Message.DeleteAsync();

            BotConfig conf    = BotConfig.Load();
            DateTime  time    = DateTime.UtcNow;
            int       minutes = (int)((time - conf.LastStartup).TotalMinutes);
            int       uptime  = 0;
            string    m       = "minutes";

            if (minutes >= 60)
            {
                uptime = minutes / 60;
                m      = "hours";
            }
            else
            {
                uptime = minutes;
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Lori's Angels Statistics",
                Color       = Color.DarkPurple,
                Description = $"Lori's Angel has been online since {time}, thats an uptime of {uptime} {m}!",
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Id}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#4
0
        private async Task BinaryAsync([Remainder] string text = null)
        {
            await Context.Message.DeleteAsync();

            if (text != null)
            {
                var binary = ToBinary(ConvertToByteArray(text, Encoding.ASCII));

                EmbedBuilder embed = new EmbedBuilder()
                {
                    Title       = $"Text to Binary",
                    Description = $"''{text}''\n\n{binary}",
                    Color       = Color.DarkPurple
                };
                embed.Footer = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                };
                await Context.Channel.SendMessageAsync(null, false, embed.Build());
            }
            else
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}binary <message>`", false);

                return;
            }
        }
示例#5
0
        private async Task HugAsync(IUser user = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}hug <@user>`", false);

                return;
            }

            List <FunObject> hugs = await FunDatabase.GetOfTypeAsync("hug");

            Random rnd = new Random();
            int    g   = rnd.Next(0, hugs.Count);
            string GIF = hugs[g].Extra;

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title    = $"{Context.User.Username} hugged {user.Username}",
                ImageUrl = GIF,
                Color    = Color.DarkPurple,
                Footer   = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.ToString()}"
                }
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#6
0
        private async Task ReadyAsync()
        {
            await bot.SetStatusAsync(UserStatus.Online);

            // Load the TopGG API Token
            string tokenLoc = Path.Combine(AppContext.BaseDirectory, "config/topgg.token");

            if (File.Exists(tokenLoc))
            {
                TOPGG_TOKEN = File.ReadAllText(tokenLoc);
            }
            else
            {
                await Util.LoggerAsync(new LogMessage(LogSeverity.Error, "TopGG", $"TopGG Token does not exist at {tokenLoc}."));
            }

            // Set the guild count for the bot
            var updateCounts = Task.Run(async() =>
            {
                await UpdateTopGGStats();
            });

            // Clear up any old game renders...
            var clearGames = Task.Run(async() =>
            {
                var files = Directory.GetFiles(Path.Combine("textures", "games"));
                foreach (string p in files)
                {
                    File.Delete(p);
                }
            });

            // Set the custom status once every 5 mins
            var status = Task.Run(async() => {
                bool flick = true;
                while (true)
                {
                    if (flick)
                    {
                        await bot.SetGameAsync($"use -help {EmojiUtil.GetRandomHeartEmoji()}", type: ActivityType.Streaming);
                    }
                    else
                    {
                        await bot.SetGameAsync($"use -changelog {EmojiUtil.GetRandomHeartEmoji()}", type: ActivityType.Streaming);
                    }
                    flick = !flick;
                    await Task.Delay(60000 * 5);
                }
            });

            await ProfileDatabase.ProcessUsers();

            //await ModerationDatabase.ProcessBansAsync();
        }
示例#7
0
 static int QPYX_toUnicode_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
         string QPYX_o_YXQP    = EmojiUtil.toUnicode(QPYX_arg0_YXQP);
         LuaDLL.lua_pushstring(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#8
0
 static int QPYX_isEmojiCharacter_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         int  QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 1);
         bool QPYX_o_YXQP    = EmojiUtil.isEmojiCharacter(QPYX_arg0_YXQP);
         LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#9
0
 static int QPYX_getLength_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
         int    QPYX_o_YXQP    = EmojiUtil.getLength(QPYX_arg0_YXQP);
         LuaDLL.lua_pushinteger(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#10
0
 static int QPYX_containsEmoji_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
         bool   QPYX_o_YXQP    = EmojiUtil.containsEmoji(QPYX_arg0_YXQP);
         LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#11
0
        private async Task EightBallAsync([Remainder] string question = null)
        {
            await Context.Message.DeleteAsync();


            if (question != null)
            {
                string reply;
                Random rnd    = new Random();
                int    random = rnd.Next(0, 3);
                switch (random)
                {
                case 0:
                    int y = rnd.Next(0, YES_REPLIES.Length);
                    reply = YES_REPLIES[y];
                    break;

                case 1:
                    int n = rnd.Next(0, NO_REPLIES.Length);
                    reply = NO_REPLIES[n];
                    break;

                default:
                    int m = rnd.Next(0, MAYBE_REPLIES.Length);
                    reply = MAYBE_REPLIES[m];
                    break;
                }

                EmbedBuilder embed = new EmbedBuilder()
                {
                    Title       = question,
                    Description = reply + "!",
                    Color       = Color.DarkPurple,
                    Footer      = new EmbedFooterBuilder()
                    {
                        Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                    },
                };

                await Context.Channel.SendMessageAsync(null, false, embed.Build());
            }
            else
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}8ball <question>`", false);

                return;
            }
        }
示例#12
0
 static int QPYX_CopyTextValueToEmojiText_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.UI.Text QPYX_arg0_YXQP = (UnityEngine.UI.Text)ToLua.CheckObject <UnityEngine.UI.Text>(L_YXQP, 1);
         EmojiText           QPYX_arg1_YXQP = (EmojiText)ToLua.CheckObject <EmojiText>(L_YXQP, 2);
         EmojiUtil.CopyTextValueToEmojiText(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#13
0
 static int QPYX_ReplaceComponentText_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.UI.Text QPYX_arg0_YXQP = (UnityEngine.UI.Text)ToLua.CheckObject <UnityEngine.UI.Text>(L_YXQP, 1);
         string    QPYX_arg1_YXQP           = ToLua.CheckString(L_YXQP, 2);
         EmojiText QPYX_o_YXQP = EmojiUtil.ReplaceComponentText(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
         ToLua.Push(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#14
0
 static int QPYX_getEmojiList_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
         string QPYX_arg1_YXQP = null;
         System.Collections.Generic.List <EmojiElement> QPYX_o_YXQP = EmojiUtil.getEmojiList(QPYX_arg0_YXQP, out QPYX_arg1_YXQP);
         ToLua.PushSealed(L_YXQP, QPYX_o_YXQP);
         LuaDLL.lua_pushstring(L_YXQP, QPYX_arg1_YXQP);
         return(2);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#15
0
        private async Task WhoAsync([Remainder] string question = null)
        {
            await Context.Message.DeleteAsync();

            if (question == null)
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}who <question>`", false);

                return;
            }

            ulong[] mentions = Context.Message.MentionedUserIds.ToArray <ulong>();

            IGuildUser answerUser;

            if (mentions.Length > 0)
            {
                Random rnd    = new Random();
                int    answer = rnd.Next(0, mentions.Length);
                answerUser = await Context.Guild.GetUserAsync(mentions[answer]);
            }
            else
            {
                var users = await Context.Guild.GetUsersAsync();

                Random rnd    = new Random();
                int    answer = rnd.Next(0, users.Count);
                answerUser = users.ToArray()[answer];
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = $"Who {await StringUtil.GetReadableMentionsAsync(Context.Guild as IGuild, question.ToLower())}",
                Description = $"The answer to that would be {answerUser.Username}.",
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#16
0
 static int QPYX__CreateEmojiUtil_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 0)
         {
             EmojiUtil QPYX_obj_YXQP = new EmojiUtil();
             ToLua.PushObject(L_YXQP, QPYX_obj_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to ctor method: EmojiUtil.New"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
示例#17
0
        private async Task TempBanMemberAsync(IUser user = null, int time = 60, string reason = null)
        {
            await Context.Message.DeleteAsync();

            BotConfig conf  = BotConfig.Load();
            var       gconf = conf.GetConfig(Context.Guild.Id);

            if (user == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}ban <user> <time> [reason]`", false);

                return;
            }

            if (reason == null)
            {
                reason = "Banned by " + Context.User.Username + "#" + Context.User.Discriminator + " for " + time + " minutes";
            }
            else
            {
                reason += " - Banned by " + Context.User.Username + "#" + Context.User.Discriminator + " for " + time + " minutes";
            }

            await BanMemberAsync(user, reason);

            await ModerationDatabase.AddTempBanAsync(Context.Guild.Id, user.Id, DateTime.Now.AddMinutes(time));

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = user.Username + " was temp banned",
                Description = reason,
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Edit moderation settings on the webpanel."
                }
            };

            await CreateLogAsync(gconf, embed);
        }
示例#18
0
        private async Task DiceAsync(int amount = 1)
        {
            await Context.Message.DeleteAsync();

            if (amount < 1)
            {
                amount = 1;
            }
            else if (amount > 100)
            {
                amount = 100;
            }

            Random     rnd   = new Random();
            List <int> rolls = new List <int>();
            int        total = 0;
            string     text  = "";

            for (int i = 0; i < amount; i++)
            {
                int roll = rnd.Next(1, 7);
                rolls.Add(roll);
                total += roll;
                text  += $"**{roll}**, ";
            }
            text = text.Substring(0, text.Length - 2);

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Dice Roll",
                Description = $"You rolled **{amount}** dice for **{total}**! Dice: [{text}]",
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#19
0
        public async Task OldestAsync()
        {
            await Context.Message.DeleteAsync();

            IUser oldest = null;

            foreach (var user in await Context.Guild.GetUsersAsync())
            {
                if (!user.IsBot)
                {
                    if (oldest == null)
                    {
                        oldest = user;
                    }
                    else if (oldest.CreatedAt.Date > user.CreatedAt.Date)
                    {
                        oldest = user;
                    }
                }
            }

            if (oldest != null)
            {
                EmbedBuilder embed = new EmbedBuilder()
                {
                };
                embed.WithAuthor(new EmbedAuthorBuilder()
                {
                    Name = oldest.Username + "#" + oldest.Discriminator, IconUrl = oldest.GetAvatarUrl()
                });
                embed.WithDescription($"The oldest account in the server, first registered {oldest.CreatedAt.Date}!");
                embed.WithColor(Color.DarkPurple);
                embed.Footer = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                };
                await Context.Channel.SendMessageAsync(null, false, embed.Build());
            }
        }
示例#20
0
        private async Task KickMemberAsync(IUser user = null, string reason = null)
        {
            await Context.Message.DeleteAsync();

            BotConfig conf  = BotConfig.Load();
            var       gconf = conf.GetConfig(Context.Guild.Id);

            if (user == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}kick <user> <reason>`", false);

                return;
            }

            if (reason == null)
            {
                reason = "Kicked by " + Context.User.Username + "#" + Context.User.Discriminator;
            }
            else
            {
                reason += " - Kicked by " + Context.User.Username + "#" + Context.User.Discriminator;
            }

            await KickMemberAsync(user, reason);

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = user.Username + " was kicked",
                Description = reason,
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Edit moderation settings on the webpanel."
                }
            };

            await CreateLogAsync(gconf, embed);
        }
示例#21
0
        private async Task AvatarAsync(IUser user = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                user = (Context.User as IUser);
            }
            string avatar = user.GetAvatarUrl(size: 2048);

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title    = $"{user.Username}#{user.Discriminator}",
                Color    = Color.DarkPurple,
                ImageUrl = avatar,
                Footer   = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                },
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#22
0
        private async Task EpicRatingAsync(IUser user = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                user = Context.User as IUser;
            }

            Random rnd    = new Random();
            float  rating = (float)(rnd.Next(0, 100) + rnd.NextDouble());

            if (user.IsBot && user.Id != 729696788097007717L)
            {
                rating = (float)(rnd.Next(0, 20) + rnd.NextDouble());
            }
            else if (user.IsBot && user.Id == 729696788097007717L)
            {
                rating = (float)(rnd.Next(80, 20) + rnd.NextDouble());
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Author = new EmbedAuthorBuilder()
                {
                    IconUrl = user.GetAvatarUrl(), Name = user.Username
                },
                Description = $"You are {rating}% EPIC!",
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}"
                }
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#23
0
        private async Task ShipAsync(IUser user = null, IUser user1 = null)
        {
            await Context.Message.DeleteAsync();

            if (user == null)
            {
                BotConfig conf  = BotConfig.Load();
                var       gconf = conf.GetConfig(Context.Guild.Id);
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}ship <user>` or `{gconf.Prefix}ship <user1> <user2>`", false);

                return;
            }
            if (user1 == null)
            {
                user1 = (Context.User as IUser);
            }

            string name1      = StringUtil.ToUppercaseFirst(user.Username);
            string name2      = StringUtil.ToUppercaseFirst(user1.Username);
            string title      = "";
            string message    = "";
            int    score      = 0;
            string name       = "";
            string desc       = "";
            float  percentage = 0f;

            // Check if entry exists in database
            var ship = RelationshipDatabase.DoesExist(user.Id, user1.Id);

            if (ship != null)
            {
                score      = ship.Percentage;
                name       = ship.Shipname;
                desc       = ship.ToDescriptiveString();
                percentage = ship.ToActualPercentage();
            }
            else
            {
                Random rnd = new Random();
                score = rnd.Next(10, 10000);
                name  = $"{name1[0].ToString().ToUpper()}{name1[1]}{name2[name2.Length - 3]}{name2[name2.Length - 2]}{name2[name2.Length - 1]}";

                ship = new LoriShip(user.Id, user1.Id, name1, name2, name, score);
                RelationshipDatabase.SaveShip(ship);
            }

            if (percentage > 95f)
            {
                title   = $"{name1} 💘 {name2}";
                message = desc;
            }
            else if (percentage > 55f)
            {
                title   = $"{name1} ❤️ {name2}";
                message = desc;
            }
            else
            {
                title   = $"{name1} 💔 {name2}";
                message = desc;
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Color       = Color.DarkPurple,
                Title       = title,
                Description = message,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Requested by {Context.User.Username}#{Context.User.Discriminator}."
                },
            };
            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#24
0
    public static EmojiText ReplaceComponentText(UnityEngine.UI.Text text, string showText)
    {
        if (text != null)
        {
            GameObject textRoot = text.gameObject;
            // Font font = text.font;
            // int fontSize = text.fontSize;
            // FontStyle fontStyle = text.fontStyle;
            // bool alignByGeometry = text.alignByGeometry;
            // TextAnchor alignment = text.alignment;
            // HorizontalWrapMode horizontalOverflow = text.horizontalOverflow;
            // VerticalWrapMode verticalOverflow = text.verticalOverflow;
            // Color color = text.color;

            // //处理GradientColor
            // UiEffect.GradientColor gradientColor = textRoot.GetComponent<UiEffect.GradientColor>();
            // bool withGradientColor = false;
            // UiEffect.GradientColor.DIRECTION direction = UiEffect.GradientColor.DIRECTION.Both;
            // Color colorBottom = Color.white;
            // Color colorTop = Color.white;
            // Color colorLeft = Color.white;
            // Color colorRight = Color.white;
            // if (gradientColor != null)
            // {
            //     withGradientColor = true;
            //     direction = gradientColor.direction;
            //     colorTop = gradientColor.colorTop;
            //     colorBottom = gradientColor.colorBottom;
            //     colorLeft = gradientColor.colorLeft;
            //     colorRight = gradientColor.colorRight;
            // }
            // Component.Destroy(gradientColor);
            Component.DestroyImmediate(text);
            EmojiText emojiText = textRoot.AddUniqueComponent <EmojiText>();
            EmojiUtil.CopyTextValueToEmojiText(text, emojiText);

            // eText.font = font;
            // eText.fontSize = fontSize;
            // eText.fontStyle = fontStyle;
            // eText.alignByGeometry = alignByGeometry;
            // eText.alignment = alignment;
            // eText.horizontalOverflow = horizontalOverflow;
            // eText.verticalOverflow = verticalOverflow;
            // eText.color = color;
            // eText.material = EmojiMaterial;
            // eText.text = showText;
            // eText.raycastTarget = text.raycastTarget;
            // eText.resizeTextForBestFit = text.resizeTextForBestFit;
            // eText.resizeTextMinSize = text.resizeTextMinSize;
            // eText.resizeTextMaxSize = text.resizeTextMaxSize;

            //eText.material.shader = Shader.Find(eText.material.shader.name);
            //处理GradientColor
            UiEffect.GradientColor gradientColor = textRoot.GetComponent <UiEffect.GradientColor>();
            if (gradientColor != null)
            {
                gradientColor.Refresh();
            }

            // if(withGradientColor)
            // {
            //     UiEffect.GradientColor newGradientColor = textRoot.AddComponent<UiEffect.GradientColor>();
            //     newGradientColor.direction = direction;
            //     newGradientColor.colorBottom = colorBottom;
            //     newGradientColor.colorTop = colorTop;
            //     newGradientColor.colorLeft = colorLeft;
            //     newGradientColor.colorRight = colorRight;
            // }
            return(emojiText);
        }
        return(null);
    }
示例#25
0
        private async Task ViewProfileAsync(ICommandContext Context, IUser User)
        {
            if (User.IsBot)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Profile Not Found", $"You can not use this command on bots!", false);

                return;
            }

            while (!ProfileDatabase.Ready())
            {
                await Task.Delay(50);
            }

            LoriUser profile = ProfileDatabase.GetUser(User.Id);

            if (profile == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Profile Not Found", $"That users profile could not be found?", false);

                return;
            }

            string avatar = User.GetAvatarUrl(size: 2048);
            string status = "**" + User.Status.ToString() + " for ";

            Color color;

            switch (User.Status)
            {
            case UserStatus.Offline:
                color = Color.LightGrey;
                break;

            case UserStatus.Online:
                color = Color.Green;
                break;

            case UserStatus.Idle:
                color = Color.Orange;
                break;

            case UserStatus.AFK:
                color = Color.Orange;
                break;

            case UserStatus.DoNotDisturb:
                color = Color.Red;
                break;

            case UserStatus.Invisible:
                color = Color.LightGrey;
                break;

            default:
                color = Color.LightGrey;
                break;
            }

            DateTime now     = DateTime.Now;
            int      seconds = (int)((now - profile.LastSeen).TotalSeconds);
            int      minutes = (int)((now - profile.LastSeen).TotalMinutes);
            int      hours   = (int)((now - profile.LastSeen).TotalHours);
            int      days    = (int)((now - profile.LastSeen).TotalDays);

            if (days > 0)
            {
                status += $"{days} Days and {hours - (days * 24)} Hours**";
            }
            else if (hours > 0)
            {
                status += $"{hours} Hours and {minutes - (hours * 60)} Minutes**";
            }
            else if (minutes > 0)
            {
                status += $"{minutes} Minutes and {seconds - (minutes * 60)} Seconds**";
            }
            else
            {
                status += $"{seconds} Seconds**";
            }

            if (User.Status == UserStatus.Offline || User.Status == UserStatus.Invisible)
            {
                status += $"\n _{profile.Activity}_";
            }
            else
            {
                status += $"\n {profile.Activity}";
            }

            if (profile.Motto.Length > 0)
            {
                status += $"\n**Motto:** {profile.Motto}";
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Author = new EmbedAuthorBuilder()
                {
                    IconUrl = avatar, Name = $"{User.Username}#{User.Discriminator}"
                },
                Description = status,
                Color       = color,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  This is a temporary look for profiles..."
                },
            };

            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Account Created On: ", Value = profile.CreatedOn.ToShortDateString(), IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Profile Created On: ", Value = profile.JoinedOn.ToShortDateString(), IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Last Updated On: ", Value = profile.LastUpdated.ToShortDateString(), IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Unique Identifier: ", Value = profile.Id, IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Username: "******"#" + User.Discriminator, IsInline = true
            });
            embed.AddField(new EmbedFieldBuilder()
            {
                Name = "Lori's Angel Guilds: ", Value = LCommandHandler.GetUserGuildCount(User.Id), IsInline = true
            });

            ProfileRenderer renderer = new ProfileRenderer(User.Id, profile);

            renderer.Render();
            await Context.Channel.SendFileAsync(renderer.GetPath());

            renderer.Dispose();

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#26
0
        // TODO: UPDATE TO USE NEW USAGE PARAMS
        public static async Task HelpAsync(ICommandContext Context, string section = "")
        {
            await Context.Message.DeleteAsync();

            BotConfig conf = BotConfig.Load();

            string CommandHelpText            = "";
            List <CommandCategory> Categories = new List <CommandCategory>();
            bool   hasNewCommands             = false;
            bool   isSpecificCommand          = false;
            string CategoryText = "";
            string Prefix       = CommandHandler.GetPrefix(Context.Guild.Id);

            foreach (BotCommand command in conf.Commands)
            {
                if (command.Category.ToString().ToLower() == section.ToLower() || (section.ToLower() == "new" && command.New))
                {
                    if (CommandHelpText.Length > 0)
                    {
                        CommandHelpText = CommandHelpText + ", " + StringUtil.ToUppercaseFirst(command.Name);
                    }
                    else
                    {
                        CommandHelpText = StringUtil.ToUppercaseFirst(command.Name);
                    }
                }

                if (command.Name.ToLower() == section.ToLower())
                {
                    string help = $"**{command.Name.ToUpper()}**\nUsage:\n{command.Usage}\n{command.Description}";
                    if (command.New)
                    {
                        help = $"**NEW** - {help}";
                    }
                    if (command.ExtraInfo != "")
                    {
                        help = $"{help}\nFeature requested by: {command.ExtraInfo}";
                    }

                    CommandHelpText   = CommandHelpText + "\n\n" + help;
                    isSpecificCommand = true;
                }

                if (!Categories.Contains(command.Category))
                {
                    Categories.Add(command.Category);
                    CategoryText = $"{CategoryText}, {StringUtil.ToUppercaseFirst(command.Category.ToString())}";
                }
                if (command.New)
                {
                    hasNewCommands = true;
                }
            }
            CategoryText = CategoryText.Split(",", 2)[1];
            if (hasNewCommands)
            {
                CategoryText = $"{CategoryText}, New";
            }

            if (CommandHelpText.Length <= 0)
            {
                CommandHelpText = $"Command Usage: {Prefix}help <category>\n\nCategories:\n{CategoryText}\n\nKnown Errors:\nerror 50007 - Users privacy settings prevent dm's\nerror 403 - Bot does not have required permissions\nOther errors are tracked by the bot, and will be looked into.";
            }
            else if (!isSpecificCommand)
            {
                CommandHelpText = $"Command Usage: {Prefix}help <command>\n\n{StringUtil.ToUppercaseFirst(section)} Commands:\n{CommandHelpText}";
            }

            EmbedBuilder embed = new EmbedBuilder()
            {
                Title       = "Bot Command Help",
                Description = CommandHelpText,
                Color       = Color.DarkPurple,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = $"{EmojiUtil.GetRandomEmoji()}  Bot Prefix: {Prefix}"
                }
            };

            await Context.Channel.SendMessageAsync(null, false, embed.Build());
        }
示例#27
0
    protected override void OnPopulateMesh(VertexHelper toFill)
    {
        if (font == null)
        {
            return;
        }
        if (EmojiIndex == null)
        {
            EmojiIndex = EmojiUtil.EmojiIndex;
        }
        if (EmojiIndex == null || EmojiIndex.Count == 0)
        {
            base.OnPopulateMesh(toFill);
            return;
        }
        Dictionary <int, EmojiInfo> emojiDic = new Dictionary <int, EmojiInfo> ();
        string resultText = string.Empty;

        if (supportRichText)
        {
            List <EmojiElement> emojiList = EmojiUtil.getEmojiList(text, out resultText);
            //Debug.Log("resultText:"+ resultText+",len:"+ resultText.Length);
            //Debug.Log("emojiList:"+ emojiList.Count);
            for (int i = 0, length = emojiList.Count; i < length; i++)
            {
                EmojiElement element = emojiList[i];
                if (element.isEmoji)
                {
                    EmojiInfo info;
                    string    unicodeValue = element.unicode;
                    //Debug.Log("unicodeValue:" + unicodeValue + ",i:" + i);
                    if (EmojiIndex.TryGetValue(unicodeValue, out info))
                    {
                        //Debug.Log("1 unicodeValue:" + unicodeValue);
                        info.len = 1;
                        emojiDic.Add(i, info);
                    }
                }
            }
        }

        // We don't care if we the font Texture changes while we are doing our Update.
        // The end result of cachedTextGenerator will be valid for this instance.
        // Otherwise we can get issues like Case 619238.
        m_DisableFontTextureRebuiltCallback = true;

        Vector2 extents = rectTransform.rect.size;

        var settings = GetGenerationSettings(extents);

        if (supportRichText && !string.IsNullOrEmpty(resultText))
        {
            cachedTextGenerator.Populate(resultText, settings);
        }
        else
        {
            cachedTextGenerator.Populate(text, settings);
        }

        Rect inputRect = rectTransform.rect;

        // get the text alignment anchor point for the text in local space
        Vector2 textAnchorPivot = GetTextAnchorPivot(alignment);
        Vector2 refPoint        = Vector2.zero;

        refPoint.x = Mathf.Lerp(inputRect.xMin, inputRect.xMax, textAnchorPivot.x);
        refPoint.y = Mathf.Lerp(inputRect.yMin, inputRect.yMax, textAnchorPivot.y);

        // Determine fraction of pixel to offset text mesh.
        Vector2 roundingOffset = PixelAdjustPoint(refPoint) - refPoint;

        // Apply the offset to the vertices
        IList <UIVertex> verts         = cachedTextGenerator.verts;
        float            unitsPerPixel = 1 / pixelsPerUnit;
        //Last 4 verts are always a new line...
        int vertCount = verts.Count - 4;

        //Debug.Log("verts:" + verts.Count);
        toFill.Clear();
        if (roundingOffset != Vector2.zero)
        {
            for (int i = 0; i < vertCount; ++i)
            {
                int tempVertsIndex = i & 3;
                m_TempVerts[tempVertsIndex]             = verts[i];
                m_TempVerts[tempVertsIndex].position   *= unitsPerPixel;
                m_TempVerts[tempVertsIndex].position.x += roundingOffset.x;
                m_TempVerts[tempVertsIndex].position.y += roundingOffset.y;
                if (tempVertsIndex == 3)
                {
                    toFill.AddUIVertexQuad(m_TempVerts);
                }
            }
        }
        else
        {
            float repairDistance     = 0;
            float repairDistanceHalf = 0;
            float repairY            = 0;
            if (vertCount > 0)
            {
                repairY = verts [3].position.y;
            }
            for (int i = 0; i < vertCount; ++i)
            {
                EmojiInfo info;
                int       index = i / 4;
                if (emojiDic.TryGetValue(index, out info))
                {
                    //compute the distance of '[' and get the distance of emoji
                    float charDis = (verts [i + 1].position.x - verts [i].position.x) * 3;
                    m_TempVerts [3] = verts [i];                    //1
                    m_TempVerts [2] = verts [i + 1];                //2
                    m_TempVerts [1] = verts [i + 2];                //3
                    m_TempVerts [0] = verts [i + 3];                //4

                    //the real distance of an emoji
                    m_TempVerts [2].position += new Vector3(charDis, 0, 0);
                    m_TempVerts [1].position += new Vector3(charDis, 0, 0);

                    //make emoji has equal width and height
                    float fixValue = (m_TempVerts [2].position.x - m_TempVerts [3].position.x - (m_TempVerts [2].position.y - m_TempVerts [1].position.y));
                    m_TempVerts [2].position -= new Vector3(fixValue, 0, 0);
                    m_TempVerts [1].position -= new Vector3(fixValue, 0, 0);

                    float curRepairDis = 0;
                    if (verts [i].position.y < repairY)                      // to judge current char in the same line or not
                    {
                        repairDistance     = repairDistanceHalf;
                        repairDistanceHalf = 0;
                        repairY            = verts [i + 3].position.y;
                    }
                    curRepairDis = repairDistance;
                    int dot = 0;                    //repair next line distance
                    for (int j = info.len - 1; j > 0; j--)
                    {
                        if (verts [i + j * 4 + 3].position.y >= verts [i + 3].position.y)
                        {
                            repairDistance += verts [i + j * 4 + 1].position.x - m_TempVerts [2].position.x;
                            break;
                        }
                        else
                        {
                            dot = i + 4 * j;
                        }
                    }
                    if (dot > 0)
                    {
                        int nextChar = i + info.len * 4;
                        if (nextChar < verts.Count)
                        {
                            repairDistanceHalf = verts [nextChar].position.x - verts [dot].position.x;
                        }
                    }

                    //repair its distance
                    for (int j = 0; j < 4; j++)
                    {
                        m_TempVerts [j].position -= new Vector3(curRepairDis, 0, 0);
                    }

                    m_TempVerts [0].position *= unitsPerPixel;
                    m_TempVerts [1].position *= unitsPerPixel;
                    m_TempVerts [2].position *= unitsPerPixel;
                    m_TempVerts [3].position *= unitsPerPixel;

                    float pixelOffset = emojiDic [index].size / 32 / 2;
                    m_TempVerts [0].uv1 = new Vector2(emojiDic [index].x + pixelOffset, emojiDic [index].y + pixelOffset);
                    m_TempVerts [1].uv1 = new Vector2(emojiDic [index].x - pixelOffset + emojiDic [index].size, emojiDic [index].y + pixelOffset);
                    m_TempVerts [2].uv1 = new Vector2(emojiDic [index].x - pixelOffset + emojiDic [index].size, emojiDic [index].y - pixelOffset + emojiDic [index].size);
                    m_TempVerts [3].uv1 = new Vector2(emojiDic [index].x + pixelOffset, emojiDic [index].y - pixelOffset + emojiDic [index].size);

                    toFill.AddUIVertexQuad(m_TempVerts);

                    i += 4 * info.len - 1;
                }
                else
                {
                    int tempVertsIndex = i & 3;
                    if (tempVertsIndex == 0 && verts [i].position.y < repairY)
                    {
                        repairY            = verts [i + 3].position.y;
                        repairDistance     = repairDistanceHalf;
                        repairDistanceHalf = 0;
                    }
                    m_TempVerts [tempVertsIndex]           = verts [i];
                    m_TempVerts [tempVertsIndex].position -= new Vector3(repairDistance, 0, 0);
                    m_TempVerts [tempVertsIndex].position *= unitsPerPixel;
                    if (tempVertsIndex == 3)
                    {
                        toFill.AddUIVertexQuad(m_TempVerts);
                    }
                }
            }
        }
        m_DisableFontTextureRebuiltCallback = false;
    }
示例#28
0
        /***
         *  Remove any bans that have timed out
         */
        public static async Task ProcessBansAsync()
        {
            var processBans = Task.Run(async() =>
            {
                while (true)
                {
                    var dbCon          = DBConnection.Instance();
                    dbCon.DatabaseName = LCommandHandler.DATABASE_NAME;
                    BotConfig conf     = BotConfig.Load();

                    if (dbCon.IsConnect())
                    {
                        var cmd    = new MySqlCommand($"SELECT * FROM tempbans", dbCon.Connection);
                        var reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                DateTime bannedTill = reader.GetDateTime(2);
                                if (bannedTill < DateTime.Now)
                                {
                                    ulong guildid = reader.GetUInt64(0);
                                    ulong userid  = reader.GetUInt64(1);

                                    var guild = CommandHandler.GetBot().GetGuild(guildid);

                                    if (guild != null)
                                    {
                                        var gconf = conf.GetConfig(guild.Id);
                                        if (gconf.LogActions)
                                        {
                                            var logs = guild.GetTextChannel(gconf.LogChannel);
                                            if (logs != null)
                                            {
                                                EmbedBuilder embed = new EmbedBuilder()
                                                {
                                                    Title       = "User Unbanned",
                                                    Description = $"A users temp ban was removed. Check audit log for more info.",
                                                    Color       = Color.DarkPurple,
                                                    Footer      = new EmbedFooterBuilder()
                                                    {
                                                        Text = $"{EmojiUtil.GetRandomEmoji()}  Edit moderation settings on the webpanel."
                                                    }
                                                };
                                                await logs.SendMessageAsync(null, false, embed.Build());
                                            }
                                        }

                                        await guild.RemoveBanAsync(userid);
                                    }

                                    var removecmd = new MySqlCommand($"REMOVE FROM tempbans WHERE userid = '{userid}'", dbCon.Connection);
                                    try
                                    {
                                        await removecmd.ExecuteNonQueryAsync();
                                        removecmd.Dispose();
                                    }
                                    catch (Exception e)
                                    {
                                        Console.WriteLine($"Failed to remove temp ban: {e.Message}");
                                        removecmd.Dispose();
                                    }
                                }
                            }
                        }

                        reader.Close();
                        cmd.Dispose();
                        dbCon.Close();
                    }

                    await Task.Delay(60000);
                }
            });
        }
示例#29
0
        public static EmbedBuilder GetCommandHelp(ulong guildId, string c = null, int page = 1)
        {
            BotConfig         conf     = BotConfig.Load();
            IndividualConfig  gconf    = conf.GetConfig(guildId);
            List <BotCommand> commands = conf.Commands;
            int pages;

            CommandCategory category = CommandCategory.Main;

            if (c != null)
            {
                c = c.ToLower().Trim();

                switch (c)
                {
                case "fun":
                    category = CommandCategory.Fun;
                    break;

                case "user":
                    category = CommandCategory.User;
                    break;

                case "server":
                    category = CommandCategory.Server;
                    break;

                case "botrelated":
                    category = CommandCategory.BotRelated;
                    break;

                case "moderation":
                    category = CommandCategory.Moderation;
                    break;

                case "games":
                    category = CommandCategory.Games;
                    break;

                case "nsfw":
                    category = CommandCategory.NSFW;
                    break;

                case "currency":
                    category = CommandCategory.Currency;
                    break;

                default:
                    category = CommandCategory.Main;
                    break;
                }
            }


            List <CommandCategory> cats           = new List <CommandCategory>();
            List <BotCommand>      commandsToShow = new List <BotCommand>();

            bool       displayCommandInfo = false;
            BotCommand commandToDisplay   = null;

            foreach (BotCommand command in commands)
            {
                if (c != null)
                {
                    if (command.Handle.ToLower() == c.ToLower().Trim())
                    {
                        commandToDisplay   = command;
                        displayCommandInfo = true;
                        break;
                    }
                }

                if (category == CommandCategory.Main)
                {
                    if (!cats.Contains(command.Category))
                    {
                        cats.Add(command.Category);
                    }
                }
                if (command.Category == category)
                {
                    if (!commandsToShow.Contains(command))
                    {
                        commandsToShow.Add(command);
                    }
                }
            }

            EmbedBuilder embed;

            if (!displayCommandInfo)
            {
                if (category == CommandCategory.Main)
                {
                    pages = (cats.Count / 10);
                }
                else
                {
                    pages = (commandsToShow.Count / 8);
                }

                if (page > pages)
                {
                    page = pages;
                }

                embed = new EmbedBuilder()
                {
                    Title  = "Help: " + StringUtil.ToUppercaseFirst(category.ToString()),
                    Color  = Color.DarkPurple,
                    Footer = new EmbedFooterBuilder()
                    {
                        Text = $"{EmojiUtil.GetRandomEmoji()}  Server Prefix: {gconf.Prefix}"
                    }
                };

                if (category == CommandCategory.Main)
                {
                    embed.Description = $"For further help use `{gconf.Prefix}help <commandCategory>`, for example `{gconf.Prefix}help fun`";

                    foreach (var cat in cats)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = StringUtil.ToUppercaseFirst(cat.ToString()), Value = "category description", IsInline = true
                        });
                    }
                }
                else
                {
                    embed.Description = $"For further help use `{gconf.Prefix}help <commandName>`, for example `{gconf.Prefix}help roast`";

                    foreach (var command in commandsToShow)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = StringUtil.ToUppercaseFirst(command.Handle), Value = command.Description, IsInline = true
                        });
                    }
                }
            }
            else
            {
                embed = new EmbedBuilder()
                {
                    Title  = "Help: " + StringUtil.ToUppercaseFirst(commandToDisplay.Handle),
                    Color  = Color.DarkPurple,
                    Footer = new EmbedFooterBuilder()
                    {
                        Text = $"{EmojiUtil.GetRandomEmoji()}  <> - Required argument, [] - Optional argument"
                    }
                };

                string desc = $"{commandToDisplay.Description}\n\n**Usage:**";

                foreach (var usage in commandToDisplay.Usage)
                {
                    desc += $"\n**{gconf.Prefix}{usage.ToString()}** (eg. {gconf.Prefix}{usage.ToExample()})";
                }

                embed.Description = desc;
            }

            return(embed);
        }