Пример #1
0
        public async Task AddRoleToRoleMention(string roleToChangeName, string roleToNotAllowToMention)
        {
            SocketRole roleNotToMention = RoleUtils.GetGuildRole(Context.Guild, roleToChangeName);
            SocketRole role             = RoleUtils.GetGuildRole(Context.Guild, roleToNotAllowToMention);

            if (roleNotToMention == null || role == null)
            {
                await Context.Channel.SendMessageAsync(
                    $"Either the **{roleToChangeName}** role doesn't exist or the **{roleToNotAllowToMention}** role doesn't exist!");

                return;
            }

            if (!role.IsMentionable)
            {
                await Context.Channel.SendMessageAsync($"The **{role}** role is already not mentionable by anyone!");

                return;
            }

            ServerListsManager.GetServer(Context.Guild).CreateRoleToRoleMention(roleNotToMention.Id, role.Id);
            ServerListsManager.SaveServerList();

            await Context.Channel.SendMessageAsync(
                $"The **{roleNotToMention.Name}** role will not be allowed to mention the **{role.Name}** role.");
        }
Пример #2
0
        public async Task SetRuleRole([Remainder] string roleName = "")
        {
            if (string.IsNullOrWhiteSpace(roleName))             //Make sure the user actually provided a role
            {
                await Context.Channel.SendMessageAsync("You need to provide a role name!");

                return;
            }

            SocketRole role = RoleUtils.GetGuildRole(Context.Guild, roleName);

            if (role == null)             //Make sure the role exists
            {
                await Context.Channel.SendMessageAsync($"The role **{roleName}** doesn't exist!");

                return;
            }

            //Modify the server settings to update for the new role
            ServerListsManager.GetServer(Context.Guild).RuleRoleId = role.Id;
            ServerListsManager.SaveServerList();

            await Context.Channel.SendMessageAsync(
                $"The role that users shell receive after successfully reacting to the rules will be the **{role.Name}** role.");
        }
Пример #3
0
        public async Task GetOptRoles()
        {
            //Get all opt roles
            OptRole[] optRoles = ServerListsManager.GetServer(Context.Guild).RoleGives.ToArray();

            //Setup string builder
            StringBuilder message = new StringBuilder();

            message.Append("**Opt Roles**\n");

            if (optRoles.Length == 0)
            {
                //There are no opt roles
                message.Append("There are no opt roles!");
            }
            else
            {
                foreach (OptRole optRole in optRoles)
                {
                    //There are opt roles, so add them to the String Builder
                    IRole role = RoleUtils.GetGuildRole(Context.Guild, optRole.RoleToGiveId);

                    message.Append(optRole.RoleRequiredId == 0
                                                ? $"`{optRole.Name}` -> **{role.Name}**\n"
                                                : $"`{optRole.Name}` -> **{role.Name}** (Requires **{RoleUtils.GetGuildRole(Context.Guild, optRole.RoleRequiredId).Name}**)\n");
                }
            }

            await Context.Channel.SendMessageAsync(message.ToString());
        }
Пример #4
0
        public async Task AddOptRole(string optRoleBaseName, string roleToAssignName,
                                     [Remainder] string requiredRoleName = "")
        {
            SocketRole roleToAssign = RoleUtils.GetGuildRole(Context.Guild, roleToAssignName);

            //Check to make sure the role exists first
            if (roleToAssign == null)
            {
                await Context.Channel.SendMessageAsync("You need to input a valid role to give!");

                return;
            }

            //If a required role was specified, check to make sure it exists
            SocketRole requiredRole = null;

            if (!string.IsNullOrWhiteSpace(requiredRoleName))
            {
                requiredRole = RoleUtils.GetGuildRole(Context.Guild, requiredRoleName);
                if (requiredRole == null)
                {
                    await Context.Channel.SendMessageAsync($"Role {requiredRoleName} doesn't exist!");

                    return;
                }
            }

            ServerList server = ServerListsManager.GetServer(Context.Guild);

            //Check to make sure a role give doesn't already exist first
            if (server.GetOptRole(optRoleBaseName) != null)
            {
                await Context.Channel.SendMessageAsync(
                    $"An opt role with the name '{optRoleBaseName}' already exists!");

                return;
            }

            //Create and add our new opt role
            OptRole roleGive = new OptRole
            {
                Name           = optRoleBaseName,
                RoleToGiveId   = roleToAssign.Id,
                RoleRequiredId = 0
            };

            if (requiredRole != null)
            {
                roleGive.RoleRequiredId = requiredRole.Id;
            }

            server.RoleGives.Add(roleGive);
            ServerListsManager.SaveServerList();

            await Context.Channel.SendMessageAsync($"An opt role with the name `{optRoleBaseName}` was created.");
        }
