예제 #1
0
        public async Task Warns()
        {
            var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json");

            if (!File.Exists(file))
            {
                GuildConfig.Setup(Context.Guild);
            }
            var embed = new EmbedBuilder();

            embed.WithTitle("Warns");
            var config = GuildConfig.GetServer(Context.Guild);

            var groupedlist = config.Warnings.GroupBy(x => x.UserId)
                              .Select(group => new
            {
                UserId = group.Key,
                List   = group.ToList()
            })
                              .ToList();

            foreach (var group in groupedlist)
            {
                string username;
                try
                {
                    var user = await Context.Guild.GetUserAsync(group.UserId);

                    username = user.Username;
                }
                catch
                {
                    username = group.List.First().User;
                }
                var list = "";
                foreach (var x in group.List)
                {
                    if (list.Length >= 800)
                    {
                        embed.AddField($"{username} [{group.UserId}]", list);
                        list = "";
                    }
                    var moderator =
                        $"{x.Moderator}                                             ".Substring(0, 20);
                    list += $"Mod: {moderator} || Reason: {x.Reason}\n";
                }
                embed.AddField($"{username} [{group.UserId}]", list);
            }

            if (embed.Fields.Count > 0)
            {
                await ReplyAsync("", false, embed.Build());
            }
            else
            {
                await ReplyAsync("There are no warns in the server...");
            }
        }
예제 #2
0
        public async Task SetLevelChannel()
        {
            var GuildObj = GuildConfig.GetServer(Context.Guild);

            GuildObj.Levels.LevellingChannel = Context.Channel.Id;
            await ReplyAsync($"Level Up Notifications will now be sent to: {Context.Channel.Name}");

            GuildConfig.SaveServer(GuildObj);
        }
예제 #3
0
        public async Task ToggleLevelUp()
        {
            var GuildObj = GuildConfig.GetServer(Context.Guild);

            GuildObj.Levels.UseLevelMessages = !GuildObj.Levels.UseLevelMessages;
            await ReplyAsync($"Level Up Notifications are now set to: {GuildObj.Levels.UseLevelMessages}");

            GuildConfig.SaveServer(GuildObj);
        }
예제 #4
0
        public async Task ToggleSystem()
        {
            var GuildObj = GuildConfig.GetServer(Context.Guild);

            GuildObj.Levels.LevellingEnabled = !GuildObj.Levels.LevellingEnabled;
            await ReplyAsync($"Levelling System is now set to: {GuildObj.Levels.LevellingEnabled}");

            GuildConfig.SaveServer(GuildObj);
        }
예제 #5
0
        public async Task ApiAIToggle()
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.chatwithmention = !jsonObj.chatwithmention;
            GuildConfig.SaveServer(jsonObj);
            await ReplyAsync(
                $"Using {Context.Client.CurrentUser.Mention} at the start of a message will allow the use or random chat messages is set to: {jsonObj.chatwithmention}");
        }
예제 #6
0
        public async Task JoinRole(IRole role = null)
        {
            var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json");

            if (role == null)
            {
                if (File.Exists(file))
                {
                    var jsonObj = GuildConfig.GetServer(Context.Guild);
                    var embed   = new EmbedBuilder();
                    var roles   = "";
                    foreach (var roleid in jsonObj.RoleConfigurations.SubRoleList)
                    {
                        try
                        {
                            roles += $"{Context.Guild.GetRole(roleid).Name}\n";
                        }
                        catch
                        {
                            //
                        }
                    }

                    embed.AddField("Subscribable Roles", $"{roles}\n" +
                                   "NOTE: If this list is empty, there are no roles setup in this server");
                    await ReplyAsync("", false, embed.Build());
                }
            }
            else
            {
                var jsonObj = GuildConfig.GetServer(Context.Guild);
                var embed   = new EmbedBuilder();
                if (jsonObj.RoleConfigurations.SubRoleList.Contains(role.Id))
                {
                    var u = (IGuildUser)Context.User;
                    if (u.RoleIds.Contains(role.Id))
                    {
                        await u.RemoveRoleAsync(role);

                        embed.AddField("Success", $"You have been removed from the role {role.Name}");
                    }
                    else
                    {
                        await u.AddRoleAsync(role);

                        embed.AddField("Success", $"You have been added to the role {role.Name}");
                    }
                }
                else
                {
                    embed.AddField("Failed", $"{role.Name} is not a subscribable role");
                }

                await ReplyAsync("", false, embed.Build());
            }
        }
