Esempio n. 1
0
        public async Task Team([Remainder] string teamName = "")
        {
            var role = await this.SelectRole(teamName, TeamDb.Teams(Context.Guild.Id).Select(x => x.MemberRoleId));

            if (role == null)
            {
                await Context.Channel.SendMessageAsync($"`{teamName}` is not a role.");

                return;
            }

            var team = TeamDb.TeamByMember(role.Id);

            if (team == null)
            {
                team = TeamDb.TeamByLeader(role.Id);
            }

            if (team == null)
            {
                await Context.Channel.SendMessageAsync($"`{role.Name}` is not a team. Create a team using `!newteam`");

                return;
            }

            var teamRole   = Context.Guild.GetRole(team.MemberRoleId);
            var leaderRole = Context.Guild.GetRole(team.LeaderRoleId);

            var eb = RoleUtil.TeamEmbed(teamRole, leaderRole);
            await Context.Channel.SendMessageAsync("", false, eb.Build());
        }
Esempio n. 2
0
        public async Task DeleteTeam([Remainder] string teamName = "")
        {
            var role = await this.SelectRole(teamName);

            if (role == null)
            {
                await Context.Channel.SendMessageAsync($"`{teamName}` is not a role.");

                return;
            }

            var team = TeamDb.TeamByMember(role.Id);

            if (team == null)
            {
                team = TeamDb.TeamByLeader(role.Id);
            }

            if (team == null)
            {
                await Context.Channel.SendMessageAsync($"`{role.Name}` is not a team. Create a team using `!newteam`");

                return;
            }

            await TeamDb.DeleteTeam(team);

            await Context.Channel.SendMessageAsync($"Deleted team {role.Name}. The weak fall, big deal.");
        }
Esempio n. 3
0
        public async Task TeamKick(IUser user, [Remainder] string str = "")
        {
            var leader = RoleUtil.GetLeaderRole(Context.Guild, Context.User);

            if (leader == null)
            {
                await Context.Channel.SendMessageAsync("You're not a leader! Getting ahead of yourself eh?~");

                return;
            }

            var team       = TeamDb.TeamByLeader(leader.Id);
            var userteam   = RoleUtil.GetMemberRole(Context.Guild, user);
            var leaderteam = Context.Guild.GetRole(team.MemberRoleId);

            if (!userteam.Equals(leaderteam))
            {
                await Context.Channel.SendMessageAsync($"They're not in your team! If you just want to kick them normaly use `{Program.GetPrefix(Context)}kick`");

                return;
            }

            await Context.Guild.GetUser(user.Id).RemoveRoleAsync(userteam);

            await Context.Channel.SendMessageAsync("Ha! One less to take care of!");

            ISocketMessageChannel ch = (ISocketMessageChannel)Context.Client.GetChannel(ServerDb.GetServer(Context.Guild.Id).TeamLogChannelId);
            await ch.SendMessageAsync($":hammer: `{Context.User}` kicked `{user}` from **{userteam.Name}**.");
        }
Esempio n. 4
0
        public async Task Join([Remainder] string teamName)
        {
            var role = await this.SelectRole(teamName, TeamDb.Teams(Context.Guild.Id).Select(x => x.MemberRoleId), respond : false);

            if (role == null)
            {
                await Context.Channel.SendMessageAsync($"*~ No teams found ~*");

                return;
            }

            if (InviteDb.IsInvited(role.Id, Context.User.Id))
            {
                var user = Context.Guild.GetUser(Context.User.Id);
                try
                {
                    await user.AddRoleAsync(role);
                } catch
                {
                    await Context.Channel.SendMessageAsync($"I tried giving a role that is above my own role. *Coughs blood.* Discord wouldn't let me...");

                    return;
                }
                await InviteDb.DeleteInvite(role.Id, user.Id);

                await Context.Channel.SendMessageAsync($"Congratulations! You joined **{role.Name}**!");

                ISocketMessageChannel ch = (ISocketMessageChannel)Context.Client.GetChannel(ServerDb.GetServer(Context.Guild.Id).TeamLogChannelId);
                await ch.SendMessageAsync($"<:TickYes:577838859107303424> `{Context.User}` joined **{role.Name}**.");

                return;
            }
            await Context.Channel.SendMessageAsync($"You're not invited to **{role.Name}**! What a shame ^^");
        }