Пример #5
0
		/// <summary>
		/// Check the user to see if they have permissions to use the command
		/// </summary>
		/// <param name="context"></param>
		/// <param name="server"></param>
		/// <param name="argPos"></param>
		/// <returns></returns>
		private bool CheckUserPermission(SocketCommandContext context, ServerList server, int argPos)
		{
			//Get the command first
			SearchResult cmdSearchResult = _commands.Search(context, argPos);
			if (!cmdSearchResult.IsSuccess) return true;

			ServerList.CommandPermission perm = server.GetCommandInfo(cmdSearchResult.Commands[0].Command.Name);
			if (perm == null) return true;

			//If they are an administrator they override permissions
			return ((SocketGuildUser) context.User).GuildPermissions.Administrator ||
			       ((SocketGuildUser) context.User).Roles.Any(role =>
				       perm.Roles.Any(permRole => role == RoleUtils.GetGuildRole(context.Guild, permRole)));
		}
Пример #6
0
        public async Task RolePoints()
        {
            StringBuilder sb     = new StringBuilder();
            ServerList    server = ServerListsManager.GetServer(Context.Guild);

            sb.Append("__**Server Point Roles**__\n");

            foreach (ServerRolePoints rolePoint in server.ServerRolePoints)
            {
                sb.Append(
                    $"[{RoleUtils.GetGuildRole(Context.Guild, rolePoint.RoleId)}] **{rolePoint.PointsRequired}**\n");
            }

            await Context.Channel.SendMessageAsync(sb.ToString());
        }
Пример #7
0
        public async Task GiveOptRole([Remainder] string optRoleName = "")
        {
            SocketGuildUser user = (SocketGuildUser)Context.User;

            if (user == null)
            {
                return;
            }

            //Make sure the imputed optRoleName is not empty or null
            if (string.IsNullOrWhiteSpace(optRoleName))
            {
                await Context.Channel.SendMessageAsync("You need to input an opt role name!");

                return;
            }

            //Get the opt role
            OptRole optRole = ServerListsManager.GetServer(Context.Guild).GetOptRole(optRoleName);

            if (optRole == null)             //And make sure it exists!
            {
                await Context.Channel.SendMessageAsync("That opt role doesn't exist!");

                return;
            }

            //If the opt role has a required role, make sure the user has it
            if (optRole.RoleRequiredId != 0)
            {
                //The user doesn't have the required role
                if (!user.UserHaveRole(optRole.RoleRequiredId))
                {
                    await Context.Channel.SendMessageAsync("You do not meet the requirements to get this opt role!");

                    return;
                }
            }

            //Give the user the role
            await user.AddRoleAsync(RoleUtils.GetGuildRole(Context.Guild, optRole.RoleToGiveId));

            //Say to the user that they now have the role
            await Context.Channel.SendMessageAsync(
                $"You now have the **{RoleUtils.GetGuildRole(Context.Guild, optRole.RoleToGiveId).Name}** role, {user.Mention}.");
        }
