Example #1
0
        public async Task toggleLevelAlert()
        {
            try
            {
                await Task.Delay(0);

                var account = UserAccounts.GetOrCreateAccount(Context.Channel.Id);
                Task.Delay(100);
                if (account.levelingAlert == 0)
                {
                    account.levelingAlert = 1;
                    UserAccounts.SaveAccounts();
                    await Context.Channel.SendMessageAsync("Leveling Alerts has been on toggled for this channel");
                }
                else
                {
                    account.levelingAlert = 0;
                    UserAccounts.SaveAccounts();
                    await Context.Channel.SendMessageAsync("Leveling Alerts has been toggled off for this channel");
                }
            }
            catch (Exception e)
            {
                Misc.ExceptionAlert(Context, e);
            }
        }
Example #2
0
        public async Task setDef()
        {
            try
            {
                await Task.Delay(0);

                await Context.Channel.SendMessageAsync("Default Channel is now " + Context.Channel.Id + " as server " + Context.Guild.Id);

                var account = UserAccounts.GetOrCreateAccount(Context.Guild.Id);
                account.DefaultChannelID = Context.Channel.Id;
                UserAccounts.SaveAccounts();
            }
            catch (Exception e)
            {
                Misc.ExceptionAlert(Context, e);
            }
        }
Example #3
0
        public async Task eat()
        {
            if (Main.main.foodAppeared)
            {
                await Context.Message.DeleteAsync();

                var m = await Context.Channel.GetMessageAsync(Main.main.messageID);

                await m.DeleteAsync();

                Main.main.foodAppeared = false;
                int p = new Random().Next(3, 8);
                await ReplyAsync(Context.User.Mention + " has picked up the food! They gained " + p + " points!");

                var user = UserAccounts.GetOrCreateAccount(Context.User.Id);
                user.XP += (uint)p;
            }
        }
Example #4
0
        public async Task info(SocketGuildUser user = null)
        {
            if (user == null)
            {
                user = Context.User as SocketGuildUser;
            }

            var          User  = UserAccounts.GetOrCreateAccount(user.Id);
            EmbedBuilder Embed = new EmbedBuilder();

            Embed.WithTitle($"{user.Nickname} info:")
            .AddInlineField("Bot stats", $"**XP:** {User.XP}\n **Level:** {User.Lvl}")
            .WithColor(Color.Blue)
            .WithFooter($"{Context.Guild.Name}", Context.Guild.Owner.GetAvatarUrl())
            .WithCurrentTimestamp()
            .WithThumbnailUrl(user.GetAvatarUrl());
            await Context.Channel.SendMessageAsync("", false, Embed.Build());
        }
Example #5
0
        public async Task AnnounceLeave(SocketGuildUser user) //Welcomes the new user
        {
            var    account = UserAccounts.GetOrCreateAccount(user.Guild.Id);
            var    channel = _client.GetChannel(account.DefaultChannelID) as SocketTextChannel; // Gets the channel to send the message in
            var    userImg = @"https://cdn.discordapp.com/avatars/" + user.Id + @"/" + user.AvatarId + @".png".Replace(" ", "%20");
            string html    = String.Format($"<html><head> <meta charset=\"utf-8\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.0/css/bootstrap.min.css\"></head><body style=\"overflow:hidden;background-image:url(&quot;http://zanoxhosting.ga/api/discord/welcomeAssets/img/eS4IxK3.png&quot;);\"> <div style=\"display:table;position:absolute;top:0;left:0;height:100%;width:100%;\"> <div style=\"display:table-cell;vertical-align:middle;\"> <div style=\"margin-left:auto;margin-right:auto;text-align:center;\"><img src=\"{userImg}\" style=\"height:125px;width:125px;\"><div></div>\" <div style=\"color:#FFF;\"><h1 style=\"font-size:25px;\"><b>Farewell,</b></h1> <h1 style=\"font-size:15px;\"><b>{user.Username}</b></h1> </div></div></div></div><script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.0/js/bootstrap.bundle.min.js\"></script></body></html>");

            var converter = new HtmlToImageConverter {
                Width = 500, Height = 250
            };

            byte[] jpgBytes = converter.GenerateImage(html, NReco.ImageGenerator.ImageFormat.Png);
            File.WriteAllBytes($"Farewell {user.Username}.png", jpgBytes);

            await channel.SendFileAsync($"Farewell {user.Username}.png", $"Farewell, {user.Mention}");

            try
            {
                File.Delete($"Farewell {user.Username}.png");
            }
            catch { }
        }
Example #6
0
        public string getPrefix(SocketCommandContext cc)
        {
            var account = UserAccounts.GetOrCreateAccount(cc.User.Id);

            return(account.prefix);
        }