Esempio n. 5
0
        public static SocketRole GetMemberRole(SocketGuild guild, IUser user)
        {
            var teams = TeamDb.Teams(guild.Id);

            foreach (Team x in teams)
            {
                var role = guild.GetRole(x.MemberRoleId);
                if (HasRole((SocketGuildUser)user, role))
                {
                    return(role);
                }
            }

            return(null);
        }
Esempio n. 6
0
        public static async Task <EmbedBuilder> TeamListEmbed(List <Team> teams, SocketGuild guild)
        {
            var eb = new EmbedBuilder();

            eb.WithColor(BasicUtil.RandomColor());

            string teamstr   = "";
            string leaderstr = "";
            int    count     = 1;

            foreach (var x in teams)
            {
                var teamRole   = guild.GetRole(x.MemberRoleId);
                var leaderRole = guild.GetRole(x.LeaderRoleId);

                if (teamRole != null && leaderRole != null)
                {
                    teamstr   += $"\n`#{count}` {teamRole.Mention}";
                    leaderstr += $"\n`#{count}` {leaderRole.Mention}";
                    count++;
                }
                else
                {
                    await TeamDb.DeleteTeam(x);
                }
            }

            try {
                eb.AddField("Teams :shield:", teamstr, true);
                eb.AddField("Leaders :crown:", leaderstr, true);
                eb.WithColor(Color.DarkRed);
            } catch
            {
                eb.WithDescription("*~ There are no teams ~*");
            }
            eb.WithTitle("Teams :european_castle:");
            return(eb);
        }
Esempio n. 7
0
        public async Task NewTeam(string leader, string member)
        {
            var leaderR = await this.SelectRole(leader, msg : "Select team leader role");

            var memberR = await this.SelectRole(member, msg : "Select team member role");

            if (leaderR == null)
            {
                await Context.Channel.SendMessageAsync($"Leader role {leader} not found.");

                return;
            }
            if (memberR == null)
            {
                await Context.Channel.SendMessageAsync($"Member role {member} not found.");

                return;
            }

            await TeamDb.AddTeam(leaderR.Id, memberR.Id, Context.Guild.Id);

            await Context.Channel.SendMessageAsync($"Added Leader role: '{leaderR.Name}' and Team role: '{memberR.Name}'");
        }
Esempio n. 8
0
        public async Task Invite([Remainder] IUser user = null)
        {
            var channel    = Context.Channel;
            var leaderRole = RoleUtil.GetLeaderRole(Context.Guild, Context.User);

            if (leaderRole == null)
            {
                await channel.SendMessageAsync("You're not a team leader, silly.");

                return;
            }

            if (RoleUtil.IsTeamed(Context.Guild, user))
            {
                await channel.SendMessageAsync($@"**{user.Username}** is already in a team, I guess you're too late ¯\_(ツ)_/¯");

                return;
            }

            var team     = TeamDb.TeamByLeader(leaderRole.Id);
            var teamRole = Context.Guild.GetRole(team.MemberRoleId);

            if (InviteDb.IsInvited(team.MemberRoleId, user.Id))
            {
                await channel.SendMessageAsync($"You already invited **{user.Username}**, baaaaaka.");

                return;
            }

            await InviteDb.NewInvite(team.MemberRoleId, user.Id);

            await channel.SendMessageAsync($"{user.Mention} You're invited to join **{teamRole.Name}**! Type `{Program.GetPrefix(Context)}jointeam {teamRole.Name}`");

            ISocketMessageChannel ch = (ISocketMessageChannel)Context.Client.GetChannel(ServerDb.GetServer(Context.Guild.Id).TeamLogChannelId);
            await ch.SendMessageAsync($"<:KannaHype:571690048001671238> `{Context.User}` invited `{user}` to **{teamRole.Name}**.");
        }
