summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu <matthieu@developershouse.xyz>2021-09-17 18:41:56 +0400
committerMatthieu <matthieu@developershouse.xyz>2021-09-17 18:41:56 +0400
commit469a8fb1ea7b689399c30badbf33fc467531c561 (patch)
tree8ea3caf86cc00c8c3b37287b6a7b1774bb5e8895
parentba0170ea15d6ebc1c9049f02adabd1ee4df6de64 (diff)
basic com implementation & cache base
-rw-r--r--.devcontainer/devcontainer.json4
-rw-r--r--BUILD34
-rw-r--r--Cargo.lock51
-rw-r--r--Cargo.toml1
-rw-r--r--cache/BUILD24
-rw-r--r--cache/Cargo.toml14
-rw-r--r--cache/cargo/BUILD.bazel58
-rw-r--r--cache/src/config.rs4
-rw-r--r--cache/src/main.rs12
-rw-r--r--cargo/crates.bzl55
-rw-r--r--cargo/remote/BUILD.combine-4.6.1.bazel82
-rw-r--r--cargo/remote/BUILD.dtoa-0.4.8.bazel57
-rw-r--r--cargo/remote/BUILD.redis-0.21.2.bazel106
-rw-r--r--cargo/remote/BUILD.sha1-0.6.0.bazel53
-rw-r--r--common/discord/types/payloads/gateway/BUILD.bazel9
-rw-r--r--common/discord/types/payloads/gateway/commands/BUILD.bazel19
-rw-r--r--common/discord/types/payloads/gateway/commands/heartbeat.go6
-rw-r--r--common/discord/types/payloads/gateway/commands/identify.go30
-rw-r--r--common/discord/types/payloads/gateway/commands/request-guild-members.go35
-rw-r--r--common/discord/types/payloads/gateway/commands/resume.go11
-rw-r--r--common/discord/types/payloads/gateway/commands/update-status.go18
-rw-r--r--common/discord/types/payloads/gateway/commands/update-voice-state.go13
-rw-r--r--common/discord/types/payloads/gateway/events/BUILD.bazel52
-rw-r--r--common/discord/types/payloads/gateway/events/channel-create.go7
-rw-r--r--common/discord/types/payloads/gateway/events/channel-delete.go7
-rw-r--r--common/discord/types/payloads/gateway/events/channel-pins-update.go12
-rw-r--r--common/discord/types/payloads/gateway/events/channel-update.go8
-rw-r--r--common/discord/types/payloads/gateway/events/guild-ban-add.go11
-rw-r--r--common/discord/types/payloads/gateway/events/guild-ban-remove.go11
-rw-r--r--common/discord/types/payloads/gateway/events/guild-create.go12
-rw-r--r--common/discord/types/payloads/gateway/events/guild-delete.go9
-rw-r--r--common/discord/types/payloads/gateway/events/guild-emojis-update.go11
-rw-r--r--common/discord/types/payloads/gateway/events/guild-integrations-update.go7
-rw-r--r--common/discord/types/payloads/gateway/events/guild-member-add.go12
-rw-r--r--common/discord/types/payloads/gateway/events/guild-member-remove.go12
-rw-r--r--common/discord/types/payloads/gateway/events/guild-member-update.go23
-rw-r--r--common/discord/types/payloads/gateway/events/guild-members-chunk.go22
-rw-r--r--common/discord/types/payloads/gateway/events/guild-role-create.go11
-rw-r--r--common/discord/types/payloads/gateway/events/guild-role-delete.go9
-rw-r--r--common/discord/types/payloads/gateway/events/guild-role-update.go11
-rw-r--r--common/discord/types/payloads/gateway/events/guild-update.go6
-rw-r--r--common/discord/types/payloads/gateway/events/hello.go9
-rw-r--r--common/discord/types/payloads/gateway/events/invalid-session.go8
-rw-r--r--common/discord/types/payloads/gateway/events/invite-create.go32
-rw-r--r--common/discord/types/payloads/gateway/events/invite-delete.go11
-rw-r--r--common/discord/types/payloads/gateway/events/message-bulk-delete.go11
-rw-r--r--common/discord/types/payloads/gateway/events/message-create.go6
-rw-r--r--common/discord/types/payloads/gateway/events/message-delete.go11
-rw-r--r--common/discord/types/payloads/gateway/events/message-reaction-add.go19
-rw-r--r--common/discord/types/payloads/gateway/events/message-reaction-remove-all.go11
-rw-r--r--common/discord/types/payloads/gateway/events/message-reaction-remove-emoji.go16
-rw-r--r--common/discord/types/payloads/gateway/events/message-reaction-remove.go17
-rw-r--r--common/discord/types/payloads/gateway/events/message-update.go8
-rw-r--r--common/discord/types/payloads/gateway/events/presence-update.go26
-rw-r--r--common/discord/types/payloads/gateway/events/ready.go27
-rw-r--r--common/discord/types/payloads/gateway/events/reconnect.go5
-rw-r--r--common/discord/types/payloads/gateway/events/resumed.go5
-rw-r--r--common/discord/types/payloads/gateway/events/typing-start.go17
-rw-r--r--common/discord/types/payloads/gateway/events/user-update.go6
-rw-r--r--common/discord/types/payloads/gateway/events/voice-server-update.go11
-rw-r--r--common/discord/types/payloads/gateway/events/voice-state-update.go6
-rw-r--r--common/discord/types/payloads/gateway/events/webhook-update.go9
-rw-r--r--common/discord/types/payloads/gateway/gateway-payload.go20
-rw-r--r--common/discord/types/structures/BUILD.bazel50
-rw-r--r--common/discord/types/structures/activity-assets.go13
-rw-r--r--common/discord/types/structures/activity-emoji.go11
-rw-r--r--common/discord/types/structures/activity-party.go10
-rw-r--r--common/discord/types/structures/activity-secrets.go11
-rw-r--r--common/discord/types/structures/activity-timestamps.go9
-rw-r--r--common/discord/types/structures/activity.go36
-rw-r--r--common/discord/types/structures/application.go38
-rw-r--r--common/discord/types/structures/attachment.go19
-rw-r--r--common/discord/types/structures/channel-mention.go15
-rw-r--r--common/discord/types/structures/channel.go45
-rw-r--r--common/discord/types/structures/client-status.go13
-rw-r--r--common/discord/types/structures/embed-author.go13
-rw-r--r--common/discord/types/structures/embed-field.go11
-rw-r--r--common/discord/types/structures/embed-footer.go11
-rw-r--r--common/discord/types/structures/embed-image.go13
-rw-r--r--common/discord/types/structures/embed-provider.go9
-rw-r--r--common/discord/types/structures/embed-thumbnail.go13
-rw-r--r--common/discord/types/structures/embed-video.go13
-rw-r--r--common/discord/types/structures/embed.go33
-rw-r--r--common/discord/types/structures/emoji.go21
-rw-r--r--common/discord/types/structures/guild-member.go27
-rw-r--r--common/discord/types/structures/guild.go117
-rw-r--r--common/discord/types/structures/identify-connection-properties.go11
-rw-r--r--common/discord/types/structures/invite.go23
-rw-r--r--common/discord/types/structures/message-activity.go11
-rw-r--r--common/discord/types/structures/message-application.go15
-rw-r--r--common/discord/types/structures/message-reference.go16
-rw-r--r--common/discord/types/structures/message.go71
-rw-r--r--common/discord/types/structures/overwrite.go13
-rw-r--r--common/discord/types/structures/presence.go17
-rw-r--r--common/discord/types/structures/reaction.go11
-rw-r--r--common/discord/types/structures/role-tags.go9
-rw-r--r--common/discord/types/structures/role.go14
-rw-r--r--common/discord/types/structures/sticker.go23
-rw-r--r--common/discord/types/structures/team-member.go15
-rw-r--r--common/discord/types/structures/team.go13
-rw-r--r--common/discord/types/structures/user.go20
-rw-r--r--common/discord/types/structures/voice-state.go29
-rw-r--r--common/discord/types/structures/welcome-screen-channel.go13
-rw-r--r--common/discord/types/structures/welcome-screen.go9
-rw-r--r--common/discord/types/types/BUILD.bazel36
-rw-r--r--common/discord/types/types/activity-flags.go19
-rw-r--r--common/discord/types/types/activity-types.go22
-rw-r--r--common/discord/types/types/channel-types.go21
-rw-r--r--common/discord/types/types/client-statuses.go14
-rw-r--r--common/discord/types/types/default-message-notification-levels.go11
-rw-r--r--common/discord/types/types/embed-types.go19
-rw-r--r--common/discord/types/types/explicit-content-filter-levels.go13
-rw-r--r--common/discord/types/types/gateway-close-event-codes.go52
-rw-r--r--common/discord/types/types/gateway-intents.go23
-rw-r--r--common/discord/types/types/gateway-op-codes.go40
-rw-r--r--common/discord/types/types/guild-features.go40
-rw-r--r--common/discord/types/types/membership-states.go11
-rw-r--r--common/discord/types/types/message-activity-types.go12
-rw-r--r--common/discord/types/types/message-flags.go20
-rw-r--r--common/discord/types/types/message-types.go25
-rw-r--r--common/discord/types/types/mfa-levels.go11
-rw-r--r--common/discord/types/types/premium-tiers.go15
-rw-r--r--common/discord/types/types/premium-types.go11
-rw-r--r--common/discord/types/types/statuses.go15
-rw-r--r--common/discord/types/types/sticker-types.go11
-rw-r--r--common/discord/types/types/system-channel-flags.go11
-rw-r--r--common/discord/types/types/target-user-types.go9
-rw-r--r--common/discord/types/types/update-status-statuses.go18
-rw-r--r--common/discord/types/types/user-flags.go22
-rw-r--r--common/discord/types/types/verification-levels.go19
-rw-r--r--common/discord/types/types/voice-gateway-close-event-codes.go53
-rw-r--r--common/discord/types/types/voice-gateway-op-codes.go37
-rw-r--r--common/rust/Cargo.toml3
-rw-r--r--common/rust/cargo/BUILD.bazel9
-rw-r--r--common/rust/src/config.rs7
-rw-r--r--common/rust/src/lib.rs4
-rw-r--r--common/rust/src/nats.rs62
-rw-r--r--common/rust/src/payloads.rs9
-rw-r--r--docs/README.md (renamed from doc/README.md)0
-rw-r--r--docs/common.md (renamed from doc/common.md)0
-rw-r--r--docs/components/auto-scaler.md (renamed from examples/config/gateway.yaml)0
-rw-r--r--docs/components/cache.md0
-rw-r--r--docs/components/gateway.md0
-rw-r--r--docs/components/ratelimiter.md0
-rw-r--r--docs/components/webhook.md (renamed from doc/components/webhook.md)0
-rw-r--r--docs/exemples/config.yaml0
-rw-r--r--docs/structure.md (renamed from doc/structure.md)0
-rw-r--r--examples/config/webhook.yaml28
-rw-r--r--examples/docker-compose.gateway.yml8
-rw-r--r--examples/docker-compose.webhook.yml13
-rw-r--r--examples/docker-compose.yml16
-rw-r--r--gateway/config/default.yaml13
-rw-r--r--gateway/docker-compose.yaml10
-rw-r--r--gateway/src/client/connection/actions.rs8
-rw-r--r--gateway/src/client/connection/mod.rs24
-rw-r--r--gateway/src/client/connection/state.rs10
-rw-r--r--gateway/src/client/connection/stream.rs36
-rw-r--r--gateway/src/client/connexion.rs255
-rw-r--r--gateway/src/client/mod.rs6
-rw-r--r--gateway/src/client/payloads/structs.rs (renamed from gateway/src/client/structs.rs)0
-rw-r--r--gateway/src/client/shard/actions.rs65
-rw-r--r--gateway/src/client/shard/connection.rs16
-rw-r--r--gateway/src/client/shard/mod.rs24
-rw-r--r--gateway/src/client/shard/state.rs14
-rw-r--r--gateway/src/client/state.rs29
-rw-r--r--gateway/src/cluster_manager.rs47
-rw-r--r--gateway/src/config.rs33
-rw-r--r--gateway/src/main.rs6
-rw-r--r--webhook/.gitignore3
-rw-r--r--webhook/Cargo.toml1
-rw-r--r--webhook/README.md0
-rw-r--r--webhook/cargo/BUILD.bazel9
-rw-r--r--webhook/config/default.yaml14
-rw-r--r--webhook/src/handle.rs174
-rw-r--r--webhook/src/handler/handler.rs123
-rw-r--r--webhook/src/handler/make_service.rs28
-rw-r--r--webhook/src/handler/mod.rs4
-rw-r--r--webhook/src/handler/signature.rs65
-rw-r--r--webhook/src/handler/types.rs10
-rw-r--r--webhook/src/main.rs14
180 files changed, 1061 insertions, 2873 deletions
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index f1cc4d9..0ff8ae1 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -12,7 +12,9 @@
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
- "extensions": [],
+ "extensions": [
+ ""
+ ],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
diff --git a/BUILD b/BUILD
index 2407489..498bd5a 100644
--- a/BUILD
+++ b/BUILD
@@ -7,26 +7,34 @@ load("@io_bazel_rules_docker//contrib:push-all.bzl", "container_push")
gazelle(name = "gazelle")
filegroup(
- name = "package_bin",
+ name = "binaries",
srcs = [
"//novactl",
"//webhook",
"//gateway",
- "//ratelimiter"
+ "//ratelimiter",
+ "//cache"
]
)
container_bundle(
- name = "bundle",
+ name = "container_images",
images = {
"$(docker_repo)/discordnova/nova/novactl:$(docker_tag)": "//novactl:image",
"$(docker_repo)/discordnova/nova/gateway:$(docker_tag)": "//gateway:image",
"$(docker_repo)/discordnova/nova/ratelimiter:$(docker_tag)": "//ratelimiter:image",
"$(docker_repo)/discordnova/nova/webhook:$(docker_tag)": "//webhook:image",
+ "$(docker_repo)/discordnova/nova/cache:$(docker_tag)": "//cache:image",
}
)
+container_push(
+ name = "container_publish",
+ bundle = ":container_images",
+ format = "OCI"
+)
+
test_suite(
name = "tests",
tests = [
@@ -37,31 +45,25 @@ test_suite(
],
)
-container_push(
- name = "publish",
- bundle = ":bundle",
- format = "OCI"
-)
-
pkg_tar(
- name = "package_tar",
+ name = "packages_tar",
extension = "tar.gz",
srcs = [
- ":package_bin"
+ ":binaries"
],
)
pkg_zip(
- name = "package_zip",
+ name = "packages_zip",
srcs = [
- ":package_bin"
+ ":binaries"
],
)
filegroup(
- name = "package",
+ name = "packages",
srcs = [
- ":package_zip",
- ":package_tar",
+ ":packages_zip",
+ ":packages_tar",
],
) \ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index 24d7405..218fe32 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -184,6 +184,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
+name = "cache"
+version = "0.1.0"
+dependencies = [
+ "common",
+ "log",
+ "nats 0.15.2",
+ "redis",
+ "serde 1.0.130",
+ "serde_json",
+]
+
+[[package]]
name = "cache-padded"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -231,12 +243,23 @@ dependencies = [
]
[[package]]
+name = "combine"
+version = "4.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a909e4d93292cd8e9c42e189f61681eff9d67b6541f96b8a1a737f23737bd001"
+dependencies = [
+ "bytes 1.1.0",
+ "memchr",
+]
+
+[[package]]
name = "common"
version = "0.1.0"
dependencies = [
"config",
"hyper",
"log",
+ "nats 0.15.2",
"pretty_env_logger",
"prometheus",
"serde 1.0.130",
@@ -399,6 +422,12 @@ dependencies = [
]
[[package]]
+name = "dtoa"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
+
+[[package]]
name = "ed25519"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1570,6 +1599,21 @@ dependencies = [
]
[[package]]
+name = "redis"
+version = "0.21.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "202c5bf92cad3d57605c366e644a7fbf305a83f19754fc66678c6265dcc9b8b4"
+dependencies = [
+ "async-trait",
+ "combine",
+ "dtoa",
+ "itoa",
+ "percent-encoding",
+ "sha1",
+ "url",
+]
+
+[[package]]
name = "redox_syscall"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1828,6 +1872,12 @@ dependencies = [
]
[[package]]
+name = "sha1"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
+
+[[package]]
name = "sha2"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2635,7 +2685,6 @@ dependencies = [
"libsodium-sys",
"log",
"nats 0.15.2",
- "pretty_env_logger",
"serde 1.0.130",
"serde_json",
"tokio 1.11.0",
diff --git a/Cargo.toml b/Cargo.toml
index 6eeff24..8bee6e4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,6 +4,7 @@ members = [
"webhook",
"ratelimiter",
"gateway",
+ "cache",
"common/rust"
]
diff --git a/cache/BUILD b/cache/BUILD
new file mode 100644
index 0000000..3b11f74
--- /dev/null
+++ b/cache/BUILD
@@ -0,0 +1,24 @@
+load("@rules_rust//rust:rust.bzl", "rust_binary", "rust_test")
+load("//cargo:crates.bzl", "all_crate_deps")
+load("@io_bazel_rules_docker//rust:image.bzl", "rust_image")
+
+test_suite(name = "tests")
+
+rust_binary(
+ name = "cache",
+ srcs = glob(["src/**"]),
+ deps = all_crate_deps() + ["//common/rust:common"],
+ visibility = ["//visibility:public"],
+)
+
+rust_test(
+ name = "cache_test",
+ crate = ":webhook"
+)
+
+rust_image(
+ name = "image",
+ binary = ":cache",
+ visibility = ["//visibility:public"],
+ base = "//bazel:base",
+)
diff --git a/cache/Cargo.toml b/cache/Cargo.toml
new file mode 100644
index 0000000..8de5801
--- /dev/null
+++ b/cache/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "cache"
+version = "0.1.0"
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+common = { path = "../common/rust" }
+nats = "0.15.2"
+serde = { version = "1.0.8", features = ["derive"] }
+log = { version = "0.4", features = ["std"] }
+serde_json = { version = "1.0" }
+redis = "*" \ No newline at end of file
diff --git a/cache/cargo/BUILD.bazel b/cache/cargo/BUILD.bazel
new file mode 100644
index 0000000..1543954
--- /dev/null
+++ b/cache/cargo/BUILD.bazel
@@ -0,0 +1,58 @@
+"""
+@generated
+cargo-raze generated Bazel file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+package(default_visibility = ["//visibility:public"])
+
+licenses([
+ "notice", # See individual crates for specific licenses
+])
+
+# Aliased targets
+alias(
+ name = "log",
+ actual = "@raze__log__0_4_14//:log",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
+
+alias(
+ name = "nats",
+ actual = "@raze__nats__0_15_2//:nats",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
+
+alias(
+ name = "redis",
+ actual = "@raze__redis__0_21_2//:redis",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
+
+alias(
+ name = "serde",
+ actual = "@raze__serde__1_0_130//:serde",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
+
+alias(
+ name = "serde_json",
+ actual = "@raze__serde_json__1_0_67//:serde_json",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
diff --git a/cache/src/config.rs b/cache/src/config.rs
new file mode 100644
index 0000000..37b1e73
--- /dev/null
+++ b/cache/src/config.rs
@@ -0,0 +1,4 @@
+use serde::Deserialize;
+
+#[derive(Debug, Deserialize, Clone, Default)]
+pub struct CacheConfiguration {} \ No newline at end of file
diff --git a/cache/src/main.rs b/cache/src/main.rs
new file mode 100644
index 0000000..9da8394
--- /dev/null
+++ b/cache/src/main.rs
@@ -0,0 +1,12 @@
+use common::config::Settings;
+use log::info;
+
+use crate::config::CacheConfiguration;
+
+mod config;
+
+
+fn main() {
+ let settings: Settings<CacheConfiguration> = Settings::new("cache").unwrap();
+ info!("loaded configuration: {:?}", settings);
+}
diff --git a/cargo/crates.bzl b/cargo/crates.bzl
index f51e66e..c7e06d0 100644
--- a/cargo/crates.bzl
+++ b/cargo/crates.bzl
@@ -18,7 +18,6 @@ _DEPENDENCIES = {
"libsodium-sys": "@raze__libsodium_sys__0_2_7//:libsodium_sys",
"log": "@raze__log__0_4_14//:log",
"nats": "@raze__nats__0_15_2//:nats",
- "pretty_env_logger": "@raze__pretty_env_logger__0_4_0//:pretty_env_logger",
"serde": "@raze__serde__1_0_130//:serde",
"serde_json": "@raze__serde_json__1_0_67//:serde_json",
"tokio": "@raze__tokio__1_11_0//:tokio",
@@ -27,6 +26,7 @@ _DEPENDENCIES = {
"config": "@raze__config__0_11_0//:config",
"hyper": "@raze__hyper__0_14_12//:hyper",
"log": "@raze__log__0_4_14//:log",
+ "nats": "@raze__nats__0_15_2//:nats",
"pretty_env_logger": "@raze__pretty_env_logger__0_4_0//:pretty_env_logger",
"prometheus": "@raze__prometheus__0_12_0//:prometheus",
"serde": "@raze__serde__1_0_130//:serde",
@@ -55,6 +55,13 @@ _DEPENDENCIES = {
"tokio-tungstenite": "@raze__tokio_tungstenite__0_15_0//:tokio_tungstenite",
"url": "@raze__url__2_2_2//:url",
},
+ "cache": {
+ "log": "@raze__log__0_4_14//:log",
+ "nats": "@raze__nats__0_15_2//:nats",
+ "redis": "@raze__redis__0_21_2//:redis",
+ "serde": "@raze__serde__1_0_130//:serde",
+ "serde_json": "@raze__serde_json__1_0_67//:serde_json",
+ },
"": {
"libc": "@raze__libc__0_2_101//:libc",
},
@@ -71,6 +78,8 @@ _PROC_MACRO_DEPENDENCIES = {
"gateway": {
"serde_repr": "@raze__serde_repr__0_1_7//:serde_repr",
},
+ "cache": {
+ },
"": {
},
}
@@ -86,6 +95,8 @@ _DEV_DEPENDENCIES = {
},
"gateway": {
},
+ "cache": {
+ },
"": {
},
}
@@ -100,6 +111,8 @@ _DEV_PROC_MACRO_DEPENDENCIES = {
},
"gateway": {
},
+ "cache": {
+ },
"": {
},
}
@@ -521,6 +534,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__combine__4_6_1",
+ url = "https://crates.io/api/v1/crates/combine/4.6.1/download",
+ type = "tar.gz",
+ sha256 = "a909e4d93292cd8e9c42e189f61681eff9d67b6541f96b8a1a737f23737bd001",
+ strip_prefix = "combine-4.6.1",
+ build_file = Label("//cargo/remote:BUILD.combine-4.6.1.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__concurrent_queue__1_2_2",
url = "https://crates.io/api/v1/crates/concurrent-queue/1.2.2/download",
type = "tar.gz",
@@ -671,6 +694,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__dtoa__0_4_8",
+ url = "https://crates.io/api/v1/crates/dtoa/0.4.8/download",
+ type = "tar.gz",
+ sha256 = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0",
+ strip_prefix = "dtoa-0.4.8",
+ build_file = Label("//cargo/remote:BUILD.dtoa-0.4.8.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__ed25519__1_2_0",
url = "https://crates.io/api/v1/crates/ed25519/1.2.0/download",
type = "tar.gz",
@@ -1821,6 +1854,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__redis__0_21_2",
+ url = "https://crates.io/api/v1/crates/redis/0.21.2/download",
+ type = "tar.gz",
+ sha256 = "202c5bf92cad3d57605c366e644a7fbf305a83f19754fc66678c6265dcc9b8b4",
+ strip_prefix = "redis-0.21.2",
+ build_file = Label("//cargo/remote:BUILD.redis-0.21.2.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__redox_syscall__0_1_57",
url = "https://crates.io/api/v1/crates/redox_syscall/0.1.57/download",
type = "tar.gz",
@@ -2081,6 +2124,16 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
+ name = "raze__sha1__0_6_0",
+ url = "https://crates.io/api/v1/crates/sha1/0.6.0/download",
+ type = "tar.gz",
+ sha256 = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d",
+ strip_prefix = "sha1-0.6.0",
+ build_file = Label("//cargo/remote:BUILD.sha1-0.6.0.bazel"),
+ )
+
+ maybe(
+ http_archive,
name = "raze__sha2__0_9_6",
url = "https://crates.io/api/v1/crates/sha2/0.9.6/download",
type = "tar.gz",
diff --git a/cargo/remote/BUILD.combine-4.6.1.bazel b/cargo/remote/BUILD.combine-4.6.1.bazel
new file mode 100644
index 0000000..6a52e24
--- /dev/null
+++ b/cargo/remote/BUILD.combine-4.6.1.bazel
@@ -0,0 +1,82 @@
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # MIT from expression "MIT"
+])
+
+# Generated Targets
+
+# Unsupported target "http" with type "bench" omitted
+
+# Unsupported target "json" with type "bench" omitted
+
+# Unsupported target "mp4" with type "bench" omitted
+
+# Unsupported target "async" with type "example" omitted
+
+# Unsupported target "date" with type "example" omitted
+
+# Unsupported target "ini" with type "example" omitted
+
+# Unsupported target "number" with type "example" omitted
+
+# Unsupported target "readme" with type "example" omitted
+
+rust_library(
+ name = "combine",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ "alloc",
+ "bytes",
+ "std",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "4.6.1",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__bytes__1_1_0//:bytes",
+ "@raze__memchr__2_4_1//:memchr",
+ ],
+)
+
+# Unsupported target "async" with type "test" omitted
+
+# Unsupported target "buffered_stream" with type "test" omitted
+
+# Unsupported target "parser" with type "test" omitted
+
+# Unsupported target "parser_macro" with type "test" omitted
diff --git a/cargo/remote/BUILD.dtoa-0.4.8.bazel b/cargo/remote/BUILD.dtoa-0.4.8.bazel
new file mode 100644
index 0000000..21cce7a
--- /dev/null
+++ b/cargo/remote/BUILD.dtoa-0.4.8.bazel
@@ -0,0 +1,57 @@
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # MIT from expression "MIT OR Apache-2.0"
+])
+
+# Generated Targets
+
+# Unsupported target "bench" with type "bench" omitted
+
+rust_library(
+ name = "dtoa",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2015",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.4.8",
+ # buildifier: leave-alone
+ deps = [
+ ],
+)
+
+# Unsupported target "test" with type "test" omitted
diff --git a/cargo/remote/BUILD.redis-0.21.2.bazel b/cargo/remote/BUILD.redis-0.21.2.bazel
new file mode 100644
index 0000000..6305a27
--- /dev/null
+++ b/cargo/remote/BUILD.redis-0.21.2.bazel
@@ -0,0 +1,106 @@
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # BSD-3-Clause from expression "BSD-3-Clause"
+])
+
+# Generated Targets
+
+# Unsupported target "bench_basic" with type "bench" omitted
+
+# Unsupported target "bench_cluster" with type "bench" omitted
+
+# Unsupported target "async-await" with type "example" omitted
+
+# Unsupported target "async-connection-loss" with type "example" omitted
+
+# Unsupported target "async-multiplexed" with type "example" omitted
+
+# Unsupported target "async-pub-sub" with type "example" omitted
+
+# Unsupported target "async-scan" with type "example" omitted
+
+# Unsupported target "basic" with type "example" omitted
+
+# Unsupported target "geospatial" with type "example" omitted
+
+# Unsupported target "streams" with type "example" omitted
+
+rust_library(
+ name = "redis",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ "acl",
+ "default",
+ "geospatial",
+ "script",
+ "sha1",
+ "streams",
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2018",
+ proc_macro_deps = [
+ "@raze__async_trait__0_1_51//:async_trait",
+ ],
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.21.2",
+ # buildifier: leave-alone
+ deps = [
+ "@raze__combine__4_6_1//:combine",
+ "@raze__dtoa__0_4_8//:dtoa",
+ "@raze__itoa__0_4_8//:itoa",
+ "@raze__percent_encoding__2_1_0//:percent_encoding",
+ "@raze__sha1__0_6_0//:sha1",
+ "@raze__url__2_2_2//:url",
+ ],
+)
+
+# Unsupported target "parser" with type "test" omitted
+
+# Unsupported target "test_acl" with type "test" omitted
+
+# Unsupported target "test_async" with type "test" omitted
+
+# Unsupported target "test_async_async_std" with type "test" omitted
+
+# Unsupported target "test_basic" with type "test" omitted
+
+# Unsupported target "test_cluster" with type "test" omitted
+
+# Unsupported target "test_geospatial" with type "test" omitted
+
+# Unsupported target "test_streams" with type "test" omitted
+
+# Unsupported target "test_types" with type "test" omitted
diff --git a/cargo/remote/BUILD.sha1-0.6.0.bazel b/cargo/remote/BUILD.sha1-0.6.0.bazel
new file mode 100644
index 0000000..ff6989f
--- /dev/null
+++ b/cargo/remote/BUILD.sha1-0.6.0.bazel
@@ -0,0 +1,53 @@
+"""
+@generated
+cargo-raze crate build file.
+
+DO NOT EDIT! Replaced on runs of cargo-raze
+"""
+
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# buildifier: disable=load
+load(
+ "@rules_rust//rust:rust.bzl",
+ "rust_binary",
+ "rust_library",
+ "rust_test",
+)
+
+package(default_visibility = [
+ # Public for visibility by "@raze__crate__version//" targets.
+ #
+ # Prefer access through "//cargo", which limits external
+ # visibility to explicit Cargo.toml dependencies.
+ "//visibility:public",
+])
+
+licenses([
+ "notice", # BSD-3-Clause from expression "BSD-3-Clause"
+])
+
+# Generated Targets
+
+rust_library(
+ name = "sha1",
+ srcs = glob(["**/*.rs"]),
+ crate_features = [
+ ],
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ edition = "2015",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.6.0",
+ # buildifier: leave-alone
+ deps = [
+ ],
+)
diff --git a/common/discord/types/payloads/gateway/BUILD.bazel b/common/discord/types/payloads/gateway/BUILD.bazel
deleted file mode 100644
index ce76e4a..0000000
--- a/common/discord/types/payloads/gateway/BUILD.bazel
+++ /dev/null
@@ -1,9 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
- name = "gateway",
- srcs = ["gateway-payload.go"],
- importpath = "github.com/discordnova/nova/common/discord/types/payloads/gateway",
- visibility = ["//visibility:public"],
- deps = ["//common/discord/types/types"],
-)
diff --git a/common/discord/types/payloads/gateway/commands/BUILD.bazel b/common/discord/types/payloads/gateway/commands/BUILD.bazel
deleted file mode 100644
index 51dfe32..0000000
--- a/common/discord/types/payloads/gateway/commands/BUILD.bazel
+++ /dev/null
@@ -1,19 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
- name = "commands",
- srcs = [
- "heartbeat.go",
- "identify.go",
- "request-guild-members.go",
- "resume.go",
- "update-status.go",
- "update-voice-state.go",
- ],
- importpath = "github.com/discordnova/nova/common/discord/types/payloads/gateway/commands",
- visibility = ["//visibility:public"],
- deps = [
- "//common/discord/types/structures",
- "//common/discord/types/types",
- ],
-)
diff --git a/common/discord/types/payloads/gateway/commands/heartbeat.go b/common/discord/types/payloads/gateway/commands/heartbeat.go
deleted file mode 100644
index e51ff6e..0000000
--- a/common/discord/types/payloads/gateway/commands/heartbeat.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package commands
-
-// GatewayCommandHeartbeat is used to maintain an active gateway connection.
-// Must be sent every heartbeat_interval milliseconds after the Opcode 10 Hello payload is received.
-// The inner d key is the last sequence number—s—received by the client. If you have not yet received one, send null.
-type GatewayCommandHeartbeat int
diff --git a/common/discord/types/payloads/gateway/commands/identify.go b/common/discord/types/payloads/gateway/commands/identify.go
deleted file mode 100644
index ee6760e..0000000
--- a/common/discord/types/payloads/gateway/commands/identify.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package commands
-
-import (
- "github.com/discordnova/nova/common/discord/types/structures"
- "github.com/discordnova/nova/common/discord/types/types"
-)
-
-// GatewayCommandIdentifyPayload is used to trigger the initial handshake with the gateway.
-type GatewayCommandIdentifyPayload struct {
- // authentication token
- Token string `json:"token"`
- // connection properties
- Properties structures.IdentifyConnectionProperties `json:"properties"`
- // whether this connection supports compression of packets
- // Default to false
- Compress bool `json:"compress,omitempty"`
- // value between 50 and 250, total number of members where the gateway will stop sending offline members in the
- // guild member list
- // Default to 50
- LargeThreshold int `json:"large_threshold,omitempty"`
- // used for Guild Sharding. array of two integers (shard_id, num_shards)
- Shard []int `json:"shard,omitempty"`
- // presence structure for initial presence information
- Presence GatewayCommandUpdateStatusPayload `json:"presence,omitempty"`
- // enables dispatching of guild subscription events (presence and typing events)
- // Default to true
- GuildSubscriptions bool `json:"guild_subscriptions,omitempty"`
- // the Gateway Intents you wish to receive
- Intents types.GatewayIntents `json:"intents"`
-}
diff --git a/common/discord/types/payloads/gateway/commands/request-guild-members.go b/common/discord/types/payloads/gateway/commands/request-guild-members.go
deleted file mode 100644
index 3e8818e..0000000
--- a/common/discord/types/payloads/gateway/commands/request-guild-members.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package commands
-
-// GatewayCommandRequestGuildMembersPayload is used o request all members for a guild or a list of guilds.
-// When initially connecting,the gateway will only send offline members if a guild has less than the large_threshold
-// members (value in the Gateway Identify).
-// If a client wishes to receive additional members, they need to explicitly request them via this operation.
-// The server will send Guild Members Chunk events in response with up to 1000 members per chunk until all members
-// that match the request have been sent.
-// Due to our privacy and infrastructural concerns with this feature, there are some limitations that apply:
-// GUILD_PRESENCES intent is required to set presences = true. Otherwise, it will always be false
-// GUILD_MEMBERS intent is required to request the entire member list—(query=‘’, limit=0<=n)
-// You will be limited to requesting 1 guild_id per request
-// Requesting a prefix (query parameter) will return a maximum of 100 members
-// Requesting user_ids will continue to be limited to returning 100 members
-type GatewayCommandRequestGuildMembersPayload struct {
- // id of the guild to get members for
- // Required: true
- GuildID string `json:"guild_id"`
- // string that username starts with, or an empty string to return all members
- // Required: one of query or user_ids
- Query string `json:"query,omitempty"`
- // maximum number of members to send matching the query; a limit of 0 can be used with an empty string query to return
- // all members
- // Required: true when specifying query
- Limit int `json:"limit,omitempty"`
- // used to specify if we want the presences of the matched members
- // Required: false
- Presences bool `json:"presences,omitempty"`
- // used to specify which users you wish to fetch
- // Required: one of query or user_ids
- UserIDs string `json:"user_ids,omitempty"`
- // nonce to identify the Guild Members Chunk response
- // Required: false
- Nonce string `json:"nonce,omitempty"`
-}
diff --git a/common/discord/types/payloads/gateway/commands/resume.go b/common/discord/types/payloads/gateway/commands/resume.go
deleted file mode 100644
index 4520efa..0000000
--- a/common/discord/types/payloads/gateway/commands/resume.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package commands
-
-// GatewayCommandResumePayload is used to replay missed events when a disconnected client resumes
-type GatewayCommandResumePayload struct {
- // session token
- Token string `json:"token"`
- // session id
- SessionID string `json:"session_id"`
- // last sequence number received
- Seq int64 `json:"seq"`
-}
diff --git a/common/discord/types/payloads/gateway/commands/update-status.go b/common/discord/types/payloads/gateway/commands/update-status.go
deleted file mode 100644
index 5740a03..0000000
--- a/common/discord/types/payloads/gateway/commands/update-status.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package commands
-
-import (
- "github.com/discordnova/nova/common/discord/types/structures"
- "github.com/discordnova/nova/common/discord/types/types"
-)
-
-// GatewayCommandUpdateStatusPayload is sent by the client to indicate a presence or status update.
-type GatewayCommandUpdateStatusPayload struct {
- // unix time (in milliseconds) of when the client went idle, or null if the client is not idle
- Since int `json:"since,omitempty"`
- // null, or the user's activities
- Activities []structures.Activity `json:"activities,omitempty"`
- // the user's new status
- Status types.UpdateStatusStatuses `json:"status"`
- // whether or not the client is afk
- AFK bool `json:"afk"`
-}
diff --git a/common/discord/types/payloads/gateway/commands/update-voice-state.go b/common/discord/types/payloads/gateway/commands/update-voice-state.go
deleted file mode 100644
index 6cca40b..0000000
--- a/common/discord/types/payloads/gateway/commands/update-voice-state.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package commands
-
-// GatewayCommandUpdateVoiceStatePayload is sent when a client wants to join, move, or disconnect from a voice channel.
-type GatewayCommandUpdateVoiceStatePayload struct {
- // id of the guild
- GuildID string `json:"guild_id"`
- // id of the voice channel client wants to join (null if disconnecting)
- ChannelID string `json:"channel_id,omitempty"`
- // is the client muted
- SelfMute bool `json:"self_mute"`
- // is the client deafened
- SelfDeaf bool `json:"self_deaf"`
-}
diff --git a/common/discord/types/payloads/gateway/events/BUILD.bazel b/common/discord/types/payloads/gateway/events/BUILD.bazel
deleted file mode 100644
index 839dc6a..0000000
--- a/common/discord/types/payloads/gateway/events/BUILD.bazel
+++ /dev/null
@@ -1,52 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
- name = "events",
- srcs = [
- "channel-create.go",
- "channel-delete.go",
- "channel-pins-update.go",
- "channel-update.go",
- "guild-ban-add.go",
- "guild-ban-remove.go",
- "guild-create.go",
- "guild-delete.go",
- "guild-emojis-update.go",
- "guild-integrations-update.go",
- "guild-member-add.go",
- "guild-member-remove.go",
- "guild-member-update.go",
- "guild-members-chunk.go",
- "guild-role-create.go",
- "guild-role-delete.go",
- "guild-role-update.go",
- "guild-update.go",
- "hello.go",
- "invalid-session.go",
- "invite-create.go",
- "invite-delete.go",
- "message-bulk-delete.go",
- "message-create.go",
- "message-delete.go",
- "message-reaction-add.go",
- "message-reaction-remove.go",
- "message-reaction-remove-all.go",
- "message-reaction-remove-emoji.go",
- "message-update.go",
- "presence-update.go",
- "ready.go",
- "reconnect.go",
- "resumed.go",
- "typing-start.go",
- "user-update.go",
- "voice-server-update.go",
- "voice-state-update.go",
- "webhook-update.go",
- ],
- importpath = "github.com/discordnova/nova/common/discord/types/payloads/gateway/events",
- visibility = ["//visibility:public"],
- deps = [
- "//common/discord/types/structures",
- "//common/discord/types/types",
- ],
-)
diff --git a/common/discord/types/payloads/gateway/events/channel-create.go b/common/discord/types/payloads/gateway/events/channel-create.go
deleted file mode 100644
index f4b9645..0000000
--- a/common/discord/types/payloads/gateway/events/channel-create.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventChannelCreatePayload is sent when a new guild channel is created, relevant to the current user.
-// The inner payload is a channel object.
-type GatewayEventChannelCreatePayload structures.Channel
diff --git a/common/discord/types/payloads/gateway/events/channel-delete.go b/common/discord/types/payloads/gateway/events/channel-delete.go
deleted file mode 100644
index 3a83cd1..0000000
--- a/common/discord/types/payloads/gateway/events/channel-delete.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventChannelDeletePayload is sent when a channel relevant to the current user is deleted.
-// The inner payload is a channel object.
-type GatewayEventChannelDeletePayload structures.Channel
diff --git a/common/discord/types/payloads/gateway/events/channel-pins-update.go b/common/discord/types/payloads/gateway/events/channel-pins-update.go
deleted file mode 100644
index 7b00170..0000000
--- a/common/discord/types/payloads/gateway/events/channel-pins-update.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package events
-
-// GatewayEventChannelPinsUpdatePayload is sent when a message is pinned or unpinned in a text channel.
-// This is not sent when a pinned message is deleted.
-type GatewayEventChannelPinsUpdatePayload struct {
- // the id of the guild
- GuildID string `json:"guild_id,omitempty"`
- // the id of the channel
- ChannelID string `json:"channel_id"`
- // the time at which the most recent pinned message was pinned
- LastPinTimestamp string `json:"last_pin_timestamp,omitempty"`
-}
diff --git a/common/discord/types/payloads/gateway/events/channel-update.go b/common/discord/types/payloads/gateway/events/channel-update.go
deleted file mode 100644
index 22a0f7c..0000000
--- a/common/discord/types/payloads/gateway/events/channel-update.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventChannelUpdatePayload is sent when a channel is updated. The inner payload is a channel object.
-// This is not sent when the field last_message_id is altered.
-// To keep track of the last_message_id changes, we should listen for Message Create events.
-type GatewayEventChannelUpdatePayload structures.Channel
diff --git a/common/discord/types/payloads/gateway/events/guild-ban-add.go b/common/discord/types/payloads/gateway/events/guild-ban-add.go
deleted file mode 100644
index bd0311f..0000000
--- a/common/discord/types/payloads/gateway/events/guild-ban-add.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildBanAddPayload is sent when a user is banned from a guild.
-type GatewayEventGuildBanAddPayload struct {
- // id of the guild
- GuildID string `json:"guild_id"`
- // the banned user
- User structures.User `json:"user"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-ban-remove.go b/common/discord/types/payloads/gateway/events/guild-ban-remove.go
deleted file mode 100644
index 784942f..0000000
--- a/common/discord/types/payloads/gateway/events/guild-ban-remove.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildBanRemovePayload is sent when a user is unbanned from a guild.
-type GatewayEventGuildBanRemovePayload struct {
- // id of the guild
- GuildID string `json:"guild_id"`
- // the unbanned user
- User structures.User `json:"user"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-create.go b/common/discord/types/payloads/gateway/events/guild-create.go
deleted file mode 100644
index 9c3eef8..0000000
--- a/common/discord/types/payloads/gateway/events/guild-create.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildCreatePayload can be sent in three different scenarios:
-// When a user is initially connecting,
-// to lazily load and back fill information for all unavailable guilds sent in the Ready event.
-// Guilds that are unavailable due to an outage will send a Guild Delete event.
-// When a Guild becomes available again to the client.
-// When the current user joins a new Guild.
-// The inner payload is a guild object, with all the extra fields specified. (Nothing on the doc)
-type GatewayEventGuildCreatePayload structures.Guild
diff --git a/common/discord/types/payloads/gateway/events/guild-delete.go b/common/discord/types/payloads/gateway/events/guild-delete.go
deleted file mode 100644
index 315e362..0000000
--- a/common/discord/types/payloads/gateway/events/guild-delete.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildDeletePayload is sent when a guild becomes or was already unavailable due to an outage,
-// or when the user leaves or is removed from a guild.
-// The inner payload is an unavailable guild object.
-// If the unavailable field is not set, the user was removed from the guild.
-type GatewayEventGuildDeletePayload structures.Guild
diff --git a/common/discord/types/payloads/gateway/events/guild-emojis-update.go b/common/discord/types/payloads/gateway/events/guild-emojis-update.go
deleted file mode 100644
index d453287..0000000
--- a/common/discord/types/payloads/gateway/events/guild-emojis-update.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildEmojisUpdatePayload is sent when when a guild's emojis have been updated.
-type GatewayEventGuildEmojisUpdatePayload struct {
- // id of the guild
- GuildID string `json:"guild_id"`
- // array of emojis
- Emojis []structures.Emoji `json:"emojis"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-integrations-update.go b/common/discord/types/payloads/gateway/events/guild-integrations-update.go
deleted file mode 100644
index 36c87dc..0000000
--- a/common/discord/types/payloads/gateway/events/guild-integrations-update.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package events
-
-// GatewayEventGuildIntegrationsUpdatePayload is sent when a guild integration is updated.
-type GatewayEventGuildIntegrationsUpdatePayload struct {
- // id of the guild whose integrations were updated
- GuildID string `json:"guild_id"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-member-add.go b/common/discord/types/payloads/gateway/events/guild-member-add.go
deleted file mode 100644
index 2b252a9..0000000
--- a/common/discord/types/payloads/gateway/events/guild-member-add.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildMemberAddPayload is sent when a new user joins a guild.
-// The inner payload is a guild member object with an extra guild_id key
-// If using Gateway Intents, the GUILD_MEMBERS intent will be required to receive this event.
-type GatewayEventGuildMemberAddPayload struct {
- structures.GuildMember
- // id of the guild
- GuildID string `json:"guild_id"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-member-remove.go b/common/discord/types/payloads/gateway/events/guild-member-remove.go
deleted file mode 100644
index 334dd33..0000000
--- a/common/discord/types/payloads/gateway/events/guild-member-remove.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildMemberRemovePayload is sent when a user is removed from a guild (leave/kick/ban).
-// If using Gateway Intents, the GUILD_MEMBERS intent will be required to receive this event.
-type GatewayEventGuildMemberRemovePayload struct {
- // the id of the guild
- GuildID string `json:"guild_id"`
- // the user who was removed
- User structures.User `json:"user"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-member-update.go b/common/discord/types/payloads/gateway/events/guild-member-update.go
deleted file mode 100644
index fccbf1a..0000000
--- a/common/discord/types/payloads/gateway/events/guild-member-update.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildMemberUpdatePayload is sent when a guild member is updated.
-// This will also fire when the user object of a guild member changes.
-// If using Gateway Intents, the GUILD_MEMBERS intent will be required to receive this event.
-type GatewayEventGuildMemberUpdatePayload struct {
- // the id of the guild
- GuildID string `json:"guild_id"`
- // user role ids
- Roles []string `json:"roles"`
- // the user
- User structures.User `json:"user"`
- // nickname of the user in the guild
- Nick string `json:"nick,omitempty"`
- // when the user joined the guild
- JoinedAt string `json:"joined_at"`
- // when the user starting boosting the guild
- PremiumSince string `json:"premium_since,omitempty"`
- // whether the user has not yet passed the guild's Membership Screening requirements
- Pending bool `json:"pending"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-members-chunk.go b/common/discord/types/payloads/gateway/events/guild-members-chunk.go
deleted file mode 100644
index 527b517..0000000
--- a/common/discord/types/payloads/gateway/events/guild-members-chunk.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildMembersChunkPayload is sent in response to Guild Request Members.
-// You can use the chunk_index and chunk_count to calculate how many chunks are left for your request.
-type GatewayEventGuildMembersChunkPayload struct {
- // the id of the guild
- GuildID string `json:"guild_id"`
- // set of guild members
- Members []structures.GuildMember `json:"members"`
- // the chunk index in the expected chunks for this response (0 <= chunk_index < chunk_count)
- ChunkIndex int `json:"chunk_index"`
- // the total number of expected chunks for this response
- ChunkCount int `json:"chunk_count"`
- // if passing an invalid id to REQUEST_GUILD_MEMBERS, it will be returned here
- NotFound []string `json:"not_found,omitempty"`
- // if passing true to REQUEST_GUILD_MEMBERS, presences of the returned members will be here
- Presences []structures.Presence `json:"presences"`
- // the nonce used in the Guild Members Request
- Nonce string `json:"nonce"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-role-create.go b/common/discord/types/payloads/gateway/events/guild-role-create.go
deleted file mode 100644
index 5823aa9..0000000
--- a/common/discord/types/payloads/gateway/events/guild-role-create.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildRoleCreatePayload is sent when a guild role is created.
-type GatewayEventGuildRoleCreatePayload struct {
- // the id of the guild
- GuildID string `json:"guild_id"`
- // the role created
- Role structures.Role `json:"role"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-role-delete.go b/common/discord/types/payloads/gateway/events/guild-role-delete.go
deleted file mode 100644
index b6a1f07..0000000
--- a/common/discord/types/payloads/gateway/events/guild-role-delete.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package events
-
-// GatewayEventGuildRoleDeletePayload is sent when a guild role is updated.
-type GatewayEventGuildRoleDeletePayload struct {
- // the id of the guild
- GuildID string `json:"guild_id"`
- // id of the role
- RoleID string `json:"role_id"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-role-update.go b/common/discord/types/payloads/gateway/events/guild-role-update.go
deleted file mode 100644
index c9c542a..0000000
--- a/common/discord/types/payloads/gateway/events/guild-role-update.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildRoleUpdatePayload is sent when a guild role is updated.
-type GatewayEventGuildRoleUpdatePayload struct {
- // the id of the guild
- GuildID string `json:"guild_id"`
- // the role updated
- Role structures.Role `json:"role"`
-}
diff --git a/common/discord/types/payloads/gateway/events/guild-update.go b/common/discord/types/payloads/gateway/events/guild-update.go
deleted file mode 100644
index b236197..0000000
--- a/common/discord/types/payloads/gateway/events/guild-update.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventGuildUpdatePayload is sent when a guild is updated. The inner payload is a guild object.
-type GatewayEventGuildUpdatePayload structures.Guild
diff --git a/common/discord/types/payloads/gateway/events/hello.go b/common/discord/types/payloads/gateway/events/hello.go
deleted file mode 100644
index ee19926..0000000
--- a/common/discord/types/payloads/gateway/events/hello.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package events
-
-// GatewayEventHelloPayload is sent on connection to the websocket.
-// Defines the heartbeat interval that the client should heartbeat to.
-type GatewayEventHelloPayload struct {
- // HeartbeatInterval is the interval (in milliseconds)
- // the client should heartbeat with
- HeartbeatInterval int `json:"heartbeat_interval"`
-}
diff --git a/common/discord/types/payloads/gateway/events/invalid-session.go b/common/discord/types/payloads/gateway/events/invalid-session.go
deleted file mode 100644
index acc0158..0000000
--- a/common/discord/types/payloads/gateway/events/invalid-session.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package events
-
-// GatewayEventInvalidSessionPayload is sent to indicate one of at least three different situations:the gateway could
-// not initialize a session after receiving an Opcode 2 Identify the gateway could not resume un anterior session
-// after receiving an Opcode 6 Resume the gateway has invalidated an active session and is requesting client
-// actionThe inner d key is a boolean that indicates whether the session may be resumable.
-// See Connecting and Resuming for more information.
-type GatewayEventInvalidSessionPayload bool
diff --git a/common/discord/types/payloads/gateway/events/invite-create.go b/common/discord/types/payloads/gateway/events/invite-create.go
deleted file mode 100644
index 3179241..0000000
--- a/common/discord/types/payloads/gateway/events/invite-create.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package events
-
-import (
- "github.com/discordnova/nova/common/discord/types/structures"
- "github.com/discordnova/nova/common/discord/types/types"
-)
-
-// GatewayEventInviteCreatePayload is sent when a new invite to a channel is created.
-type GatewayEventInviteCreatePayload struct {
- // the channel the invite is for
- ChannelID string `json:"channel_id"`
- // the unique invite code
- Code string `json:"code"`
- // the time at which the invite was created
- CreatedAt string `json:"created_at"`
- // the guild of the invite
- GuildID string `json:"guild_id,omitempty"`
- // the user that created the invite
- Inviter structures.User `json:"inviter,omitempty"`
- // how long the invite is valid for (in seconds)
- MaxAge int `json:"max_age"`
- // the maximum number of times the invite can be used
- MaxUses int `json:"max_uses"`
- // the target user for this invite
- TargetUser structures.User `json:"target_user,omitempty"`
- // the type of user target for this invite
- TargetUserType types.TargetUserTypes `json:"target_user_type"`
- // whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role)
- Temporary bool `json:"temporary"`
- // how many times the invite has been used (always will be 0)
- Uses int `json:"uses"`
-}
diff --git a/common/discord/types/payloads/gateway/events/invite-delete.go b/common/discord/types/payloads/gateway/events/invite-delete.go
deleted file mode 100644
index 080ed45..0000000
--- a/common/discord/types/payloads/gateway/events/invite-delete.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-// GatewayEventInviteDeletePayload is sent when an invite is deleted.
-type GatewayEventInviteDeletePayload struct {
- // the channel of the invite
- ChannelID string `json:"channel_id"`
- // the guild of the invite
- GuildID string `json:"guild_id"`
- // the unique invite code
- Code string `json:"code"`
-}
diff --git a/common/discord/types/payloads/gateway/events/message-bulk-delete.go b/common/discord/types/payloads/gateway/events/message-bulk-delete.go
deleted file mode 100644
index 7f6c60d..0000000
--- a/common/discord/types/payloads/gateway/events/message-bulk-delete.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-// GatewayEventMessageBulkDeletePayload is sent when multiple messages are deleted at once.
-type GatewayEventMessageBulkDeletePayload struct {
- // the ids of the messages
- IDs []string `json:"ids"`
- // the id of the channel
- ChannelID string `json:"channel_id"`
- // the id of the guild
- GuildID string `json:"guild_id,omitempty"`
-}
diff --git a/common/discord/types/payloads/gateway/events/message-create.go b/common/discord/types/payloads/gateway/events/message-create.go
deleted file mode 100644
index 4a947fa..0000000
--- a/common/discord/types/payloads/gateway/events/message-create.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventMessageCreatePayload is sent when a message is created. The inner payload is a message object.
-type GatewayEventMessageCreatePayload structures.Message
diff --git a/common/discord/types/payloads/gateway/events/message-delete.go b/common/discord/types/payloads/gateway/events/message-delete.go
deleted file mode 100644
index ae6da52..0000000
--- a/common/discord/types/payloads/gateway/events/message-delete.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-// GatewayEventMessageDeletePayload is sent when a message is deleted.
-type GatewayEventMessageDeletePayload struct {
- // the id of the message
- ID string `json:"id"`
- // the id of the channel
- ChannelID string `json:"channel_id"`
- // the id of the guild
- GuildID string `json:"guild_id"`
-}
diff --git a/common/discord/types/payloads/gateway/events/message-reaction-add.go b/common/discord/types/payloads/gateway/events/message-reaction-add.go
deleted file mode 100644
index ca2afd3..0000000
--- a/common/discord/types/payloads/gateway/events/message-reaction-add.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventMessageReactionAdd is sent when a user adds a reaction to a message.
-type GatewayEventMessageReactionAdd struct {
- // the id of the user
- UserID string `json:"user_id"`
- // the id of the channel
- ChannelID string `json:"channel_id"`
- // the id of the message
- MessageID string `json:"message_id"`
- // the id of the guild
- GuildID string `json:"guild_id,omitempty"`
- // the member who reacted if this happened in a guild
- Member structures.GuildMember `json:"member"`
- // the emoji used to react
- Emoji structures.Emoji `json:"emoji"`
-}
diff --git a/common/discord/types/payloads/gateway/events/message-reaction-remove-all.go b/common/discord/types/payloads/gateway/events/message-reaction-remove-all.go
deleted file mode 100644
index c25c005..0000000
--- a/common/discord/types/payloads/gateway/events/message-reaction-remove-all.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-// GatewayEventMessageReactionRemoveAll is sent when a user explicitly removes all reactions from a message.
-type GatewayEventMessageReactionRemoveAll struct {
- // the id of the channel
- ChannelID string `json:"channel_id"`
- // the id of the message
- MessageID string `json:"message_id"`
- // the id of the guild
- GuildID string `json:"guild_id,omitempty"`
-}
diff --git a/common/discord/types/payloads/gateway/events/message-reaction-remove-emoji.go b/common/discord/types/payloads/gateway/events/message-reaction-remove-emoji.go
deleted file mode 100644
index 07a8335..0000000
--- a/common/discord/types/payloads/gateway/events/message-reaction-remove-emoji.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventMessageReactionRemoveEmojiPayload is sent when a bot removes all instances of a given emoji from the
-// reactions of a message.
-type GatewayEventMessageReactionRemoveEmojiPayload struct {
- // the id of the channel
- ChannelID string `json:"channel_id"`
- // the id of the guild
- GuildID string `json:"guild_id,omitempty"`
- // the id of the message
- MessageID string `json:"message_id"`
- // the emoji that was removed
- Emoji structures.Emoji `json:"emoji"`
-}
diff --git a/common/discord/types/payloads/gateway/events/message-reaction-remove.go b/common/discord/types/payloads/gateway/events/message-reaction-remove.go
deleted file mode 100644
index 4245ef8..0000000
--- a/common/discord/types/payloads/gateway/events/message-reaction-remove.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventMessageReactionRemove is sent when a user removes a reaction from a message.
-type GatewayEventMessageReactionRemove struct {
- // the id of the user
- UserID string `json:"user_id"`
- // the id of the channel
- ChannelID string `json:"channel_id"`
- // the id of the message
- MessageID string `json:"message_id"`
- // the id of the guild
- GuildID string `json:"guild_id,omitempty"`
- // the emoji used to react
- Emoji structures.Emoji `json:"emoji"`
-}
diff --git a/common/discord/types/payloads/gateway/events/message-update.go b/common/discord/types/payloads/gateway/events/message-update.go
deleted file mode 100644
index 2f2c553..0000000
--- a/common/discord/types/payloads/gateway/events/message-update.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventMessageUpdatePayload is sent when a message is updated. The inner payload is a message object.
-// Unlike creates, message updates may contain only a subset of the full message object payload
-// (but will always contain an id and channel_id).
-type GatewayEventMessageUpdatePayload structures.Message
diff --git a/common/discord/types/payloads/gateway/events/presence-update.go b/common/discord/types/payloads/gateway/events/presence-update.go
deleted file mode 100644
index 9280ce4..0000000
--- a/common/discord/types/payloads/gateway/events/presence-update.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package events
-
-import (
- "github.com/discordnova/nova/common/discord/types/structures"
- "github.com/discordnova/nova/common/discord/types/types"
-)
-
-// GatewayEventPresenceUpdatePayload is sent when a user's presence or info, such as name or avatar, is updated.
-// If you are using Gateway Intents, you must specify the GUILD_PRESENCES intent in order to receive
-// Presence Update events
-// The user object within this event can be partial, the only field which must be sent is the id field,
-// everything else is optional. Along with this limitation, no fields are required,
-// and the types of the fields are not validated.
-// Your client should expect any combination of fields and types within this event.
-type GatewayEventPresenceUpdatePayload struct {
- // the user presence is being updated for
- User structures.User `json:"user"`
- // id of the guild
- GuildID string `json:"guild_id"`
- // either "idle", "dnd", "online", or "offline"
- Status types.Statuses `json:"status"`
- // user's current activities
- Activities []structures.Activity `json:"activities"`
- // user's platform-dependent status
- ClientStatus types.ClientStatuses `json:"client_status"`
-}
diff --git a/common/discord/types/payloads/gateway/events/ready.go b/common/discord/types/payloads/gateway/events/ready.go
deleted file mode 100644
index 9d841b4..0000000
--- a/common/discord/types/payloads/gateway/events/ready.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventReadyPayload is the ready event is dispatched when a client has
-// completed the initial handshake with the gateway (for new sessions).
-// The ready event can be the largest and most complex event the gateway
-// will send, as it contains all the state required for a client
-// to begin interacting with the rest of the platform.
-type GatewayEventReadyPayload struct {
- // V is the gateway version
- V int `json:"v"`
- // User is information about the user including email
- User structures.User `json:"user"`
- // PrivateChannels is an empty array
- PrivateChannels []string `json:"private_channels"`
- // Guilds are the guilds the user is in
- // Note: they are only sent as unavailable guilds
- Guilds []structures.Guild `json:"guilds"`
- // SessionID is used for resuming connections
- SessionID string `json:"session_id"`
- // Shard is the shard information associated with the session, if sent
- // when identifying. This is an array of two integers (shard_id, num_shards)
- Shard []int `json:"shard,omitempty"`
- // contains id and flags
- Application structures.Application `json:"application"`
-}
diff --git a/common/discord/types/payloads/gateway/events/reconnect.go b/common/discord/types/payloads/gateway/events/reconnect.go
deleted file mode 100644
index f840363..0000000
--- a/common/discord/types/payloads/gateway/events/reconnect.go
+++ /dev/null
@@ -1,5 +0,0 @@
-package events
-
-// GatewayEventReconnectPayload is the payload sent when receiving a Reconnect event
-// There is nothing...
-type GatewayEventReconnectPayload struct{}
diff --git a/common/discord/types/payloads/gateway/events/resumed.go b/common/discord/types/payloads/gateway/events/resumed.go
deleted file mode 100644
index 7908d32..0000000
--- a/common/discord/types/payloads/gateway/events/resumed.go
+++ /dev/null
@@ -1,5 +0,0 @@
-package events
-
-// GatewayEventResumedPayload is the payload sent when receiving a Resumed event
-// There is nothing...
-type GatewayEventResumedPayload struct{}
diff --git a/common/discord/types/payloads/gateway/events/typing-start.go b/common/discord/types/payloads/gateway/events/typing-start.go
deleted file mode 100644
index 1ccb06c..0000000
--- a/common/discord/types/payloads/gateway/events/typing-start.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventTypingStartPayload is sent when a user starts typing in a channel.
-type GatewayEventTypingStartPayload struct {
- // id of the channel
- ChannelID string `json:"channel_id"`
- // id of the guild
- GuildID string `json:"guild_id,omitempty"`
- // id of the user
- UserID string `json:"user_id"`
- // unix time (in seconds) of when the user started typing
- Timestamp int `json:"timestamp"`
- // the member who started typing if this happened in a guild
- Member structures.GuildMember `json:"member,omitempty"`
-}
diff --git a/common/discord/types/payloads/gateway/events/user-update.go b/common/discord/types/payloads/gateway/events/user-update.go
deleted file mode 100644
index c0fea63..0000000
--- a/common/discord/types/payloads/gateway/events/user-update.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventUserUpdatePayload is sent when properties about the user change.
-type GatewayEventUserUpdatePayload structures.User
diff --git a/common/discord/types/payloads/gateway/events/voice-server-update.go b/common/discord/types/payloads/gateway/events/voice-server-update.go
deleted file mode 100644
index c356fd5..0000000
--- a/common/discord/types/payloads/gateway/events/voice-server-update.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package events
-
-// GatewayEventVoiceServerUpdate is sent when a guild's voice server is updated.
-type GatewayEventVoiceServerUpdate struct {
- // voice connection token
- Token string `json:"token"`
- // the guild this voice server update is for
- GuildID string `json:"guild_id"`
- // the voice server host
- Endpoint string `json:"endpoint"`
-}
diff --git a/common/discord/types/payloads/gateway/events/voice-state-update.go b/common/discord/types/payloads/gateway/events/voice-state-update.go
deleted file mode 100644
index 102000c..0000000
--- a/common/discord/types/payloads/gateway/events/voice-state-update.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package events
-
-import "github.com/discordnova/nova/common/discord/types/structures"
-
-// GatewayEventVoiceStateUpdatePayload is sent when someone joins/leaves/moves voice channels
-type GatewayEventVoiceStateUpdatePayload structures.VoiceState
diff --git a/common/discord/types/payloads/gateway/events/webhook-update.go b/common/discord/types/payloads/gateway/events/webhook-update.go
deleted file mode 100644
index 7de5bd5..0000000
--- a/common/discord/types/payloads/gateway/events/webhook-update.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package events
-
-// GatewayEventWebhookUpdatePayload is sent when a guild channel's webhook is created, updated, or deleted.
-type GatewayEventWebhookUpdatePayload struct {
- // id of the guild
- GuildID string `json:"guild_id"`
- // id of the channel
- ChannelID string `json:"channel_id"`
-}
diff --git a/common/discord/types/payloads/gateway/gateway-payload.go b/common/discord/types/payloads/gateway/gateway-payload.go
deleted file mode 100644
index ed937d6..0000000
--- a/common/discord/types/payloads/gateway/gateway-payload.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package gateway
-
-import (
- "encoding/json"
-
- "github.com/discordnova/nova/common/discord/types/types"
-)
-
-// Payload is the base of each payload sent to the Gateway, everything
-// else is in the d property.
-type Payload struct {
- // Op is the opcode for the payload
- Op types.GatewayOpCodes `json:"op"`
- // D is the event data
- D json.RawMessage `json:"d"`
- // S is a sequence number used for resuming sessions and heartbeats
- S int64 `json:"s"`
- // T is the event name for this payload
- T string `json:"t"`
-}
diff --git a/common/discord/types/structures/BUILD.bazel b/common/discord/types/structures/BUILD.bazel
deleted file mode 100644
index 63e4e11..0000000
--- a/common/discord/types/structures/BUILD.bazel
+++ /dev/null
@@ -1,50 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
- name = "structures",
- srcs = [
- "activity.go",
- "activity-assets.go",
- "activity-emoji.go",
- "activity-party.go",
- "activity-secrets.go",
- "activity-timestamps.go",
- "application.go",
- "attachment.go",
- "channel.go",
- "channel-mention.go",
- "client-status.go",
- "embed.go",
- "embed-author.go",
- "embed-field.go",
- "embed-footer.go",
- "embed-image.go",
- "embed-provider.go",
- "embed-thumbnail.go",
- "embed-video.go",
- "emoji.go",
- "guild.go",
- "guild-member.go",
- "identify-connection-properties.go",
- "invite.go",
- "message.go",
- "message-activity.go",
- "message-application.go",
- "message-reference.go",
- "overwrite.go",
- "presence.go",
- "reaction.go",
- "role.go",
- "role-tags.go",
- "sticker.go",
- "team.go",
- "team-member.go",
- "user.go",
- "voice-state.go",
- "welcome-screen.go",
- "welcome-screen-channel.go",
- ],
- importpath = "github.com/discordnova/nova/common/discord/types/structures",
- visibility = ["//visibility:public"],
- deps = ["//common/discord/types/types"],
-)
diff --git a/common/discord/types/structures/activity-assets.go b/common/discord/types/structures/activity-assets.go
deleted file mode 100644
index 5a5c26b..0000000
--- a/common/discord/types/structures/activity-assets.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// ActivityAssets is a representation of the assets object sent in an Activity
-type ActivityAssets struct {
- // the id for a large asset of the activity, usually a snowflake
- LargeImage string `json:"large_image,omitempty"`
- // text displayed when hovering over the large image of the activity
- LargeText string `json:"large_text,omitempty"`
- // the id for a small asset of the activity, usually a snowflake
- SmallImage string `json:"small_image,omitempty"`
- // text displayed when hovering over the small image of the activity
- SmallText string `json:"small_text,omitempty"`
-}
diff --git a/common/discord/types/structures/activity-emoji.go b/common/discord/types/structures/activity-emoji.go
deleted file mode 100644
index 99d994c..0000000
--- a/common/discord/types/structures/activity-emoji.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package structures
-
-// ActivityEmoji is the representation of an Emoji object sent for Activities
-type ActivityEmoji struct {
- // the name of the emoji
- Name string `json:"name"`
- // the id of the emoji
- ID string `json:"id,omitempty"`
- // whether this emoji is animated
- Animated bool `json:"animated,omitempty"`
-}
diff --git a/common/discord/types/structures/activity-party.go b/common/discord/types/structures/activity-party.go
deleted file mode 100644
index 9a867ea..0000000
--- a/common/discord/types/structures/activity-party.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package structures
-
-// ActivityParty is a representation of a party sent in an Activity
-type ActivityParty struct {
- // the id of the party
- ID string `json:"id,omitempty"`
- // used to show the party's current and maximum size
- // This is an array of two integers (current_size, max_size)
- Size []int `json:"size,omitempty"`
-}
diff --git a/common/discord/types/structures/activity-secrets.go b/common/discord/types/structures/activity-secrets.go
deleted file mode 100644
index f7fb732..0000000
--- a/common/discord/types/structures/activity-secrets.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package structures
-
-// ActivitySecrets is a representation of the secrets object sent in an Activity
-type ActivitySecrets struct {
- // the secret for joining a party
- Join string `json:"join,omitempty"`
- // the secret for spectating a game
- Spectate string `json:"spectate,omitempty"`
- // the secret for a specific instanced match
- Match string `json:"match,omitempty"`
-}
diff --git a/common/discord/types/structures/activity-timestamps.go b/common/discord/types/structures/activity-timestamps.go
deleted file mode 100644
index fecf05f..0000000
--- a/common/discord/types/structures/activity-timestamps.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package structures
-
-// ActivityTimestamps are the timestamps of an activity
-type ActivityTimestamps struct {
- // unix time (in milliseconds) of when the activity started
- Start int `json:"start,omitempty"`
- // unix time (in milliseconds) of when the activity ends
- End int `json:"end,omitempty"`
-}
diff --git a/common/discord/types/structures/activity.go b/common/discord/types/structures/activity.go
deleted file mode 100644
index 7a64b27..0000000
--- a/common/discord/types/structures/activity.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Activity represents a presence's activity
-// Bots are only able to send name, type, and optionally url.
-type Activity struct {
- // the activity's name
- Name string `json:"name"`
- // activity type
- Type int `json:"type"`
- // stream url, is validated when type is 1
- URL string `json:"url,omitempty"`
- // unix timestamp of when the activity was added to the user's session
- CreatedAt int `json:"created_at"`
- // unix timestamps for start and/or end of the game
- Timestamps ActivityTimestamps `json:"timestamps,omitempty"`
- // application id for the game
- ApplicationID string `json:"application_id,omitempty"`
- // what the player is currently doing
- Details string `json:"details,omitempty"`
- // the user's current party status
- State string `json:"state,omitempty"`
- // the emoji used for a custom status
- Emoji ActivityEmoji `json:"emoji,omitempty"`
- // information for the current party of the player
- Party ActivityParty `json:"party,omitempty"`
- // images for the presence and their hover texts
- Assets ActivityAssets `json:"assets,omitempty"`
- // secrets for Rich Presence joining and spectating
- Secrets ActivitySecrets `json:"secrets,omitempty"`
- // whether or not the activity is an instanced game session
- Instance bool `json:"instance,omitempty"`
- // activity flags ORd together, describes what the payload includes
- Flags types.ActivityFlags `json:"flags,omitempty"`
-}
diff --git a/common/discord/types/structures/application.go b/common/discord/types/structures/application.go
deleted file mode 100644
index c9d96ef..0000000
--- a/common/discord/types/structures/application.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package structures
-
-// Application represents a Discord Application
-type Application struct {
- // the id of the app
- ID string `json:"id"`
- // the name of the app
- Name string `json:"name"`
- // the icon hash of the app
- Icon string `json:"icon,omitempty"`
- // the description of the app
- Description string `json:"description"`
- // an array of rpc origin urls, if rpc is enabled
- RPCOrigins []string `json:"rpc_origins,omitempty"`
- // when false only app owner can join the app's bot to guilds
- BotPublic bool `json:"bot_public"`
- // when true the app's bot will only join upon completion of the full oauth2 code grant flow
- BotRequireCodeGrant bool `json:"bot_require_code_grant"`
- // partial user object containing info on the owner of the application
- Owner User `json:"owner"`
- // if this application is a game sold on Discord, this field will be the summary field for the store page of its sku
- Summary string `json:"summary"`
- // the base64 encoded key for the GameSDK's GetTicket
- VerifyKey string `json:"verify_key"`
- // if the application belongs to a team, this will be a list of the members of that team
- Team Team `json:"team"`
- // if this application is a game sold on Discord, this field will be the guild to which it has been linked
- GuildID string `json:"guild_id,omitempty"`
- // if this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created,
- // if exists
- PrimarySKUID string `json:"primary_sku_id,omitempty"`
- // if this application is a game sold on Discord, this field will be the URL slug that links to the store page
- Slug string `json:"slug,omitempty"`
- // if this application is a game sold on Discord, this field will be the hash of the image on store embeds
- CoverImage string `json:"cover_image,omitempty"`
- // the application's public flags
- Flags int `json:"flags"`
-}
diff --git a/common/discord/types/structures/attachment.go b/common/discord/types/structures/attachment.go
deleted file mode 100644
index 49374a6..0000000
--- a/common/discord/types/structures/attachment.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package structures
-
-// Attachment is the representation of a message attachment
-type Attachment struct {
- // attachment id
- ID string `json:"id"`
- // name of file attached
- Filename string `json:"filename"`
- // size of file in bytes
- Size int `json:"size"`
- // source url of file
- URL string `json:"url"`
- // a proxied url of file
- ProxyURL string `json:"proxy_url"`
- // height of file (if image)
- Height int `json:"height,omitempty"`
- // width of file (if image)
- Width int `json:"width,omitempty"`
-}
diff --git a/common/discord/types/structures/channel-mention.go b/common/discord/types/structures/channel-mention.go
deleted file mode 100644
index 7b70d0a..0000000
--- a/common/discord/types/structures/channel-mention.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// ChannelMention is a representation of a Channel mention
-type ChannelMention struct {
- // id of the channel
- ID string `json:"id"`
- // id of the guild containing the channel
- GuildID string `json:"guild_id"`
- // the type of channel
- Type types.ChannelTypes `json:"type"`
- // the name of the channel
- Name string `json:"name"`
-}
diff --git a/common/discord/types/structures/channel.go b/common/discord/types/structures/channel.go
deleted file mode 100644
index d9c8124..0000000
--- a/common/discord/types/structures/channel.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Channel represents a guild or DM channel
-type Channel struct {
- // the id of this channel
- ID string `json:"id"`
- // the type of channel
- Type types.ChannelTypes `json:"type"`
- // the id of the guild
- GuildID string `json:"guild_id,omitempty"`
- // sorting position of the channel
- Position int `json:"position,omitempty"`
- // explicit permission overwrites for members and roles
- PermissionOverwrites []Overwrite `json:"permission_overwrites,omitempty"`
- // the name of the channel (2-100 characters)
- Name string `json:"name,omitempty"`
- // the channel topic (0-1024 characters)
- Topic string `json:"topic,omitempty"`
- // whether the channel is nsfw
- NSFW bool `json:"nsfw,omitempty"`
- // the id of the last message sent in this channel (may not point to an existing or valid message)
- LastMessageID string `json:"last_message_id,omitempty"`
- // the bitrate (in bits) of the voice channel
- Bitrate int `json:"bitrate,omitempty"`
- // the user limit of the voice channel
- UserLimit int `json:"user_limit,omitempty"`
- // amount of seconds a user has to wait before sending another message (0-21600);
- // bots, as well as users with the permission manage_messages or manage_channel, are unaffected
- RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
- // the recipients of the DM
- Recipients []User `json:"recipients,omitempty"`
- // icon hash
- Icon string `json:"icon,omitempty"`
- // id of the DM creator
- OwnerID string `json:"owner_id,omitempty"`
- // application id of the group DM creator if it is bot-created
- ApplicationID string `json:"application_id,omitempty"`
- // id of the parent category for a channel (each parent category can contain up to 50 channels)
- ParentID string `json:"parent_id,omitempty"`
- // when the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a
- // message is not pinned.
- LastPinTimestamp string `json:"last_pin_timestamp,omitempty"`
-}
diff --git a/common/discord/types/structures/client-status.go b/common/discord/types/structures/client-status.go
deleted file mode 100644
index 956409e..0000000
--- a/common/discord/types/structures/client-status.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// ClientStatus is the representation of a Client Status, for sessions indication
-type ClientStatus struct {
- // the user's status set for an active desktop (Windows, Linux, Mac) application session
- Desktop types.ClientStatuses `json:"desktop,omitempty"`
- // the user's status set for an active mobile (iOS, Android) application session
- Mobile types.ClientStatuses `json:"mobile,omitempty"`
- // the user's status set for an active web (browser, bot account) application session
- Web types.ClientStatuses `json:"web,omitempty"`
-}
diff --git a/common/discord/types/structures/embed-author.go b/common/discord/types/structures/embed-author.go
deleted file mode 100644
index 62112a9..0000000
--- a/common/discord/types/structures/embed-author.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// EmbedAuthor represents the author object of an embed
-type EmbedAuthor struct {
- // name of author
- Name string `json:"name,omitempty"`
- // url of author
- URL string `json:"url,omitempty"`
- // url of author icon (only supports http(s) and attachments)
- IconURL string `json:"icon_url,omitempty"`
- // a proxied url of author icon
- ProxyIconURL string `json:"proxy_icon_url,omitempty"`
-}
diff --git a/common/discord/types/structures/embed-field.go b/common/discord/types/structures/embed-field.go
deleted file mode 100644
index 64179a4..0000000
--- a/common/discord/types/structures/embed-field.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package structures
-
-// EmbedField is the representation of a field in an embed
-type EmbedField struct {
- // name of the field
- Name string `json:"name"`
- // value of the field
- Value string `json:"value"`
- // whether or not this field should display inline
- Inline bool `json:"inline,omitempty"`
-}
diff --git a/common/discord/types/structures/embed-footer.go b/common/discord/types/structures/embed-footer.go
deleted file mode 100644
index cbe943c..0000000
--- a/common/discord/types/structures/embed-footer.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package structures
-
-// EmbedFooter represents the footer of an embed
-type EmbedFooter struct {
- // footer text
- Text string `json:"text"`
- // url of footer icon (only supports http(s) and attachments)
- IconURL string `json:"icon_url,omitempty"`
- // a proxied url of footer icon
- ProxyIconURL string `json:"proxy_icon_url,omitempty"`
-}
diff --git a/common/discord/types/structures/embed-image.go b/common/discord/types/structures/embed-image.go
deleted file mode 100644
index 565bb2b..0000000
--- a/common/discord/types/structures/embed-image.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// EmbedImage represents the image object of an embed
-type EmbedImage struct {
- // source url of image (only supports http(s) and attachments)
- URL string `json:"url,omitempty"`
- // a proxied url of the image
- ProxyURL string `json:"proxy_url,omitempty"`
- // height of image
- Height int `json:"height,omitempty"`
- // width of image
- Width int `json:"width,omitempty"`
-}
diff --git a/common/discord/types/structures/embed-provider.go b/common/discord/types/structures/embed-provider.go
deleted file mode 100644
index eca330c..0000000
--- a/common/discord/types/structures/embed-provider.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package structures
-
-// EmbedProvider represents the provider object of an embed
-type EmbedProvider struct {
- // name of provider
- Name string `json:"name,omitempty"`
- // url of provider
- URL string `json:"url,omitempty"`
-}
diff --git a/common/discord/types/structures/embed-thumbnail.go b/common/discord/types/structures/embed-thumbnail.go
deleted file mode 100644
index f9c55e2..0000000
--- a/common/discord/types/structures/embed-thumbnail.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// EmbedThumbnail represents the thumbnail object of an embed
-type EmbedThumbnail struct {
- // source url of thumbnail (only supports http(s) and attachments)
- URL string `json:"url,omitempty"`
- // a proxied url of the thumbnail
- ProxyURL string `json:"proxy_url,omitempty"`
- // height of thumbnail
- Height int `json:"height,omitempty"`
- // width of thumbnail
- Width int `json:"width,omitempty"`
-}
diff --git a/common/discord/types/structures/embed-video.go b/common/discord/types/structures/embed-video.go
deleted file mode 100644
index 2b9b957..0000000
--- a/common/discord/types/structures/embed-video.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// EmbedVideo represents the video object of an embed
-type EmbedVideo struct {
- // source url of video
- URL string `json:"url,omitempty"`
- // a proxied url of the video
- ProxyURL string `json:"proxy_url,omitempty"`
- // height of video
- Height int `json:"height,omitempty"`
- // width of video
- Width int `json:"width,omitempty"`
-}
diff --git a/common/discord/types/structures/embed.go b/common/discord/types/structures/embed.go
deleted file mode 100644
index f87f40d..0000000
--- a/common/discord/types/structures/embed.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Embed is the representation of an Embed
-type Embed struct {
- // title of embed
- Title string `json:"title,omitempty"`
- // type of embed (always "rich" for webhook embeds)
- Type types.EmbedTypes `json:"type,omitempty"`
- // description of embed
- Description string `json:"description,omitempty"`
- // url of embed
- URL string `json:"url,omitempty"`
- // timestamp of embed content
- Timestamp string `json:"timestamp,omitempty"`
- // color code of the embed
- Color int `json:"color,omitempty"`
- // footer information
- Footer EmbedFooter `json:"footer,omitempty"`
- // image information
- Image EmbedImage `json:"image,omitempty"`
- // thumbnail information
- Thumbnail EmbedThumbnail `json:"thumbnail,omitempty"`
- // video information
- Video EmbedVideo `json:"video,omitempty"`
- // provider information
- Provider EmbedProvider `json:"provider,omitempty"`
- // author information
- Author EmbedAuthor `json:"author,omitempty"`
- // fields information
- Fields []EmbedField `json:"fields,omitempty"`
-}
diff --git a/common/discord/types/structures/emoji.go b/common/discord/types/structures/emoji.go
deleted file mode 100644
index 26d474e..0000000
--- a/common/discord/types/structures/emoji.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package structures
-
-// Emoji is a representation of a Discord Emoji
-type Emoji struct {
- // ID is the emoji id and can be null for default Discord emojis
- ID string `json:"id,omitempty"`
- // Name is the emoji name and can only be nil in Reaction Emoji objects
- Name string `json:"name,omitempty"`
- // roles this emoji is whitelisted to
- Roles string `json:"roles,omitempty"`
- // user that created this emoji
- User User `json:"user,omitempty"`
- // whether this emoji must be wrapped in colons
- RequireColons bool `json:"require_colons,omitempty"`
- // whether this emoji is managed
- Managed bool `json:"managed,omitempty"`
- // whether this emoji is animated
- Animated bool `json:"animated,omitempty"`
- // whether this emoji can be used, may be false due to loss of Server Boosts
- Available bool `json:"available,omitempty"`
-}
diff --git a/common/discord/types/structures/guild-member.go b/common/discord/types/structures/guild-member.go
deleted file mode 100644
index 863d020..0000000
--- a/common/discord/types/structures/guild-member.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package structures
-
-// GuildMember is the representation of a Guild member
-type GuildMember struct {
- // the user this guild member represents
- // The field user won't be included in the member object attached to MESSAGE_CREATE and MESSAGE_UPDATE gateway
- // events.
- User User `json:"user,omitempty"`
- // this users guild nickname
- Nick string `json:"nick"`
- // array of role object ids
- Roles []string `json:"roles"`
- // when the user joined the guild
- JoinedAt string `json:"joined_at"`
- // when the user started boosting the guild
- PremiumSince string `json:"premium_since,omitempty"`
- // whether the user is deafened in voice channels
- Deaf bool `json:"deaf"`
- // whether the user is muted in voice channels
- Mute bool `json:"mute"`
- // whether the user has not yet passed the guild's Membership Screening requirements
- // In GUILD_ events, pending will always be included as true or false. In non GUILD_ events which can only be
- // triggered by non-pending users, pending will not be included.
- Pending bool `json:"pending,omitempty"`
- // total permissions of the member in the channel, including overrides, returned when in the interaction object
- Permissions string `json:"permissions,omitempty"`
-}
diff --git a/common/discord/types/structures/guild.go b/common/discord/types/structures/guild.go
deleted file mode 100644
index fd2a36f..0000000
--- a/common/discord/types/structures/guild.go
+++ /dev/null
@@ -1,117 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Guild is the representation of a Discord Guild, AKA server
-type Guild struct {
- // ID is the guild id
- ID string `json:"id"`
- // Name is the guild name (2-100 characters, excluding trailing and
- // leading whitespace)
- Name string `json:"name"`
- // Icon is the icon hash
- Icon string `json:"icon,omitempty"`
- // IconHash is the icon hash, returned when in the template object
- IconHash string `json:"icon_hash,omitempty"`
- // Splash is the splash hash
- Splash string `json:"splash,omitempty"`
- // DiscoverySplash is discovery splash hash; only present for
- // guilds with the "DISCOVERABLE" feature
- DiscoverySplash string `json:"discovery_splash,omitempty"`
- // Owner is true if the user is the owner of the guild.
- // It is only sent when using the GET Current User Guilds endpoint
- // and is relative to the requested user
- Owner bool `json:"owner,omitempty"`
- // OwnerID is the id of owner
- OwnerID string `json:"owner_id,omitempty"`
- // Permissions are the total permissions for the user in the guild
- // (excludes overrides)
- // It is only sent when using the GET Current User Guilds endpoint
- // and is relative to the requested user
- Permissions string `json:"permissions,omitempty"`
- // Region is the voice region id for the guild
- Region string `json:"region"`
- // AFKChannelID is the id of the afk channel
- AFKChannelID string `json:"afk_channel_id,omitempty"`
- // AFKTimeout is the afk timeout in seconds
- AFKTimeout int `json:"afk_timeout"`
- // true if the server widget is enabled
- WidgetEnabled bool `json:"widget_enabled,omitempty"`
- // the channel id that the widget will generate an invite to, or null if set to no invite
- WidgetChannelID string `json:"widget_channel_id,omitempty"`
- // verification level required for the guild
- VerificationLevel types.VerificationLevels `json:"verification_level"`
- // default message notifications level
- DefaultMessageNotifications types.DefaultMessageNotificationLevels `json:"default_message_notifications"`
- // explicit content filter level
- ExplicitContentFilter types.ExplicitContentFilterLevels `json:"explicit_content_filter"`
- // roles in the guild
- Roles []Role `json:"roles"`
- // custom guild emojis
- Emojis []Emoji `json:"emojis"`
- // enabled guild features
- Features []types.GuildFeatures `json:"features"`
- // required MFA level for the guild
- MFALevel types.MFALevels `json:"mfa_level"`
- // application id of the guild creator if it is bot-created
- ApplicationID string `json:"application_id,omitempty"`
- // the id of the channel where guild notices such as welcome messages and boost events are posted
- SystemChannelID string `json:"system_channel_id,omitempty"`
- // system channel flags
- SystemChannelFlags types.SystemChannelFlags `json:"system_channel_flags,omitempty"`
- // the id of the channel where Community guilds can display rules and/or guidelines
- RulesChannelID string `json:"rules_channel_id,omitempty"`
- // when this guild was joined at
- // This field is only sent within the GUILD_CREATE event
- JoinedAt string `json:"joined_at,omitempty"`
- // true if this is considered a large guild
- // This field is only sent within the GUILD_CREATE event
- Large bool `json:"large,omitempty"`
- // true if this guild is unavailable due to an outage
- // This field is only sent within the GUILD_CREATE event
- Unavailable bool `json:"unavailable,omitempty"`
- // total number of members in this guild
- // This field is only sent within the GUILD_CREATE event
- MemberCount int `json:"member_count,omitempty"`
- // states of members currently in voice channels; lacks the guild_id key
- // This field is only sent within the GUILD_CREATE event
- VoiceStates []VoiceState `json:"voice_states,omitempty"`
- // users in the guild
- // This field is only sent within the GUILD_CREATE event
- Members []GuildMember `json:"members,omitempty"`
- // channels in the guild
- // This field is only sent within the GUILD_CREATE event
- Channels []Channel `json:"channels,omitempty"`
- // presences of the members in the guild, will only include non-offline members if the size is greater than
- // large threshold
- // This field is only sent within the GUILD_CREATE event
- Presences []Presence `json:"presences,omitempty"`
- // the maximum number of presences for the guild (the default value, currently 25000,
- // is in effect when null is returned)
- MaxPresences int `json:"max_presences,omitempty"`
- // the maximum number of members for the guild
- MaxMembers int `json:"max_members,omitempty"`
- // the vanity url code for the guild
- VanityURLCode string `json:"vanity_url_code,omitempty"`
- // the description for the guild, if the guild is discoverable
- Description string `json:"description,omitempty"`
- // banner hash
- Banner string `json:"banner,omitempty"`
- // premium tier (Server Boost level)
- PremiumTier types.PremiumTiers `json:"premium_tier"`
- // the number of boosts this guild currently has
- PremiumSubscriptionCount int `json:"premium_subscription_count,omitempty"`
- // the preferred locale of a Community guild; used in server discovery and notices from Discord; defaults to "en-US"
- PreferredLocale string `json:"preferred_locale"`
- // the id of the channel where admins and moderators of Community guilds receive notices from Discord
- PublicUpdatesChannelID string `json:"public_updates_channel_id,omitempty"`
- // the maximum amount of users in a video channel
- MaxVideoChannelUsers int `json:"max_video_channel_users,omitempty"`
- // approximate number of members in this guild, returned from the GET /guilds/<id> endpoint when with_counts is true
- ApproximateMemberCount int `json:"approximate_member_count,omitempty"`
- // approximate number of non-offline members in this guild, returned from the GET /guilds/<id> endpoint when
- // with_counts is true
- ApproximatePresenceCount int `json:"approximate_presence_count,omitempty"`
- // the welcome screen of a Community guild, shown to new members, returned when in the invite object
- WelcomeScreen WelcomeScreen `json:"welcome_screen,omitempty"`
-}
diff --git a/common/discord/types/structures/identify-connection-properties.go b/common/discord/types/structures/identify-connection-properties.go
deleted file mode 100644
index fa399d7..0000000
--- a/common/discord/types/structures/identify-connection-properties.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package structures
-
-// IdentifyConnectionProperties is the identify connection properties object of an identify command
-type IdentifyConnectionProperties struct {
- // your operating system
- OS string `json:"$os"`
- // your library name
- Browser string `json:"$browser"`
- // your library name
- Device string `json:"$device"`
-}
diff --git a/common/discord/types/structures/invite.go b/common/discord/types/structures/invite.go
deleted file mode 100644
index db11bfa..0000000
--- a/common/discord/types/structures/invite.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Invite is the representation of a Discord Invite
-type Invite struct {
- // the invite code (unique ID)
- Code string `json:"code"`
- // the guild this invite is for
- Guild Guild `json:"guild,omitempty"`
- // the channel this invite is for
- Channel Channel `json:"channel"`
- // the user who created the invite
- Inviter User `json:"inviter,omitempty"`
- // the target user for this invite
- TargetUser User `json:"target_user,omitempty"`
- // the type of user target for this invite
- TargetUserType types.TargetUserTypes `json:"target_user_type,omitempty"`
- // approximate count of online members (only present when target_user is set)
- ApproximatePresenceCount int `json:"approximate_presence_count,omitempty"`
- // approximate count of total members
- ApproximateMemberCount int `json:"approximate_member_count"`
-}
diff --git a/common/discord/types/structures/message-activity.go b/common/discord/types/structures/message-activity.go
deleted file mode 100644
index 4b0f3d1..0000000
--- a/common/discord/types/structures/message-activity.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// MessageActivity is the message activity
-type MessageActivity struct {
- // type of message activity
- Type types.MessageActivityTypes `json:"type"`
- // party_id from a Rich Presence event
- PartyID string `json:"party_id"`
-}
diff --git a/common/discord/types/structures/message-application.go b/common/discord/types/structures/message-application.go
deleted file mode 100644
index 73dfb01..0000000
--- a/common/discord/types/structures/message-application.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package structures
-
-// MessageApplication is the application object of a message
-type MessageApplication struct {
- // id of the application
- ID string `json:"id"`
- // id of the embed's image asset
- CoverImage string `json:"cover_image,omitempty"`
- // application's description
- Description string `json:"description"`
- // id of the application's icon
- Icon string `json:"icon,omitempty"`
- // name of the application
- Name string `json:"name"`
-}
diff --git a/common/discord/types/structures/message-reference.go b/common/discord/types/structures/message-reference.go
deleted file mode 100644
index 48411a8..0000000
--- a/common/discord/types/structures/message-reference.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package structures
-
-// MessageReference is the reference object of a message
-type MessageReference struct {
- // id of the originating message
- MessageID string `json:"message_id,omitempty"`
- // id of the originating message's channel
- // channel_id is optional when creating a reply, but will always be present when receiving an event/response
- // that includes this data model.
- ChannelID string `json:"channel_id,omitempty"`
- // id of the originating message's guild
- GuildID string `json:"guild_id,omitempty"`
- // when sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply)
- // message, default true
- FailIfNotExists bool `json:"fail_if_not_exists,omitempty"`
-}
diff --git a/common/discord/types/structures/message.go b/common/discord/types/structures/message.go
deleted file mode 100644
index a4c92ca..0000000
--- a/common/discord/types/structures/message.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Message is the representation of a Discord Message
-type Message struct {
- // id of the message
- ID string `json:"id"`
- // id of the channel the message was sent in
- ChannelID string `json:"channel_id"`
- // id of the guild the message was sent in
- GuildID string `json:"guild_id,omitempty"`
- // the author of this message (not guaranteed to be a valid user, see below)
- // The author object follows the structure of the user object,
- // but is only a valid user in the case where the message is generated by a user or bot user.
- // If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar.
- // ou can tell if a message is generated by a webhook by checking for the webhook_id on the message object.
- Author User `json:"author"`
- // member properties for this message's author
- // The member object exists in MESSAGE_CREATE and MESSAGE_UPDATE events from text-based guild channels.
- // This allows bots to obtain real-time member data without requiring bots to store member state in memory.
- Member GuildMember `json:"member,omitempty"`
- // contents of the message
- Content string `json:"content"`
- // when this message was sent
- Timestamp string `json:"timestamp"`
- // when this message was edited (or null if never)
- EditedTimestamp string `json:"edited_timestamp,omitempty"`
- // whether this was a TTS message
- TTS bool `json:"tts"`
- // whether this message mentions everyone
- MentionEveryone bool `json:"mention_everyone"`
- // users specifically mentioned in the message
- // The user objects in the mentions array will only have the partial member field present in MESSAGE_CREATE and
- // MESSAGE_UPDATE events from text-based guild channels.
- Mentions []User `json:"mentions"`
- // roles specifically mentioned in this message
- MentionRoles []string `json:"mention_roles"`
- // channels specifically mentioned in this message
- MentionChannels []ChannelMention `json:"mention_channels"`
- // any attached files
- Attachments []Attachment `json:"attachments"`
- // any embedded content
- Embeds []Embed `json:"embeds"`
- // reactions to the message
- Reactions []Reaction `json:"reactions,omitempty"`
- // used for validating a message was sent
- Nonce string `json:"nonce,omitempty"`
- // whether this message is pinned
- Pinned bool `json:"pinned"`
- // if the message is generated by a webhook, this is the webhook's id
- WebhookID string `json:"webhook_id,omitempty"`
- // type of message
- Type types.MessageTypes `json:"type"`
- // sent with Rich Presence-related chat embeds
- Activity MessageActivity `json:"activity,omitempty"`
- // sent with Rich Presence-related chat embeds
- Application MessageApplication `json:"application,omitempty"`
- // reference data sent with cross posted messages and replies
- MessageReference MessageReference `json:"message_reference,omitempty"`
- // message flags combined as a bitfield
- Flags types.MessageFlags `json:"flags,omitempty"`
- // the stickers sent with the message (bots currently can only receive messages with stickers, not send)
- Stickers []Sticker `json:"stickers"`
- // the message associated with the message_reference
- // This field is only returned for messages with a type of 19 (REPLY).
- // If the message is a reply but the referenced_message field is not present, the backend did not attempt to fetch
- // the message that was being replied to, so its state is unknown.
- // If the field exists but is null, the referenced message was deleted.
- ReferencedMessage *Message `json:"referenced_message,omitempty"`
-}
diff --git a/common/discord/types/structures/overwrite.go b/common/discord/types/structures/overwrite.go
deleted file mode 100644
index d120cc1..0000000
--- a/common/discord/types/structures/overwrite.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// Overwrite is a representation of Overwrite in Discord permissions system
-type Overwrite struct {
- // role or user id
- ID string `json:"id"`
- // either 0 (role) or 1 (member)
- Type int `json:"type"`
- // permission bit set
- Allow string `json:"allow"`
- // permission bit set
- Deny string `json:"deny"`
-}
diff --git a/common/discord/types/structures/presence.go b/common/discord/types/structures/presence.go
deleted file mode 100644
index 1122f00..0000000
--- a/common/discord/types/structures/presence.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Presence is the representation of a user's presence on a guild.
-type Presence struct {
- // the user presence is being updated for
- User User `json:"user"`
- // id of the guild
- GuildID string `json:"guild_id"`
- // either "idle", "dnd", "online", or "offline"
- Status types.Statuses `json:"status"`
- // user's current activities
- Activities []Activity `json:"activities"`
- // user's platform-dependent status
- ClientStatus ClientStatus `json:"client_status"`
-}
diff --git a/common/discord/types/structures/reaction.go b/common/discord/types/structures/reaction.go
deleted file mode 100644
index 12409a8..0000000
--- a/common/discord/types/structures/reaction.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package structures
-
-// Reaction represents a message reaction
-type Reaction struct {
- // times this emoji has been used to react
- Count int `json:"count"`
- // whether the current user reacted using this emoji
- Me bool `json:"me"`
- // emoji information
- Emoji Emoji `json:"emoji"`
-}
diff --git a/common/discord/types/structures/role-tags.go b/common/discord/types/structures/role-tags.go
deleted file mode 100644
index fc8ab98..0000000
--- a/common/discord/types/structures/role-tags.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package structures
-
-// RoleTags is the tag a role has
-type RoleTags struct {
- BotID string `json:"bot_id,omitempty"`
- IntegrationID string `json:"integration_id,omitempty"`
- // ALWAYS NULL YET
- PremiumSubscriber struct{} `json:"premium_subscriber"`
-}
diff --git a/common/discord/types/structures/role.go b/common/discord/types/structures/role.go
deleted file mode 100644
index b381cc5..0000000
--- a/common/discord/types/structures/role.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package structures
-
-// Role is a Discord Role
-type Role struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Color int `json:"color"`
- Hoist bool `json:"hoist"`
- Position int `json:"position"`
- Permissions string `json:"permissions"`
- Managed bool `json:"managed"`
- Mentionable bool `json:"mentionable"`
- Tags RoleTags `json:"tags,omitempty"`
-}
diff --git a/common/discord/types/structures/sticker.go b/common/discord/types/structures/sticker.go
deleted file mode 100644
index cc11112..0000000
--- a/common/discord/types/structures/sticker.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// Sticker represents a Discord message sticker
-type Sticker struct {
- // id of the sticker
- ID string `json:"id"`
- // id of the pack the sticker is from
- PackID string `json:"pack_id"`
- // name of the sticker
- Name string `json:"name"`
- // description of the sticker
- Description string `json:"description"`
- // a comma-separated list of tags for the sticker
- Tags string `json:"tags,omitempty"`
- // sticker asset hash
- Asset string `json:"asset"`
- // sticker preview asset hash
- PreviewAsset string `json:"preview_asset,omitempty"`
- // type of sticker format
- FormatType types.StickerTypes `json:"format_type"`
-}
diff --git a/common/discord/types/structures/team-member.go b/common/discord/types/structures/team-member.go
deleted file mode 100644
index c8f7c50..0000000
--- a/common/discord/types/structures/team-member.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// TeamMember represents a member of a Discord Team
-type TeamMember struct {
- // the user's membership state on the team
- MembershipState types.MembershipStates `json:"membership_state"`
- // will always be ["*"]
- Permissions []string `json:"permissions"`
- // the id of the parent team of which they are a member
- TeamID string `json:"team_id"`
- // the avatar, discriminator, id, and username of the user
- User User `json:"user"`
-}
diff --git a/common/discord/types/structures/team.go b/common/discord/types/structures/team.go
deleted file mode 100644
index f050f7f..0000000
--- a/common/discord/types/structures/team.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// Team represents a Discord Team
-type Team struct {
- // a hash of the image of the team's icon
- Icon string `json:"icon,omitempty"`
- // the unique id of the team
- ID string `json:"id"`
- // the members of the team
- Members []TeamMember `json:"members"`
- // the user id of the current team owner
- OwnerUserID string `json:"owner_user_id"`
-}
diff --git a/common/discord/types/structures/user.go b/common/discord/types/structures/user.go
deleted file mode 100644
index 7682536..0000000
--- a/common/discord/types/structures/user.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package structures
-
-import "github.com/discordnova/nova/common/discord/types/types"
-
-// User represents the User Structure sent by the Discord API
-type User struct {
- ID string `json:"id"`
- Username string `json:"username"`
- Discriminator string `json:"discriminator"`
- Avatar string `json:"avatar,omitempty"`
- Bot bool `json:"bot,omitempty"`
- System bool `json:"system,omitempty"`
- MFAEnabled bool `json:"mfa_enabled,omitempty"`
- Locale string `json:"locale,omitempty"`
- Verified bool `json:"verified,omitempty"`
- Email string `json:"email,omitempty"`
- Flags types.UserFlags `json:"flags,omitempty"`
- PremiumType types.PremiumTypes `json:"premium_type,omitempty"`
- PublicFlags types.UserFlags `json:"public_flags,omitempty"`
-}
diff --git a/common/discord/types/structures/voice-state.go b/common/discord/types/structures/voice-state.go
deleted file mode 100644
index b0f95e4..0000000
--- a/common/discord/types/structures/voice-state.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package structures
-
-// VoiceState is a representation of a user's voice connection status
-type VoiceState struct {
- // the guild id this voice state is for
- GuildID string `json:"guild_id,omitempty"`
- // the channel id this user is connected to
- ChannelID string `json:"channel_id,omitempty"`
- // the user id this voice state is for
- UserID string `json:"user_id,omitempty"`
- // the guild member this voice state is for
- Member GuildMember `json:"member,omitempty"`
- // the session id for this voice state
- SessionID string `json:"session_id"`
- // whether this user is deafened by the server
- Deaf bool `json:"deaf"`
- // whether this user is muted by the server
- Mute bool `json:"mute"`
- // whether this user is locally deafened
- SelfDeaf bool `json:"self_deaf"`
- // whether this user is locally muted
- SelfMute bool `json:"self_mute"`
- // whether this user is streaming using "Go Live"
- SelfStream bool `json:"self_stream,omitempty"`
- // whether this user's camera is enabled
- SelfVideo bool `json:"self_video"`
- // whether this user is muted by the current user
- Suppress bool `json:"suppress"`
-}
diff --git a/common/discord/types/structures/welcome-screen-channel.go b/common/discord/types/structures/welcome-screen-channel.go
deleted file mode 100644
index 9da92d5..0000000
--- a/common/discord/types/structures/welcome-screen-channel.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package structures
-
-// WelcomeScreenChannel is a representation of a channel in a welcome screen
-type WelcomeScreenChannel struct {
- // the channel's id
- ChannelID string `json:"channel_id"`
- // the description shown for the channel
- Description string `json:"description"`
- // the emoji id, if the emoji is custom
- EmojiID string `json:"emoji_id,omitempty"`
- // the emoji name if custom, the unicode character if standard, or null if no emoji is set
- EmojiName string `json:"emoji_name,omitempty"`
-}
diff --git a/common/discord/types/structures/welcome-screen.go b/common/discord/types/structures/welcome-screen.go
deleted file mode 100644
index 1377ec4..0000000
--- a/common/discord/types/structures/welcome-screen.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package structures
-
-// WelcomeScreen is a representation of a Guild welcome screen
-type WelcomeScreen struct {
- // the server description shown in the welcome screen
- Description string `json:"description,omitempty"`
- // the channels shown in the welcome screen, up to 5
- WelcomeChannels []WelcomeScreenChannel `json:"welcome_channels"`
-}
diff --git a/common/discord/types/types/BUILD.bazel b/common/discord/types/types/BUILD.bazel
deleted file mode 100644
index f4f23a3..0000000
--- a/common/discord/types/types/BUILD.bazel
+++ /dev/null
@@ -1,36 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
- name = "types",
- srcs = [
- "activity-flags.go",
- "activity-types.go",
- "channel-types.go",
- "client-statuses.go",
- "default-message-notification-levels.go",
- "embed-types.go",
- "explicit-content-filter-levels.go",
- "gateway-close-event-codes.go",
- "gateway-intents.go",
- "gateway-op-codes.go",
- "guild-features.go",
- "membership-states.go",
- "message-activity-types.go",
- "message-flags.go",
- "message-types.go",
- "mfa-levels.go",
- "premium-tiers.go",
- "premium-types.go",
- "statuses.go",
- "sticker-types.go",
- "system-channel-flags.go",
- "target-user-types.go",
- "update-status-statuses.go",
- "user-flags.go",
- "verification-levels.go",
- "voice-gateway-close-event-codes.go",
- "voice-gateway-op-codes.go",
- ],
- importpath = "github.com/discordnova/nova/common/discord/types/types",
- visibility = ["//visibility:public"],
-)
diff --git a/common/discord/types/types/activity-flags.go b/common/discord/types/types/activity-flags.go
deleted file mode 100644
index 0f8e54c..0000000
--- a/common/discord/types/types/activity-flags.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package types
-
-// ActivityFlags are the flags of an activity
-type ActivityFlags int
-
-const (
- // ActivityFlagInstance is the flag for instanced activities
- ActivityFlagInstance ActivityFlags = 1 << 0
- // ActivityFlagJoin is the flag for activities we can join
- ActivityFlagJoin = 1 << 1
- // ActivityFlagSpectate is the flag for activities we can spectate
- ActivityFlagSpectate = 1 << 2
- // ActivityFlagJoinRequest is the flag for activities we can request to join
- ActivityFlagJoinRequest = 1 << 3
- // ActivityFlagSync is the flag for sync activities
- ActivityFlagSync = 1 << 4
- // ActivityFlagPlay is the flag for playable activities
- ActivityFlagPlay = 1 << 5
-)
diff --git a/common/discord/types/types/activity-types.go b/common/discord/types/types/activity-types.go
deleted file mode 100644
index 1864799..0000000
--- a/common/discord/types/types/activity-types.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package types
-
-// ActivityTypes are the different types for an activity
-type ActivityTypes int
-
-const (
- // ActivityTypeGame is the "Playing {name}" activity
- ActivityTypeGame ActivityTypes = 0
- // ActivityTypeStreaming is the "Streaming {details}" activity
- // The streaming type currently only supports Twitch and YouTube.
- // Only https://twitch.tv/ and https://youtube.com/ urls will work.
- ActivityTypeStreaming = 1
- // ActivityTypeListening is the "Listening to {name}" activity
- ActivityTypeListening = 2
-
- /* yes, there is no 3 */
-
- // ActivityTypeCustom is the "{emoji} {name}" activity
- ActivityTypeCustom = 4
- // ActivityTypeCompeting is the "Competing in {name}" activity
- ActivityTypeCompeting = 5
-)
diff --git a/common/discord/types/types/channel-types.go b/common/discord/types/types/channel-types.go
deleted file mode 100644
index 2aa9c9f..0000000
--- a/common/discord/types/types/channel-types.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package types
-
-// ChannelTypes are the different types of channel
-type ChannelTypes int
-
-const (
- // ChannelTypeGuildText is a text channel within a server
- ChannelTypeGuildText ChannelTypes = 0
- // ChannelTypeDM is a direct message between users
- ChannelTypeDM = 1
- // ChannelTypeGuildVoice is a voice channel within a server
- ChannelTypeGuildVoice = 2
- // ChannelTypeGroupDM is a direct message between multiple users
- ChannelTypeGroupDM = 3
- // ChannelTypeGuildCategory is an organizational category that contains up to 50 channels
- ChannelTypeGuildCategory = 4
- // ChannelTypeGuildNews is a channel that users can follow and cross post into their own server
- ChannelTypeGuildNews = 5
- // ChannelTypeGuildStore is a channel in which game developers can sell their game on Discord
- ChannelTypeGuildStore = 6
-)
diff --git a/common/discord/types/types/client-statuses.go b/common/discord/types/types/client-statuses.go
deleted file mode 100644
index a01b451..0000000
--- a/common/discord/types/types/client-statuses.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package types
-
-// ClientStatuses are the different client status for active sessions
-type ClientStatuses string
-
-const (
- // ClientStatusOnline is the status for online users
- ClientStatusOnline ClientStatuses = "online"
- // ClientStatusIdle is the status for idle sessions
- ClientStatusIdle ClientStatuses = "idle"
- // ClientStatusDnD is the status for do not disturb sessions
- ClientStatusDnD ClientStatuses = "dnd"
- /* There is no offline: https://discord.com/developers/docs/topics/gateway#client-status-object */
-)
diff --git a/common/discord/types/types/default-message-notification-levels.go b/common/discord/types/types/default-message-notification-levels.go
deleted file mode 100644
index d60a58c..0000000
--- a/common/discord/types/types/default-message-notification-levels.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package types
-
-// DefaultMessageNotificationLevels is the notification level for a guild
-type DefaultMessageNotificationLevels int
-
-const (
- // DefaultMessageNotificationLevelAllMessages notify on every message
- DefaultMessageNotificationLevelAllMessages DefaultMessageNotificationLevels = 0
- // DefaultMessageNotificationLevelOnlyMentions notify only on mentions
- DefaultMessageNotificationLevelOnlyMentions = 1
-)
diff --git a/common/discord/types/types/embed-types.go b/common/discord/types/types/embed-types.go
deleted file mode 100644
index 407f93f..0000000
--- a/common/discord/types/types/embed-types.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package types
-
-// EmbedTypes are the different types of a Embed
-type EmbedTypes string
-
-const (
- // EmbedTypeRich is a generic embed rendered from embed attributes
- EmbedTypeRich EmbedTypes = "rich"
- // EmbedTypeImage is an image embed
- EmbedTypeImage = "image"
- // EmbedTypeVideo is a video embed
- EmbedTypeVideo = "video"
- // EmbedTypeGIFV is an animated gif image embed rendered as a video embed
- EmbedTypeGIFV = "gifv"
- // EmbedTypeArticle is an article embed
- EmbedTypeArticle = "article"
- // EmbedTypeLink is a link embed
- EmbedTypeLink = "link"
-)
diff --git a/common/discord/types/types/explicit-content-filter-levels.go b/common/discord/types/types/explicit-content-filter-levels.go
deleted file mode 100644
index d53e71c..0000000
--- a/common/discord/types/types/explicit-content-filter-levels.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package types
-
-// ExplicitContentFilterLevels is the level for the Explicit Content
-type ExplicitContentFilterLevels int
-
-const (
- // ExplicitContentFilterLevelDisabled disables the scan
- ExplicitContentFilterLevelDisabled = 0
- // ExplicitContentFilterLevelMembersWithoutRoles scans for members without roles
- ExplicitContentFilterLevelMembersWithoutRoles = 1
- // ExplicitContentFilterLevelAllMembers scans for anyone
- ExplicitContentFilterLevelAllMembers = 2
-)
diff --git a/common/discord/types/types/gateway-close-event-codes.go b/common/discord/types/types/gateway-close-event-codes.go
deleted file mode 100644
index a28a455..0000000
--- a/common/discord/types/types/gateway-close-event-codes.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package types
-
-// GatewayCloseEventCodes is a code explaining the reason
-// the gateway connection closed
-type GatewayCloseEventCodes int
-
-// GatewayCloseEventCodes values
-const (
- // GatewayCloseEventCodeUnknownError is corresponding to a
- // Discord internal error
- GatewayCloseEventCodeUnknownError GatewayCloseEventCodes = 4000
- // GatewayCloseEventCodeUnknownOpCode is used when an
- // invalid payload for a payload or opcode was sent
- GatewayCloseEventCodeUnknownOpCode = 4001
- // GatewayCloseEventCodeDecodeError is used when an invalid payload was sent
- GatewayCloseEventCodeDecodeError = 4002
- // GatewayCloseEventCodeNotAuthenticated is used when a payload was
- // sent prior to the Identify payload
- GatewayCloseEventCodeNotAuthenticated = 4003
- // GatewayCloseEventCodeAuthenticationFailed is used when the account token
- // in the Identify payload is incorrect
- GatewayCloseEventCodeAuthenticationFailed = 4004
- // GatewayCloseEventCodeAlreadyAuthenticated is used when more than one
- // Identify payload was sent
- GatewayCloseEventCodeAlreadyAuthenticated = 4005
-
- /* There is no 4006... */
-
- // GatewayCloseEventCodeInvalidSeq is used when the sequence of a
- // resuming payload is invalid. Need tro reconnect and start a new session
- GatewayCloseEventCodeInvalidSeq = 4007
- // GatewayCloseEventCodeRateLimited is used when a rate limit applied.
- GatewayCloseEventCodeRateLimited = 4008
- // GatewayCloseEventCodeSessionTimedOut is used when a session expired.
- // Need to reconnect and start a new one
- GatewayCloseEventCodeSessionTimedOut = 4009
- // GatewayCloseEventCodeInvalidShard is used when an invalid shard was sent
- // in the Identify payload
- GatewayCloseEventCodeInvalidShard = 4010
- // GatewayCloseEventCodeShardingRequired is used when a session handle too
- // many guild. The connection needs more shards
- GatewayCloseEventCodeShardingRequired = 4011
- // GatewayCloseEventCodeInvalidAPIVersion is used when an invalid version
- // of the gateway was sent
- GatewayCloseEventCodeInvalidAPIVersion = 4012
- // GatewayCloseEventCodeInvalidIntents is used when invalid intents were
- // provided.
- GatewayCloseEventCodeInvalidIntents = 4013
- // GatewayCloseEventCodeDisallowedIntents is used when a provided intent is
- // not enabled.
- GatewayCloseEventCodeDisallowedIntents = 4014
-)
diff --git a/common/discord/types/types/gateway-intents.go b/common/discord/types/types/gateway-intents.go
deleted file mode 100644
index 7fc4aef..0000000
--- a/common/discord/types/types/gateway-intents.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package types
-
-// GatewayIntents are the Intents for the Gateway
-type GatewayIntents int
-
-//
-const (
- GatewayIntentGuilds GatewayIntents = 1 << 0
- GatewayIntentGuildMembers = 1 << 1
- GatewayIntentGuildBans = 1 << 2
- GatewayIntentGuildEmojis = 1 << 2
- GatewayIntentGuildIntegrations = 1 << 4
- GatewayIntentGuildWebhooks = 1 << 5
- GatewayIntentGuildInvites = 1 << 6
- GatewayIntentGuildVoiceStates = 1 << 7
- GatewayIntentGuildPresences = 1 << 8
- GatewayIntentGuildMessages = 1 << 9
- GatewayIntentGuildMessageReactions = 1 << 10
- GatewayIntentGuildMessageTyping = 1 << 11
- GatewayIntentDirectMessages = 1 << 12
- GatewayIntentDirectMessageReactions = 1 << 13
- GatewayIntentDirectMessageTyping = 1 << 14
-)
diff --git a/common/discord/types/types/gateway-op-codes.go b/common/discord/types/types/gateway-op-codes.go
deleted file mode 100644
index a4942f3..0000000
--- a/common/discord/types/types/gateway-op-codes.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package types
-
-// GatewayOpCodes are code tagged by the Discord Gateway to type payloads
-type GatewayOpCodes int
-
-// Valid OpCode values
-const (
- // GatewayOpCodeDispatch is when an event was dispatched.
- GatewayOpCodeDispatch GatewayOpCodes = 0
- // GatewayOpCodeHeartbeat is fired periodically by the client
- // to keep the connection alive.
- GatewayOpCodeHeartbeat = 1
- // GatewayOpCodeIdentify starts a new session during the initial handshake.
- GatewayOpCodeIdentify = 2
- // GatewayOpCodePresenceUpdate updates the client's presence.
- GatewayOpCodePresenceUpdate = 3
- // GatewayOpCodeVoiceStateUpdate is used to join/leave or
- // move between voice channels.
- GatewayOpCodeVoiceStateUpdate = 4
-
- // Yes, there is no 5
-
- // GatewayOpCodeResume resumes a previous session that was disconnected.
- GatewayOpCodeResume = 6
- // GatewayOpCodeReconnect announces that you should attempt to reconnect
- // and resume immediately.
- GatewayOpCodeReconnect = 7
- // GatewayOpCodeRequestGuildMembers requests information about offline guild
- // members in a large guild.
- GatewayOpCodeRequestGuildMembers = 8
- // GatewayOpCodeInvalidSession announces that the session has been invalidated and
- // you should reconnect and identify/resume accordingly.
- GatewayOpCodeInvalidSession = 9
- // GatewayOpCodeHello is sent immediately after connecting and contains
- // the heartbeat_interval to use.
- GatewayOpCodeHello = 10
- // GatewayOpCodeHeartbeatACK is sent in response to receiving a heartbeat
- // to acknowledge that it has been received.
- GatewayOpCodeHeartbeatACK = 11
-)
diff --git a/common/discord/types/types/guild-features.go b/common/discord/types/types/guild-features.go
deleted file mode 100644
index a01489a..0000000
--- a/common/discord/types/types/guild-features.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package types
-
-// GuildFeatures is the features enabled for a Guild
-type GuildFeatures string
-
-const (
- // GuildFeatureInviteSplash is the feature where a guild can set an invite splash background
- GuildFeatureInviteSplash GuildFeatures = "INVITE_SPLASH"
- // GuildFeatureVIPRegions is the feature where a guild has access to set 384kbps bitrate in voice
- // // (previously VIP voice servers)
- GuildFeatureVIPRegions = "VIP_REGIONS"
- // GuildFeatureVanityURL is the feature where a guild has access to set a vanity URL
- GuildFeatureVanityURL = "VANITY_URL"
- // GuildFeatureVerified is the feature where a guild is verified
- GuildFeatureVerified = "VERIFIED"
- // GuildFeaturePartnered is the feature where a guild is partnered
- GuildFeaturePartnered = "PARTNERED"
- // GuildFeatureCommunity is the feature where a guild can enable welcome screen, Membership Screening,
- // and discovery, and receives community updates
- GuildFeatureCommunity = "COMMUNITY"
- // GuildFeatureCommerce is the feature where a guild has access to use commerce features (i.e. create store channels)
- GuildFeatureCommerce = "COMMERCE"
- // GuildFeatureNews is the feature where a guild has access to create news channels
- GuildFeatureNews = "NEWS"
- // GuildFeatureDiscoverable is the feature where a guild is able to be discovered in the directory
- GuildFeatureDiscoverable = "DISCOVERABLE"
- // GuildFeatureFeaturable is the feature where a guild is able to be featured in the directory
- GuildFeatureFeaturable = "FEATURABLE"
- // GuildFeatureAnimatedIcon is the feature where a guild has access to set an animated guild icon
- GuildFeatureAnimatedIcon = "ANIMATED_ICON"
- // GuildFeatureBanner is the feature where a guild has access to set a guild banner image
- GuildFeatureBanner = "BANNER"
- // GuildFeatureWelcomeScreenEnabled is the feature where a guild has enabled the welcome screen
- GuildFeatureWelcomeScreenEnabled = "WELCOME_SCREEN_ENABLED"
- // GuildFeatureMemberMemberVerificationGateEnabled is the feature where a guild has enabled Membership Screening
- GuildFeatureMemberMemberVerificationGateEnabled = "MEMBER_VERIFICATION_GATE_ENABLED"
- // GuildFeaturePreviewEnabled is the feature where a guild can be previewed before joining via
- // Membership Screening or the directory
- GuildFeaturePreviewEnabled = "PREVIEW_ENABLED"
-)
diff --git a/common/discord/types/types/membership-states.go b/common/discord/types/types/membership-states.go
deleted file mode 100644
index 013faec..0000000
--- a/common/discord/types/types/membership-states.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package types
-
-// MembershipStates are the different state of a membership in a Team
-type MembershipStates int
-
-const (
- // MembershipStateInvited is the state of a pending invitation
- MembershipStateInvited MembershipStates = 1
- // MembershipStateAccepted is the state of an accepted invitation
- MembershipStateAccepted = 2
-)
diff --git a/common/discord/types/types/message-activity-types.go b/common/discord/types/types/message-activity-types.go
deleted file mode 100644
index 57f4ab4..0000000
--- a/common/discord/types/types/message-activity-types.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-// MessageActivityTypes are the types of a message activity
-type MessageActivityTypes int
-
-//
-const (
- MessageActivityTypeJoin MessageActivityTypes = 1
- MessageActivityTypeSpectate = 2
- MessageActivityTypeListen = 3
- MessageActivityTypeJoinRequest = 5
-)
diff --git a/common/discord/types/types/message-flags.go b/common/discord/types/types/message-flags.go
deleted file mode 100644
index a38c630..0000000
--- a/common/discord/types/types/message-flags.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package types
-
-// MessageFlags are the flags of a message
-type MessageFlags int
-
-const (
- // MessageFlagCrossPosted is used when this message has been published to subscribed channels (
- // via Channel Following)
- MessageFlagCrossPosted MessageFlags = 1 << 0
- // MessageFlagIsCrossPost is used when this message originated from a message in another channel (
- // via Channel Following)
- MessageFlagIsCrossPost = 1 << 1
- // MessageFlagSuppressEmbeds is used when not include any embeds when serializing this message
- MessageFlagSuppressEmbeds = 1 << 2
- // MessageFlagSourceMessageDeleted is used when the source message for this cross post has been deleted (
- // via Channel Following)
- MessageFlagSourceMessageDeleted = 1 << 3
- // MessageFlagUrgent is used when this message came from the urgent message system
- MessageFlagUrgent = 1 << 4
-)
diff --git a/common/discord/types/types/message-types.go b/common/discord/types/types/message-types.go
deleted file mode 100644
index 03fab40..0000000
--- a/common/discord/types/types/message-types.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package types
-
-// MessageTypes are the types of a message
-type MessageTypes int
-
-//
-const (
- MessageTypeDefault MessageTypes = 0
- MessageTypeRecipientAdd = 1
- MessageTypeRecipientRemove = 2
- MessageTypeCall = 3
- MessageTypeChannelNameChange = 4
- MessageTypeChannelIconChange = 5
- MessageTypeChannelPinnedMessage = 6
- MessageTypeGuildMemberJoin = 7
- MessageTypeUserPremiumGuildSubscription = 8
- MessageTypeUserPremiumGuildSubscriptionTier1 = 9
- MessageTypeUserPremiumGuildSubscriptionTier2 = 10
- MessageTypeUserPremiumGuildSubscriptionTier3 = 11
- MessageTypeChannelFollowAdd = 12
- MessageTypeGuildDiscoveryDisqualified = 14
- MessageTypeGuildDiscoveryRequalified = 15
- MessageTypeReply = 19
- MessageTypeApplicationCommand = 20
-)
diff --git a/common/discord/types/types/mfa-levels.go b/common/discord/types/types/mfa-levels.go
deleted file mode 100644
index b33a0f2..0000000
--- a/common/discord/types/types/mfa-levels.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package types
-
-// MFALevels are the different level of MFA (a2f)
-type MFALevels int
-
-const (
- // MFALevelNone is the level where MFA is not required
- MFALevelNone MFALevels = 0
- // MFALevelElevated is the level where MFA is required
- MFALevelElevated = 1
-)
diff --git a/common/discord/types/types/premium-tiers.go b/common/discord/types/types/premium-tiers.go
deleted file mode 100644
index 901271a..0000000
--- a/common/discord/types/types/premium-tiers.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package types
-
-// PremiumTiers are the different tiers of a premium on a guild (aka Boosts)
-type PremiumTiers int
-
-const (
- // PremiumTierNone is the tier with no boosts
- PremiumTierNone PremiumTiers = 0
- // PremiumTierTier1 is the first boosts tier
- PremiumTierTier1 = 1
- // PremiumTierTier2 is the second boosts tier
- PremiumTierTier2 = 2
- // PremiumTierTier3 is the third boosts tier
- PremiumTierTier3 = 3
-)
diff --git a/common/discord/types/types/premium-types.go b/common/discord/types/types/premium-types.go
deleted file mode 100644
index 5ad2d8e..0000000
--- a/common/discord/types/types/premium-types.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package types
-
-// PremiumTypes is the level of premium a user has.
-type PremiumTypes int
-
-// Values for PremiumTypes
-const (
- PremiumTypeNone PremiumTypes = 0
- PremiumTypeNitroClassic = 1
- PremiumTypeNitro = 2
-)
diff --git a/common/discord/types/types/statuses.go b/common/discord/types/types/statuses.go
deleted file mode 100644
index eed7957..0000000
--- a/common/discord/types/types/statuses.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package types
-
-// Statuses is a Presence status for a user
-type Statuses string
-
-const (
- // StatusOnline is the status for an online user
- StatusOnline Statuses = "online"
- // StatusIdle is the status for an idle user
- StatusIdle = "idle"
- // StatusDND is the status for a user in Do not Disturb
- StatusDND = "dnd"
- // StatusOffline is the status for an offline or invisible user
- StatusOffline = "offline"
-)
diff --git a/common/discord/types/types/sticker-types.go b/common/discord/types/types/sticker-types.go
deleted file mode 100644
index 6b3290c..0000000
--- a/common/discord/types/types/sticker-types.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package types
-
-// StickerTypes are the types of a sticker
-type StickerTypes int
-
-//
-const (
- StickerTypePNG StickerTypes = 1
- StickerTypeAPNG = 2
- StickerTypeLottie = 3
-)
diff --git a/common/discord/types/types/system-channel-flags.go b/common/discord/types/types/system-channel-flags.go
deleted file mode 100644
index 8fa0d4b..0000000
--- a/common/discord/types/types/system-channel-flags.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package types
-
-// SystemChannelFlags are the flags of a channel
-type SystemChannelFlags int
-
-const (
- // SystemChannelFlagSuppressJoinNotifications is the flag when a channel suppresses member join notifications
- SystemChannelFlagSuppressJoinNotifications SystemChannelFlags = 1 << 0
- // SystemChannelFlagSuppressPremiumSubscriptions is the flag when a channel suppresses server boost notifications
- SystemChannelFlagSuppressPremiumSubscriptions = 1 << 1
-)
diff --git a/common/discord/types/types/target-user-types.go b/common/discord/types/types/target-user-types.go
deleted file mode 100644
index a02d2d2..0000000
--- a/common/discord/types/types/target-user-types.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package types
-
-// TargetUserTypes are the types of invite target
-type TargetUserTypes int
-
-const (
- // TargetUserTypeStream is a stream target
- TargetUserTypeStream TargetUserTypes = 1
-)
diff --git a/common/discord/types/types/update-status-statuses.go b/common/discord/types/types/update-status-statuses.go
deleted file mode 100644
index b2d41b7..0000000
--- a/common/discord/types/types/update-status-statuses.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package types
-
-// UpdateStatusStatuses are the statuses used in a Update Status gateway command
-type UpdateStatusStatuses string
-
-//
-const (
- // UpdateStatusStatusOnline is the online status
- UpdateStatusStatusOnline UpdateStatusStatuses = "online"
- // UpdateStatusStatusDoNotDisturb is the Do Not Disturb status
- UpdateStatusStatusDoNotDisturb = "dnd"
- // UpdateStatusStatusIdle is the AFK status
- UpdateStatusStatusIdle = "idle"
- // UpdateStatusStatusInvisible is the Invisible status, shown as offline
- UpdateStatusStatusInvisible = "invisible"
- // UpdateStatusStatusOffline is the offline status
- UpdateStatusStatusOffline = "offline"
-)
diff --git a/common/discord/types/types/user-flags.go b/common/discord/types/types/user-flags.go
deleted file mode 100644
index 41e0076..0000000
--- a/common/discord/types/types/user-flags.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package types
-
-// UserFlags is the flags of a User
-type UserFlags int
-
-// Valid UserFlags
-const (
- UserFlagNone UserFlags = 0
- UserFlagDiscordEmployee = 1 << 0
- UserFlagPartneredServerOwner = 1 << 1
- UserFlagHypeSquadEvents = 1 << 2
- UserFlagBugHunterLevel1 = 1 << 3
- UserFlagHouseBravery = 1 << 6
- UserFlagHouseBrilliance = 1 << 7
- UserFlagHouseBalance = 1 << 8
- UserFlagEarlySupporter = 1 << 9
- UserFlagTeamUser = 1 << 10
- UserFlagSystem = 1 << 12
- UserFlagBugHunterLevel2 = 1 << 14
- UserFlagVerifiedBot = 1 << 16
- UserFlagEarlyVerifiedBotDeveloper = 1 << 17
-)
diff --git a/common/discord/types/types/verification-levels.go b/common/discord/types/types/verification-levels.go
deleted file mode 100644
index cd08578..0000000
--- a/common/discord/types/types/verification-levels.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package types
-
-// VerificationLevels is the verification level of a guild
-type VerificationLevels int
-
-const (
- // VerificationLevelNone needs nothing
- VerificationLevelNone VerificationLevels = 0
- // VerificationLevelLow needs members to have a verified email
- VerificationLevelLow = 1
- // VerificationLevelMedium needs members to be registered on Discord for
- // longer than 5 minutes
- VerificationLevelMedium = 2
- // VerificationLevelHigh needs members to be a member of the server for
- // longer than 10 minutes
- VerificationLevelHigh = 3
- // VerificationLevelVeryHigh needs members to have a verified phone number
- VerificationLevelVeryHigh = 4
-)
diff --git a/common/discord/types/types/voice-gateway-close-event-codes.go b/common/discord/types/types/voice-gateway-close-event-codes.go
deleted file mode 100644
index 50ed029..0000000
--- a/common/discord/types/types/voice-gateway-close-event-codes.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package types
-
-// VoiceGatewayCloseEventCodes is a code explaining the close of a connection
-// to the Voice gateway
-type VoiceGatewayCloseEventCodes int
-
-// Valid codes
-const (
- // VoiceGatewayCloseEventCodeUnknownOpcode is used after sending an
- // invalid Opcode
- VoiceGatewayCloseEventCodeUnknownOpcode VoiceGatewayCloseEventCodes = 4001
- // VoiceGatewayCloseEventCodeFailedToDecodePayload is used after sending an
- // invalid payload
- VoiceGatewayCloseEventCodeFailedToDecodePayload = 4002
- // VoiceGatewayCloseEventCodeNotAuthenticated is used after sending a payload
- // prior to the Identifying one.
- VoiceGatewayCloseEventCodeNotAuthenticated = 4003
- // VoiceGatewayCloseEventCodeAuthenticationFailed is used after sending an
- // invalid Identify payload
- VoiceGatewayCloseEventCodeAuthenticationFailed = 4004
- // VoiceGatewayCloseEventCodeAlreadyAuthenticated is used when sending more
- // than ono Identify payload
- VoiceGatewayCloseEventCodeAlreadyAuthenticated = 4005
- // VoiceGatewayCloseEventCodeSessionNoLongerValid is used when a session is
- // no longer valid
- VoiceGatewayCloseEventCodeSessionNoLongerValid = 4006
-
- /* there is no 4007 and 4008 */
-
- // VoiceGatewayCloseEventCodeSessionTimeout is used when a session timed out
- VoiceGatewayCloseEventCodeSessionTimeout = 4009
-
- /* no 4010 :angry_face: */
-
- // VoiceGatewayCloseEventCodeServerNotFound is used after asking for an
- // invalid voice server
- VoiceGatewayCloseEventCodeServerNotFound = 4011
- // VoiceGatewayCloseEventCodeUnknownProtocol is used after sending an
- // unrecognized protocol
- VoiceGatewayCloseEventCodeUnknownProtocol = 4012
-
- /* There is no 1043!!!! */
-
- // VoiceGatewayCloseEventCodeDisconnected is used when the client has
- // been disconnected and should not reconnect (deleted channel, kicked...)
- VoiceGatewayCloseEventCodeDisconnected = 4014
- // VoiceGatewayCloseEventCodeVoiceServerCrashed is used after a voice
- // server crashed. Need to resume the connection...
- VoiceGatewayCloseEventCodeVoiceServerCrashed = 4015
- // VoiceGatewayCloseEventCodeUnknownEncryptionMode is used after sending a
- // payload with an unrecognized encryption
- VoiceGatewayCloseEventCodeUnknownEncryptionMode = 4016
-)
diff --git a/common/discord/types/types/voice-gateway-op-codes.go b/common/discord/types/types/voice-gateway-op-codes.go
deleted file mode 100644
index e3a64f7..0000000
--- a/common/discord/types/types/voice-gateway-op-codes.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package types
-
-// VoiceGatewayOpCodes are code tagged by the Discord Gateway to type payloads
-type VoiceGatewayOpCodes int
-
-// Valid OpCode values
-const (
- // VoiceGatewayOpCodeIdentify is used to begin a voice websocket connection
- VoiceGatewayOpCodeIdentify VoiceGatewayOpCodes = 0
- // VoiceGatewayOpCodeSelectProtocol is used to select the voice protocol
- VoiceGatewayOpCodeSelectProtocol = 1
- // VoiceGatewayOpCodeReady is used to complete the websocket handshake
- VoiceGatewayOpCodeReady = 2
- // VoiceGatewayOpCodeHeartbeat is used to keep the connection alive
- VoiceGatewayOpCodeHeartbeat = 3
- // VoiceGatewayOpCodeSessionDescription is used to describe the session
- VoiceGatewayOpCodeSessionDescription = 4
- // VoiceGatewayOpCodeSpeaking is used to indicate which users are speaking
- VoiceGatewayOpCodeSpeaking = 5
- // VoiceGatewayOpCodeHeartbeatACK is used to acknowledge a
- // received heartbeat
- VoiceGatewayOpCodeHeartbeatACK = 6
- // VoiceGatewayOpCodeResume is used to resume a connection
- VoiceGatewayOpCodeResume = 7
- // VoiceGatewayOpCodeHello is used to give the time to wait between sending
- // heartbeats in milliseconds
- VoiceGatewayOpCodeHello = 8
- // VoiceGatewayOpCodeResumed is used to acknowledge a successful
- // session resume
- VoiceGatewayOpCodeResumed = 9
-
- /* there is no 10, 11 and 12 :/ */
-
- // VoiceGatewayOpCodeClientDisconnect is used to announce the client
- // has disconnected from the voice channel
- VoiceGatewayOpCodeClientDisconnect = 13
-)
diff --git a/common/rust/Cargo.toml b/common/rust/Cargo.toml
index d631c6c..ec81c4b 100644
--- a/common/rust/Cargo.toml
+++ b/common/rust/Cargo.toml
@@ -10,4 +10,5 @@ serde = { version = "1.0.8", features = ["derive"] }
config = "0.11"
hyper = { version = "0.14", features = ["full"] }
tokio = { version = "1", features = ["full"] }
-prometheus = "0.12.0" \ No newline at end of file
+prometheus = "0.12.0"
+nats = "0.15.2" \ No newline at end of file
diff --git a/common/rust/cargo/BUILD.bazel b/common/rust/cargo/BUILD.bazel
index ff92458..f92a2e9 100644
--- a/common/rust/cargo/BUILD.bazel
+++ b/common/rust/cargo/BUILD.bazel
@@ -40,6 +40,15 @@ alias(
)
alias(
+ name = "nats",
+ actual = "@raze__nats__0_15_2//:nats",
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+)
+
+alias(
name = "pretty_env_logger",
actual = "@raze__pretty_env_logger__0_4_0//:pretty_env_logger",
tags = [
diff --git a/common/rust/src/config.rs b/common/rust/src/config.rs
index 6d8fb33..c158a21 100644
--- a/common/rust/src/config.rs
+++ b/common/rust/src/config.rs
@@ -11,6 +11,7 @@ pub struct Settings<T> {
#[serde(skip_deserializing)]
pub config: T,
pub monitoring: crate::monitoring::MonitoringConfiguration,
+ pub nats: crate::nats::NatsConfiguration,
}
impl<T> Settings<T> where T: Deserialize<'static> + std::default::Default + Clone {
@@ -25,14 +26,12 @@ impl<T> Settings<T> where T: Deserialize<'static> + std::default::Default + Clon
default.merge(File::with_name("config/local").required(false))?;
// we can configure each component using environment variables
- default.merge(Environment::with_prefix(&format!("NOVA_{}", service_name)))?;
+ default.merge(Environment::with_prefix("NOVA").separator("_"))?;
let mut config: Settings<T> = default.clone().try_into().unwrap();
// try to load the config
config.config = default.get::<T>(&service_name).unwrap();
-
- // setup the logger
- pretty_env_logger::init_custom_env(&format!("NOVA_{}_LOG", service_name));
+ pretty_env_logger::init();
// start the monitoring system if needed
crate::monitoring::start_monitoring(&config.monitoring);
diff --git a/common/rust/src/lib.rs b/common/rust/src/lib.rs
index 5122334..24e16ec 100644
--- a/common/rust/src/lib.rs
+++ b/common/rust/src/lib.rs
@@ -1,4 +1,6 @@
/// This crate contains shared code in all the rust projects
/// It contains utilities such as monitoring, logging and more.
pub mod config;
-pub mod monitoring; \ No newline at end of file
+pub mod monitoring;
+pub mod nats;
+pub mod payloads; \ No newline at end of file
diff --git a/common/rust/src/nats.rs b/common/rust/src/nats.rs
new file mode 100644
index 0000000..59b480c
--- /dev/null
+++ b/common/rust/src/nats.rs
@@ -0,0 +1,62 @@
+use nats::{Options, Connection};
+use serde::Deserialize;
+
+#[derive(Clone, Debug, Deserialize)]
+struct NatsConfigurationClientCert {
+ cert: String,
+ key: String
+}
+#[derive(Clone, Debug, Deserialize)]
+struct NatsConfigurationTls {
+ mtu: Option<usize>,
+}
+
+#[derive(Clone, Debug, Deserialize)]
+pub struct NatsConfiguration {
+ client_cert: Option<NatsConfigurationClientCert>,
+ root_cert: Option<Vec<String>>,
+ jetstream_api_prefix: Option<String>,
+ max_reconnects: Option<usize>,
+ reconnect_buffer_size: Option<usize>,
+ tls: Option<NatsConfigurationTls>,
+ client_name: Option<String>,
+ tls_required: Option<bool>,
+ host: String,
+}
+
+///
+impl Into<Connection> for NatsConfiguration {
+ fn into(self) -> Connection {
+ let mut options = Options::new();
+
+ if let Some(client_cert) = self.client_cert {
+ options = options.client_cert(client_cert.cert, client_cert.key);
+ }
+
+ if let Some(root_certs) = self.root_cert {
+ for root_cert in root_certs {
+ options = options.add_root_certificate(root_cert);
+ }
+ }
+
+ if let Some(jetstream_api_prefix) = self.jetstream_api_prefix {
+ options = options.jetstream_api_prefix(jetstream_api_prefix)
+ }
+
+ options = options.max_reconnects(self.max_reconnects);
+ options = options.no_echo();
+ options = options.reconnect_buffer_size(self.reconnect_buffer_size.unwrap_or(64 * 1024));
+ options = options.tls_required(self.tls_required.unwrap_or(false));
+ options = options.with_name(&self.client_name.unwrap_or("Nova".to_string()));
+
+
+ if let Some(tls) = self.tls {
+ let mut config = nats::rustls::ClientConfig::new();
+ config.set_mtu(&tls.mtu);
+ // todo: more options?
+ options = options.tls_client_config(config);
+ }
+
+ options.connect(&self.host).unwrap()
+ }
+}
diff --git a/common/rust/src/payloads.rs b/common/rust/src/payloads.rs
new file mode 100644
index 0000000..1957077
--- /dev/null
+++ b/common/rust/src/payloads.rs
@@ -0,0 +1,9 @@
+use serde::{Deserialize, Serialize};
+
+/// Payload send to the nova cache queues
+#[derive(Serialize, Deserialize, Debug, Clone)]
+#[serde(bound(deserialize = "T: Deserialize<'de> + std::default::Default + Clone"))]
+pub struct CachePayload<T> {
+ pub tracing: (),
+ pub data: T
+}
diff --git a/doc/README.md b/docs/README.md
index fcc815a..fcc815a 100644
--- a/doc/README.md
+++ b/docs/README.md
diff --git a/doc/common.md b/docs/common.md
index 3dce3ac..3dce3ac 100644
--- a/doc/common.md
+++ b/docs/common.md
diff --git a/examples/config/gateway.yaml b/docs/components/auto-scaler.md
index e69de29..e69de29 100644
--- a/examples/config/gateway.yaml
+++ b/docs/components/auto-scaler.md
diff --git a/docs/components/cache.md b/docs/components/cache.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/components/cache.md
diff --git a/docs/components/gateway.md b/docs/components/gateway.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/components/gateway.md
diff --git a/docs/components/ratelimiter.md b/docs/components/ratelimiter.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/components/ratelimiter.md
diff --git a/doc/components/webhook.md b/docs/components/webhook.md
index 76361ef..76361ef 100644
--- a/doc/components/webhook.md
+++ b/docs/components/webhook.md
diff --git a/docs/exemples/config.yaml b/docs/exemples/config.yaml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/exemples/config.yaml
diff --git a/doc/structure.md b/docs/structure.md
index 1f82ae3..1f82ae3 100644
--- a/doc/structure.md
+++ b/docs/structure.md
diff --git a/examples/config/webhook.yaml b/examples/config/webhook.yaml
deleted file mode 100644
index fdb76d4..0000000
--- a/examples/config/webhook.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-debug: true
-server:
- address: "0.0.0.0"
- port: 8000
-discord:
- # Theses credentials are public anyways
- client_id: 738817757650485300
- public_key: "475bed67e20fb1e2d9b9007607f08d7b25b5a0aa936ef2d4ddaf7d592c993860"
-
-gateway:
- relaying:
- relay_instances: 0
- clustering:
- cluster_size: 1 # The total number of clusters
- cluster_id: 0 # Current cluster id
- shard_count: 1 # 10 shards by cluster
- discord:
- token: "token"
- large_threshold: 100
- intents: 16384
-
-webhook:
- server:
- address: 0.0.0.0
- port: 8000
- discord:
- client_id: 738817757650485300
- public_key: "475bed67e20fb1e2d9b9007607f08d7b25b5a0aa936ef2d4ddaf7d592c993860"
diff --git a/examples/docker-compose.gateway.yml b/examples/docker-compose.gateway.yml
deleted file mode 100644
index 8f42454..0000000
--- a/examples/docker-compose.gateway.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-version: "3.3"
-
-services:
- gateway:
- image: "ghcr.io/discordnova/nova/gateway@sha256:3432794af8d6f910b06bf8502bc92e5ecca3d6f4c0ec302ca77df03c6a94b014"
- environment:
- - DISCORD_TOKEN="<your discord token>"
- - RUST_LOG=debug \ No newline at end of file
diff --git a/examples/docker-compose.webhook.yml b/examples/docker-compose.webhook.yml
deleted file mode 100644
index 165b4cf..0000000
--- a/examples/docker-compose.webhook.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-version: "3.3"
-
-services:
- webhook:
- image: "ghcr.io/discordnova/nova/webhook@sha256:df10d97bb1707aaefca97150ffeae0908981da496c351bb51aa65bdf66eee41b"
- networks:
- - internal
- volumes:
- - ./config/webhook.yaml:/app/webhook/image_binary.runfiles/nova/config/default.yaml
- environment:
- - RUST_LOG=info
- ports:
- - 8000:8000 \ No newline at end of file
diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
deleted file mode 100644
index d639fcf..0000000
--- a/examples/docker-compose.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-version: "3.3"
-
-services:
- nats:
- image: "nats"
- expose:
- - "4222"
- ports:
- - "8222:8222"
- - "4222:4222"
- hostname: nats
- networks:
- - internal
-
-networks:
- internal: {} \ No newline at end of file
diff --git a/gateway/config/default.yaml b/gateway/config/default.yaml
deleted file mode 100644
index 1c6cd41..0000000
--- a/gateway/config/default.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-monitoring:
- enabled: false
-gateway:
- relaying:
- relay_instances: 0
- clustering:
- cluster_size: 1 # The total number of clusters
- cluster_id: 0 # Current cluster id
- shard_count: 1 # 10 shards by cluster
- discord:
- token: "token"
- large_threshold: 100
- intents: 16384 \ No newline at end of file
diff --git a/gateway/docker-compose.yaml b/gateway/docker-compose.yaml
deleted file mode 100644
index c6b070e..0000000
--- a/gateway/docker-compose.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-version: "3.3"
-
-services:
- cluster1:
- image: ghcr.io/discordnova/nova/gateway@sha256:e37764f61b76617200cc4444dd9e50e76e8ecd9c0a9d411779731fd80a986260
- environment:
- - NOVA_gateway_LOG=debug
- restart: always
- volumes:
- - ./config/default.yaml:/app/gateway/gateway.runfiles/nova/config/default.yaml
diff --git a/gateway/src/client/connection/actions.rs b/gateway/src/client/connection/actions.rs
new file mode 100644
index 0000000..ed57613
--- /dev/null
+++ b/gateway/src/client/connection/actions.rs
@@ -0,0 +1,8 @@
+use super::{Connection, state::ConnectionState};
+
+impl Connection {
+ /// Returns the current state of the connection.
+ pub fn state(&self) -> ConnectionState {
+ return self.state.clone();
+ }
+} \ No newline at end of file
diff --git a/gateway/src/client/connection/mod.rs b/gateway/src/client/connection/mod.rs
new file mode 100644
index 0000000..a5867a7
--- /dev/null
+++ b/gateway/src/client/connection/mod.rs
@@ -0,0 +1,24 @@
+use tokio::net::TcpStream;
+use tokio_tungstenite::{MaybeTlsStream, WebSocketStream};
+
+mod stream;
+mod state;
+mod actions;
+
+/// Underlying representation of a Discord event stream
+/// that streams the Event payloads to the shard structure
+pub struct Connection {
+ /// The channel given by tokio_tungstenite that represents the websocket connection
+ connection: Option<WebSocketStream<MaybeTlsStream<TcpStream>>>,
+ /// The state of the connection
+ state: state::ConnectionState,
+}
+
+impl Connection {
+ pub fn new() -> Self {
+ Connection {
+ connection: None,
+ state: state::ConnectionState::default()
+ }
+ }
+} \ No newline at end of file
diff --git a/gateway/src/client/connection/state.rs b/gateway/src/client/connection/state.rs
new file mode 100644
index 0000000..972d79e
--- /dev/null
+++ b/gateway/src/client/connection/state.rs
@@ -0,0 +1,10 @@
+/// This struct represents the state of a connection
+#[derive(Debug, Clone)]
+pub struct ConnectionState {}
+impl Default for ConnectionState {
+ fn default() -> Self {
+ Self { }
+ }
+}
+
+impl ConnectionState {} \ No newline at end of file
diff --git a/gateway/src/client/connection/stream.rs b/gateway/src/client/connection/stream.rs
new file mode 100644
index 0000000..9bfeace
--- /dev/null
+++ b/gateway/src/client/connection/stream.rs
@@ -0,0 +1,36 @@
+use std::{
+ pin::Pin,
+ task::{Context, Poll},
+};
+
+use super::Connection;
+use crate::client::payloads::message::MessageBase;
+use futures::{Sink, Stream};
+
+impl Stream for Connection {
+ type Item = MessageBase;
+
+ fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
+ Poll::Pending
+ }
+}
+
+impl Sink<MessageBase> for Connection {
+ type Error = ();
+
+ fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
+ todo!()
+ }
+
+ fn start_send(self: Pin<&mut Self>, item: MessageBase) -> Result<(), Self::Error> {
+ todo!()
+ }
+
+ fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
+ todo!()
+ }
+
+ fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
+ todo!()
+ }
+}
diff --git a/gateway/src/client/connexion.rs b/gateway/src/client/connexion.rs
deleted file mode 100644
index 8d68158..0000000
--- a/gateway/src/client/connexion.rs
+++ /dev/null
@@ -1,255 +0,0 @@
-use crate::client::payloads::{message::OpCodes, payloads::{Hello, Identify, IdentifyProprerties}};
-use super::{
- payloads::message::MessageBase,
- state::{Stage, State},
- utils::get_gateway_url,
-};
-use futures_util::{SinkExt, StreamExt};
-use log::{error, info, trace, warn};
-use std::{str::from_utf8, time::Duration};
-use tokio::{net::TcpStream, select, time::Instant};
-use tokio_tungstenite::{MaybeTlsStream, WebSocketStream, connect_async, tungstenite::{self, Message, handshake::client::Request}};
-use crate::client::structs::ClientConfig;
-use tokio::sync::mpsc;
-
-#[derive(Debug)]
-pub enum CloseReason {
- ConnexionAlredyOpen,
- ConnexionEnded,
- ErrorEncountered(&'static str),
- ConnexionError(tungstenite::Error),
-}
-pub enum HandleResult {
- Success,
- Error(CloseReason),
-}
-
-pub struct Connexion {
- state: State,
- config: ClientConfig,
- connexion: Option<WebSocketStream<MaybeTlsStream<TcpStream>>>,
- terminate: Option<mpsc::Sender<CloseReason>>,
-}
-
-impl Connexion {
- pub fn new(config: ClientConfig) -> Self {
- Connexion {
- state: State::default(),
- connexion: None,
- config,
- terminate: None
- }
- }
-
- /// Terminate the connexion and the "start" method related to it.
- async fn _terminate_websocket(&mut self, message: &CloseReason) {
- if let Some(connexion) = &mut self.connexion {
- if let Err(err) = connexion.close(None).await {
- error!("failed to close socket {}", err);
- } else {
- info!("closed the socket: {:?}", message);
- }
- } else {
- warn!("a termination request was sent without a connexion openned")
- }
- }
-
- /// Initialize a connexion to the gateway
- /// returns if a connexion is already present
- pub async fn start(mut self) -> CloseReason {
- if let Some(_) = self.connexion {
- CloseReason::ConnexionAlredyOpen
- } else {
- // we reset the state before starting the connection
- self.state = State::default();
- let request = Request::builder()
- .uri(get_gateway_url(false, "json", 9))
- .body(())
- .unwrap();
-
- let connexion_result = connect_async(request).await;
- // we connect outselves to the websocket server
- if let Err(err) = connexion_result {
- return CloseReason::ConnexionError(err);
- }
- self.connexion = Some(connexion_result.unwrap().0);
-
- let (tx, mut rx) = mpsc::channel::<CloseReason>(1);
- self.terminate = Some(tx);
-
- // this is the loop that will maintain the whole connexion
- loop {
- if let Some(connexion) = &mut self.connexion {
- // if we do not have a hello message received yet, then we do not use the heartbeat interval
- // and we just wait for messages to arrive
- if self.state.stage == Stage::Unknown {
- select! {
- msg = connexion.next() => self._handle_message(&msg).await,
- Some(reason) = rx.recv() => {
- // gateway termination requested
- self._terminate_websocket(&reason);
- return reason
- }
- }
- } else {
- let timer = self.state.interval.as_mut().unwrap().tick();
- select! {
- msg = connexion.next() => self._handle_message(&msg).await,
- _ = timer => self._do_heartbeat().await,
- Some(reason) = rx.recv() => {
- // gateway termination requested
- self._terminate_websocket(&reason);
- return reason
- }
- }
- }
- } else {
- return CloseReason::ConnexionEnded;
- }
- }
- }
- }
-
- async fn _handle_message(
- &mut self,
- data: &Option<Result<Message, tokio_tungstenite::tungstenite::Error>>,
- ) {
- if let Some(message) = data {
- match message {
- Ok(message) => match message {
- Message::Text(text) => {
- self._handle_discord_message(&text).await;
- }
- Message::Binary(message) => {
- self._handle_discord_message(from_utf8(message).unwrap())
- .await;
- }
- Message::Close(code) => {
- error!("discord connexion closed: {:?}", code);
- self.terminate.as_ref().unwrap().send(CloseReason::ConnexionEnded).await.unwrap();
- }
-
- _ => self.terminate.as_ref().unwrap().send(CloseReason::ErrorEncountered(
- "unsupported message type encountered",
- )).await.unwrap(),
- },
- Err(_error) => self.terminate.as_ref().unwrap().send(CloseReason::ErrorEncountered(
- "error while reading a message",
- )).await.unwrap(),
- }
- } else {
- self.terminate.as_ref().unwrap().send(CloseReason::ErrorEncountered(
- "error while reading a message",
- )).await.unwrap()
- }
- }
-
- async fn _handle_discord_message(&mut self, raw_message: &str) {
- let a: Result<MessageBase, serde_json::Error> = serde_json::from_str(raw_message);
- let message = a.unwrap();
-
- // handles the state
- if let Some(index) = message.s {
- self.state.sequence = index;
- }
-
- match message.op {
- OpCodes::Dispatch => {
- let t = message.t.unwrap();
- trace!("dispatch message received: {:?}", t);
- },
- OpCodes::PresenceUpdate => {
- println!("presence update message received: {:?}", message.d);
- },
- OpCodes::VoiceStateUpdate => {
- println!("voice update");
- }
- OpCodes::Reconnect => {
- println!("reconnect {:?}", message.d);
- },
- OpCodes::InvalidSession => {
- println!("invalid session: {:?}", message.d);
- },
- OpCodes::Hello => {
- if let Ok(hello) = serde_json::from_value::<Hello>(message.d) {
- info!("server sent hello {:?}", hello);
- info!("heartbeating every {}ms", hello.heartbeat_interval);
- self.state.interval = Some(tokio::time::interval_at(
- Instant::now() + Duration::from_millis(hello.heartbeat_interval),
- Duration::from_millis(hello.heartbeat_interval),
- ));
- self.state.stage = Stage::Initialized;
- let mut shard: Option<[i64; 2]> = None;
- if let Some(sharding) = &self.config.shard {
- shard = Some([sharding.current_shard.clone(), sharding.total_shards.clone()]);
- info!("shard information: {:?}", shard);
- }
- self._send(&MessageBase {
- t: None,
- op: OpCodes::Identify,
- s: None,
- d: serde_json::to_value(&Identify{
- token: self.config.token.clone(),
- intents: self.config.intents.clone().bits(),
- properties: IdentifyProprerties {
- os: "Linux".into(),
- browser: "Nova".into(),
- device: "Linux".into(),
- },
- shard: shard,
- }).unwrap(),
- }).await;
- // do login
- // todo: session logic
- }
- }
- OpCodes::HeartbeatACK => {
- info!(
- "heartbeat acknowledged after {}ms",
- (std::time::Instant::now() - self.state.last_heartbeat_time).as_millis()
- );
- self.state.last_heartbeat_acknowledged = true;
- }
- _ => {} // invalid payloads
- }
- }
-
- async fn _do_heartbeat(&mut self) {
- if !self.state.last_heartbeat_acknowledged {
- self.terminate.as_ref().unwrap().send(CloseReason::ErrorEncountered(
- "the server did not acknowledged the last heartbeat",
- )).await.unwrap();
- return;
- }
- self.state.last_heartbeat_acknowledged = false;
-
- info!("sending heartbeat");
- self._send(&MessageBase {
- t: None,
- d: serde_json::to_value(self.state.sequence).unwrap(),
- s: None,
- op: OpCodes::Heartbeat,
- })
- .await;
- self.state.last_heartbeat_time = std::time::Instant::now();
- }
-
- async fn _send(&mut self, data: &MessageBase) {
- if let Some(connexion) = &mut self.connexion {
- if let Ok(json) = serde_json::to_vec(data) {
- if let Err(error) = connexion.send(Message::Binary(json)).await {
- error!("failed to write to socket: {}", error);
- self.terminate.as_ref().unwrap().send(CloseReason::ErrorEncountered(
- "failed to write to the socket",
- ))
- .await.unwrap();
- }
- } else {
- self.terminate.as_ref().unwrap().send(CloseReason::ErrorEncountered(
- "failed to serialize the message",
- ))
- .await.unwrap();
- }
- }
- }
-}
diff --git a/gateway/src/client/mod.rs b/gateway/src/client/mod.rs
index 3ffd489..5e99ebc 100644
--- a/gateway/src/client/mod.rs
+++ b/gateway/src/client/mod.rs
@@ -1,5 +1,3 @@
-mod utils;
-mod state;
+pub mod connection;
pub mod payloads;
-pub mod connexion;
-pub mod structs; \ No newline at end of file
+pub mod shard; \ No newline at end of file
diff --git a/gateway/src/client/structs.rs b/gateway/src/client/payloads/structs.rs
index 1f186c6..1f186c6 100644
--- a/gateway/src/client/structs.rs
+++ b/gateway/src/client/payloads/structs.rs
diff --git a/gateway/src/client/shard/actions.rs b/gateway/src/client/shard/actions.rs
new file mode 100644
index 0000000..cb212bf
--- /dev/null
+++ b/gateway/src/client/shard/actions.rs
@@ -0,0 +1,65 @@
+use futures::SinkExt;
+use log::error;
+use serde_json::Value;
+
+use crate::client::payloads::message::{MessageBase, OpCodes};
+
+use super::Shard;
+
+/// Implement the available actions for nova in the gateway.
+impl Shard {
+ /// Updates the presence of the current shard.
+ #[allow(dead_code)]
+ pub async fn presence_update(&mut self) -> Result<(), ()> {
+ if let Some(connection) = &mut self.connection {
+ connection
+ .send(MessageBase {
+ t: None,
+ s: None,
+ op: OpCodes::PresenceUpdate,
+ // todo: proper payload for this
+ d: Value::Null,
+ })
+ .await?;
+ } else {
+ error!("the connection is not open")
+ }
+ Ok(())
+ }
+ /// Updates the voice status of the current shard in a certain channel.
+ #[allow(dead_code)]
+ pub async fn voice_state_update(&mut self) -> Result<(), ()> {
+ if let Some(connection) = &mut self.connection {
+ connection
+ .send(MessageBase {
+ t: None,
+ s: None,
+ op: OpCodes::VoiceStateUpdate,
+ // todo: proper payload for this
+ d: Value::Null,
+ })
+ .await?;
+ } else {
+ error!("the connection is not open")
+ }
+ Ok(())
+ }
+ /// Ask discord for more informations about offline guild members.
+ #[allow(dead_code)]
+ pub async fn request_guild_members(&mut self) -> Result<(), ()> {
+ if let Some(connection) = &mut self.connection {
+ connection
+ .send(MessageBase {
+ t: None,
+ s: None,
+ op: OpCodes::RequestGuildMembers,
+ // todo: proper payload for this
+ d: Value::Null,
+ })
+ .await?;
+ } else {
+ error!("the connection is not open")
+ }
+ Ok(())
+ }
+}
diff --git a/gateway/src/client/shard/connection.rs b/gateway/src/client/shard/connection.rs
new file mode 100644
index 0000000..ca0ef07
--- /dev/null
+++ b/gateway/src/client/shard/connection.rs
@@ -0,0 +1,16 @@
+use super::Shard;
+use crate::client::connection::Connection;
+use log::info;
+
+impl Shard {
+ async fn start(self: &mut Self) {
+ let mut should_exit = false;
+
+ while !should_exit {
+ info!("Starting connection for shard");
+ // create the new connection
+ self.connection = Some(Connection::new());
+ should_exit = true;
+ }
+ }
+}
diff --git a/gateway/src/client/shard/mod.rs b/gateway/src/client/shard/mod.rs
new file mode 100644
index 0000000..1962d07
--- /dev/null
+++ b/gateway/src/client/shard/mod.rs
@@ -0,0 +1,24 @@
+use std::sync::Arc;
+
+use self::state::SessionState;
+
+use super::connection::Connection;
+mod actions;
+mod connection;
+mod state;
+
+/// Represents a shard & all the reconnection logic related to it
+pub struct Shard {
+ connection: Option<Connection>,
+ state: SessionState,
+}
+
+impl Shard {
+ /// Creates a new shard instance
+ pub fn new() -> Self {
+ Shard {
+ connection: None,
+ state: SessionState::default(),
+ }
+ }
+}
diff --git a/gateway/src/client/shard/state.rs b/gateway/src/client/shard/state.rs
new file mode 100644
index 0000000..6c10871
--- /dev/null
+++ b/gateway/src/client/shard/state.rs
@@ -0,0 +1,14 @@
+/// This struct represents the state of a session
+pub struct SessionState {
+ pub sequence: u64,
+ pub session_id: String,
+}
+
+impl Default for SessionState {
+ fn default() -> Self {
+ Self {
+ sequence: Default::default(),
+ session_id: Default::default(),
+ }
+ }
+}
diff --git a/gateway/src/client/state.rs b/gateway/src/client/state.rs
deleted file mode 100644
index 553fea7..0000000
--- a/gateway/src/client/state.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-use std::time::Instant;
-use tokio::time::Interval;
-
-#[derive(PartialEq)]
-pub enum Stage {
- Unknown,
- Initialized,
- LoggedIn,
-}
-
-pub struct State {
- pub stage: Stage,
- pub sequence: i64,
- pub last_heartbeat_acknowledged: bool,
- pub last_heartbeat_time: Instant,
- pub interval: Option<Interval>,
-}
-
-impl State {
- pub fn default() -> Self {
- State {
- sequence: 0,
- interval: None,
- stage: Stage::Unknown,
- last_heartbeat_acknowledged: true,
- last_heartbeat_time: std::time::Instant::now(),
- }
- }
-}
diff --git a/gateway/src/cluster_manager.rs b/gateway/src/cluster_manager.rs
deleted file mode 100644
index 627fcfd..0000000
--- a/gateway/src/cluster_manager.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use crate::client::connexion::Connexion;
-use crate::client::structs::*;
-use crate::config::Config;
-use log::info;
-use futures::future::select_all;
-
-pub struct ClusterManager {
- gateway_connexions: Vec<Connexion>,
- config: Config,
-}
-
-impl ClusterManager {
-
- pub fn new(config: crate::config::Config) -> ClusterManager {
- // create the memory for containing all the gateways
- let gateways: Vec<Connexion> = Vec::with_capacity(config.clustering.shard_count as usize);
-
- ClusterManager {
- gateway_connexions: gateways,
- config,
- }
- }
-
- pub async fn start(mut self) {
- info!("Starting cluster manager...");
- info!("I am cluster {}/{} managing {} discord shards", self.config.clustering.cluster_id+1, self.config.clustering.cluster_size, self.config.clustering.shard_count);
-
- for i in 0..self.config.clustering.shard_count {
- let shard_id = self.config.clustering.cluster_id * self.config.clustering.cluster_size + i;
- info!("Starting shard {} for cluster {} for discord shard {}", i, self.config.clustering.cluster_id, shard_id);
- self.gateway_connexions.push(Connexion::new(ClientConfig{
- token: self.config.discord.token.clone(),
- intents: self.config.discord.intents,
- large_threshold: self.config.discord.large_threshold,
- shard: Some(Sharding {
- total_shards: self.config.clustering.cluster_size * self.config.clustering.shard_count,
- current_shard: shard_id,
- }),
- }));
- }
- let tasks = self.gateway_connexions.into_iter().map(|item| {
- Box::pin(item.start())
- });
- let task = select_all(tasks).await;
- info!("one shard crashed, we need a restart {:?}", task.0);
- }
-} \ No newline at end of file
diff --git a/gateway/src/config.rs b/gateway/src/config.rs
deleted file mode 100644
index 6dc2c28..0000000
--- a/gateway/src/config.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-use enumflags2::BitFlags;
-use crate::client::structs::Intents;
-use serde::Deserialize;
-
-/// Config for the client connection.
-#[derive(Debug, Deserialize, Clone, Default)]
-pub struct ClusterClientConfig {
- pub token: String,
- pub large_threshold: Option<u64>,
- pub intents: BitFlags<Intents>
-}
-
-/// Configuration for the cluster manager
-#[derive(Debug, Deserialize, Clone, Default)]
-pub struct ClusterClientSharding {
- pub cluster_size: i64,
- pub cluster_id: i64,
- pub shard_count: i64
-}
-
-/// Configuration for the output of the cluster
-#[derive(Debug, Deserialize, Clone, Default)]
-pub struct ClusterRelay {
- pub relay_instances: i64
-}
-
-/// Configuration for the gateway component
-#[derive(Debug, Deserialize, Clone, Default)]
-pub struct Config {
- pub discord: ClusterClientConfig,
- pub clustering: ClusterClientSharding,
- pub relaying: ClusterRelay,
-}
diff --git a/gateway/src/main.rs b/gateway/src/main.rs
index 4e4836c..9733487 100644
--- a/gateway/src/main.rs
+++ b/gateway/src/main.rs
@@ -1,12 +1,8 @@
mod client;
-mod config;
-mod cluster_manager;
use common::config::Settings;
#[tokio::main]
async fn main() {
- let settings: Settings<config::Config> = Settings::new("gateway").unwrap();
- let manager = cluster_manager::ClusterManager::new(settings.config);
- manager.start().await;
+ let settings: Settings<()> = Settings::new("gateway").unwrap();
}
diff --git a/webhook/.gitignore b/webhook/.gitignore
deleted file mode 100644
index 36de683..0000000
--- a/webhook/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-config/local*
-target/
-nacl_test/ \ No newline at end of file
diff --git a/webhook/Cargo.toml b/webhook/Cargo.toml
index f2c278e..045c710 100644
--- a/webhook/Cargo.toml
+++ b/webhook/Cargo.toml
@@ -11,7 +11,6 @@ config = "0.11"
serde = { version = "1.0.8", features = ["derive"] }
libsodium-sys = "0.2.7"
hex = "0.4.3"
-pretty_env_logger = "0.4"
serde_json = { version = "1.0" }
common = { path = "../common/rust" }
nats = "0.15.2"
diff --git a/webhook/README.md b/webhook/README.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/webhook/README.md
diff --git a/webhook/cargo/BUILD.bazel b/webhook/cargo/BUILD.bazel
index e698ae3..e035ab6 100644
--- a/webhook/cargo/BUILD.bazel
+++ b/webhook/cargo/BUILD.bazel
@@ -67,15 +67,6 @@ alias(
)
alias(
- name = "pretty_env_logger",
- actual = "@raze__pretty_env_logger__0_4_0//:pretty_env_logger",
- tags = [
- "cargo-raze",
- "manual",
- ],
-)
-
-alias(
name = "serde",
actual = "@raze__serde__1_0_130//:serde",
tags = [
diff --git a/webhook/config/default.yaml b/webhook/config/default.yaml
deleted file mode 100644
index 770d67f..0000000
--- a/webhook/config/default.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-monitoring:
- enabled: true
- address: 0.0.0.0
- port: 8001
-
-
-webhook:
- server:
- address: 0.0.0.0
- port: 8000
- discord:
- client_id: 738817757650485300
- public_key: "2dc5873bb9e603dbf70e6abc217768b9d7dfacef9e74ddaefcca6a9aed41f30d"
-
diff --git a/webhook/src/handle.rs b/webhook/src/handle.rs
deleted file mode 100644
index b87d9a5..0000000
--- a/webhook/src/handle.rs
+++ /dev/null
@@ -1,174 +0,0 @@
-use hyper::service::Service;
-use hyper::{body::to_bytes, HeaderMap};
-use hyper::{Body, Method, Request, Response, StatusCode};
-use libsodium_sys::crypto_sign_ed25519_verify_detached;
-use log::info;
-use serde_json::Value;
-use std::future;
-use std::future::Future;
-use std::pin::Pin;
-use std::str::from_utf8;
-use std::task::{Context, Poll};
-use serde::{Deserialize, Serialize};
-use crate::config::Config;
-use nats::{Connection, connect};
-
-pub fn validate_signature(b64_public_key: &str, data: &Vec<u8>, b64_signature: &str) -> bool {
- // First, we need to check if the signature & private key is valid base64.
- let signature_result = hex::decode(b64_signature);
- let public_key_result = hex::decode(b64_public_key);
-
- if signature_result.is_ok() && public_key_result.is_ok() {
- // Since we now have the signatures in u8 vectors. We will initialize all the
- // parameters for the ffi call to sodium.
- let signature_pointer = signature_result.unwrap();
- let private_key_pointer = public_key_result.unwrap();
-
- let data_pointer = data.as_ptr();
- let data_len = data.len() as u64;
-
- // A ffi call is considered unsafe by the Rust compiler
- // we assume all the parameters are correct for the call
- unsafe {
- // If the signature is valid, sodium will return 0
- return crypto_sign_ed25519_verify_detached(
- signature_pointer.as_ptr(),
- data_pointer,
- data_len,
- private_key_pointer.as_ptr(),
- ) == 0;
- }
- }
- false
-}
-
-fn get_signature(headers: &HeaderMap) -> Option<(&str, &str)> {
- let signature = headers.get("X-Signature-Ed25519");
- let timestamp = headers.get("X-Signature-Timestamp");
-
- if signature.is_some() && timestamp.is_some() {
- return Some((
- signature.unwrap().to_str().unwrap(),
- timestamp.unwrap().to_str().unwrap(),
- ));
- }
- None
-}
-
-pub struct HandlerService {
- pub config: Config,
- pub nats: Box<Connection>
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Ping {
- #[serde(rename = "type")]
- t: i32
-}
-
-impl Service<Request<Body>> for HandlerService {
- type Response = Response<Body>;
- type Error = hyper::Error;
- type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
-
- fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> {
- Poll::Ready(Ok(()))
- }
-
- fn call(&mut self, req: Request<Body>) -> Self::Future {
- if req.method() == Method::POST {
- let public_key = self.config.discord.public_key.clone();
- let nats = self.nats.clone();
- return Box::pin(async move {
- let headers = req.headers().clone();
- if let Some((signature, timestamp)) = get_signature(&headers) {
- if let Ok(data) = to_bytes(req.into_body()).await {
- let contatenated_data = [timestamp.as_bytes().to_vec(), data.to_vec()].concat();
-
- if validate_signature(public_key.as_str(), &contatenated_data, signature) {
- let d: Value = serde_json::from_str(from_utf8(&data).unwrap()).unwrap();
- let t = d.get("type").unwrap().as_i64().unwrap();
-
- if t == 1 {
- return Ok(Response::builder().header("Content-Type", "application/json").body(serde_json::to_string(&Ping {
- t: 1
- }).unwrap().into()).unwrap());
- } else {
- info!("Handled event");
- nats.publish(&format!("nova.dispatch.interaction_raw"), data).unwrap();
- return Ok(Response::builder().header("Content-Type", "application/json").body(serde_json::to_string(&Ping {
- t: 5
- }).unwrap().into()).unwrap());
- }
- } else {
- Ok(Response::builder().status(StatusCode::UNAUTHORIZED).body("signature verification failed".into()).unwrap())
- }
- } else {
- Ok(Response::builder().status(StatusCode::UNAUTHORIZED).body("failed to read body".into()).unwrap())
- }
- } else {
- Ok(Response::builder().status(StatusCode::UNAUTHORIZED).body("no signature specified".into()).unwrap())
- }
- });
- } else {
- return Box::pin(async {
- Ok(Response::builder().status(StatusCode::UNAUTHORIZED).body("bad method".into()).unwrap())
- });
- }
- }
-}
-
-pub struct MakeSvc {
- pub settings: Config,
- pub nats: Box<Connection>,
-}
-
-impl<T> Service<T> for MakeSvc {
- type Response = HandlerService;
- type Error = std::io::Error;
- type Future = future::Ready<Result<Self::Response, Self::Error>>;
-
- fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
- Ok(()).into()
- }
-
- fn call(&mut self, _: T) -> Self::Future {
- future::ready(Ok(HandlerService {
- config: self.settings.clone(),
- nats: self.nats.clone(),
- }))
- }
-}
-
-#[cfg(test)]
-mod test {
- use crate::handle::validate_signature;
-
- #[test]
- fn validate_signature_test() {
- let signature = "543ec3547d57f9ddb1ec4c5c36503ebf288ffda3da3d510764c9a49c2abb57690ef974c63d174771bdd2481de1066966f57abbec12a3ec171b9f6e2373837002";
- let public_key = "eefe0c24473737cb2035232e3b4eb91c206f0a14684168f3503f7d8316058d6f";
- let content = "message de test incroyable".as_bytes().to_vec();
- assert!(validate_signature(public_key, &content, signature))
- }
-
- #[test]
- fn validate_signature_reverse_test() {
- let signature = "543ec3547d57f9ddb1ec4c5c36503ebf288ffda3da3d510764c9a49c2abb57690ef974c63d174771bdd2481de1066966f57abbec12a3ec171b9f6e2373837002";
- let public_key = "c029eea18437292c87c62aec34e7d1bd4e38fe6126f3f7c446de6375dc666044";
- let content = "ceci est un test qui ne fonctionnera pas!"
- .as_bytes()
- .to_vec();
- assert!(!validate_signature(public_key, &content, signature))
- }
-
- #[test]
- fn invalid_hex() {
- let signature = "zzz";
- let public_key = "zzz";
- let content = "ceci est un test qui ne fonctionnera pas!"
- .as_bytes()
- .to_vec();
- assert!(!validate_signature(public_key, &content, signature))
- }
-}
diff --git a/webhook/src/handler/handler.rs b/webhook/src/handler/handler.rs
new file mode 100644
index 0000000..923c650
--- /dev/null
+++ b/webhook/src/handler/handler.rs
@@ -0,0 +1,123 @@
+use super::{signature::validate_signature, types::Interaction};
+use crate::config::Config;
+use hyper::{Body, Method, Request, Response, StatusCode, body::{to_bytes, Bytes}, service::Service};
+use log::{error, info, trace};
+use nats::Connection;
+use serde::{Deserialize, Serialize};
+use std::{future::Future, io::{Error, ErrorKind}, pin::Pin, str::from_utf8, sync::Arc, task::{Context, Poll}};
+
+/// Hyper service used to handle the discord webhooks
+#[derive(Clone)]
+pub struct HandlerService {
+ pub config: Config,
+ pub nats: Arc<Connection>,
+}
+
+impl HandlerService {
+ async fn check_request(&self, req: Request<Body>) -> Result<Bytes, Error> {
+ if req.method() == Method::POST {
+ let headers = req.headers().clone();
+ let signature = headers.get("X-Signature-Ed25519");
+ let timestamp = headers.get("X-Signature-Timestamp");
+ if let (Some(timestamp), Some(signature)) = (timestamp, signature) {
+ if let Ok(data) = to_bytes(req.into_body()).await {
+ let contatenated_data = [timestamp.as_bytes().to_vec(), data.to_vec()].concat();
+ if let Ok(signature_str) = &signature.to_str() {
+ if validate_signature(
+ &self.config.discord.public_key,
+ &contatenated_data,
+ signature_str,
+ ) {
+ Ok(data)
+ } else {
+ Err(Error::new(
+ ErrorKind::InvalidData,
+ "invalid signature specified",
+ ))
+ }
+ } else {
+ Err(Error::new(
+ ErrorKind::BrokenPipe,
+ "failed to read signature",
+ ))
+ }
+ } else {
+ Err(Error::new(ErrorKind::BrokenPipe, "unable to read body"))
+ }
+ } else {
+ Err(Error::new(ErrorKind::InvalidData, "missing headers"))
+ }
+ } else {
+ Err(Error::new(ErrorKind::InvalidData, "invalid method"))
+ }
+ }
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Ping {
+ #[serde(rename = "type")]
+ t: i32
+}
+
+/// Implementation of the service
+impl Service<Request<Body>> for HandlerService {
+ type Response = Response<Body>;
+ type Error = hyper::Error;
+ type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
+
+ fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> {
+ Poll::Ready(Ok(()))
+ }
+
+ fn call(&mut self, req: Request<Body>) -> Self::Future {
+ let self_clone = self.clone();
+
+ Box::pin(async move {
+ match self_clone.check_request(req).await {
+ Ok(data) => {
+ let value: Interaction = serde_json::from_str(from_utf8(&data).unwrap()).unwrap();
+ trace!("received value: {:?}", value);
+
+ match value.t {
+ 1 => {
+ info!("sending pong");
+ // a ping must be responded with another ping
+ return Ok(Response::builder().header("Content-Type", "application/json").body(serde_json::to_string(&Ping {
+ t: 1
+ }).unwrap().into()).unwrap());
+ },
+ _ => {
+ let payload = serde_json::to_string(&common::payloads::CachePayload {
+ tracing: (),
+ data: value,
+ }).unwrap();
+
+ match self_clone.nats.request("nova.cache.dispatch.interaction", payload) {
+ Ok(response) => {
+ Ok(
+ Response::builder()
+ .header("Content-Type", "application/json")
+ .body(from_utf8(&response.data).unwrap().to_string().into())
+ .unwrap()
+ )
+ },
+ Err(error) => {
+ error!("failed to request nats: {}", error);
+ Ok(
+ Response::builder()
+ .status(500)
+ .body("an internal server error occured".to_string().into())
+ .unwrap()
+ )
+ }
+ }
+ },
+ }
+ },
+ Err(error) => {
+ Ok(Response::builder().status(StatusCode::UNAUTHORIZED).body(error.to_string().into()).unwrap())
+ }
+ }
+ })
+ }
+}
diff --git a/webhook/src/handler/make_service.rs b/webhook/src/handler/make_service.rs
new file mode 100644
index 0000000..96b203d
--- /dev/null
+++ b/webhook/src/handler/make_service.rs
@@ -0,0 +1,28 @@
+use std::{future::{Ready, ready}, sync::Arc, task::{Context, Poll}};
+use hyper::service::Service;
+use nats::Connection;
+use crate::config::Config;
+use super::handler::HandlerService;
+
+
+pub struct MakeSvc {
+ pub settings: Config,
+ pub nats: Arc<Connection>,
+}
+
+impl<T> Service<T> for MakeSvc {
+ type Response = HandlerService;
+ type Error = std::io::Error;
+ type Future = Ready<Result<Self::Response, Self::Error>>;
+
+ fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
+ Ok(()).into()
+ }
+
+ fn call(&mut self, _: T) -> Self::Future {
+ ready(Ok(HandlerService {
+ config: self.settings.clone(),
+ nats: self.nats.clone(),
+ }))
+ }
+}
diff --git a/webhook/src/handler/mod.rs b/webhook/src/handler/mod.rs
new file mode 100644
index 0000000..490c580
--- /dev/null
+++ b/webhook/src/handler/mod.rs
@@ -0,0 +1,4 @@
+pub mod make_service;
+mod signature;
+mod handler;
+mod types; \ No newline at end of file
diff --git a/webhook/src/handler/signature.rs b/webhook/src/handler/signature.rs
new file mode 100644
index 0000000..5af6b63
--- /dev/null
+++ b/webhook/src/handler/signature.rs
@@ -0,0 +1,65 @@
+use libsodium_sys::crypto_sign_ed25519_verify_detached;
+
+/// Checks the signature of a given data using the hex signature and the public key.
+pub fn validate_signature(hex_public_key: &str, data: &Vec<u8>, hex_signature: &str) -> bool {
+ // First, we need to check if the signature & private key is valid base64.
+ let signature_result = hex::decode(hex_signature);
+ let public_key_result = hex::decode(hex_public_key);
+
+ if signature_result.is_ok() && public_key_result.is_ok() {
+ // Since we now have the signatures in u8 vectors. We will initialize all the
+ // parameters for the ffi call to sodium.
+ let signature_pointer = signature_result.unwrap();
+ let private_key_pointer = public_key_result.unwrap();
+
+ let data_pointer = data.as_ptr();
+ let data_len = data.len() as u64;
+
+ // A ffi call is considered unsafe by the Rust compiler
+ // we assume all the parameters are correct for the call
+ unsafe {
+ // If the signature is valid, sodium will return 0
+ return crypto_sign_ed25519_verify_detached(
+ signature_pointer.as_ptr(),
+ data_pointer,
+ data_len,
+ private_key_pointer.as_ptr(),
+ ) == 0;
+ }
+ }
+ false
+}
+
+#[cfg(test)]
+mod test {
+ use crate::handler::signature::validate_signature;
+
+
+ #[test]
+ fn validate_signature_test() {
+ let signature = "543ec3547d57f9ddb1ec4c5c36503ebf288ffda3da3d510764c9a49c2abb57690ef974c63d174771bdd2481de1066966f57abbec12a3ec171b9f6e2373837002";
+ let public_key = "eefe0c24473737cb2035232e3b4eb91c206f0a14684168f3503f7d8316058d6f";
+ let content = "message de test incroyable".as_bytes().to_vec();
+ assert!(validate_signature(public_key, &content, signature))
+ }
+
+ #[test]
+ fn validate_signature_reverse_test() {
+ let signature = "543ec3547d57f9ddb1ec4c5c36503ebf288ffda3da3d510764c9a49c2abb57690ef974c63d174771bdd2481de1066966f57abbec12a3ec171b9f6e2373837002";
+ let public_key = "c029eea18437292c87c62aec34e7d1bd4e38fe6126f3f7c446de6375dc666044";
+ let content = "ceci est un test qui ne fonctionnera pas!"
+ .as_bytes()
+ .to_vec();
+ assert!(!validate_signature(public_key, &content, signature))
+ }
+
+ #[test]
+ fn invalid_hex() {
+ let signature = "zzz";
+ let public_key = "zzz";
+ let content = "ceci est un test qui ne fonctionnera pas!"
+ .as_bytes()
+ .to_vec();
+ assert!(!validate_signature(public_key, &content, signature))
+ }
+}
diff --git a/webhook/src/handler/types.rs b/webhook/src/handler/types.rs
new file mode 100644
index 0000000..4cba12a
--- /dev/null
+++ b/webhook/src/handler/types.rs
@@ -0,0 +1,10 @@
+use serde::{Serialize, Deserialize};
+use serde_json::Value;
+
+#[derive(Debug, Deserialize, Clone, Default, Serialize)]
+pub struct Interaction {
+ #[serde(rename = "type")]
+ pub t: i16,
+ pub data: Option<Value>,
+}
+
diff --git a/webhook/src/main.rs b/webhook/src/main.rs
index b9fefc5..c127c2c 100644
--- a/webhook/src/main.rs
+++ b/webhook/src/main.rs
@@ -1,10 +1,10 @@
-use std::net::ToSocketAddrs;
-mod handle;
+use std::{net::ToSocketAddrs, sync::Arc};
+mod handler;
mod config;
+use crate::handler::make_service::MakeSvc;
use hyper::Server;
-use log::info;
-use handle::MakeSvc;
+use log::{info, error};
use common::config::Settings;
use crate::config::Config;
@@ -22,13 +22,13 @@ async fn main() {
"Starting server on {}:{}",
settings.config.server.address, settings.config.server.port
);
- let nats = Box::new(nats::connect("localhost").unwrap());
+
let server = Server::bind(&addr).serve(MakeSvc {
settings: settings.config.clone(),
- nats
+ nats: Arc::new(settings.nats.into()),
});
if let Err(e) = server.await {
- eprintln!("server error: {}", e);
+ error!("server error: {}", e);
}
}