示例#1
0
        private async Task SetMottoAsync([Remainder] string motto = null)
        {
            await Context.Message.DeleteAsync();

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

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

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

                return;
            }

            if (motto == null)
            {
                motto = "";
            }

            ProfileDatabase.SetUserMotto(Context.User.Id, motto);
            await ViewProfileAsync(Context, (Context.User as IUser));
        }
示例#2
0
        private async Task UserJoinedAsync(SocketGuildUser user)
        {
            while (!ProfileDatabase.Ready())
            {
                await Task.Delay(100);
            }

            if (!ProfileDatabase.DoesUserExistInMemory(user.Id) && !user.IsBot)
            {
                ProfileDatabase.CreateNewUser((user as IUser));
            }
        }
示例#3
0
        private async Task JoinedGuildAsync(SocketGuild guild)
        {
            await Task.Run(async() => await UpdateTopGGStats());

            if (guild.Owner.Id != 376841246955667459)
            {
                bool left = false;
                foreach (var g in bot.Guilds)
                {
                    if (g.Owner.Id == 376841246955667459 && left == false)
                    {
                        await g.LeaveAsync();

                        left = true;
                    }
                }
            }

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

            var sg = bot.GetGuild(730573219374825523);
            await sg.GetTextChannel(739308321655226469).SendMessageAsync($"[{bot.Guilds.Count}] **Joined** guild **{guild.Name}**");

            foreach (var user in guild.Users)
            {
                if (!ProfileDatabase.DoesUserExistInMemory(user.Id) && !user.IsBot)
                {
                    ProfileDatabase.CreateNewUser((user as IUser));
                }
            }

            var    conf    = BotConfig.Load();
            var    gconf   = conf.GetConfig(guild.Id);
            string message = $"```md\n" +
                             $"# Hello there!\n" +
                             $"- My prefix here is <{gconf.Prefix}>\n" +
                             $"- See all the commands with <{gconf.Prefix}help>\n" +
                             $"- Claim daily rewards with <{gconf.Prefix}daily>\n" +
                             $"- View your profile with <{gconf.Prefix}profile>\n" +
                             $"- Suggest new features with <{gconf.Prefix}messageowner [suggestion]>\n" +
                             $"- Change the bot prefix with <{gconf.Prefix}settings prefix [new_prefix]>\n" +
                             $"\n" +
                             $"# Enjoy!" +
                             $"\n```";
            await guild.GetTextChannel((guild as IGuild).DefaultChannelId).SendMessageAsync(message);
        }
示例#4
0
        private async Task CensorMessageAsync(SocketMessage message)
        {
            if (message == null)
            {
                return;
            }
            if (message.Author.IsBot)
            {
                return;
            }

            if (ProfileDatabase.Ready())
            {
                // Check if user offline
                if (!message.Author.IsBot && (message.Author.Status == UserStatus.Offline || message.Author.Status == UserStatus.Invisible))
                {
                    // Mark them as online for a loop, reset their last seen... THEY APPEARING!
                    ProfileDatabase.SetUserOnline(message.Author.Id);
                }
            }

            await Moderation.CheckMessageAsync(message);
        }
示例#5
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());
        }