Пример #8
0
        public async Task AddRolePoints(uint pointsAmount, [Remainder] string roleName)
        {
            //First, lets make sure that the role actually exists
            SocketRole role = RoleUtils.GetGuildRole(Context.Guild, roleName);

            if (role == null)
            {
                await Context.Channel.SendMessageAsync("That role doesn't exists!");

                return;
            }

            ServerList server = ServerListsManager.GetServer(Context.Guild);

            //Make sure a point role with that many points doesn't exist
            if (server.GetServerRolePoints(pointsAmount).PointsRequired != 0)
            {
                await Context.Channel.SendMessageAsync(
                    $"A role is already given when a user gets `{pointsAmount}` points.");

                return;
            }

            //Can't have a point role lower then the amount of points given each time
            if (pointsAmount >= server.PointGiveAmount)
            {
                await Context.Channel.SendMessageAsync(
                    $"You have to set required points higher then `{server.PointGiveAmount}`!");

                return;
            }

            ServerRolePoints serverRolePoints = new ServerRolePoints
            {
                RoleId         = role.Id,
                PointsRequired = pointsAmount
            };

            //Add our point role to our list
            server.ServerRolePoints.Add(serverRolePoints);
            ServerListsManager.SaveServerList();

            await Context.Channel.SendMessageAsync(
                $"Ok, when a user gets {pointsAmount} points they shell receive the **{role.Name}** role.\nPlease note any user who already have {pointsAmount} points won't get the role.");
        }
Пример #9
0
        public async Task GetRolePings()
        {
            ServerList server = ServerListsManager.GetServer(Context.Guild);

            StringBuilder builder = new StringBuilder();

            builder.Append("__**Role to Roles**__\n```");

            foreach (ServerRoleToRoleMention roleToRole in server.RoleToRoleMentions)
            {
                builder.Append(
                    $"{RoleUtils.GetGuildRole(Context.Guild, roleToRole.RoleNotToMentionId).Name} =====> {RoleUtils.GetGuildRole(Context.Guild, roleToRole.RoleId).Name}\n");
            }

            builder.Append("```");

            await Context.Channel.SendMessageAsync(builder.ToString());
        }
Пример #10
0
        /// <summary>
        /// Checks if a given user is allowed to @mention a certain role, and warns them if not
        /// </summary>
        /// <param name="message">The message to check</param>
        /// <param name="user">The author of the message</param>
        /// <returns>Whether the user is allowed to do that action</returns>
        public bool CheckRoleMentions(SocketUserMessage message, SocketGuildUser user)
        {
            UserAccountServerData serverAccount =
                UserAccountsManager.GetAccount(user).GetOrCreateServer(user.Guild.Id);

            if (serverAccount.IsAccountNotWarnable)
            {
                return(false);
            }

            //If it is the owner of the Discord server, ignore
            if (user.Id == user.Guild.OwnerId)
            {
                return(false);
            }

            ServerList server = ServerListsManager.GetServer(user.Guild);

            //Go over each role a user has
            foreach (SocketRole role in user.Roles)
            {
                foreach (ServerRoleToRoleMention notToMentionRoles in server.RoleToRoleMentions.Where(notToMentionRoles =>
                                                                                                      role.Id == notToMentionRoles.RoleNotToMentionId))
                {
                    message.DeleteAsync();

                    if (serverAccount.RoleToRoleMentionWarnings >=
                        server.AntiSpamSettings.RoleToRoleMentionWarnings)
                    {
                        message.Channel.SendMessageAsync(
                            $"Hey {user.Mention}, you have been pinging the **{RoleUtils.GetGuildRole(user.Guild, notToMentionRoles.RoleId).Name}** role, which you are not allowed to ping!\nA warning has been added to your account, for info see your profile.");
                        serverAccount.Warnings++;
                        UserAccountsManager.SaveAccounts();
                    }

                    serverAccount.RoleToRoleMentionWarnings++;

                    return(true);
                }
            }

            return(false);
        }
