Exemple #1
0
        public override async Task ButtonAction(SocketReaction action)
        {
            switch (action.Emote.ToString())
            {
            case ReactionHandler.CHECK_STR:
                // Time for security checks

                /// These checks were done when the command was called - Arcy

                BanDataNode ban = new BanDataNode(Context.User, Reason);

                if (notifyTarget)
                {
                    bool sent = await BotUtils.DMUserAsync(BotUtils.GetGUser(Target.Id), new BanNotifyEmbed(ban.Reason).GetEmbed());

                    if (!sent)
                    {
                        await Context.Channel.SendMessageAsync(BotUtils.BadDMResponse);
                    }
                }

                AdminDataManager.AddBan(Target, ban);
                await Context.Channel.SendMessageAsync(BotUtils.KamtroAngry($"User {BotUtils.GetFullUsername(Target)} has been banned."));

                await ServerData.Server.AddBanAsync(Target.Id, 0, Reason);

                break;

            case diamond:
                notifyTarget = !notifyTarget;
                await UpdateEmbed();

                break;
            }
        }
        private async Task AddRep(SocketUser user)
        {
            if (user.Id == Context.User.Id)
            {
                await ReplyAsync(BotUtils.KamtroText("You can't give a repuation point to yourself!"));

                return;
            }

            // Change formatting based on nicknames and channel
            SocketGuildUser targetGuildUser = BotUtils.GetGUser(user.Id);
            SocketGuildUser currentUser     = BotUtils.GetGUser(Context);

            await UserDataManager.AddRep(currentUser, targetGuildUser);

            // Notify user if they have notification on
            if (UserDataManager.GetUserSettings(targetGuildUser).RepNotify)
            {
                await targetGuildUser.SendMessageAsync(BotUtils.KamtroText($"You have received a reputation point from {currentUser.GetDisplayName()}."));
            }

            if (Context.Channel is SocketDMChannel)
            {
                await ReplyAsync(BotUtils.KamtroText($"You have given a reputation point to {targetGuildUser.GetDisplayName()}."));
            }
            else
            {
                SocketGuildUser guildUser = BotUtils.GetGUser(Context);

                await ReplyAsync(BotUtils.KamtroText($"{guildUser.GetDisplayName()} has given a reputation point to {targetGuildUser.GetDisplayName()}."));
            }
        }
        public static void LoadInventories()
        {
            string data = FileManager.ReadFullFile(DataFileNames.UserInventoriesFile);
            Dictionary <ulong, UserInventoryNode> UserInventories = JsonConvert.DeserializeObject <Dictionary <ulong, UserInventoryNode> >(data) ?? new Dictionary <ulong, UserInventoryNode>();

            foreach (ulong id in UserInventories.Keys)
            {
                if (BotUtils.GetGUser(id) == null)
                {
                    continue;
                }

                if (UserDataManager.UserData.ContainsKey(id))
                {
                    // User has a data file, things are all good
                    UserDataManager.GetUserData(BotUtils.GetGUser(id)).Inventory = UserInventories[id];
                }
                else
                {
                    // wacky things are going on, create a user profile and then load inventory
                    UserDataManager.AddUser(BotUtils.GetGUser(id));
                    UserDataManager.GetUserData(BotUtils.GetGUser(id)).Inventory = UserInventories[id];
                }
            }

            KLog.Info("Loaded Inventories.");
        }
Exemple #4
0
 public async Task HelpCommandAsync()
 {
     bool      isAdmin = ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN);
     bool      isMod   = ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.MODERATOR) || isAdmin;
     HelpEmbed he      = new HelpEmbed(Context, isMod, isAdmin);
     await he.Display(Context.User.GetOrCreateDMChannelAsync().Result);
 }
Exemple #5
0
        public async Task ReplaceSettingsFileAsync([Remainder] string message = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // This is an admin only command
            }
            if (Context.Message.Attachments.Count == 1)
            {
                Attachment file = Context.Message.Attachments.ElementAt(0);

                if (file.Filename != "settings.json")
                {
                    await ReplyAsync(BotUtils.KamtroText("The settings file must be a json file named settings.json!"));

                    return;
                }

                // At this point, the file is valid
                string url = file.Url;

                WebClient wc = new WebClient();
                wc.DownloadFile(url, AdminDataManager.StrikeLogPath);

                KLog.Info($"Settings file updated by {BotUtils.GetFullUsername(Context.User)}");
                await ReplyAsync(BotUtils.KamtroText("The settings file has been updated!"));
            }
        }
