### Create and Configure System Channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/system_channel.md This example demonstrates how to create a text channel and then configure it as the system channel for a server. It also shows how to set system channel flags to suppress certain notifications. ```terraform resource "discord_text_channel" "system" { name = "discord-notifications" server_id = var.server_id } resource "discord_system_channel" "system" { server_id = discord_text_channel.system.server_id system_channel_id = discord_text_channel.system.id system_channel_flags = 6 # Suppress premium subscriptions (2) + server setup tips (4) } ``` -------------------------------- ### Import a System Channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/system_channel.md This example shows how to import an existing system channel into Terraform management. Ensure you replace `` with the actual ID of the system channel you wish to import. ```shell terraform import discord_system_channel.example "" ``` -------------------------------- ### Basic Server Onboarding Configuration Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server_onboarding.md Configures server onboarding with multiple choice and dropdown prompts. Ensure at least one default channel is specified when enabled. This example demonstrates setting up two prompts: one for user interests (multiple choice) and another for experience level (dropdown). ```terraform resource "discord_server_onboarding" "example" { server_id = var.server_id enabled = true mode = 1 # Advanced mode (0 = Default, 1 = Advanced) # Minimum 1 channel required by Discord default_channel_ids = [ discord_text_channel.general.id, ] prompt { title = "What are your interests?" type = 0 # Multiple choice single_select = false required = true in_onboarding = true option { title = "Gaming" description = "Access gaming channels and get the gamer role" emoji_name = "🎮" channel_ids = [discord_text_channel.gaming.id] role_ids = [discord_role.gamer.id] } option { title = "Development" description = "Join development discussion channels" emoji_name = "💻" channel_ids = [ discord_text_channel.dev_chat.id, discord_text_channel.code_help.id ] role_ids = [discord_role.developer.id] } option { title = "Community" description = "Join general community channels" emoji_name = "❤️" channel_ids = [discord_text_channel.community.id] } } prompt { title = "What is your experience level?" type = 1 # Dropdown single_select = true required = false in_onboarding = true option { title = "Beginner" description = "New to the community" role_ids = [discord_role.beginner.id] } option { title = "Intermediate" description = "Some experience" role_ids = [discord_role.intermediate.id] } option { title = "Expert" description = "Experienced member" role_ids = [discord_role.expert.id] } } } ``` -------------------------------- ### Import a Discord Webhook Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/webhook.md This example shows how to import an existing webhook into your Terraform state. Replace "" with the actual ID of the webhook you wish to import. ```shell terraform import discord_webhook.example "" ``` -------------------------------- ### Configure Auto Moderation Rules in Terraform Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/auto_moderation_rule.md Examples demonstrating how to define various Auto Moderation rules including keyword presets, mention spam limits, and regex link filtering. ```terraform # Built-in profanity / sexual content / slurs filter, alerting a mod log channel. resource "discord_auto_moderation_rule" "offensive_language" { server_id = var.server_id name = "Offensive language" event_type = 1 # MESSAGE_SEND trigger_type = 4 # KEYWORD_PRESET trigger_metadata { presets = [1, 2, 3] # profanity, sexual_content, slurs } exempt_roles = var.moderator_role_ids actions { type = 1 # BLOCK_MESSAGE metadata { custom_message = "Message blocked. Offensive language is not allowed." } } actions { type = 2 # SEND_ALERT_MESSAGE metadata { channel_id = var.mod_log_channel_id } } } # Mention-spam protection with a 5-mention cap. resource "discord_auto_moderation_rule" "mention_spam" { server_id = var.server_id name = "Anti mention spam" event_type = 1 trigger_type = 5 # MENTION_SPAM trigger_metadata { mention_total_limit = 5 mention_raid_protection_enabled = true } exempt_roles = var.moderator_role_ids actions { type = 1 metadata { custom_message = "Too many mentions in a single message." } } actions { type = 2 metadata { channel_id = var.mod_log_channel_id } } } # Regex link filter — blocks any http(s) link. resource "discord_auto_moderation_rule" "link_filter" { server_id = var.server_id name = "Link filter" event_type = 1 trigger_type = 1 # KEYWORD trigger_metadata { regex_patterns = ["https?://"] } exempt_roles = var.moderator_role_ids actions { type = 1 metadata { custom_message = "Links are not allowed. Contact a moderator." } } actions { type = 2 metadata { channel_id = var.mod_log_channel_id } } } ``` -------------------------------- ### discord_member_roles Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/member_roles.md Example of how to use the `discord_member_roles` resource to manage roles for a specific user on a server. This includes adding a role and explicitly setting a role to be removed. ```APIDOC ## discord_member_roles Resource ### Description A resource to manage member roles for a server. ### Usage ```terraform resource "discord_member_roles" "jake" { user_id = var.user_id server_id = var.server_id role { role_id = var.role_id_to_add } role { role_id = var.role_id_to_always_remove has_role = false } } ``` ### Schema #### Required - `role` (Block Set, Min: 1) Roles to manage. (see [below for nested schema](#nestedblock--role)) - `server_id` (String) ID of the server to manage roles in. - `user_id` (String) ID of the user to manage roles for. #### Read-Only - `id` (String) The ID of this resource. ### Nested Schema for `role` Required: - `role_id` (String) The role ID to manage. Optional: - `has_role` (Boolean) Whether the user should have the role. (default `true`) ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_member_roles.example ":" ``` ``` -------------------------------- ### discord_color Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/color.md The discord_color data source is a helper to get the integer representation of a hex or RGB color. You can provide either a hex code (e.g., "#4287f5") or an RGB string (e.g., "rgb(46, 204, 113)"). The output is available as the `dec` attribute. ```APIDOC ## discord_color (Data Source) A simple helper to get the integer representation of a hex or RGB color. ### Example Usage ```terraform data "discord_color" "blue" { hex = "#4287f5" } data "discord_color" "green" { rgb = "rgb(46, 204, 113)" } resource "discord_role" "blue" { // ... color = data.discord_color.blue.dec } resource "discord_role" "green" { // ... color = data.discord_color.green.dec } ``` ## Schema ### Optional - `hex` (String) The hex color code. Either this or `rgb` is required. - `rgb` (String) The RGB color, in format: `rgb(R, G, B)`. Either this or `hex` is required. ### Read-Only - `dec` (Number) The integer representation of the passed color. - `id` (String) The ID of this resource. ``` -------------------------------- ### Get Integer Color from Hex or RGB Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/color.md Use the discord_color data source to convert a hex color code (e.g., "#4287f5") or an RGB string (e.g., "rgb(46, 204, 113)") into its decimal integer representation. This is useful for setting colors on resources like discord_role. ```terraform data "discord_color" "blue" { hex = "#4287f5" } data "discord_color" "green" { rgb = "rgb(46, 204, 113)" } resource "discord_role" "blue" { // ... color = data.discord_color.blue.dec } resource "discord_role" "green" { // ... color = data.discord_color.green.dec } ``` -------------------------------- ### discord_server_onboarding Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server_onboarding.md Manages server onboarding configuration. Onboarding allows new members to customize their experience by answering questions that automatically assign roles and grant channel access. Requires at least 1 default channel. ```APIDOC ## discord_server_onboarding Resource ### Description Manages server onboarding configuration. Onboarding allows new members to customize their experience by answering questions that automatically assign roles and grant channel access. Requires at least 1 default channel. ### Schema #### Required - `default_channel_ids` (List of String) Channel IDs that members get opted into automatically. Minimum 1 required. - `server_id` (String) The ID of the server to configure onboarding for. #### Optional - `enabled` (Boolean) Whether onboarding is enabled. Requires minimum 1 default channel when enabled. - `mode` (Number) Onboarding mode. 0 = Default (counts default channels), 1 = Advanced (counts default channels and questions). - `prompt` (Block List) Prompts (questions) shown during onboarding and in the Channels & Roles customization tab. (see [below for nested schema](#nestedblock--prompt)) #### Read-Only - `id` (String) The ID of this resource. ### Nested Schema for `prompt` #### Required: - `option` (Block List, Min: 1) Options (answers) available for this prompt. (see [below for nested schema](#nestedblock--prompt--option)) - `title` (String) Title of the prompt (question text). #### Optional: - `in_onboarding` (Boolean) Whether the prompt is shown in the onboarding flow. If false, only appears in Channels & Roles tab. - `required` (Boolean) Whether the prompt is required before a user completes onboarding. - `single_select` (Boolean) Whether users are limited to selecting one option. Default false (allows multiple selections). - `type` (Number) Type of prompt. 0 = Multiple Choice, 1 = Dropdown. #### Read-Only: - `id` (String) ID of the prompt. Automatically generated by Discord. ### Nested Schema for `prompt.option` #### Required: - `title` (String) Title of the option. #### Optional: - `channel_ids` (List of String) Channel IDs a member is added to when selecting this option. - `description` (String) Description of the option. - `emoji_animated` (Boolean) Whether the emoji is animated. - `emoji_id` (String) Emoji ID for the option (custom emoji). - `emoji_name` (String) Emoji name for the option (unicode emoji or custom emoji name). - `role_ids` (List of String) Role IDs assigned to a member when selecting this option. #### Read-Only: - `id` (String) ID of the option. Automatically generated by Discord. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_server_onboarding.example "" ``` ``` -------------------------------- ### Importing Server Onboarding Configuration Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server_onboarding.md Demonstrates how to import an existing server onboarding configuration into Terraform management. Replace `` with the actual server ID. ```bash terraform import discord_server_onboarding.example "" ``` -------------------------------- ### Assign Moderator Permissions to a Role Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/permission.md Assign the computed moderator permissions to a Discord role resource. This example demonstrates setting the `permissions` attribute of a `discord_role` using the `allow_bits` from the `discord_permission` data source. ```terraform resource "discord_role" "moderator" { // ... permissions = data.discord_permission.moderator.allow_bits } ``` -------------------------------- ### Create a Discord server Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server.md Basic configuration for defining a new Discord server resource. ```terraform resource "discord_server" "my_server" { name = "My Awesome Server" region = "us-west" } ``` -------------------------------- ### Configure Discord Provider and Create Server Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/index.md Configure the Discord provider with your API token and create a new Discord server. The server icon can be specified using a local image file. ```terraform provider "discord" { token = var.discord_token } data "discord_local_image" "logo" { file = "logo.png" } resource "discord_server" "my_server" { name = "My Awesome Server" region = "us-west" default_message_notifications = 0 icon_data_uri = data.discord_local_image.logo.data_uri } ``` -------------------------------- ### Get Data URI of a Local Image Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/local_image.md Use this data source to specify a local image file and retrieve its data URI. This is useful for setting image-based attributes in Discord resources, such as server icons. ```terraform data "discord_local_image" "logo" { file = "logo.png" } resource "discord_server" "server" { // ... icon_data_uri = data.discord_local_image.logo.data_uri } ``` -------------------------------- ### Create a managed server with Terraform Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/managed_server.md Basic configuration for defining a managed server resource. ```terraform resource "discord_managed_server" "my_server" { server_id = "my-server-id" } ``` -------------------------------- ### Import a managed server Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/managed_server.md Syntax for importing an existing Discord server into Terraform state. ```shell terraform import discord_managed_server.example "" ``` -------------------------------- ### Import a Discord Invite Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/invite.md This shows how to import an existing Discord invite into your Terraform state. Replace `` with the actual invite code. ```shell terraform import discord_invite.example "" ``` -------------------------------- ### Import Discord Server Widget Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server_widget.md Syntax for importing an existing server widget into Terraform state. ```shell terraform import discord_server_widget.example "" ``` -------------------------------- ### Import a Discord server Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server.md Command syntax for importing an existing Discord server into Terraform state. ```shell terraform import discord_server.example "" ``` -------------------------------- ### Create a Discord Invite Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/invite.md Use this snippet to create a new invite for a specified channel. Set `max_age` to `0` for a permanent invite. Ensure `var.channel_id` is defined. ```terraform resource "discord_invite" "chatting" { channel_id = var.channel_id max_age = 0 } ``` -------------------------------- ### Import a news channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/news_channel.md Uses the terraform import command to bring an existing Discord news channel into the Terraform state. ```shell terraform import discord_news_channel.example "" ``` -------------------------------- ### Import discord_role_everyone Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role_everyone.md Import an existing discord_role_everyone resource into your Terraform configuration using the server ID. ```bash terraform import discord_role_everyone.example "" ``` -------------------------------- ### Create a discord_role Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role.md Use this resource to define a new role in your Discord server. Configure its name, permissions, color, and visibility settings. ```terraform resource "discord_role" "moderator" { server_id = var.server_id name = "Moderator" permissions = data.discord_permission.moderator.allow_bits color = data.discord_color.blue.dec hoist = true mentionable = true position = 5 } ``` -------------------------------- ### Configure Discord Server Widget Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server_widget.md Defines a voice channel and associates it with a server widget resource. ```terraform resource "discord_voice_channel" "lobby" { name = "lobby" server_id = var.server_id } resource "discord_server_widget" "example" { server_id = var.server_id enabled = true channel_id = discord_voice_channel.lobby.id } ``` -------------------------------- ### Create a Voice Channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/voice_channel.md Use this resource to create a new voice channel. Specify the channel's name, the server it belongs to, and its position. Ensure the server ID is provided. ```terraform resource "discord_voice_channel" "general" { name = "General" server_id = var.server_id position = 0 } ``` -------------------------------- ### Import discord_role_positions Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role_positions.md Imports an existing discord_role_positions resource into the Terraform state. ```shell terraform import discord_role_positions.main "" ``` -------------------------------- ### Manage @everyone Role Permissions Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role_everyone.md Use this resource to configure the permissions for the default @everyone role. Ensure the `server_id` and `permissions` are correctly set. ```terraform resource "discord_role_everyone" "everyone" { server_id = var.server_id permissions = data.discord_permission.everyone.allow_bits } ``` -------------------------------- ### Fetch server information Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/server.md Retrieves server details by ID and outputs the server region. ```terraform data "discord_server" "discord_api" { server_id = "81384788765712384" } output "discord_api_region" { value = data.discord_server.discord_api.region } ``` -------------------------------- ### Create a guild sticker with Terraform Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/guild_sticker.md Defines a new guild sticker resource by specifying the server ID, name, description, tags, and the local file path. ```terraform resource "discord_guild_sticker" "example" { server_id = var.server_id name = "wave" description = "Waving hello" tags = "👋" file = "${path.module}/assets/wave.png" } ``` -------------------------------- ### discord_server_widget Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server_widget.md Configuration schema and usage for the discord_server_widget resource. ```APIDOC ## discord_server_widget Resource ### Description Manage the widget settings of a Discord server using Terraform. ### Schema #### Required - **enabled** (Boolean) - Whether the server widget is enabled. - **server_id** (String) - The ID of the server to manage the widget for. #### Optional - **channel_id** (String) - The channel ID that the widget will generate an invite to, or null if set to no invite. #### Read-Only - **id** (String) - The ID of this resource. ### Import Import is supported using the following syntax: `terraform import discord_server_widget.example ""` ``` -------------------------------- ### discord_invite Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/invite.md This resource allows you to create and manage Discord channel invites. You can specify the channel ID, maximum age, maximum uses, and whether the invite should be temporary or unique. ```APIDOC ## discord_invite (Resource) ### Description A resource to create an invite for a channel. ### Schema #### Required - `channel_id` (String) ID of the channel to create an invite for. #### Optional - `max_age` (Number) Age of the invite. `0` for permanent. (default `86400`) - `max_uses` (Number) Max number of uses for the invite. `0` (the default) for unlimited. - `temporary` (Boolean) Whether the invite kicks users after they close Discord. (default `false`) - `unique` (Boolean) Whether this should create a new invite every time. #### Read-Only - `code` (String) The invite code. - `id` (String) The invite code. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_invite.example "" ``` ``` -------------------------------- ### Fetch Role by Name and Output Color Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/role.md Use this snippet to retrieve a role's details using its server ID and role name. The output block demonstrates how to access the role's color. ```terraform data "discord_role" "mods_name" { server_id = "81384788765712384" name = "Mods" } output "mods_color" { value = data.discord_role.mods_id.color } ``` -------------------------------- ### discord_local_image Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/local_image.md This data source reads a local image file and provides its data URI, which can be used for resources like server icons. ```APIDOC ## discord_local_image ### Description A simple helper to get data URI of a local image. ### Schema #### Required - `file` (String) - The path to the file to process. #### Read-Only - `data_uri` (String) - The data URI of the `file`. - `id` (String) - The ID of this resource. ``` -------------------------------- ### Import a Discord Text Channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/text_channel.md Uses the terraform import command to bring an existing Discord channel into state management. ```shell terraform import discord_text_channel.example "" ``` -------------------------------- ### Create a Discord Webhook Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/webhook.md Use this snippet to create a new webhook for a specified channel. You can optionally set a name and an avatar using a local image or a remote URL. The webhook's URL and token are sensitive outputs. ```terraform data "discord_local_image" "avatar" { file = "avatar.png" } resource "discord_webhook" "webhook" { channel_id = var.channel_id name = "Bot" avatar_data_uri = data.discord_local_image.avatar.data_uri } output "webhook-url" { value = nonsensitive(discord_webhook.webhook.url) } ``` -------------------------------- ### Fetch Role by ID and Output Color Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/role.md Use this snippet to retrieve a role's details using its server ID and role ID. The output block demonstrates how to access the role's color. ```terraform data "discord_role" "mods_id" { server_id = "81384788765712384" role_id = "175643578071121920" } output "mods_color" { value = data.discord_role.mods_id.color } ``` -------------------------------- ### Create a simple text message in Discord Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/message.md Use this to send a basic text message to a specified channel. ```terraform resource "discord_message" "hello_world" { channel_id = var.channel_id content = "hello world" } ``` -------------------------------- ### Create a news channel in Terraform Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/news_channel.md Defines a new news channel resource with a specified name, server ID, and position. ```terraform resource "discord_news_channel" "general" { name = "general" server_id = var.server_id position = 0 } ``` -------------------------------- ### discord_role Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role.md This resource allows you to create and manage a role within a Discord server. You can define its name, permissions, color, and other attributes. ```APIDOC ## discord_role Resource ### Description A resource to create a role. ### Schema #### Required - `name` (String) Name of the role. - `server_id` (String) Which server the role will be in. #### Optional - `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) Permission bits of the role. - `position` (Number) Position of the role. This is reverse indexed, with `@everyone` being `0`. #### Read-Only - `id` (String) ID of the role. - `managed` (Boolean) Whether this role is managed by another service. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_role.example ":" ``` ``` -------------------------------- ### Create a Category Channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/category_channel.md Use this resource to define and create a new category channel. Ensure the `server_id` is correctly set to the target server. ```terraform resource "discord_category_channel" "chatting" { name = "Chatting" server_id = var.server_id position = 0 } ``` -------------------------------- ### discord_system_channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/system_channel.md Fetches a server's system channel using its ID. ```APIDOC ## discord_system_channel (Data Source) Fetches a server's system channel. ### Schema #### Required - `server_id` (String) The server ID to search for. #### Read-Only - `id` (String) The ID of the server. - `system_channel_flags` (Number) The system channel flags of the server. - `system_channel_id` (String) The ID of the server's system channel. ``` -------------------------------- ### Import Member Roles Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/member_roles.md Import an existing member roles configuration into Terraform state. Ensure the server ID and member ID are correctly formatted. ```bash terraform import discord_member_roles.example ":" ``` -------------------------------- ### Import a Voice Channel Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/voice_channel.md Import an existing voice channel into Terraform management. Use the `terraform import` command with the resource type and instance name, followed by the channel ID. ```shell terraform import discord_voice_channel.example "" ``` -------------------------------- ### Import Discord Role Connection Metadata Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role_connection_metadata.md Imports an existing role connection metadata resource into Terraform state using the application ID. ```shell terraform import discord_role_connection_metadata.example "" ``` -------------------------------- ### discord_server Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/server.md The discord_server resource allows for the creation and management of a Discord server. It supports various configuration options for server settings and provides read-only attributes for server metadata. ```APIDOC ## discord_server (Resource) ### Description A resource to create and manage a Discord server. ### Required Parameters - **name** (String) - Name of the server. ### Optional Parameters - **afk_channel_id** (String) - ID of the channel AFK users will be moved to. - **afk_timeout** (Number) - How many seconds before moving an AFK user. - **default_message_notifications** (Number) - Default message notification settings (0 = all messages, 1 = mentions). - **description** (String) - Description of the server. - **explicit_content_filter** (Number) - Explicit content filter level of the server. - **icon_data_uri** (String) - Data URI of an image to set the server icon to. - **icon_url** (String) - Remote URL to set the icon of the server to. - **owner_id** (String) - Owner ID of the server. - **region** (String) - Region of the server. - **splash_data_uri** (String) - Data URI of an image to set the splash image. - **splash_url** (String) - Remote URL to set the splash image. - **verification_level** (Number) - Verification level of the server. ### Read-Only Attributes - **icon_hash** (String) - Hash of the icon. - **id** (String) - The ID of the server. - **roles** (List of Object) - List of roles in the server. - **server_id** (String) - The ID of the server to manage. - **splash_hash** (String) - Hash of the splash. ### Import terraform import discord_server.example "" ``` -------------------------------- ### Import Auto Moderation Rule via Terraform CLI Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/auto_moderation_rule.md Use this command to import an existing rule by specifying the server ID and rule ID. ```shell terraform import discord_auto_moderation_rule.example ":" ``` -------------------------------- ### Fetch a Discord Member Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/member.md Use this data source to retrieve a member's details from a specific server. Provide the server ID and the user ID to fetch the member's information. The output can then be used to display the member's username and discriminator. ```terraform data "discord_member" "jake" { server_id = "81384788765712384" user_id = "103559217914318848" } output "jakes_username_and_discrim" { value = "${data.discord_member.jake.username}#${data.discord_member.jake.discriminator}" } ``` -------------------------------- ### Create a channel permission override Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/channel_permission.md Use this resource to create a permission override for a specific role within a channel. Ensure that the `channel_id`, `overwrite_id`, and `type` are correctly set, and provide the `allow` permission bits. ```terraform resource "discord_channel_permission" "chatting" { channel_id = var.channel_id type = "role" overwrite_id = var.role_id allow = data.discord_permission.chatting.allow_bits } ``` -------------------------------- ### Create a message with an embed Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/message.md Use this to send a message containing a rich embed with a title, footer, and multiple fields. ```terraform resource "discord_message" "hello_world" { channel_id = var.channel_id embed { title = "Hello World" footer { text = "I'm awesome" } fields { name = "foo" value = "bar" inline = true } fields { name = "bar" value = "baz" inline = false } } } ``` -------------------------------- ### Create Discord Text Channels Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/text_channel.md Defines basic and advanced text channel configurations within a Discord server. ```terraform resource "discord_text_channel" "general" { name = "general" server_id = var.server_id position = 0 } resource "discord_text_channel" "announcements" { name = "announcements" server_id = var.server_id position = 1 topic = "Important announcements only." rate_limit_per_user = 60 # 60-second slowmode } ``` -------------------------------- ### discord_webhook Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/webhook.md This resource allows you to create and manage a Discord webhook. You can specify the channel ID, webhook name, and optionally provide an avatar using a data URI or a remote URL. The resource also exposes read-only attributes such as the webhook URL, token, and avatar hash. ```APIDOC ## discord_webhook (Resource) ### Description A resource to create a webhook for a channel. ### Schema #### Required - `channel_id` (String) ID of the channel to create a webhook for. - `name` (String) Default name of the webhook. #### Optional - `avatar_data_uri` (String) Data URI of an image to set as the default avatar of the webhook. - `avatar_url` (String) Remote URL for setting the default avatar of the webhook. #### Read-Only - `avatar_hash` (String) Hash of the avatar. - `github_url` (String, Sensitive) The GitHub-compatible webhook URL. - `id` (String) The ID of the webhook. - `slack_url` (String, Sensitive) The Slack-compatible webhook URL. - `token` (String, Sensitive) The webhook token. - `url` (String, Sensitive) The webhook URL. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_webhook.example "" ``` ``` -------------------------------- ### discord_role_everyone Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role_everyone.md Manages permissions for the default @everyone role in a Discord server. Requires the server ID and optionally accepts permission bits. ```APIDOC ## discord_role_everyone Resource ### Description Resource to manage permissions for the default `@everyone` role. ### Schema #### Required - `server_id` (String) Which server the role will be in. #### Optional - `permissions` (Number) The permission bits of the role. ### Read-Only - `id` (String) The ID of the server. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_role_everyone.example "" ``` ``` -------------------------------- ### discord_category_channel Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/category_channel.md Resource for creating a category channel in a Discord server. ```APIDOC ## discord_category_channel Resource ### Description Resource for creating a category channel in a Discord server. ### Schema #### Required - `name` (String) Name of the channel. - `server_id` (String) ID of server this channel is in. #### Optional - `position` (Number) Position of the channel, `0`-indexed. - `type` (String) The type of the channel. This is only for internal use and should never be provided. #### Read-Only - `channel_id` (String) The ID of the channel. - `id` (String) The ID of the channel. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_category_channel.example "" ``` ``` -------------------------------- ### discord_voice_channel Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/voice_channel.md This resource allows you to create and manage voice channels in a Discord server. You can specify properties like name, server ID, bitrate, category, position, user limit, and permission synchronization. ```APIDOC ## discord_voice_channel Resource ### Description A resource to create a voice channel. ### Schema #### Required - `name` (String) Name of the channel. - `server_id` (String) ID of server this channel is in. #### Optional - `bitrate` (Number) Bitrate of the channel. - `category` (String) ID of category to place this channel in. - `position` (Number) Position of the channel, `0`-indexed. - `sync_perms_with_category` (Boolean) Whether channel permissions should be synced with the category this channel is in. - `type` (String) The type of the channel. This is only for internal use and should never be provided. - `user_limit` (Number) User limit of the channel. #### Read-Only - `channel_id` (String) The ID of the channel. - `id` (String) The ID of the channel. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_voice_channel.example "" ``` ``` -------------------------------- ### discord_permission Data Source Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/permission.md This data source allows you to define permissions for roles or channel overrides by specifying individual permission states (allow/deny) and optionally extending existing permission bits. It computes the final `allow_bits` and `deny_bits` which can be used in other resources like `discord_role` or `discord_channel_permission`. ```APIDOC ## discord_permission (Data Source) ### Description A simple helper to get computed bit total of a list of permissions. ### Usage ```terraform data "discord_permission" "example_name" { # Individual permission settings view_channel = "allow" # or "deny" send_messages = "allow" # or "deny" use_vad = "deny" # or "allow" priority_speaker = "deny" # or "allow" # Optionally extend existing permissions allow_extends = data.discord_permission.another_source.allow_bits deny_extends = data.discord_permission.another_source.deny_bits } ``` ### Arguments * `view_channel` - (Optional) Whether to allow viewing channels. Accepts `"allow"` or `"deny"`. * `send_messages` - (Optional) Whether to allow sending messages. Accepts `"allow"` or `"deny"`. * `use_vad` - (Optional) Whether to allow using Voice Activity Detection. Accepts `"allow"` or `"deny"`. * `priority_speaker` - (Optional) Whether to allow priority speaker. Accepts `"allow"` or `"deny"`. * `allow_extends` - (Optional) Bitmask of permissions to extend from an existing allow list. * `deny_extends` - (Optional) Bitmask of permissions to extend from an existing deny list. ### Attributes * `allow_bits` - The computed bitmask representing the total allowed permissions. * `deny_bits` - The computed bitmask representing the total denied permissions. ``` -------------------------------- ### discord_role_positions Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role_positions.md The discord_role_positions resource allows for atomic reordering of multiple roles within a Discord server. It is recommended to use this resource instead of individual role position updates to avoid race conditions and configuration drift. ```APIDOC ## discord_role_positions (Resource) ### Description Atomically sets the positions of multiple roles in a single Discord API call. This resource is used to order roles consistently and avoid race conditions that occur when updating roles individually. ### Schema #### Required - **position** (Block Set, Min: 1) - One block per role whose position should be managed. - **server_id** (String) - ID of the guild whose roles to reorder. #### Read-Only - **id** (String) - The ID of this resource. ### Nested Schema for position - **position** (Number) - Target position. Discord's @everyone role is always at position 0; higher numbers appear higher in the role list. - **role_id** (String) - ID of the role. ### Import terraform import discord_role_positions.main "" ``` -------------------------------- ### Import a discord_role Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role.md Import an existing Discord role into your Terraform state. This is useful for managing roles that were created outside of Terraform. ```shell terraform import discord_role.example ":" ``` -------------------------------- ### discord_role_connection_metadata Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/role_connection_metadata.md The discord_role_connection_metadata resource manages application role connection metadata records. ```APIDOC ## discord_role_connection_metadata (Resource) ### Description Manages application role connection metadata to define criteria for linked roles. ### Required Parameters - **application_id** (String) - The ID of the application to configure. - **metadata** (Block List) - List of role connection metadata records (Max 5). ### Nested Schema for metadata - **description** (String) - Description of the metadata field (1-200 characters). - **key** (String) - Dictionary key (a-z, 0-9, or _ ; 1-50 characters). - **name** (String) - Name of the metadata field (1-100 characters). - **type** (Number) - Type of metadata value (1-8). ### Read-Only - **id** (String) - The ID of this resource. ### Import terraform import discord_role_connection_metadata.example "" ``` -------------------------------- ### discord_text_channel Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/text_channel.md Configuration schema and usage for the discord_text_channel resource. ```APIDOC ## discord_text_channel Resource ### Description Manages a text channel within a Discord server. ### Required Arguments - **name** (String) - Name of the channel. - **server_id** (String) - ID of server this channel is in. ### Optional Arguments - **category** (String) - ID of category to place this channel in. - **nsfw** (Boolean) - Whether the channel is NSFW. - **position** (Number) - Position of the channel, 0-indexed. - **rate_limit_per_user** (Number) - Slowmode: minimum number of seconds a user has to wait between sending messages. - **sync_perms_with_category** (Boolean) - Whether channel permissions should be synced with the category. - **topic** (String) - Topic of the channel. ### Read-Only Attributes - **channel_id** (String) - The ID of the channel. - **id** (String) - The ID of the channel. ### Import terraform import discord_text_channel.example "" ``` -------------------------------- ### discord_server Data Source Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/server.md Fetches information about a specific Discord server using its ID or name. ```APIDOC ## discord_server (Data Source) ### Description Fetches a server's information from Discord. ### Configuration ```terraform data "discord_server" "example" { server_id = "81384788765712384" } ``` ### Optional Parameters - **name** (String) - The server name to search for. - **server_id** (String) - The server ID to search for. ### Read-Only Attributes - **afk_channel_id** (Number) - The AFK channel ID. - **afk_timeout** (Number) - The AFK timeout of the server. - **default_message_notifications** (Number) - The default message notification level of the server. - **description** (String) - The description of the server. - **explicit_content_filter** (Number) - The explicit content filter level of the server. - **icon_hash** (String) - The hash of the server icon. - **id** (String) - The ID of the server. - **owner_id** (String) - The ID of the owner. - **region** (String) - The region of the server. - **roles** (List of Object) - List of roles in the server. - **splash_hash** (String) - The hash of the server splash. - **verification_level** (Number) - The required verification level of the server. ``` -------------------------------- ### discord_channel_permission Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/channel_permission.md This resource allows you to create and manage permission overrides for specific roles or users within a Discord channel. You can define which permissions are allowed or denied. ```APIDOC ## discord_channel_permission Resource ### Description A resource to create a permission override for a channel. ### Schema #### Required - `channel_id` (String) ID of the channel for this override. - `overwrite_id` (String) ID of the user or role for this override. - `type` (String) Type of the override. Must be `role` or `user`. #### Optional - `allow` (Number) Permission bits for the allowed permissions on this override. At least one of `allow` or `deny` must be set. - `deny` (Number) Permission bits for the denied permissions on this override. At least one of `allow` or `deny` must be set. #### Read-Only - `id` (String) Hash of the channel ID, override ID, and type. ### Import Import is supported using the following syntax: The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: ```shell terraform import discord_channel_permission.example "::" ``` ``` -------------------------------- ### discord_managed_server Resource Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/resources/managed_server.md The discord_managed_server resource allows you to manage the configuration of a Discord server. It requires a server_id and supports various optional settings like name, region, and notification preferences. ```APIDOC ## Resource: discord_managed_server ### Description Manages the configuration of a Discord server. ### Required Parameters - **server_id** (String) - The ID of the server to manage. ### Optional Parameters - **afk_channel_id** (String) - ID of the channel AFK users will be moved to. - **afk_timeout** (Number) - How many seconds before moving an AFK user. - **default_message_notifications** (Number) - Default message notification settings. (0 = all messages, 1 = mentions) - **description** (String) - Description of the server. - **explicit_content_filter** (Number) - Explicit content filter level of the server. - **icon_data_uri** (String) - Data URI of an image to set the server icon to. Overrides icon_url. - **icon_url** (String) - Remote URL to set the icon of the server to. - **name** (String) - Name of the server. - **owner_id** (String) - Owner ID of the server. Setting this will transfer ownership. - **region** (String) - Region of the server. - **splash_data_uri** (String) - Data URI of an image to set the splash image of the server to. Overrides splash_url. - **splash_url** (String) - Remote URL to set the splash image of the server to. - **verification_level** (Number) - Verification level of the server. ### Read-Only Attributes - **icon_hash** (String) - Hash of the icon. - **id** (String) - The ID of the server. - **roles** (List of Object) - List of roles in the server. - **splash_hash** (String) - Hash of the splash. ### Import terraform import discord_managed_server.example "" ``` -------------------------------- ### Define Member Permissions Source: https://github.com/lucky3028/terraform-provider-discord/blob/main/docs/data-sources/permission.md Use this snippet to define a set of permissions for a member role, specifying which actions are allowed and denied. ```terraform data "discord_permission" "member" { view_channel = "allow" send_messages = "allow" use_vad = "deny" priority_speaker = "deny" } ```