Пример #11
0
        public async Task RemoveRoleToRoleMention(string roleToChangeName, string roleAllowedToMentionName)
        {
            SocketRole roleNotToMention = RoleUtils.GetGuildRole(Context.Guild, roleToChangeName);
            SocketRole role             = RoleUtils.GetGuildRole(Context.Guild, roleAllowedToMentionName);

            if (roleNotToMention == null || role == null)
            {
                await Context.Channel.SendMessageAsync(
                    $"Either the **{roleToChangeName}** role doesn't exist or the **{roleAllowedToMentionName}** role doesn't exist!");

                return;
            }

            ServerList server = ServerListsManager.GetServer(Context.Guild);
            List <ServerRoleToRoleMention> roleToRoleMentionsWithRole = server.GetRoleToRoleMention(role.Id);

            if (roleToRoleMentionsWithRole.Count == 0)
            {
                await Context.Channel.SendMessageAsync($"The **{role}** role doesn't have any preventions on it!");

                return;
            }

            foreach (ServerRoleToRoleMention roleMention in roleToRoleMentionsWithRole)
            {
                //We found it
                if (roleMention.RoleNotToMentionId == roleNotToMention.Id)
                {
                    server.RoleToRoleMentions.Remove(roleMention);
                    await Context.Channel.SendMessageAsync(
                        $"The **{roleNotToMention.Name}** role can now mention the **{role.Name}** role.");

                    ServerListsManager.SaveServerList();

                    return;
                }

                await Context.Channel.SendMessageAsync(
                    $"The **{roleNotToMention.Name}** role can already mention the **{role}** role.");
            }
        }
Пример #12
0
        public async Task HasRole(string roleName, SocketGuildUser user)
        {
            //Get the role
            IRole role = RoleUtils.GetGuildRole(Context.Guild, roleName);

            if (role == null)
            {
                await Context.Channel.SendMessageAsync("That role doesn't exist!");

                return;
            }

            if (user.UserHaveRole(role.Id))
            {
                await Context.Channel.SendMessageAsync($"**{user.Username}** has the role **{role.Name}**.");
            }
            else
            {
                await Context.Channel.SendMessageAsync($"**{user.Username}** doesn't have the role **{role}**.");
            }
        }
Пример #13
0
        /// <summary>
        /// Gives a user server points, and gives them a role if they past a certain amount of points
        /// </summary>
        /// <param name="user"></param>
        /// <param name="channel"></param>
        /// <param name="amount"></param>
        public static async void GiveUserServerPoints(SocketGuildUser user, SocketTextChannel channel, uint amount)
        {
            UserAccountServerData userAccount = UserAccountsManager.GetAccount(user).GetOrCreateServer(user.Guild.Id);

            userAccount.Points += amount;

            UserAccountsManager.SaveAccounts();

            //Give the user a role if they have enough points for it.
            ServerList       server     = ServerListsManager.GetServer(user.Guild);
            ServerRolePoints serverRole =
                server.GetServerRolePoints(userAccount.Points);

            Logger.Debug("{@Username} now has {@Points} points on guild {@GuildId}", user.Username, userAccount.Points, user.Guild.Id);

            if (serverRole.PointsRequired == 0)
            {
                return;
            }
            await user.AddRoleAsync(RoleUtils.GetGuildRole(user.Guild, serverRole.RoleId));

            await channel.SendMessageAsync(
                $"Congrats {user.Mention}, you got {userAccount.Points} points and got the **{RoleUtils.GetGuildRole(user.Guild, serverRole.RoleId).Name}** role!");
        }
Пример #14
0
 private static string FormatRoles(IEnumerable <ulong> roles, SocketGuild guild)
 {
     return(roles.Aggregate("", (current, role) => current + $"{RoleUtils.GetGuildRole(guild, role).Name}, "));
 }
