Exemplo n.º 1
0
        public async Task SetupIodem()
        {
            foreach (SocketGuildUser user in Context.Guild.Users)
            {
                var account = UserAccounts.GetAccount(user);

                account.Name = user.DisplayName();
                account.ServerStats.LegacyStreak = new EndlessStreak()
                {
                    Solo      = account.ServerStats.ColossoHighestRoundEndlessSolo,
                    Duo       = account.ServerStats.ColossoHighestRoundEndlessDuo,
                    DuoNames  = account.ServerStats.ColossoHighestRoundEndlessDuoNames,
                    Trio      = account.ServerStats.ColossoHighestRoundEndlessTrio,
                    TrioNames = account.ServerStats.ColossoHighestRoundEndlessTrioNames,
                    Quad      = account.ServerStats.ColossoHighestRoundEndlessQuad,
                    QuadNames = account.ServerStats.ColossoHighestRoundEndlessQuadNames
                };
            }

            foreach (SocketGuild guild in Global.Client.Guilds)
            {
                var gs = GuildSettings.GetGuildSettings(guild);
                gs.Name = guild.Name;
            }
            Console.WriteLine(Global.Client.Guilds.Sum(g => g.Emotes.Count));
            UserAccounts.SaveAccounts();
            GuildSettings.SaveGuilds();
            await Task.CompletedTask;
        }
Exemplo n.º 2
0
        private async Task Client_GuildMemberUpdated(SocketGuildUser user_before, SocketGuildUser user)
        {
            var guild = GuildSettings.GetGuildSettings(user.Guild);

            if (user_before.DisplayName() != user.DisplayName())
            {
                EntityConverter.ConvertUser(user).Name = user.DisplayName();
                _ = guild.TestCommandChannel
                    .SendMessageAsync($"{user.Mention} changed Nickname from {user_before.DisplayName()} to {user.DisplayName()}");
            }

            if (user_before.IsPending == true && user.IsPending == false)
            {
                if (GuildSettings.GetGuildSettings(user.Guild).sendWelcomeMessage)
                {
                    _ = guild.MainChannel.SendMessageAsync(embed:
                                                           new EmbedBuilder()
                                                           .WithColor(Colors.Get("Iodem"))
                                                           .WithDescription(string.Format(welcomeMsg.Random(), user.DisplayName()))
                                                           .Build());
                }
            }

            if (user_before.PremiumSince.HasValue != user.PremiumSince.HasValue)
            {
                var isBoosting = user.PremiumSince.HasValue;
                _ = guild.TestCommandChannel
                    .SendMessageAsync($"{"<:Exclamatory:549529360604856323>"} {user.Mention} is {(isBoosting ? "now" : "no longer")} boosting the server.");
            }

            await Task.CompletedTask;
        }
Exemplo n.º 3
0
        public override async Task RunAsync()
        {
            var gs = GuildSettings.GetGuildSettings(Context.Guild);

            try
            {
                if (Context is RequestInteractionContext r)
                {
                    await r.OriginalInteraction.DeferAsync();
                }
            }
            catch (HttpException)
            {
            }
            var acc        = EntityConverter.ConvertUser(Context.User);
            var openBattle = new EndlessBattleEnvironment(_battleService, $"{Context.User.Username}", gs.ColossoChannel, false, await _battleService.PrepareBattleChannel($"Endless-{Context.User.Username}", Context.Guild, persistent: false));

            if (FastTrack && acc.Inv.RemoveBalance(Cost))
            {
                UserAccountProvider.StoreUser(acc);
                openBattle.SetStreak(12);
            }

            _battleService.AddBattleEnvironment(openBattle);
            await Context.Channel.SendMessageAsync(
                $"{Context.User.Username}, {openBattle.BattleChannel.Mention} has been prepared for an endless adventure");
        }