예제 #7
0
        public async Task ToggleLevelChannel()
        {
            var GuildObj = GuildConfig.GetServer(Context.Guild);

            GuildObj.Levels.UseLevelChannel = !GuildObj.Levels.UseLevelChannel;
            await ReplyAsync(
                $"Sending Level Up notifications to a specific channel is now set to: {GuildObj.Levels.UseLevelChannel}");

            GuildConfig.SaveServer(GuildObj);
        }
예제 #8
0
        public async Task Clear()
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.Blacklist = new List <string>();

            GuildConfig.SaveServer(jsonObj, Context.Guild);

            await ReplyAsync("The blacklist has been cleared.");
        }
예제 #9
0
        public async Task SetMod(IRole modRole)
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.ModeratorRoleId = modRole.Id;

            GuildConfig.SaveServer(jsonObj, Context.Guild);

            await ReplyAsync($"ModRole has been set as {modRole.Mention}");
        }
예제 #10
0
        public async Task ToggleLevelIncrement()
        {
            var GuildObj = GuildConfig.GetServer(Context.Guild);

            GuildObj.Levels.IncrementLevelRewards = !GuildObj.Levels.IncrementLevelRewards;
            await ReplyAsync(
                $"Users will only have one level reward at a time: {GuildObj.Levels.IncrementLevelRewards}");

            GuildConfig.SaveServer(GuildObj);
        }
예제 #11
0
        public async Task JoinC(string color)
        {
            var guild = GuildConfig.GetServer(Context.Guild);

            if (guild.RoleConfigurations.ColorRoleList.AllowCustomColorRoles)
            {
                CustomColor DCol;
                var         Hexed = false;
                if (color.StartsWith("#"))
                {
                    color = color.Replace("#", "");
                    Hexed = true;
                }

                if (Enum.TryParse(color, out GuildConfig.roleConfigurations.ColorRoles.Colours ECol) && !Hexed)
                {
                    DCol = getCol(ECol);
                }
                else
                {
                    DCol = getCol(color);
                }

                var colorrole = Context.Guild.Roles.FirstOrDefault(x => string.Equals(x.Name, $"#{DCol.ColorNameStripped.ToString()}", StringComparison.CurrentCultureIgnoreCase));
                if (colorrole == null)
                {
                    var newrole = await Context.Guild.CreateRoleAsync($"#{DCol.ColorNameStripped.ToLower()}");

                    var position = (Context.Guild as SocketGuild).Roles.Where(r => r.Members.Select(m => m.Id).Contains(Context.Client.CurrentUser.Id)).Max(x => x.Position);
                    await newrole.ModifyAsync(x => x.Position = position - 1);

                    await newrole.ModifyAsync(x => x.Color = DCol.Color);

                    colorrole = newrole;
                }

                var croles = (Context.User as SocketGuildUser).Roles.Where(x => x.Name.StartsWith("#")).ToList();
                if (croles.Any())
                {
                    await(Context.User as SocketGuildUser).RemoveRolesAsync(croles);
                }

                await(Context.User as IGuildUser).AddRoleAsync(colorrole);
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Description = $"Success, you have been given the role {colorrole.Mention}",
                    Color       = DCol.Color
                });
            }
            else
            {
                //Not Enabled
                await ReplyAsync("Color Error, Not enabled by administrator");
            }
        }
예제 #12
0
        public async Task SetModLogChannel()
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.ModLogChannel = Context.Channel.Id;

            GuildConfig.SaveServer(jsonObj);

            await ReplyAsync($"Mod Log will now be sent in:\n" +
                             $"{Context.Channel.Name}");
        }
예제 #13
0
        public async Task ToggleModLog()
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.LogModCommands = !jsonObj.LogModCommands;

            GuildConfig.SaveServer(jsonObj);

            await ReplyAsync($"Log Mod Commands: {jsonObj.LogModCommands}\n" +
                             $"Use the SetModLogChannel Command so set the channel where these will be sent!");
        }
예제 #14
0
        public async Task PMSGRaw()
        {
            var guild = GuildConfig.GetServer(Context.Guild);
            var embed = new EmbedBuilder
            {
                Description = $"{Format.Sanitize(guild.PartnerSetup.Message)}",
                Color       = Color.Blue
            };

            await ReplyAsync("", false, embed.Build());
        }
예제 #15
0
        public async Task BlMessage([Remainder] string blmess = null)
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.BlacklistMessage = blmess ?? "";


            GuildConfig.SaveServer(jsonObj, Context.Guild);

            await ReplyAsync("The blacklist has been cleared.");
        }