Exemple #6
0
        public async Task RolesAsync([Remainder] string args = "")
        {
            SocketGuildUser _user = BotUtils.GetGUser(Context);
            RoleEmbed       embed = new RoleEmbed(Context, _user);

            await embed.Display(Context.Channel);
        }
Exemple #7
0
        public static async Task <bool> BuyItem(ulong userid, int shopSlot, int quantity)
        {
            if (shopSlot > Shop.Count || shopSlot < 0)
            {
                return(false);
            }

            SocketGuildUser user     = BotUtils.GetGUser(userid);
            UserDataNode    customer = UserDataManager.GetUserData(user);
            ShopNode        item     = Shop[shopSlot];

            if (quantity > 0 && customer.Kamtrokens >= item.Price * quantity)
            {
                customer.Kamtrokens      -= item.Price * quantity;
                customer.KamtrokensSpent += item.Price * quantity;

                UserInventoryManager.GetInventory(userid).AddItem(item.ItemID, quantity);

                await AchievementManager.OnBuy(user);

                UserDataManager.SaveUserData();
                UserInventoryManager.SaveInventories();
                return(true);
            }

            return(false);
        }
        /// Arcy
        public async Task MessageRelayAsync([Remainder] string message = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;
            }

            SocketGuildUser user = BotUtils.GetGUser(Context);

            // Check if admin
            if (user.GuildPermissions.Administrator || ServerData.AdminUsers.Contains(user))
            {
                // Check if in relay users collection
                if (ServerData.RelayUsers.Contains(user))
                {
                    await ReplyAsync(BotUtils.KamtroText("You will no longer receive direct messages sent to Kamtro bot."));

                    ServerData.RelayUsers.Remove(user);
                }
                else
                {
                    await ReplyAsync(BotUtils.KamtroText("You will receive direct messages sent to Kamtro bot."));

                    ServerData.RelayUsers.Add(user);
                }
            }
        }
Exemple #9
0
        public async Task ToggleDebugAsync([Remainder] string args = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // permissions checking
            }
            if (string.IsNullOrWhiteSpace(args))
            {
                Program.Debug = !Program.Debug;
                await ReplyAsync(BotUtils.KamtroText($"Debug mode turned {(Program.Debug ? "on" : "off")}."));

                return;
            }

            if (args.ToLower() == "on")
            {
                Program.Debug = true;
                KLog.Important("Debug mode turned on");
                await ReplyAsync(BotUtils.KamtroText("Debug mode turned on."));
            }
            else if (args.ToLower() == "off")
            {
                Program.Debug = false;
                KLog.Important("Debug mode turned off");
                await ReplyAsync(BotUtils.KamtroText("Debug mode turned off."));
            }
            else if (args.ToLower() == "mode")
            {
                await ReplyAsync(BotUtils.KamtroText($"Debug mode is {(Program.Debug ? "on" : "off")}"));
            }
            else
            {
                await ReplyAsync(BotUtils.KamtroText("Invalid arguments. No args to toggle, '!debug on' to turn debug mode on, '!debug off' to turn debug mode off, '!debug mode' to see current debug mode."));
            }
        }
Exemple #10
0
        public NotificationSettingsEmbed(SocketCommandContext ctx)
        {
            SetCtx(ctx);

            Settings = UserDataManager.GetUserSettings(BotUtils.GetGUser(ctx));

            AddMenuOptions(ReactionHandler.SELECT, ReactionHandler.UP, ReactionHandler.DOWN, ReactionHandler.DONE);
        }
Exemple #11
0
        public ShopEmbed(SocketCommandContext ctx)
        {
            SetCtx(ctx);

            Customer = UserDataManager.GetUserData(BotUtils.GetGUser(ctx));

            AddMenuOptions(ReactionHandler.SELECT, ReactionHandler.UP, ReactionHandler.DOWN, ReactionHandler.BACK);
        }