Esempio n. 9
0
        public async Task TeamList([Remainder] string str = "")
        {
            var eb = await RoleUtil.TeamListEmbed(TeamDb.Teams(Context.Guild.Id), Context.Guild);

            await Context.Channel.SendMessageAsync("", false, eb.Build());
        }
Esempio n. 10
0
        // Embeds
        //Embed Method: profile
        public static async Task <EmbedBuilder> ProfileEmbed(SocketGuildUser user)
        {
            var eb = new EmbedBuilder();

            string name = user.Username;

            var role = RoleUtil.GetMemberRole(user.Guild, user) ?? RoleUtil.GetLeaderRole(user.Guild, user);

            if (role != null)
            {
                var team = TeamDb.TeamByMember(role.Id) ?? TeamDb.TeamByLeader(role.Id);
                if (team != null)
                {
                    role = user.Roles.FirstOrDefault(x => x.Id == team.LeaderRoleId);
                    if (role == null)
                    {
                        role = user.Roles.FirstOrDefault(x => x.Id == team.MemberRoleId);
                    }

                    name += $" | {role.Name}";
                }
            }

            if (PremiumDb.IsPremium(user.Id, ProType.ProPlus))
            {
                name += " | Pro+ 🌟";
            }
            else if (PremiumDb.IsPremium(user.Id, ProType.Pro))
            {
                name += " | Pro ⭐";
            }
            eb.WithAuthor(name, user.GetAvatarUrl(), $"https://namiko.moe/Guild/{user.Guild.Id}/{user.Id}");

            var waifus     = UserInventoryDb.GetWaifus(user.Id, user.Guild.Id);
            int waifucount = waifus.Count();
            int waifuprice = WaifuUtil.WaifuValue(waifus);

            var  daily   = DailyDb.GetDaily(user.Id, user.Guild.Id);
            long timeNow = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            string text = "";

            text += $"Amount: {BalanceDb.GetToasties(user.Id, user.Guild.Id).ToString("n0")}\n" +
                    $"Daily: {(daily == null ? "0" : ((daily.Date + 172800000) < timeNow ? "0" : daily.Streak.ToString()))}\n" +
                    $"Boxes Opened: {ProfileDb.GetLootboxOpenedAmount(user.Id)}\n";
            eb.AddField("Toasties <:toastie3:454441133876183060>", text, true);

            text = $"Amount: {waifucount}\n" +
                   $"Value: {waifuprice.ToString("n0")}\n";
            foreach (var x in MarriageDb.GetMarriages(user.Id, user.Guild.Id))
            {
                try
                {
                    if (!text.Contains("Married: "))
                    {
                        text += "Married: ";
                    }
                    text += $"{BasicUtil.IdToMention(GetWifeId(x, user.Id))}\n";
                } catch { }
            }
            eb.AddField("Waifus :two_hearts:", text, true);

            var waifu = FeaturedWaifuDb.GetFeaturedWaifu(user.Id, user.Guild.Id);

            if (waifu != null)
            {
                eb.WithImageUrl(waifu.HostImageUrl);
                eb.AddField("Featured Waifu <:MiaHug:536580304018735135>", $"**{waifu.Name}** - *{waifu.Source}*");
            }

            var    rep    = ProfileDb.GetRepAmount(user.Id);
            string footer = $"Votes: {await VoteDb.VoteCount(user.Id)} • ";

            footer += $"Rep: {rep} • ";
            // Activities require guildpresence
            //footer += $"Status: '{user.Status}'";
            //var activity = user.Activities.FirstOrDefault();
            //if (activity != null)
            //    footer += $", {activity.Type}: '{activity.Name}'";
            eb.WithFooter(footer);

            //quote
            string quote = ProfileDb.GetQuote(user.Id);

            if (!String.IsNullOrEmpty(quote) & !WebUtil.IsValidUrl(quote))
            {
                eb.WithDescription(quote);
            }

            //image
            string image = ProfileDb.GetImage(user.Id);

            if (WebUtil.IsValidUrl(image))
            {
                eb.WithThumbnailUrl(image);
            }

            eb.Color = ProfileDb.GetHex(out string colour, user.Id)? (Discord.Color)HexToColor(colour) : BasicUtil.RandomColor();
            return(eb);
        }