예제 #16
0
파일: Tags.cs 프로젝트: ZeroCry/Passive-BOT
        public async Task Tag(string tagname = null)
        {
            if (tagname == null)
            {
                var tags = GuildConfig.GetServer(Context.Guild).Dict;
                if (tags.Count > 0)
                {
                    var taglist = string.Join(", ", tags.Select(x => x.Tagname));
                    await ReplyAsync($"**Tags:** {taglist}");
                }
                else
                {
                    await ReplyAsync("This server has no tags yet.");
                }
            }
            else
            {
                var server = GuildConfig.GetServer(Context.Guild);
                var embed  = new EmbedBuilder();
                if (server.Dict.Count > 0)
                {
                    var tag = server.Dict.FirstOrDefault(x =>
                                                         string.Equals(x.Tagname, tagname, StringComparison.CurrentCultureIgnoreCase));
                    if (tag == null)
                    {
                        await ReplyAsync($"No tag with the name **{tagname}** exists.");
                    }
                    else
                    {
                        string ownername;
                        try
                        {
                            var own = await Context.Guild.GetUserAsync(tag.Creator);

                            ownername = own.Username;
                        }
                        catch
                        {
                            ownername = "Owner Left";
                        }

                        embed.AddField(tag.Tagname, tag.Content);
                        embed.WithFooter(x =>
                        {
                            x.Text =
                                $"Tag Owner: {ownername} || Uses: {tag.uses} || Command Invokee: {Context.User.Username}";
                        });
                        tag.uses++;
                        GuildConfig.SaveServer(server);
                        await ReplyAsync("", false, embed.Build());
                    }
                }
            }
        }
예제 #17
0
            public async Task InitStore()
            {
                var guildobj = GuildConfig.GetServer(Context.Guild);
                var sitems   = new List <GuildConfig.gambling.TheStore.Storeitem>
                {
                    new GuildConfig.gambling.TheStore.Storeitem
                    {
                        ItemName = ":wrench:",
                        ItemID   = -15,
                        Hidden   = true,
                        cost     = 15
                    },
                    new GuildConfig.gambling.TheStore.Storeitem
                    {
                        ItemName = ":evergreen_tree:",
                        ItemID   = -10,
                        Hidden   = true,
                        cost     = 10
                    },
                    new GuildConfig.gambling.TheStore.Storeitem
                    {
                        ItemName = ":full_moon:",
                        ItemID   = -5,
                        Hidden   = true,
                        cost     = 12
                    },
                    new GuildConfig.gambling.TheStore.Storeitem
                    {
                        ItemName = ":zap:",
                        ItemID   = -16,
                        Hidden   = true,
                        cost     = 50
                    },
                    new GuildConfig.gambling.TheStore.Storeitem
                    {
                        ItemName = ":apple:",
                        ItemID   = -11,
                        Hidden   = true,
                        cost     = 25
                    },
                    new GuildConfig.gambling.TheStore.Storeitem
                    {
                        ItemName = ":gem:",
                        ItemID   = -6,
                        Hidden   = true,
                        cost     = 100
                    }
                };

                guildobj.Gambling.Store.ShowItems.AddRange(sitems);
                GuildConfig.SaveServer(guildobj);
                await ReplyAsync("Added");
            }
예제 #18
0
        public async Task SetMod(IRole modRole)
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            if (!jsonObj.RoleConfigurations.ModeratorRoleList.Contains(modRole.Id))
            {
                jsonObj.RoleConfigurations.ModeratorRoleList.Add(modRole.Id);
            }

            GuildConfig.SaveServer(jsonObj);

            await ReplyAsync($"{modRole.Mention} has been added to the moderator roles");
        }
예제 #19
0
        public async Task ShowLVRewards()
        {
            var GuildObj = GuildConfig.GetServer(Context.Guild);

            var embed = new EmbedBuilder
            {
                Title       = $"Level Rewards in {Context.Guild.Name}",
                Description =
                    $"Reward Roles:\n {(GuildObj.Levels.LevelRoles.Any() ? string.Join("\n", GuildObj.Levels.LevelRoles.Where(lr => Context.Guild.Roles.Select(x => x.Id).Contains(lr.RoleID)).Select(x => $"{Context.Guild.GetRole(x.RoleID)?.Mention ?? "ERROR"} LV: {x.LevelToEnter}")) : "N/A")}"
            };

            await ReplyAsync("", false, embed.Build());
        }