Exemple #12
0
 public async Task RefreshShopAsync([Remainder] string args = "")
 {
     if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
     {
         return;
     }
     ShopManager.GenShopSelection();
     await ReplyAsync(BotUtils.KamtroText("Shop Refreshed."));
 }
Exemple #13
0
 public async Task SettingsFileAsync([Remainder] string message = "")
 {
     if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
     {
         return;                                                                                                // This is an admin only command
     }
     // Check if the file is being used
     await Context.Channel.SendFileAsync("Config/settings.json");
 }
Exemple #14
0
        public TitleEmbed(SocketCommandContext ctx)
        {
            SetCtx(ctx);

            Titles = AchievementManager.GetTitles();
            User   = BotUtils.GetGUser(ctx);

            AddMenuOptions(ReactionHandler.SELECT, ReactionHandler.UP, ReactionHandler.DOWN, ReactionHandler.BACK);
        }
Exemple #15
0
        public async Task HackedAsync()
        {
            SocketGuildUser user = BotUtils.GetGUser(Context);

            if (ServerData.HasPermissionLevel(user, ServerData.PermissionLevel.ADMIN))
            {
                await Hacked();
            }
        }
Exemple #16
0
        public CoinFlipEmbed(SocketCommandContext ctx)
        {
            SetCtx(ctx);

            User = BotUtils.GetGUser(ctx);
            Data = UserDataManager.GetUserData(User);

            AddMenuOptions(new MenuOptionNode(HEADS, "Heads"), new MenuOptionNode(TAILS, "Tails"));
        }
Exemple #17
0
        public async Task PorterAsync([Remainder] string message = "")
        {
            if (UserDataManager.GetUserData(BotUtils.GetGUser(Context)).PorterSupporter)
            {
                Random random      = new Random();
                string porterEmoji = CustomEmotes.porterEmojis[random.Next(0, CustomEmotes.porterEmojis.Length)];

                await Context.Channel.SendMessageAsync(porterEmoji);
            }
        }
        public static async Task RemindUser(ReminderPointer rp)
        {
            ReminderNode node = GetReminder(rp);

            SocketGuildUser user = BotUtils.GetGUser(rp.User);

            IDMChannel channel = await user.GetOrCreateDMChannelAsync();

            await channel.SendMessageAsync(embed : new BasicEmbed("Reminder!", node.Description, node.Name, BotUtils.Kamtro).GetEmbed());
        }
        public async Task ResetRepAsync([Remainder] string name = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.MODERATOR))
            {
                return;
            }

            UserDataManager.ResetRep();

            await ReplyAsync(BotUtils.KamtroText("Rep reset."));
        }
Exemple #20
0
        public async Task ReloadConfigAsync()
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // This is an admin only command
            }
            Program.ReloadConfig();
            ReactionHandler.SetupRoleMap();

            await ReplyAsync(BotUtils.KamtroText("Settings Reloaded."));
        }
Exemple #21
0
        public async Task RemModifyRoleAsync([Remainder] string roleName = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // This is an admin only command
            }
            if (string.IsNullOrWhiteSpace(roleName))
            {
                await ReplyAsync(BotUtils.KamtroText("Please specify a role name!"));
            }

            ulong id;

            if (ulong.TryParse(roleName, out id) && BotUtils.GetRole(id) != null)
            {
                await RemModifyRole(BotUtils.GetRole(id));

                return;
            }

            // if it's not a recognized ID, treat it as a name

            List <SocketRole> roles = new List <SocketRole>();

            foreach (SocketRole r in BotUtils.GetRoles(roleName))
            {
                if (Program.Settings.ModifiableRoles.Contains(r.Id))
                {
                    roles.Add(r);
                }
            }

            if (roles.Count == 0)
            {
                await ReplyAsync(BotUtils.KamtroText("I couldn't find any roles on the list that matched the name you told me!"));

                return;
            }
            else if (roles.Count > 10)
            {
                await ReplyAsync(BotUtils.KamtroText("There were too many roles with that name! Please be more specific, or use the role ID"));

                return;
            }
            else if (roles.Count == 1)
            {
                await RemModifyRole(roles[0]);
            }
            else
            {
                RoleSelectionEmbed rse = new RoleSelectionEmbed(roles, RemModifyRole, BotUtils.GetGUser(Context));
                await rse.Display(Context.Channel);
            }
        }