Пример #15
0
        public Task ReactionAdded(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel channel,
                                  SocketReaction reaction)
        {
            try
            {
                SocketGuildUser user = (SocketGuildUser)reaction.User;

                //Make sure user isn't null
                if (user == null)
                {
                    return(Task.CompletedTask);
                }

                //Make sure the user isn't a bot as well
                if (user.IsBot)
                {
                    return(Task.CompletedTask);
                }

                //Something happened, make sure the message ID isn't 0, this is just in case
                if (reaction.MessageId == 0)
                {
                    return(Task.CompletedTask);
                }

                SocketGuild guild  = ((SocketGuildChannel)channel).Guild;
                ServerList  server = ServerListsManager.GetServer(guild);

                //If the message the user reacted to is the rules message
                if (reaction.MessageId == server.RuleMessageId && server.RuleEnabled)
                {
                    if (reaction.Emote.Name != server.RuleReactionEmoji)                     //Check to make sure it is the right emoji
                    {
                        return(Task.CompletedTask);
                    }

                    //Add the role
                    SocketRole role = RoleUtils.GetGuildRole(guild, server.RuleRoleId);
                    user.AddRoleAsync(role);

                    return(Task.CompletedTask);
                }

                //If this message is a vote
                if (server.GetVote(reaction.MessageId) != null)
                {
                    Vote vote = server.GetVote(reaction.MessageId);
                    if (reaction.Emote.Name == vote.YesEmoji)
                    {
                        vote.YesCount++;
                    }
                    else if (reaction.Emote.Name == vote.NoEmoji)
                    {
                        vote.NoCount++;
                    }

                    ServerListsManager.SaveServerList();

                    return(Task.CompletedTask);
                }

                //So the reaction wasn't anything important, so add some XP to the user
                LevelingSystem.GiveUserXp(user, (SocketTextChannel)reaction.Channel, 5);
            }
            catch (Exception ex)
            {
                Logger.Error("An error occured while managing reaction added event! {@Exception}", ex);
            }

            return(Task.CompletedTask);
        }
Пример #16
0
        /// <summary>
        /// Stops a role from being able to use a command
        /// </summary>
        /// <param name="command"></param>
        /// <param name="roles"></param>
        /// <param name="channel"></param>
        /// <param name="guild"></param>
        /// <returns></returns>
        public async Task RemovePerm(string command, string[] roles, IMessageChannel channel, SocketGuild guild)
        {
            if (!CanModifyPerm(command))
            {
                await channel.SendMessageAsync($"Cannot set the permission of the command `{command}`.");

                return;
            }

            if (!DoesCmdExist(command))
            {
                await channel.SendMessageAsync($"The command `{command}` doesn't exist!");

                return;
            }

            List <IRole> iRoles = new List <IRole>();

            ServerList server = ServerListsManager.GetServer(guild);

            //Check all the imputed roles to see if they exists
            foreach (string role in roles)
            {
                IRole iRole = RoleUtils.GetGuildRole(guild, role);
                if (iRole == null)
                {
                    await channel.SendMessageAsync($"The role **{role}** doesn't exist!");

                    return;
                }

                iRoles.Add(iRole);
            }

            //Doesn't exist
            if (server.GetCommandInfo(command) == null)
            {
                await channel.SendMessageAsync($"The command `{command}` already has no roles assigned to it!");
            }
            else
            {
                //Check all roles and make sure they are assigned to the command
                foreach (IRole role in iRoles.Where(role => server.GetCommandInfo(command).GetRole(role.Id) == 0))
                {
                    await channel.SendMessageAsync(
                        $"The command `{command}` doesn't have the role **{role}** assigned to it!");

                    return;
                }

                //Now begin removing all the roles, since we know all the entered roles are already assigned to the command
                foreach (IRole role in iRoles)
                {
                    server.GetCommandInfo(command).Roles.Remove(server.GetCommandInfo(command).GetRole(role.Id));
                }

                //There are no more roles assigned to the command so remove it entirely
                RemoveAllCommandsWithNoRoles(server);

                ServerListsManager.SaveServerList();
                await channel.SendMessageAsync(RemovePermMessage(roles, command, server));
            }
        }