예제 #20
0
        public async Task SellItem(int quantity, [Remainder] string name = null)
        {
            await Setupuser(Context.Guild, Context.User);

            var guildobj = GuildConfig.GetServer(Context.Guild);

            var selecteditem = guildobj.Gambling.Store.ShowItems.FirstOrDefault(x =>
                                                                                string.Equals(name, x.ItemName, StringComparison.InvariantCultureIgnoreCase));
            var uprofile = guildobj.Gambling.Users.FirstOrDefault(x => x.userID == Context.User.Id);

            if (selecteditem == null)
            {
                await ReplyAsync($"{name} is not an item i the store.");

                return;
            }

            var invitem = uprofile.Inventory.Where(x => x.Durability == 100)
                          .FirstOrDefault(x => x.ItemID == selecteditem.ItemID);

            if (invitem == null)
            {
                await ReplyAsync(
                    $"You do not own this item (or you have already used it and it's durability has decreased.)");

                return;
            }

            if (invitem.quantity < quantity)
            {
                await ReplyAsync($"You cannot sell this many of that item");

                return;
            }

            if (invitem.quantity - quantity == 0)
            {
                uprofile.Inventory.Remove(invitem);
            }
            else
            {
                invitem.quantity = invitem.quantity - quantity;
            }

            uprofile.coins = uprofile.coins + selecteditem.cost * quantity;
            if (selecteditem.quantity != -1)
            {
                selecteditem.quantity = selecteditem.quantity + quantity;
            }
            GuildConfig.SaveServer(guildobj);
        }
예제 #21
0
        public async Task ResetKick()
        {
            var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json");

            if (!File.Exists(file))
            {
                GuildConfig.Setup(Context.Guild);
            }
            var config = GuildConfig.GetServer(Context.Guild);

            config.Kicking = new List <GuildConfig.Kicks>();
            GuildConfig.SaveServer(config, Context.Guild);
            await ReplyAsync($"All server kicks have been cleared.");
        }
예제 #22
0
 public async Task UnHideCommand([Remainder] string cmdname = null)
 {
     if (_service.Commands.Any(x => string.Equals(x.Name, cmdname, StringComparison.CurrentCultureIgnoreCase)))
     {
         var jsonObj = GuildConfig.GetServer(Context.Guild);
         jsonObj.Visibilityconfig.BlacklistedCommands.Remove(cmdname.ToLower());
         GuildConfig.SaveServer(jsonObj);
         await ReplyAsync($"{cmdname} is now accessible to non-admins again");
     }
     else
     {
         await ReplyAsync($"No command found with this name.");
     }
 }
예제 #23
0
        public async Task CreateGiveaway([Remainder] string description)
        {
            var server = GuildConfig.GetServer(Context.Guild);

            var comp = new GuildConfig().Comp;

            comp.Message = description;
            comp.Users   = new List <ulong>();
            comp.Creator = Context.User.Id;
            server.Comp  = comp;

            GuildConfig.SaveServer(server);

            await ReplyAsync("GiveAway Created.");
        }
예제 #24
0
 public async Task HideModule([Remainder] string modulename = null)
 {
     if (_service.Modules.Any(x => string.Equals(x.Name, modulename, StringComparison.CurrentCultureIgnoreCase)))
     {
         var jsonObj = GuildConfig.GetServer(Context.Guild);
         jsonObj.Visibilityconfig.BlacklistedModules.Add(modulename.ToLower());
         GuildConfig.SaveServer(jsonObj);
         await ReplyAsync(
             $"Commands from {modulename} will no longer be accessible or visible to regular users");
     }
     else
     {
         await ReplyAsync($"No module found with this name.");
     }
 }
예제 #25
0
        public async Task NoMention(bool status)
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.MentionAll = status;
            GuildConfig.SaveServer(jsonObj, Context.Guild);

            if (status)
            {
                await ReplyAsync("Mass Mentions will now be deleted!");
            }
            else
            {
                await ReplyAsync("Mass Mentions are now allowed to be sent");
            }
        }
예제 #26
0
        public async Task NoInvite(bool status)
        {
            var jsonObj = GuildConfig.GetServer(Context.Guild);

            jsonObj.Invite = status;
            GuildConfig.SaveServer(jsonObj, Context.Guild);

            if (status)
            {
                await ReplyAsync("Invite links will now be deleted!");
            }
            else
            {
                await ReplyAsync("Invite links are now allowed to be sent");
            }
        }