Exemple #22
0
        public async Task OfflineAsync()
        {
            SocketGuildUser user = BotUtils.GetGUser(Context);

            if (ServerData.HasPermissionLevel(user, ServerData.PermissionLevel.MODERATOR))
            {
                await ReplyAsync(BotUtils.KamtroText("Goodnight 💤"));

                await Program.Client.LogoutAsync();
            }
        }
        public static UserInventoryNode GetInventory(ulong userId)
        {
            UserDataManager.AddUserIfNotExists(BotUtils.GetGUser(userId));

            if (UserDataManager.GetUserData(BotUtils.GetGUser(userId)).Inventory == null)
            {
                UserDataManager.GetUserData(BotUtils.GetGUser(userId)).Inventory = new UserInventoryNode();
                SaveInventories();
            }

            return(UserDataManager.GetUserData(BotUtils.GetGUser(userId)).Inventory);
        }
Exemple #24
0
        public async Task OliveGardenAsync([Remainder] string message = "")
        {
            string copyPasta = "Ever wonder what I would do to your right pinky toe?" +
                               " I'd take it out to a night at Olive Garden, but only get the breadsticks since that'd be a little expensive if we got more than just that. " +
                               "As you take a bite out of the breadstick, I'll slowly reach down towards your hamstring and give you a ham steak to sautee that big boy. " +
                               "Afterwards we'll head home and I'll slowly lie you down onto the cold tile floor and slide you across it like a cat on a towel. " +
                               "It's pretty fun. Anyways, once I slide you into the room like a cute kitty I'll slither on top of you and pull a bread stick out of my chest tuft. " +
                               "Remember this breadstick? It's the one we got from Olive Garden. I slowly put it in your mouth and tell you to eat it, because that's all we got til Tuesday bitch.";

            await ReplyAsync(BotUtils.KamtroText(copyPasta));

            await AchievementManager.AddTitle(BotUtils.GetGUser(Context), AchievementManager.TitleIDs.OLIVE_GARDENER);
        }
Exemple #25
0
        public ReminderEmbed(SocketCommandContext ctx)
        {
            SetCtx(ctx);

            User         = BotUtils.GetGUser(ctx);
            UserTimeZone = UserDataManager.GetUserData(User).TimeZone;

            Timeout = new TimeSpan(0, 30, 0);

            RefreshList();

            AddMenuOptions(ReactionHandler.SELECT, new MenuOptionNode(ASTERISK_NEW, "Add"), ReactionHandler.UP, ReactionHandler.DOWN, new MenuOptionNode(ReactionHandler.DECLINE_STR, "Delete"), new MenuOptionNode(PENCIL, "Edit"), ReactionHandler.BACK);
            RegisterMenuFields();
        }
        private async Task StrikeUser(SocketUser user)
        {
            // First, the classic null check
            if (BotUtils.GetGUser(Context) == null)
            {
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("That user does not exist!"));

                KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike non-existant member {BotUtils.GetFullUsername(user)}");
                return;
            }

            // Flavor text for trying to strike yourself
            if (user.Id == Context.User.Id)
            {
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("We would like to save the strikes for those that deserve it."));

                return;
            }

            // next, check to see if Kamtro has perms to ban the user
            if (!BotUtils.HighestUser(BotUtils.GetGUser(Context.Client.CurrentUser.Id), BotUtils.GetGUser(user.Id)))
            {
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("The user is higher than me, so I cannot strike them."));

                KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike member {BotUtils.GetFullUsername(user)} of higher status than bot");
                return;
            }

            // next, check if the caller can ban the user
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                if (BotUtils.HighestUser(BotUtils.GetGUser(user.Id), BotUtils.GetGUser(Context), true))
                {
                    await Context.Channel.SendMessageAsync(BotUtils.KamtroText("This user is higher or equal than you, and as such, you cannot strike them."));

                    KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike member {BotUtils.GetFullUsername(user)} of higher status than caller");
                    return;
                }
            }

            if (AdminDataManager.GetStrikes(user) >= 2)
            {
                await BanUser(user);

                return;
            }

            StrikeEmbed se = new StrikeEmbed(Context, user);
            await se.Display();
        }