Пример #17
0
        /// <summary>
        /// Lets only a certain role use a command
        /// </summary>
        /// <param name="command"></param>
        /// <param name="roles"></param>
        /// <param name="channel"></param>
        /// <param name="guild"></param>
        /// <returns></returns>
        public async Task AddPerm(string command, string[] roles, IMessageChannel channel, SocketGuild guild)
        {
            if (!CanModifyPerm(command))
            {
                await channel.SendMessageAsync($"Cannot set the permission of **{command}**");

                return;
            }

            if (!DoesCmdExist(command))
            {
                await channel.SendMessageAsync($"The command **{command}** doesn't exist!");

                return;
            }

            List <IRole> iRoles = new List <IRole>();

            ServerList server = ServerListsManager.GetServer(guild);

            //Check all roles to see if they actually exists
            foreach (string role in roles)
            {
                if (RoleUtils.GetGuildRole(guild, role) != null)
                {
                    //Add all the roles Ids
                    iRoles.Add(RoleUtils.GetGuildRole(guild, role));
                    continue;
                }

                await channel.SendMessageAsync($"The role **{role}** doesn't exist!");

                return;
            }

            if (server.GetCommandInfo(command) == null)
            {
                //The command didn't exist before, so we will create a new one and just add the roles
                List <ulong> rolesIds = iRoles.Select(iRole => iRole.Id).ToList();

                server.CommandPermissions.Add(new ServerList.CommandPermission
                {
                    Command = command,
                    Roles   = rolesIds
                });

                ServerListsManager.SaveServerList();

                await channel.SendMessageAsync(AddPermMessage(roles, command));
            }
            else             //The command already exists
            {
                //Check to see if all the roles we are adding are non-existing roles assigned to the command
                foreach (IRole iRole in iRoles.Where(iRole => server.GetCommandInfo(command).GetRole(iRole.Id) != 0))
                {
                    await channel.SendMessageAsync(
                        $"The command `{command}` already has the role **{iRole.Name}**.");

                    return;
                }

                //Since we now know that all the roles we are assigning are not assigned, we add them to the list of roles
                foreach (IRole iRole in iRoles)
                {
                    server.GetCommandInfo(command).Roles.Add(iRole.Id);
                }

                ServerListsManager.SaveServerList();
                await channel.SendMessageAsync(AddPermMessage(roles, command));
            }
        }