Exemplo n.º 4
0
        internal static async void LevelUp(UserAccount userAccount, SocketGuildUser user, IMessageChannel channel = null)
        {
            if (userAccount.LevelNumber < 10 && (userAccount.LevelNumber % 5) > 0)
            {
                channel = GuildSettings.GetGuildSettings(user.Guild).CommandChannel;
            }
            if (channel == null)
            {
                return;
            }
            // the user leveled up
            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get(userAccount.Element.ToString()));
            embed.WithTitle("LEVEL UP!");
            embed.WithDescription("<:Up_Arrow:571309108289077258> " + userAccount.GsClass + " " + user.Mention + " just leveled up!");
            embed.AddField("LEVEL", userAccount.LevelNumber, true);
            embed.AddField("XP", userAccount.XP, true);
            if (userAccount.LevelNumber == 10)
            {
                embed.AddField("Congratulations!", "You have unlocked Easy mode in the Weyard battle channels!");
            }
            else if (userAccount.LevelNumber == 30)
            {
                embed.AddField("Congratulations!", "You have unlocked Medium mode in the Weyard battle channels!");
            }
            else if (userAccount.LevelNumber == 50)
            {
                embed.AddField("Congratulations!", "You have unlocked Hard mode in the Weyard battle channels, as well as the Endless mode!");
            }
            await channel.SendMessageAsync("", embed : embed.Build());
        }
Exemplo n.º 5
0
 private async Task Client_UserLeft(SocketGuildUser user)
 {
     if (GuildSettings.GetGuildSettings(user.Guild).sendLeaveMessage)
     {
         _ = GuildSettings.GetGuildSettings(user.Guild).TestCommandChannel.SendMessageAsync($"{user.DisplayName()} left the party :(.");
     }
     await Task.CompletedTask;
 }
Exemplo n.º 6
0
        private async Task OnUserJoinAsync(SocketGuildUser user)
        {
            if (GuildSettings.GetGuildSettings(user.Guild.Id).AutoJoin)
            {
                await new AnonChannelManagement(GuildSettings.GetGuildSettings(user.Guild.Id).CatagoryID).CreateAnonChannel(user);
            }

            return;
        }
Exemplo n.º 7
0
 // Override the CheckPermissions method
 public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command,
                                                                 IServiceProvider services)
 {
     if (context.Guild != null && GuildSettings.GetGuildSettings(context.Guild).IsUserServer)
     {
         return(Task.FromResult(PreconditionResult.FromSuccess()));
     }
     return(Task.FromResult(PreconditionResult.FromError("You must be in an approved server to run this.")));
 }
Exemplo n.º 8
0
 private async Task Client_GuildMemberUpdated(SocketGuildUser before, SocketGuildUser after)
 {
     if (before.DisplayName() != after.DisplayName())
     {
         UserAccounts.GetAccount(after).Name = after.DisplayName();
         _ = GuildSettings.GetGuildSettings(after.Guild).TestCommandChannel
             .SendMessageAsync($"{after.Mention} changed Nickname from {before.DisplayName()} to {after.DisplayName()}");
     }
     await Task.CompletedTask;
 }
Exemplo n.º 9
0
        public async Task AddAsync(SocketMessage message)
        {
            if (!(message.Author is SocketGuildUser user))
            {
                return;
            }
            ulong catagoryID = GuildSettings.GetGuildSettings(user.Guild.Id).CatagoryID;

            await new AnonChannelManagement(catagoryID).RemoveAnnonChannel(user);
        }
Exemplo n.º 10
0
 private async Task Client_UserJoined(SocketGuildUser user)
 {
     _ = GuildSettings.GetGuildSettings(user.Guild).TestCommandChannel.SendMessageAsync(embed:
                                                                                        new EmbedBuilder()
                                                                                        .WithAuthor(user)
                                                                                        .AddField("Account Created", user.CreatedAt)
                                                                                        .AddField("User Joined", user.JoinedAt)
                                                                                        .AddField("Status", user.Status, true)
                                                                                        .Build());
     await Task.CompletedTask;
 }
Exemplo n.º 11
0
        private async Task Client_UserLeft(SocketGuild guild, SocketUser user)
        {
            var settings = GuildSettings.GetGuildSettings(guild);

            if (settings.SendLeaveMessage)
            {
                var channel = settings.TestCommandChannel;
                _ = channel.SendMessageAsync($"{user.Mention} ({user.Username}) left the party :(");
            }
            await Task.CompletedTask;
        }
Exemplo n.º 12
0
        private async Task _client_UserBanned(SocketUser user, SocketGuild guild)
        {
            if (GuildSettings.GetGuildSettings(guild).SendLeaveMessage)
            {
                var r = await guild.GetBanAsync(user);

                var channel = GuildSettings.GetGuildSettings(guild).TestCommandChannel;
                _ = channel.SendMessageAsync($"{user.Mention} left the party :) {r.Reason}");
            }
            await Task.CompletedTask;
        }
