Skip to content

Commit

Permalink
Merge pull request #171 from Cyb3r-Jak3/mark-role-postion-as-computed
Browse files Browse the repository at this point in the history
Mark guild Role position as computed
  • Loading branch information
Lucky3028 authored Oct 28, 2024
2 parents 809232a + 3cd9165 commit 3015043
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions discord/resource_discord_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ func resourceDiscordRole() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: false,
Description: "The name of the role.",
Description: "Name of the role.",
},
"permissions": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
ForceNew: false,
Description: "The permission bits of the role.",
Description: "Permission bits of the role.",
},
"color": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Description: "The integer representation of the role color with decimal color code.",
Description: "Integer representation of the role color with decimal color code.",
},
"hoist": {
Type: schema.TypeBool,
Expand All @@ -63,10 +63,10 @@ func resourceDiscordRole() *schema.Resource {
"position": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Computed: true,
ForceNew: false,
ValidateFunc: validation.IntAtLeast(1),
Description: "The position of the role. This is reverse indexed, with `@everyone` being `0`.",
Description: "Position of the role. This is reverse indexed, with `@everyone` being `0`.",
},
"managed": {
Type: schema.TypeBool,
Expand All @@ -76,7 +76,7 @@ func resourceDiscordRole() *schema.Resource {
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of the role.",
Description: "ID of the role.",
},
},
}
Expand Down Expand Up @@ -133,6 +133,8 @@ func resourceRoleCreate(ctx context.Context, d *schema.ResourceData, m interface
} else {
d.Set("position", newPosition)
}
} else {
d.Set("position", role.Position)
}

d.SetId(role.ID)
Expand Down
10 changes: 5 additions & 5 deletions docs/resources/role.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ resource "discord_role" "moderator" {

### Required

- `name` (String) The name of the role.
- `name` (String) Name of the role.
- `server_id` (String) Which server the role will be in.

### Optional

- `color` (Number) The integer representation of the role color with decimal color code.
- `color` (Number) Integer representation of the role color with decimal color code.
- `hoist` (Boolean) Whether the role should be hoisted. (default `false`)
- `mentionable` (Boolean) Whether the role should be mentionable. (default `false`)
- `permissions` (Number) The permission bits of the role.
- `position` (Number) The position of the role. This is reverse indexed, with `@everyone` being `0`.
- `permissions` (Number) Permission bits of the role.
- `position` (Number) Position of the role. This is reverse indexed, with `@everyone` being `0`.

### Read-Only

- `id` (String) The ID of the role.
- `id` (String) ID of the role.
- `managed` (Boolean) Whether this role is managed by another service.

## Import
Expand Down

0 comments on commit 3015043

Please sign in to comment.