Пример #18
0
        private async Task SetupServerQuick(SocketGuild guild, ISocketMessageChannel channel, SocketMessage message, bool addRulesMessage = true, bool setupWelcomeChannel = true,
                                            bool setupRuleReaction = true)
        {
            //Rules message
            string rules = _quickRulesText;

            if (addRulesMessage)
            {
                //Check rules file, or if rules where provided
                if (message.Attachments.Count != 0)
                {
                    Attachment attachment = message.Attachments.ElementAt(0);
                    if (!attachment.Filename.EndsWith(".txt"))
                    {
                        await channel.SendMessageAsync("The provided rules file isn't in a `.txt` file format!");

                        return;
                    }

                    rules = await Global.HttpClient.GetStringAsync(attachment.Url);
                }

                else if (string.IsNullOrWhiteSpace(rules) && message.Attachments.Count == 0)
                {
                    await channel.SendMessageAsync("You MUST provide a rules file!");

                    return;
                }
            }

            Logger.Log($"Running server quick setup on {guild.Name}({guild.Id})");

            ServerList server = ServerListsManager.GetServer(guild);

            //Setup the roles
            IRole memberRole = RoleUtils.GetGuildRole(guild, "Member");

            //There is already a role called "member"
            if (memberRole != null)
            {
                await memberRole.ModifyAsync(properties => properties.Permissions = _memberRoleGuildPermissions);
            }
            else
            {
                //create a new role called member
                memberRole = await guild.CreateRoleAsync("Member", _memberRoleGuildPermissions);

                await guild.EveryoneRole.ModifyAsync(properties => properties.Permissions = _everyoneRoleGuildPermissions);
            }

            //Setup the welcome channel
            if (setupWelcomeChannel)
            {
                ulong welcomeChannelId;

                //First, lets check if they already have a #welcome channel of sorts
                if (guild.SystemChannel == null)
                {
                    //They don't, so set one up
                    RestTextChannel welcomeChannel =
                        await guild.CreateTextChannelAsync("welcome",
                                                           properties => { properties.Topic    = "Were everyone gets a warm welcome!";
                                                                           properties.Position = 0; });

                    await welcomeChannel.AddPermissionOverwriteAsync(guild.EveryoneRole, _everyoneChannelPermissions);

                    welcomeChannelId = welcomeChannel.Id;
                }
                else
                {
                    //They already do, so alter the pre-existing one to have right perms, and to not have Discord random messages put there
                    await guild.SystemChannel.AddPermissionOverwriteAsync(guild.EveryoneRole, _everyoneChannelPermissions);

                    welcomeChannelId = guild.SystemChannel.Id;

                    await guild.ModifyAsync(properties => properties.SystemChannel = null);
                }

                //Setup welcome message
                server.WelcomeChannelId      = welcomeChannelId;
                server.WelcomeMessageEnabled = true;
                server.GoodbyeMessageEnabled = true;

                //Do a delay
                await Task.Delay(1000);
            }

            //Rule reaction
            if (addRulesMessage && setupRuleReaction)
            {
                //Setup rules channel
                RestTextChannel rulesChannel = await guild.CreateTextChannelAsync("rules",
                                                                                  properties => { properties.Position = 1;
                                                                                                  properties.Topic    = "Rules of this Discord server"; });

                await rulesChannel.AddPermissionOverwriteAsync(guild.EveryoneRole, _everyoneChannelPermissions);

                RestUserMessage rulesMessage = await rulesChannel.SendMessageAsync(rules);

                //Setup rules reaction
                await rulesMessage.AddReactionAsync(new Emoji(RulesEmoji));

                server.RuleReactionEmoji    = RulesEmoji;
                server.RuleMessageId        = rulesMessage.Id;
                server.RuleMessageChannelId = rulesChannel.Id;
                server.RuleRoleId           = memberRole.Id;
                server.RuleEnabled          = true;
            }

            //Setup the rest of the channels

            //General category
            await AddCategoryWithChannels(guild, memberRole, "General", 3);

            //Do a delay between categories
            await Task.Delay(500);

            //Gamming category
            await AddCategoryWithChannels(guild, memberRole, "Gamming", 4);

            //DONE!
            ServerListsManager.SaveServerList();
            await Context.Channel.SendMessageAsync("Quick Setup is done!");

            Logger.Log($"server quick setup on {guild.Name}({guild.Id}) is done!");
        }
Пример #19
0
        public async Task RoleUpdated(SocketRole before, SocketRole after)
        {
            SocketGuild guild  = before.Guild;
            ServerList  server = ServerListsManager.GetServer(guild);

            IDMChannel dm = await guild.Owner.GetOrCreateDMChannelAsync();

            //Check all server role pings to make sure they are still mentionable
            List <ServerRoleToRoleMention> rolesToRemove = server.RoleToRoleMentions
                                                           .Where(roleToRole => roleToRole.RoleId == after.Id && !after.IsMentionable).ToList();

            foreach (ServerRoleToRoleMention roleToRemove in rolesToRemove)
            {
                await dm.SendMessageAsync(
                    $"The **{after.Name}** role was changed to not mentionable so it was deleted from the **{RoleUtils.GetGuildRole(guild, roleToRemove.RoleNotToMentionId).Name}** => **{RoleUtils.GetGuildRole(guild, roleToRemove.RoleId).Name}** role to role ping list. ({guild.Name})");

                server.RoleToRoleMentions.Remove(roleToRemove);
                ServerListsManager.SaveServerList();

                return;
            }
        }