Exemplo n.º 13
0
        private async Task SendWelcomeMessage(SocketGuildUser user)
        {
            var guild = GuildSettings.GetGuildSettings(user.Guild);

            if (GuildSettings.GetGuildSettings(user.Guild).SendWelcomeMessage)
            {
                _ = guild.MainChannel.SendMessageAsync(embed:
                                                       new EmbedBuilder()
                                                       .WithColor(Colors.Get("Iodem"))
                                                       .WithDescription(string.Format(_welcomeMsg.Random(), user.DisplayName()))
                                                       .Build());
            }
        }
Exemplo n.º 14
0
        private async Task Client_UserJoined(SocketGuildUser user)
        {
            _ = GuildSettings.GetGuildSettings(user.Guild).TestCommandChannel.SendMessageAsync(embed:
                                                                                               new EmbedBuilder()
                                                                                               .WithAuthor(user)
                                                                                               .AddField("Account Created", user.CreatedAt)
                                                                                               .AddField("User Joined", user.JoinedAt)
                                                                                               .AddField("Status", user.Status, true)
                                                                                               .Build());

            Console.WriteLine($"Joined: hasValue:{user.IsPending.HasValue} isPending:{user.IsPending.GetValueOrDefault()}");
            if (user.IsPending.HasValue && !user.IsPending.Value)
            {
                await SendWelcomeMessage(user);
            }
            await Task.CompletedTask;
        }
Exemplo n.º 15
0
        private static async Task WriteAndDeleteRewards(List <string> text, ITextChannel channel)
        {
            if (text.Count == 0)
            {
                return;
            }

            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get("Iodem"));
            embed.WithDescription($"{string.Join("\n", text)}");
            _ = GuildSettings.GetGuildSettings(channel.Guild).CommandChannel.SendMessageAsync("", false, embed.Build());
            var msg = await channel.SendMessageAsync("", false, embed.Build());

            await Task.Delay(5000);

            _ = msg.DeleteAsync();
        }
Exemplo n.º 16
0
        private async Task OnMessageReceivedAsync(SocketMessage s)
        {
            var msg = s as SocketUserMessage;     // Ensure the message is from a user/bot

            if (msg == null)
            {
                return;
            }
            if (msg.Author.Id == _discord.CurrentUser.Id)
            {
                return;                                               // Ignore self when checking commands
            }
            var context = new SocketCommandContext(_discord, msg);    // Create the command context

            var guildUser = msg.Author as SocketGuildUser;            // Ensure that it is a message sent from a guild

            if (guildUser == null)
            {
                return;
            }

            var guildSettings = GuildSettings.GetGuildSettings(guildUser.Id);

            GuildSettings.GetGuildSettings(guildUser.Guild.Id).Prefix;

            int argPos = 0;     // Check if the message has a valid command prefix

            if (msg.HasStringPrefix(prefix, ref argPos) || msg.HasMentionPrefix(_discord.CurrentUser, ref argPos))
            {
                var result = await _commands.ExecuteAsync(context, argPos, _provider); // Execute the command

                if (!result.IsSuccess)                                                 // If not successful, reply with the error.
                {
                    await context.Channel.SendMessageAsync(result.ToString());
                }
            }
            else
            {
                guildUser.Guild.getc

                    await new AnonMessageHandaler().Message(s, );
                //message goodies go here
            }
        }
Exemplo n.º 17
0
        private async Task Client_UserJoined(SocketGuildUser user)
        {
            if (GuildSettings.GetGuildSettings(user.Guild).sendWelcomeMessage)
            {
                _ = GuildSettings.GetGuildSettings(user.Guild).MainChannel.SendMessageAsync(embed:
                                                                                            new EmbedBuilder()
                                                                                            .WithColor(Colors.Get("Iodem"))
                                                                                            .WithDescription(string.Format(welcomeMsg[Global.Random.Next(0, welcomeMsg.Length)], user.DisplayName()))
                                                                                            .Build());
            }

            _ = GuildSettings.GetGuildSettings(user.Guild).TestCommandChannel.SendMessageAsync(embed:
                                                                                               new EmbedBuilder()
                                                                                               .WithAuthor(user)
                                                                                               .AddField("Account Created", user.CreatedAt)
                                                                                               .AddField("User Joined", user.JoinedAt)
                                                                                               .AddField("Status", user.Status, true)
                                                                                               .Build());
            await Task.CompletedTask;
        }