Exemple #27
0
        /// <summary>
        /// Crafts the item. No checks in method
        /// </summary>
        /// <param name="item">The item to craft</param>
        private void Craft(uint itemId)
        {
            Item item = ItemManager.GetItem(itemId);

            foreach (uint k in item.GetRecipe().Keys)
            {
                LoseItem(k, item.GetRecipe()[k]);
            }

            AddItem(itemId);

            KLog.Info($"User {BotUtils.GetFullUsername(BotUtils.GetGUser(UserDataManager.UserData.FirstOrDefault(x => x.Value.Inventory == this).Key))} crafted item {item.Name} (ID: {itemId})");

            ParseInventory();
        }
Exemple #28
0
        public async Task SnokbuttAsync([Remainder] string message = "")
        {
            Random random = new Random();
            int    num    = random.Next(0, 100);

            if (num == 0)
            {
                await Context.Channel.SendFileAsync("Images/Snokbutt2.png");
            }
            else
            {
                await Context.Channel.SendFileAsync("Images/Snokbutt.png");
            }
            await AchievementManager.AddTitle(BotUtils.GetGUser(Context), AchievementManager.TitleIDs.RETRO_BUTT);
        }
        public async Task UserInfoAsync([Remainder] string args = null)
        {
            // Moderator check
            SocketGuildUser user = BotUtils.GetGUser(Context);

            if (ServerData.HasPermissionLevel(user, ServerData.PermissionLevel.MODERATOR))
            {
                // Only command was used. Get info on current user
                if (string.IsNullOrWhiteSpace(args))
                {
                    await DisplayUserInfoEmbed(user);

                    return;
                }
                else
                {
                    List <SocketGuildUser> users = BotUtils.GetUser(Context.Message);

                    // No user found
                    if (users.Count == 0)
                    {
                        await ReplyAsync(BotUtils.KamtroText("I could not find that user. Please try again and make sure you are spelling the user correctly."));

                        return;
                    }
                    // Get info on user
                    else if (users.Count == 1)
                    {
                        await DisplayUserInfoEmbed(users[0]);

                        return;
                    }
                    // Name is too vague. More than 10 users found
                    else if (users.Count > 10)
                    {
                        await ReplyAsync(BotUtils.KamtroText("That name is too vague. Please try specifying the user."));

                        return;
                    }
                    // More than one user mentioned, or ambiguous user
                    else
                    {
                        UserSelectionEmbed use = new UserSelectionEmbed(users, DisplayUserInfoEmbed, BotUtils.GetGUser(Context.User.Id));
                        await use.Display(Context.Channel);
                    }
                }
            }
        }
Exemple #30
0
        public async Task AddEmoteRoleAsync([Remainder] string args = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // This is an admin only command
            }
            if (string.IsNullOrWhiteSpace(args))
            {
                await ReplyAsync(BotUtils.KamtroText("Please specify a role!"));

                return;
            }

            ulong id;

            if (ulong.TryParse(args, out id) && BotUtils.GetRole(id) != null)
            {
                await AddRoleEmote(BotUtils.GetRole(id));

                return;
            }

            // if it's not a recognized ID, treat it as a name

            List <SocketRole> roles = BotUtils.GetRoles(args);

            if (roles.Count == 0)
            {
                await ReplyAsync(BotUtils.KamtroText("I couldn't find any roles that matched the name you told me!"));

                return;
            }
            else if (roles.Count > 10)
            {
                await ReplyAsync(BotUtils.KamtroText("There were too many roles with that name! Please be more specific, or use the role ID"));

                return;
            }
            else if (roles.Count == 1)
            {
                await AddRoleEmote(roles[0]);
            }
            else
            {
                RoleSelectionEmbed rse = new RoleSelectionEmbed(roles, AddRoleEmote, BotUtils.GetGUser(Context));
                await rse.Display(Context.Channel);
            }
        }