Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can almost get a server working, but not quite #2

Open
webcoyote opened this issue Sep 11, 2020 · 1 comment
Open

Can almost get a server working, but not quite #2

webcoyote opened this issue Sep 11, 2020 · 1 comment

Comments

@webcoyote
Copy link
Contributor

I'm endeavoring to create a server using Terraform and your library, and while everything runs, and (apparently) a server is created, I'm not able to see any text channels, and get this error:

No Text Channels
You find yourself in a strange place. You don't have access to any text channels, or there are none in this server.

Here's the code:

variable "discord_token" {
  description = "Discord token"
  type        = string
  default     = "<SECRET TOKEN GOES HERE>"
}

terraform {
  required_version = ">= 0.13"
}

locals {
  server_name = "Test Site"
  region = "us-west"
}

terraform {
  required_providers {
    discord = {
      source = "aequasi/discord"
      version = "0.0.4"
    }
  }
}

provider discord {
  token = var.discord_token
}

resource discord_server my_server {
  name = local.server_name
  region = local.region
  default_message_notifications = 0
}

resource discord_category_channel public {
  name = "public"
  position = 0
  server_id = discord_server.my_server.id
}

resource discord_text_channel welcome {
  name = "welcome"
  topic = "The welcome channel"
  position = 0
  category = discord_category_channel.public.id
  server_id = discord_server.my_server.id
}

data discord_permission member {
  view_channel     = "allow"
  send_messages    = "allow"
}

resource discord_role_everyone everyone {
  permissions = data.discord_permission.member.allow_bits
  server_id = discord_server.my_server.id
}

And the result:

terraform apply --auto-approve
data.discord_permission.member: Refreshing state... [id=3681448725]
discord_server.my_server: Refreshing state... [id=753831833946292296]
discord_category_channel.public: Refreshing state... [id=753831838853627925]
discord_role_everyone.everyone: Refreshing state... [id=753831833946292296]
discord_text_channel.welcome: Refreshing state... [id=753831840258719744]
discord_channel_permission.public: Refreshing state... [id=2655848062]

Any suggestions? And thanks. I hope that a simple example like the code above might help other folks get things working too.

@webcoyote
Copy link
Contributor Author

Found the solution. For future readers, it turns out that you need to invite yourself to the server:

resource discord_invite welcome {
    channel_id = discord_text_channel.welcome.id
    max_age = 0
}

output invite {
  value = "https://discord.gg/${discord_invite.welcome.id}"
}

Open the link to add yourself to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant