Exemple #1
0
        public async Task AddRole(CommandContext ctx, DiscordRole role)
        {
            if (!await CommandHelpers.CheckPermissions(ctx, RequiredPermissions))
            {
                return;
            }

            JoinRoles associatedJoinRoles =
                _joinRolesInteractions.JoinRoles.FirstOrDefault(joinRoles => joinRoles.Guild == ctx.Guild);

            if (associatedJoinRoles == null)
            {
                await ctx.RespondAsync("JoinRoles are not enabled for this guild");

                return;
            }

            JoinRole joinRole = new JoinRole(role);

            if (associatedJoinRoles.Roles.Contains(joinRole))
            {
                await ctx.RespondAsync("This role was already added");

                return;
            }

            associatedJoinRoles.Roles.Add(joinRole);
            await ctx.RespondAsync($"Added {role.Name} to the roles to add when a person joins");

            _joinRolesInteractions.SaveToFile();
        }
Exemple #2
0
 public SerializedJoinRole(JoinRole joinRole)
 {
     RoleId = joinRole.Role.Id;
 }