Auto Roles - rules that give members roles when they join the server.

A rule gives its roleIds (and removes its removeRoleIds) when EVERY condition it sets holds: who it applies to (humans, bots or both), account age, passing membership screening, and - Premium - the invite the member joined with. Premium also adds timers: a delay before the roles are given, and a duration after which they are removed again. Each rule is judged on its own, so a member can match several. Rules apply to NEW joins only.

Invite rules: inviteCodes holds real invite codes plus two special values - 'vanity' (the server's vanity URL) and 'unknown' (Noti could not tell which invite was used, for example two members joining at once, or Noti missing Manage Server). A real code never matches an unclear join; only a rule that lists 'unknown' does, which makes it the opt-in fallback.

A server that lost Premium keeps its rules, but a rule using invites or timers stops applying until it is edited back under the plan - it never falls back to firing for every join.

Behind the autoRoles launch flag: every method answers 403 until it is beta/public for the caller, and 403 when the server's plan lacks Auto Roles. data.limits from getGuildAutoRoles says what the plan allows, so the page can lock controls and disable "add rule".

Constructors

Methods

  • Create a rule. name and at least one of roleIds are required; everything else takes its default.

    400 names the problem: a bad value, a role both given and removed, a minimum account age above the maximum, or a role Noti cannot use (missing, managed, @everyone, above Noti's role, or Noti lacks Manage Roles). 403 when the server is at its plan's rule limit, or sends a delay, duration or invite codes without Premium.

    Parameters

    • __namedParameters: {
          auth: string;
          guildId: string;
          name: string;
          roleIds: string[];
      } & Omit<GuildAutoRoleUpdate, "name" | "roleIds">

    Returns Promise<WebResponse<GuildAutoRoleData>>

  • Delete a rule. Roles it already gave stay; a pending delayed grant finds the rule gone and does nothing. 404 when it is not this server's.

    Parameters

    • __namedParameters: {
          auth: string;
          guildId: string;
          ruleId: string;
      }
      • auth: string
      • guildId: string
      • ruleId: string

    Returns Promise<WebResponse<{
        deleted: string;
    }>>

  • The server's invites, for the rule editor's invite picker. Premium (403 without invite rules).

    canRead: false means Noti lacks Manage Server - the same permission it needs to tell which invite a member used. Show a warning: without it, only rules listing 'unknown' can ever match. 503 when the server's shard cannot be reached.

    Parameters

    • __namedParameters: {
          auth: string;
          guildId: string;
      }
      • auth: string
      • guildId: string

    Returns Promise<WebResponse<GuildAutoRoleInvitesData>>

  • Change a rule, field by field - omit one to leave it unchanged. Checked against the rule as it will be, so sending only minAccountAgeDays is still refused when it passes the stored maximum. Clearing a Premium field (null, or [] for inviteCodes) is always accepted, so a server that lost Premium can get its rules back under its plan. Only roles the change ADDS are checked against the server. 404 when the rule is not this server's.

    Parameters

    • __namedParameters: {
          auth: string;
          guildId: string;
          ruleId: string;
      } & GuildAutoRoleUpdate

    Returns Promise<WebResponse<GuildAutoRoleData>>