예제 #27
0
        public async Task Removelevel(IRole role)
        {
            var GuildObj = GuildConfig.GetServer(Context.Guild);

            if (GuildObj.Levels.LevelRoles.Any(x => x.RoleID == role.Id))
            {
                GuildObj.Levels.LevelRoles.Remove(GuildObj.Levels.LevelRoles.FirstOrDefault(x => x.RoleID == role.Id));
                await ReplyAsync($"Success Level Role has been removed.");

                GuildConfig.SaveServer(GuildObj);
            }
            else
            {
                await ReplyAsync($"ERROR: This role is not a level!");
            }
        }
예제 #28
0
        public async Task MineTask()
        {
            var rnd        = new Random();
            var guildobj   = GuildConfig.GetServer(Context.Guild);
            var uprofile   = guildobj.Gambling.Users.FirstOrDefault(x => x.userID == Context.User.Id);
            var rvalue     = rnd.Next(1, 8);
            var rreward    = rnd.Next(0, 10);
            var CheckStone = uprofile.Inventory.FirstOrDefault(x => x.ItemID == -5);

            if (CheckStone == null)
            {
                uprofile.Inventory.Add(new GuildConfig.gambling.user.item
                {
                    ItemID   = -5,
                    quantity = rvalue
                });
            }
            else
            {
                CheckStone.quantity = CheckStone.quantity + rvalue;
            }

            var rewardstr = "";

            if (rreward == 9)
            {
                var CheckGem = uprofile.Inventory.FirstOrDefault(x => x.ItemID == -6);
                if (CheckGem == null)
                {
                    uprofile.Inventory.Add(new GuildConfig.gambling.user.item
                    {
                        ItemID   = -6,
                        quantity = 1
                    });
                }
                else
                {
                    CheckGem.quantity++;
                }

                rewardstr = $"Congratulations, you also mined: 1 Gem! :gem:";
            }

            await ReplyAsync($":full_moon: You Mined {rvalue} Stone!\n{rewardstr}");

            GuildConfig.SaveServer(guildobj);
        }
예제 #29
0
        public async Task WoodCut()
        {
            var rnd       = new Random();
            var guildobj  = GuildConfig.GetServer(Context.Guild);
            var uprofile  = guildobj.Gambling.Users.FirstOrDefault(x => x.userID == Context.User.Id);
            var rvalue    = rnd.Next(1, 10);
            var rreward   = rnd.Next(0, 10);
            var CheckWood = uprofile.Inventory.FirstOrDefault(x => x.ItemID == -10);

            if (CheckWood == null)
            {
                uprofile.Inventory.Add(new GuildConfig.gambling.user.item
                {
                    ItemID   = -10,
                    quantity = rvalue
                });
            }
            else
            {
                CheckWood.quantity = CheckWood.quantity + rvalue;
            }

            var rewardstr = "";

            if (rreward == 9)
            {
                var CheckApple = uprofile.Inventory.FirstOrDefault(x => x.ItemID == -11);
                if (CheckApple == null)
                {
                    uprofile.Inventory.Add(new GuildConfig.gambling.user.item
                    {
                        ItemID   = -11,
                        quantity = 1
                    });
                }
                else
                {
                    CheckApple.quantity++;
                }

                rewardstr = $"Congratulations, you also Picked: 1 Apple! :apple:";
            }

            await ReplyAsync($":evergreen_tree: You Cut {rvalue} Logs!\n{rewardstr}");

            GuildConfig.SaveServer(guildobj);
        }
예제 #30
0
        public async Task WarnUser(SocketGuildUser user, [Remainder] string reason = null)
        {
            var file = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json");

            if (!File.Exists(file))
            {
                GuildConfig.Setup(Context.Guild);
            }
            var embed = new EmbedBuilder();

            if (reason == null)
            {
                embed.AddField("Error", "Please Specify a reason for warning the user, ie\n" +
                               "`.warn @noobnoob being a noob");
                await ReplyAsync("", false, embed.Build());

                return;
            }
            var config = GuildConfig.GetServer(Context.Guild);

            var add = new GuildConfig.Warns
            {
                Moderator = Context.User.Username,
                Reason    = reason,
                User      = user.Username,
                UserId    = user.Id
            };

            try
            {
                await user.SendMessageAsync($"You have been warned in {Context.Guild.Name} for:\n" +
                                            $"`{reason}`");
            }
            catch
            {
                //
            }

            config.Warnings.Add(add);
            GuildConfig.SaveServer(config, Context.Guild);

            embed.AddField("User Warned", $"User: {user.Username}\n" +
                           $"UserID: {user.Id}\n" +
                           $"Moderator: {Context.User.Username}\n" +
                           $"Reason: {reason}");
            await ReplyAsync("", false, embed.Build());
        }