Exemplo n.º 18
0
        private async Task Client_GuildMemberUpdated(Cacheable <SocketGuildUser, ulong> before, SocketGuildUser user)
        {
            var guild      = GuildSettings.GetGuildSettings(user.Guild);
            var userBefore = before.Value;

            if (userBefore.DisplayName() != user.DisplayName())
            {
                EntityConverter.ConvertUser(user).Name = user.DisplayName();
                _ = guild.TestCommandChannel
                    .SendMessageAsync(
                    $"{user.Mention} changed Nickname from {userBefore.DisplayName()} to {user.DisplayName()}");
            }

            //Console.WriteLine($"Updated: before:{userBefore.IsPending.GetValueOrDefault()} after:{user.IsPending.GetValueOrDefault()}");
            //if (userBefore.IsPending.GetValueOrDefault() == true && user.IsPending.GetValueOrDefault() == false)
            //{
            //    await SendWelcomeMessage(user);
            //    Console.WriteLine($"{user.Username} joined");
            //}

            //if (userBefore.PremiumSince.HasValue != user.PremiumSince.HasValue)
            //{
            //    var isBoosting = user.PremiumSince.HasValue;
            //    if (isBoosting)
            //    {
            //        _ = guild.MainChannel
            //            .SendMessageAsync(
            //                $"<:Exclamatory:549529360604856323> {user.Mention} is now boosting the server.");
            //    }
            //    else
            //    {
            //        _ = guild.TestCommandChannel
            //        .SendMessageAsync(
            //            $"<:Exclamatory:549529360604856323> {user.Mention} is no longer boosting the server.");
            //    }
            //}

            await Task.CompletedTask;
        }
Exemplo n.º 19
0
        private async Task Client_Ready()
        {
            var channel = (SocketTextChannel)client.GetChannel(535209634408169492) ?? (SocketTextChannel)client.GetChannel(668443234292334612);

            if (channel != null && (DateTime.Now - Global.RunningSince).TotalSeconds < 15)
            {
                await channel.SendMessageAsync($"Hello, I am back up. {Environment.OSVersion}");

                foreach (var guild in client.Guilds)
                {
                    var gs = GuildSettings.GetGuildSettings(guild);
                    if (gs.AutoSetup && gs.ColossoChannel != null)
                    {
                        await ColossoPvE.Setup(guild);

                        Console.WriteLine($"Setup in {gs.Name}");
                    }
                }
            }
            //setup colosso
            await client.SetStatusAsync(UserStatus.Idle);

            Global.UpSince = DateTime.UtcNow;
        }
Exemplo n.º 20
0
        public async Task PublicChannelAsync(SocketMessage message,
                                             [Summary("10")] bool enableChannel)
        {
            if (!(message.Author is SocketGuildUser user))
            {
                return;
            }
            ulong catagoryID = GuildSettings.GetGuildSettings(user.Guild.Id).CatagoryID;

            if (enableChannel)
            {
                if (true)//do an sql if channel is already made)


                {
                    await new AnonChannelManagement(catagoryID).CreatePublicAnonChannel(user.Guild);
                }
            }
            else
            {
                await new AnonChannelManagement(catagoryID).RemovePublicAnonChannel(user.Guild);
            }
            //sets some sql doodad to
        }
Exemplo n.º 21
0
        public override async Task RunAsync()
        {
            var gs = GuildSettings.GetGuildSettings(Context.Guild);

            try
            {
                if (Context is RequestInteractionContext r)
                {
                    await r.OriginalInteraction.DeferAsync();
                }
            }
            catch (HttpException)
            {
            }

            var openBattle = new GauntletBattleEnvironment(_battleService, $"{Context.User.Username}",
                                                           gs.ColossoChannel,
                                                           await _battleService.PrepareBattleChannel($"{_dungeon.Name}-{Context.User.Username}",
                                                                                                     Context.Guild, persistent: false), _dungeon.Name, false);

            _battleService.AddBattleEnvironment(openBattle);
            await Context.Channel.SendMessageAsync(
                $"{Context.User.Username}, {openBattle.BattleChannel.Mention} has been prepared for your adventure to {_dungeon.Name}");
        }
Exemplo n.º 22
0
        internal static async void UserSentMessage(SocketGuildUser user, SocketTextChannel channel)
        {
            if (channel == null || BlackListedChannels.Contains(channel.Id) || user == null)
            {
                return;
            }

            if (channel.Id == GuildSettings.GetGuildSettings(channel.Guild).ColossoChannel?.Id)
            {
                return;
            }

            var userAccount = EntityConverter.ConvertUser(user);

            // if the user has a timeout, ignore them
            var sinceLastXp = DateTime.UtcNow - userAccount.LastXp;
            var oldLevel    = userAccount.LevelNumber;

            if (sinceLastXp.TotalMinutes >= 3)
            {
                userAccount.LastXp = DateTime.UtcNow;
                userAccount.AddXp((uint)Global.RandomNumber(30, 50));
            }

            if (DateTime.Now.Date != userAccount.ServerStats.LastDayActive.Date)
            {
                userAccount.ServerStats.UniqueDaysActive++;
                userAccount.ServerStats.LastDayActive = DateTime.Now.Date;
            }

            if (channel.Id == GuildSettings.GetGuildSettings(channel.Guild)?.ColossoChannel?.Id)
            {
                userAccount.ServerStats.MessagesInColossoTalks++;
                if (userAccount.ServerStats.MessagesInColossoTalks >= 50)
                {
                    _ = GoldenSunCommands.AwardClassSeries("Swordsman Series", user, channel);
                }
            }

            var newLevel = userAccount.LevelNumber;

            if (oldLevel != newLevel)
            {
                LevelUp(userAccount, user, channel);
            }

            if (channel.Id != userAccount.ServerStats.MostRecentChannel)
            {
                userAccount.ServerStats.MostRecentChannel = channel.Id;
                userAccount.ServerStats.ChannelSwitches  += 2;
                if (userAccount.ServerStats.ChannelSwitches >= 14)
                {
                    _ = GoldenSunCommands.AwardClassSeries("Air Pilgrim Series", user, channel);
                }
            }
            else
            {
                if (userAccount.ServerStats.ChannelSwitches > 0)
                {
                    userAccount.ServerStats.ChannelSwitches--;
                }
            }
            UserAccountProvider.StoreUser(userAccount);
            await Task.CompletedTask;
        }
Exemplo n.º 23
0
 private async Task OnUserLeftAsync(SocketGuildUser user)
 {
     await new AnonChannelManagement(GuildSettings.GetGuildSettings(user.Guild.Id).CatagoryID).RemoveAnnonChannel(user);
 }
Exemplo n.º 24
0
        internal static async void UserSentMessage(SocketGuildUser user, SocketTextChannel channel)
        {
            if (blackListedChannels.Contains(channel.Id))
            {
                return;
            }

            if (channel.Id == GuildSettings.GetGuildSettings(channel.Guild).ColossoChannel?.Id)
            {
                return;
            }

            var userAccount = UserAccounts.GetAccount(user);

            // if the user has a timeout, ignore them
            var  sinceLastXP = DateTime.UtcNow - userAccount.LastXP;
            uint oldLevel    = userAccount.LevelNumber;

            if (sinceLastXP.TotalMinutes >= 3)
            {
                userAccount.LastXP = DateTime.UtcNow;
                userAccount.AddXp((uint)(new Random()).Next(30, 50));
            }

            if ((DateTime.Now.Date != userAccount.ServerStats.LastDayActive.Date))
            {
                userAccount.ServerStats.UniqueDaysActive++;
                userAccount.ServerStats.LastDayActive = DateTime.Now.Date;

                if ((DateTime.Now - user.JoinedAt).Value.TotalDays > 30)
                {
                    await GoldenSun.AwardClassSeries("Hermit Series", user, channel);
                }
            }

            if (channel.Id != userAccount.ServerStats.MostRecentChannel)
            {
                userAccount.ServerStats.MostRecentChannel = channel.Id;
                userAccount.ServerStats.ChannelSwitches  += 2;
                if (userAccount.ServerStats.ChannelSwitches >= 14)
                {
                    await GoldenSun.AwardClassSeries("Air Pilgrim Series", user, channel);
                }
            }
            else
            {
                if (userAccount.ServerStats.ChannelSwitches > 0)
                {
                    userAccount.ServerStats.ChannelSwitches--;
                }
            }

            if (channel.Id == GuildSettings.GetGuildSettings(channel.Guild)?.ColossoChannel?.Id)
            {
                userAccount.ServerStats.MessagesInColossoTalks++;
                if (userAccount.ServerStats.MessagesInColossoTalks >= 50)
                {
                    await GoldenSun.AwardClassSeries("Swordsman Series", user, channel);
                }
            }

            UserAccounts.SaveAccounts();
            uint newLevel = userAccount.LevelNumber;

            if (oldLevel != newLevel)
            {
                LevelUp(userAccount, user, channel);
            }

            await Task.CompletedTask;
        }