feat: add /pickable-roles and /pick-role basis

This commit is contained in:
41666 2021-08-01 18:57:57 -04:00
parent c2ee4f380a
commit a4207d5713
22 changed files with 343 additions and 23 deletions

View file

@ -68,6 +68,11 @@ resource "cloudflare_worker_script" "backend" {
name = "ROOT_USERS"
text = join(",", var.root_users)
}
secret_text_binding {
name = "INTERACTIONS_SHARED_KEY"
text = random_password.interactions_token.result
}
}
resource "cloudflare_record" "api" {

View file

@ -4,6 +4,13 @@ locals {
])
}
resource "random_password" "interactions_token" {
length = 64
keepers = {
"worker_tag" = var.worker_tag
}
}
resource "discord-interactions_guild_command" "hello-world" {
for_each = local.internalTestingGuilds
guild_id = each.value
@ -12,6 +19,49 @@ resource "discord-interactions_guild_command" "hello-world" {
description = "Say hello!"
}
resource "discord-interactions_global_command" "roleypoly" {
name = "roleypoly"
description = "Sends you a link to pick your roles in your browser"
}
resource "discord-interactions_global_command" "pick-role" {
name = "pick-role"
description = "Pick a role! (See which ones can be picked with /pickable-roles)"
option {
name = "role"
description = "The role you want"
type = 8
}
}
resource "discord-interactions_guild_command" "pick-role" {
for_each = local.internalTestingGuilds
guild_id = each.value
name = "pick-role"
description = "Pick a role! (See which ones can be picked with /pickable-roles)"
option {
name = "role"
description = "The role you want"
type = 8
}
}
resource "discord-interactions_global_command" "pickable-roles" {
name = "pickable-roles"
description = "See all the roles you can pick with /pick-roles"
}
resource "discord-interactions_guild_command" "pickable-roles" {
for_each = local.internalTestingGuilds
guild_id = each.value
name = "pickable-roles"
description = "See all the roles you can pick with /pick-roles"
}
resource "cloudflare_worker_script" "interactions" {
name = "roleypoly-interactions-${var.environment_tag}"
content = file("${path.module}/${var.interactions_path_to_worker}")
@ -21,6 +71,11 @@ resource "cloudflare_worker_script" "interactions" {
text = var.discord_public_key
}
secret_text_binding {
name = "INTERACTIONS_SHARED_KEY"
text = random_password.interactions_token.result
}
plain_text_binding {
name = "UI_PUBLIC_URI"
text = var.ui_public_uri

View file

@ -92,6 +92,12 @@ variable "bot_tag" {
description = ":tag or @sha265: of ghcr.io/roleypoly/bot"
}
variable "worker_tag" {
type = string
default = ""
description = "Usually the commit hash, this invalidates some secrets that can always be rotated"
}
variable "allowed_callback_hosts" {
type = string
default = ""