Merge pull request #2 from JellyWX/soundboard

Soundboard
This commit is contained in:
Jude Southworth 2021-08-26 13:48:12 +01:00 committed by GitHub
commit 4d8f1acb57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 2190 additions and 1644 deletions

336
Cargo.lock generated
View File

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "adler" name = "adler"
version = "1.0.2" version = "1.0.2"
@ -8,11 +10,12 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]] [[package]]
name = "aead" name = "aead"
version = "0.4.1" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "922b33332f54fc0ad13fa3e514601e8d30fb54e1f3eadc36643f6526db645621" checksum = "6e3e798aa0c8239776f54415bc06f3d74b1850f3f830b45c35cfc80556973f70"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"rand_core",
] ]
[[package]] [[package]]
@ -52,9 +55,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]] [[package]]
name = "async-trait" name = "async-trait"
version = "0.1.50" version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -147,9 +150,9 @@ dependencies = [
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1"
[[package]] [[package]]
name = "bitvec" name = "bitvec"
@ -192,9 +195,9 @@ checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.68" version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -233,8 +236,8 @@ dependencies = [
[[package]] [[package]]
name = "command_attr" name = "command_attr"
version = "0.3.6" version = "0.3.7"
source = "git+https://github.com/serenity-rs/serenity?branch=next#a24132fc66bea5fe7772d9f694ab3517d24d286b" source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -259,9 +262,9 @@ checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.1.4" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -323,6 +326,7 @@ checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"num_cpus", "num_cpus",
"serde",
] ]
[[package]] [[package]]
@ -376,9 +380,9 @@ dependencies = [
[[package]] [[package]]
name = "env_logger" name = "env_logger"
version = "0.8.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [ dependencies = [
"atty", "atty",
"humantime", "humantime",
@ -401,9 +405,9 @@ dependencies = [
[[package]] [[package]]
name = "flume" name = "flume"
version = "0.10.5" version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa9d66b91e902db43baefd8e40c8678ce29db2cf1d88ebd715174368d5fe70a9" checksum = "2e90cc80fad5bb391b38127896b0fa27d97e7fef74742797f4da518d67e1292f"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
@ -451,9 +455,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27" checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
@ -466,9 +470,9 @@ dependencies = [
[[package]] [[package]]
name = "futures-channel" name = "futures-channel"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
@ -476,15 +480,15 @@ dependencies = [
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99"
[[package]] [[package]]
name = "futures-executor" name = "futures-executor"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79" checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-task", "futures-task",
@ -493,15 +497,15 @@ dependencies = [
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582"
[[package]] [[package]]
name = "futures-macro" name = "futures-macro"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57"
dependencies = [ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
"proc-macro-hack", "proc-macro-hack",
@ -512,21 +516,21 @@ dependencies = [
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78"
dependencies = [ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
"futures-channel", "futures-channel",
@ -598,12 +602,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.11.2" version = "0.11.2"
@ -619,7 +617,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf"
dependencies = [ dependencies = [
"hashbrown 0.11.2", "hashbrown",
] ]
[[package]] [[package]]
@ -633,9 +631,9 @@ dependencies = [
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.18" version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -659,9 +657,9 @@ dependencies = [
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "0.4.2" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5"
dependencies = [ dependencies = [
"bytes", "bytes",
"http", "http",
@ -688,9 +686,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.8" version = "0.14.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3f71a7eea53a3f8257a7b4795373ff886397178cd634430ea94e12d7fe4fe34" checksum = "0b61cf2d1aebcf6e6352c97b81dc2244ca29194be1b276f5d8ad5c6330fffb11"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
@ -702,7 +700,7 @@ dependencies = [
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project", "pin-project-lite",
"socket2", "socket2",
"tokio", "tokio",
"tower-service", "tower-service",
@ -751,12 +749,12 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.6.2" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
dependencies = [ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
"hashbrown 0.9.1", "hashbrown",
] ]
[[package]] [[package]]
@ -770,18 +768,18 @@ dependencies = [
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.9" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.3.0" version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"
[[package]] [[package]]
name = "itoa" name = "itoa"
@ -791,9 +789,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.51" version = "0.3.52"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" checksum = "ce791b7ca6638aae45be056e068fc756d871eb3b3b10b8efa62d1c9cec616752"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -822,9 +820,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.95" version = "0.2.99"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765"
[[package]] [[package]]
name = "libm" name = "libm"
@ -871,9 +869,9 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]] [[package]]
name = "matches" name = "matches"
version = "0.1.8" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "memchr" name = "memchr"
@ -909,9 +907,9 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.7.11" version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
@ -931,18 +929,18 @@ dependencies = [
[[package]] [[package]]
name = "nanorand" name = "nanorand"
version = "0.5.2" version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1378b66f7c93a1c0f8464a19bf47df8795083842e5090f4b7305973d5a22d0" checksum = "729eb334247daa1803e0a094d0a5c55711b85571179f5ec6e53eccfdf7008958"
dependencies = [ dependencies = [
"getrandom", "getrandom",
] ]
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.2.7" version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
@ -1076,9 +1074,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.7.2" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
@ -1088,9 +1086,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.34" version = "0.10.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7830286ad6a3973c0f1d9b73738f69c76b739301d0229c4b96501695cbe4c8" checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -1108,9 +1106,9 @@ checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.63" version = "0.9.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b0d6fb7d80f877617dfcb014e605e2b5ab2fb0afdf27935219bb6bd984cb98" checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d"
dependencies = [ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
"cc", "cc",
@ -1163,18 +1161,18 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "1.0.7" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08"
dependencies = [ dependencies = [
"pin-project-internal", "pin-project-internal",
] ]
[[package]] [[package]]
name = "pin-project-internal" name = "pin-project-internal"
version = "1.0.7" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1183,9 +1181,9 @@ dependencies = [
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.6" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -1228,9 +1226,9 @@ dependencies = [
[[package]] [[package]]
name = "poly1305" name = "poly1305"
version = "0.7.0" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fe800695325da85083cd23b56826fccb2e2dc29b218e7811a6f33bc93f414be" checksum = "9fcffab1f78ebbdf4b93b68c1ffebc24037eedf271edaca795732b24e5e4e349"
dependencies = [ dependencies = [
"cpufeatures", "cpufeatures",
"opaque-debug", "opaque-debug",
@ -1257,9 +1255,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.27" version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid",
] ]
@ -1281,9 +1279,9 @@ checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [ dependencies = [
"libc", "libc",
"rand_chacha", "rand_chacha",
@ -1293,9 +1291,9 @@ dependencies = [
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [ dependencies = [
"ppv-lite86", "ppv-lite86",
"rand_core", "rand_core",
@ -1303,27 +1301,27 @@ dependencies = [
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.6.2" version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [ dependencies = [
"getrandom", "getrandom",
] ]
[[package]] [[package]]
name = "rand_hc" name = "rand_hc"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [ dependencies = [
"rand_core", "rand_core",
] ]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.2.8" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
dependencies = [ dependencies = [
"bitflags", "bitflags",
] ]
@ -1365,9 +1363,9 @@ dependencies = [
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.3" version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2296f2fac53979e8ccbc4a1136b25dcefd37be9ed7e4a1f6b05a6029c84ff124" checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22"
dependencies = [ dependencies = [
"base64", "base64",
"bytes", "bytes",
@ -1420,9 +1418,9 @@ dependencies = [
[[package]] [[package]]
name = "rsa" name = "rsa"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ef841a26fc5d040ced0417c6c6a64ee851f42489df11cdf0218e545b6f8d28" checksum = "7b0aeddcca1082112a6eeb43bf25fd7820b066aaf6eaef776e19d0a1febe38fe"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"digest", "digest",
@ -1465,9 +1463,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]] [[package]]
name = "salsa20" name = "salsa20"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c7c5f10864beba947e1a1b43f3ef46c8cc58d1c2ae549fa471713e8ff60787a" checksum = "ecbd2eb639fd7cab5804a0837fe373cc2172d15437e804c054a9fb885cb923b0"
dependencies = [ dependencies = [
"cipher", "cipher",
"zeroize", "zeroize",
@ -1507,9 +1505,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.2.0" version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3670b1d2fdf6084d192bc71ead7aabe6c06aa2ea3fbd9cc3ac111fa5c2b1bd84" checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation", "core-foundation",
@ -1520,9 +1518,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "2.2.0" version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3676258fd3cfe2c9a0ec99ce3038798d847ce3e4bb17746373eb9f0f1ac16339" checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -1530,18 +1528,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.126" version = "1.0.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.126" version = "1.0.127"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1550,9 +1548,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.64" version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -1584,8 +1582,8 @@ dependencies = [
[[package]] [[package]]
name = "serenity" name = "serenity"
version = "0.10.7" version = "0.10.8"
source = "git+https://github.com/serenity-rs/serenity?branch=next#a24132fc66bea5fe7772d9f694ab3517d24d286b" source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"async-tungstenite", "async-tungstenite",
@ -1594,8 +1592,12 @@ dependencies = [
"bytes", "bytes",
"chrono", "chrono",
"command_attr", "command_attr",
"dashmap",
"flate2", "flate2",
"futures", "futures",
"mime",
"mime_guess",
"parking_lot",
"percent-encoding", "percent-encoding",
"reqwest", "reqwest",
"serde", "serde",
@ -1611,7 +1613,7 @@ dependencies = [
[[package]] [[package]]
name = "serenity-voice-model" name = "serenity-voice-model"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/serenity-rs/serenity?branch=next#a24132fc66bea5fe7772d9f694ab3517d24d286b" source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"enum_primitive", "enum_primitive",
@ -1622,9 +1624,9 @@ dependencies = [
[[package]] [[package]]
name = "sha-1" name = "sha-1"
version = "0.9.6" version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16" checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81"
dependencies = [ dependencies = [
"block-buffer", "block-buffer",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -1657,9 +1659,9 @@ dependencies = [
[[package]] [[package]]
name = "simple_asn1" name = "simple_asn1"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc31e6cf34ad4321d3a2b8f934949b429e314519f753a77962f16c664dca8e13" checksum = "8eb4ea60fb301dc81dfc113df680571045d375ab7345d171c5dc7d7e13107a80"
dependencies = [ dependencies = [
"chrono", "chrono",
"num-bigint 0.4.0", "num-bigint 0.4.0",
@ -1669,9 +1671,9 @@ dependencies = [
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.3" version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
@ -1681,9 +1683,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad"
dependencies = [ dependencies = [
"libc", "libc",
"winapi", "winapi",
@ -1691,8 +1693,8 @@ dependencies = [
[[package]] [[package]]
name = "songbird" name = "songbird"
version = "0.2.0-beta.3" version = "0.2.0-beta.4"
source = "git+https://github.com/serenity-rs/songbird?branch=next#e0ea2f5fe2fe14cb2de0774227f27cb1175d8295" source = "git+https://github.com/serenity-rs/songbird?branch=next#2a2543ebc830ba442bcd836733d52114fd1b3f8a"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"async-tungstenite", "async-tungstenite",
@ -1723,7 +1725,7 @@ dependencies = [
[[package]] [[package]]
name = "soundfx-rs" name = "soundfx-rs"
version = "1.3.0" version = "1.4.0"
dependencies = [ dependencies = [
"dashmap", "dashmap",
"dotenv", "dotenv",
@ -1896,9 +1898,9 @@ dependencies = [
[[package]] [[package]]
name = "subtle" name = "subtle"
version = "2.4.0" version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]] [[package]]
name = "symphonia-core" name = "symphonia-core"
@ -1915,9 +1917,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.72" version = "1.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1926,9 +1928,9 @@ dependencies = [
[[package]] [[package]]
name = "synstructure" name = "synstructure"
version = "0.12.4" version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1967,18 +1969,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.25" version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.25" version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1997,9 +1999,9 @@ dependencies = [
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.2.0" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338"
dependencies = [ dependencies = [
"tinyvec_macros", "tinyvec_macros",
] ]
@ -2012,9 +2014,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.6.1" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a38d31d7831c6ed7aad00aa4c12d9375fd225a6dd77da1d25b707346319a975" checksum = "01cf844b23c6131f624accf65ce0e4e9956a8bb329400ea5bcc26ae3a5c20b0b"
dependencies = [ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
"bytes", "bytes",
@ -2031,9 +2033,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "1.2.0" version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2063,9 +2065,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-stream" name = "tokio-stream"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8864d706fdb3cc0843a49647ac892720dac98a6eeb818b77190592cf4994066" checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"pin-project-lite", "pin-project-lite",
@ -2187,12 +2189,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.5" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085"
dependencies = [
"matches",
]
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
@ -2205,9 +2204,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "1.7.1" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
@ -2223,9 +2222,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
[[package]] [[package]]
name = "universal-hash" name = "universal-hash"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"subtle", "subtle",
@ -2247,6 +2246,7 @@ dependencies = [
"idna", "idna",
"matches", "matches",
"percent-encoding", "percent-encoding",
"serde",
] ]
[[package]] [[package]]
@ -2272,9 +2272,9 @@ checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0"
[[package]] [[package]]
name = "vcpkg" name = "vcpkg"
version = "0.2.13" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "025ce40a007e1907e58d5bc1a594def78e5573bb0b1160bc389634e8f12e4faa" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "version_check" name = "version_check"
@ -2300,9 +2300,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.74" version = "0.2.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"serde", "serde",
@ -2312,9 +2312,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.74" version = "0.2.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
@ -2327,9 +2327,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.24" version = "0.4.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" checksum = "16646b21c3add8e13fdb8f20172f8a28c3dbf62f45406bcff0233188226cfe0c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"js-sys", "js-sys",
@ -2339,9 +2339,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.74" version = "0.2.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -2349,9 +2349,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.74" version = "0.2.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2362,15 +2362,15 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.74" version = "0.2.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2"
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.51" version = "0.3.52"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" checksum = "01c70a82d842c9979078c772d4a1344685045f1a5628f677c2b2eab4dd7d2696"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
@ -2453,9 +2453,9 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
[[package]] [[package]]
name = "xsalsa20poly1305" name = "xsalsa20poly1305"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a214b4d445e6534a858c970b44eb526c398dbfaa2961e3efb637307af634284d" checksum = "2e0f69b133860e3614a4d4fdd6f0d7fe3219e9d67a7e8cd537676a4ebc8313db"
dependencies = [ dependencies = [
"aead", "aead",
"poly1305", "poly1305",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "soundfx-rs" name = "soundfx-rs"
version = "1.3.0" version = "1.4.0"
authors = ["jellywx <judesouthworth@pm.me>"] authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018" edition = "2018"

View File

@ -5,7 +5,7 @@ use syn::parse::{Error, Result};
use syn::spanned::Spanned; use syn::spanned::Spanned;
use syn::{Attribute, Ident, Lit, LitStr, Meta, NestedMeta, Path}; use syn::{Attribute, Ident, Lit, LitStr, Meta, NestedMeta, Path};
use crate::structures::{ApplicationCommandOptionType, Arg, PermissionLevel}; use crate::structures::{ApplicationCommandOptionType, Arg, CommandKind, PermissionLevel};
use crate::util::{AsOption, LitExt}; use crate::util::{AsOption, LitExt};
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
@ -321,6 +321,18 @@ impl AttributeOption for PermissionLevel {
} }
} }
impl AttributeOption for CommandKind {
fn parse(values: Values) -> Result<Self> {
validate(&values, &[ValueKind::SingleList])?;
Ok(values
.literals
.get(0)
.map(|(_, l)| CommandKind::from_str(&*l.to_str()).unwrap())
.unwrap())
}
}
impl AttributeOption for Arg { impl AttributeOption for Arg {
fn parse(values: Values) -> Result<Self> { fn parse(values: Values) -> Result<Self> {
validate(&values, &[ValueKind::EqualsList])?; validate(&values, &[ValueKind::EqualsList])?;

View File

@ -68,9 +68,9 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
_ => { _ => {
match_options!(name, values, options, span => [ match_options!(name, values, options, span => [
aliases; aliases;
usage; group;
required_permissions; required_permissions;
allow_slash kind
]); ]);
} }
} }
@ -79,10 +79,10 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
let Options { let Options {
aliases, aliases,
description, description,
usage, group,
examples, examples,
required_permissions, required_permissions,
allow_slash, kind,
mut cmd_args, mut cmd_args,
} = options; } = options;
@ -108,7 +108,10 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
let arg_idents = cmd_args let arg_idents = cmd_args
.iter() .iter()
.map(|arg| n.with_suffix(arg.name.as_str()).with_suffix(ARG)) .map(|arg| {
n.with_suffix(arg.name.replace(" ", "_").replace("-", "_").as_str())
.with_suffix(ARG)
})
.collect::<Vec<Ident>>(); .collect::<Vec<Ident>>();
let mut tokens = cmd_args let mut tokens = cmd_args
@ -146,10 +149,10 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
fun: #name, fun: #name,
names: &[#_name, #(#aliases),*], names: &[#_name, #(#aliases),*],
desc: #description, desc: #description,
usage: #usage, group: #group,
examples: &[#(#examples),*], examples: &[#(#examples),*],
required_permissions: #required_permissions, required_permissions: #required_permissions,
allow_slash: #allow_slash, kind: #kind,
args: &[#(&#arg_idents),*], args: &[#(&#arg_idents),*],
}; };

View File

@ -7,7 +7,7 @@ use syn::{
Attribute, Block, FnArg, Ident, Pat, ReturnType, Stmt, Token, Type, Visibility, Attribute, Block, FnArg, Ident, Pat, ReturnType, Stmt, Token, Type, Visibility,
}; };
use crate::util::{self, Argument, AsOption, Parenthesised}; use crate::util::{self, Argument, Parenthesised};
fn parse_argument(arg: FnArg) -> Result<Argument> { fn parse_argument(arg: FnArg) -> Result<Argument> {
match arg { match arg {
@ -214,6 +214,55 @@ impl ToTokens for PermissionLevel {
} }
} }
#[derive(Debug)]
pub enum CommandKind {
Slash,
Both,
Text,
}
impl Default for CommandKind {
fn default() -> Self {
Self::Both
}
}
impl CommandKind {
pub fn from_str(s: &str) -> Option<Self> {
Some(match s.to_uppercase().as_str() {
"SLASH" => Self::Slash,
"BOTH" => Self::Both,
"TEXT" => Self::Text,
_ => return None,
})
}
}
impl ToTokens for CommandKind {
fn to_tokens(&self, stream: &mut TokenStream2) {
let path = quote!(crate::framework::CommandKind);
let variant;
match self {
Self::Slash => {
variant = quote!(Slash);
}
Self::Both => {
variant = quote!(Both);
}
Self::Text => {
variant = quote!(Text);
}
}
stream.extend(quote! {
#path::#variant
});
}
}
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum ApplicationCommandOptionType { pub(crate) enum ApplicationCommandOptionType {
SubCommand, SubCommand,
@ -247,7 +296,9 @@ impl ApplicationCommandOptionType {
impl ToTokens for ApplicationCommandOptionType { impl ToTokens for ApplicationCommandOptionType {
fn to_tokens(&self, stream: &mut TokenStream2) { fn to_tokens(&self, stream: &mut TokenStream2) {
let path = quote!(serenity::model::interactions::ApplicationCommandOptionType); let path = quote!(
serenity::model::interactions::application_command::ApplicationCommandOptionType
);
let variant = match self { let variant = match self {
ApplicationCommandOptionType::SubCommand => quote!(SubCommand), ApplicationCommandOptionType::SubCommand => quote!(SubCommand),
ApplicationCommandOptionType::SubCommandGroup => quote!(SubCommandGroup), ApplicationCommandOptionType::SubCommandGroup => quote!(SubCommandGroup),
@ -290,10 +341,10 @@ impl Default for Arg {
pub(crate) struct Options { pub(crate) struct Options {
pub aliases: Vec<String>, pub aliases: Vec<String>,
pub description: String, pub description: String,
pub usage: AsOption<String>, pub group: String,
pub examples: Vec<String>, pub examples: Vec<String>,
pub required_permissions: PermissionLevel, pub required_permissions: PermissionLevel,
pub allow_slash: bool, pub kind: CommandKind,
pub cmd_args: Vec<Arg>, pub cmd_args: Vec<Arg>,
} }
@ -301,7 +352,7 @@ impl Options {
#[inline] #[inline]
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
allow_slash: true, group: "Other".to_string(),
..Default::default() ..Default::default()
} }
} }

224
src/cmds/info.rs Normal file
View File

@ -0,0 +1,224 @@
use regex_command_attr::command;
use serenity::{client::Context, framework::standard::CommandResult};
use crate::{
framework::{Args, CommandInvoke, CreateGenericResponse, RegexFramework},
THEME_COLOR,
};
use crate::framework::CommandKind;
use std::{collections::HashMap, sync::Arc};
#[command]
#[group("Information")]
#[description("Get information on the commands of the bot")]
#[arg(
name = "command",
description = "Get help for a specific command",
kind = "String",
required = false
)]
#[example("`/help` - see all commands")]
#[example("`/help play` - get help about the `play` command")]
pub async fn help(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
fn get_groups(framework: Arc<RegexFramework>) -> HashMap<&'static str, Vec<&'static str>> {
let mut groups = HashMap::new();
for command in &framework.commands_ {
let entry = groups.entry(command.group).or_insert(vec![]);
entry.push(command.names[0]);
}
groups
}
let framework = ctx
.data
.read()
.await
.get::<RegexFramework>()
.cloned()
.unwrap();
if let Some(command_name) = args.named("command") {
if let Some(command) = framework.commands.get(command_name) {
let examples = if command.examples.is_empty() {
"".to_string()
} else {
format!(
"**Examples**
{}",
command
.examples
.iter()
.map(|e| format!("{}", e))
.collect::<Vec<String>>()
.join("\n")
)
};
let args = if command.args.is_empty() {
"**Arguments**
*This command has no arguments*"
.to_string()
} else {
format!(
"**Arguments**
{}",
command
.args
.iter()
.map(|a| format!(
" • `{}` {} - {}",
a.name,
if a.required { "" } else { "[optional]" },
a.description
))
.collect::<Vec<String>>()
.join("\n")
)
};
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().embed(|e| {
e.title(format!("{} Help", command_name))
.color(THEME_COLOR)
.description(format!(
"**Available In**
`Slash Commands` {}
` Text Commands` {}
**Aliases**
{}
**Overview**
{}
{}
{}",
if command.kind != CommandKind::Text {
""
} else {
""
},
if command.kind != CommandKind::Slash {
""
} else {
""
},
command
.names
.iter()
.map(|n| format!("`{}`", n))
.collect::<Vec<String>>()
.join(" "),
command.desc,
args,
examples
))
}),
)
.await?;
} else {
let groups = get_groups(framework);
let groups_iter = groups.iter().map(|(name, commands)| {
(
name,
commands
.iter()
.map(|c| format!("`{}`", c))
.collect::<Vec<String>>()
.join(" "),
true,
)
});
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().embed(|e| {
e.title("Invalid Command")
.color(THEME_COLOR)
.description("Type `/help command` to view help about a command below:")
.fields(groups_iter)
}),
)
.await?;
}
} else {
let groups = get_groups(framework);
let groups_iter = groups.iter().map(|(name, commands)| {
(
name,
commands
.iter()
.map(|c| format!("`{}`", c))
.collect::<Vec<String>>()
.join(" "),
true,
)
});
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().embed(|e| {
e.title("Help")
.color(THEME_COLOR)
.description("Type `/help command` to view help about a command below:")
.fields(groups_iter)
}),
)
.await?;
}
Ok(())
}
#[command]
#[group("Information")]
#[aliases("invite")]
#[description("Get additional information on the bot")]
async fn info(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
_args: Args,
) -> CommandResult {
let current_user = ctx.cache.current_user();
invoke.respond(ctx.http.clone(), CreateGenericResponse::new()
.embed(|e| e
.title("Info")
.color(THEME_COLOR)
.footer(|f| f
.text(concat!(env!("CARGO_PKG_NAME"), " ver ", env!("CARGO_PKG_VERSION"))))
.description(format!("Default prefix: `?`
Reset prefix: `@{0} prefix ?`
Invite me: https://discord.com/api/oauth2/authorize?client_id={1}&permissions=3165184&scope=applications.commands%20bot
**Welcome to SoundFX!**
Developer: <@203532103185465344>
Find me on https://discord.jellywx.com/ and on https://github.com/JellyWX :)
**Sound Credits**
\"The rain falls against the parasol\" https://freesound.org/people/straget/
\"Heavy Rain\" https://freesound.org/people/lebaston100/
\"Rain on Windows, Interior, A\" https://freesound.org/people/InspectorJ/
\"Seaside Waves, Close, A\" https://freesound.org/people/InspectorJ/
\"Small River 1 - Fast - Close\" https://freesound.org/people/Pfannkuchn/
**An online dashboard is available!** Visit https://soundfx.jellywx.com/dashboard
There is a maximum sound limit per user. This can be removed by subscribing at **https://patreon.com/jellywx**", current_user.name, current_user.id.as_u64())))).await?;
Ok(())
}

346
src/cmds/manage.rs Normal file
View File

@ -0,0 +1,346 @@
use regex_command_attr::command;
use serenity::{
client::Context,
framework::standard::CommandResult,
model::id::{GuildId, RoleId},
};
use crate::{
framework::{Args, CommandInvoke, CreateGenericResponse},
sound::Sound,
MySQL, MAX_SOUNDS, PATREON_GUILD, PATREON_ROLE,
};
use std::time::Duration;
#[command("upload")]
#[group("Manage")]
#[description("Upload a new sound to the bot")]
#[arg(
name = "name",
description = "Name to upload sound to",
kind = "String",
required = true
)]
pub async fn upload_new_sound(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
fn is_numeric(s: &String) -> bool {
for char in s.chars() {
if char.is_digit(10) {
continue;
} else {
return false;
}
}
true
}
let new_name = args
.named("name")
.map(|n| n.to_string())
.unwrap_or(String::new());
if !new_name.is_empty() && new_name.len() <= 20 {
if !is_numeric(&new_name) {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
// need to check the name is not currently in use by the user
let count_name =
Sound::count_named_user_sounds(invoke.author_id().0, &new_name, pool.clone())
.await?;
if count_name > 0 {
invoke.respond(ctx.http.clone(), CreateGenericResponse::new().content("You are already using that name. Please choose a unique name for your upload.")).await?;
} else {
// need to check how many sounds user currently has
let count = Sound::count_user_sounds(invoke.author_id().0, pool.clone()).await?;
let mut permit_upload = true;
// need to check if user is patreon or nah
if count >= *MAX_SOUNDS {
let patreon_guild_member = GuildId(*PATREON_GUILD)
.member(ctx, invoke.author_id())
.await;
if let Ok(member) = patreon_guild_member {
permit_upload = member.roles.contains(&RoleId(*PATREON_ROLE));
} else {
permit_upload = false;
}
}
if permit_upload {
let attachment = if let Some(attachment) = invoke
.msg()
.map(|m| m.attachments.get(0).map(|a| a.url.clone()))
.flatten()
{
Some(attachment)
} else {
invoke.respond(ctx.http.clone(), CreateGenericResponse::new().content("Please now upload an audio file under 1MB in size (larger files will be automatically trimmed):")).await?;
let reply = invoke
.channel_id()
.await_reply(&ctx)
.author_id(invoke.author_id())
.timeout(Duration::from_secs(120))
.await;
match reply {
Some(reply_msg) => {
if let Some(attachment) = reply_msg.attachments.get(0) {
Some(attachment.url.clone())
} else {
invoke.followup(ctx.http.clone(), CreateGenericResponse::new().content("Please upload 1 attachment following your upload command. Aborted")).await?;
None
}
}
None => {
invoke
.followup(
ctx.http.clone(),
CreateGenericResponse::new()
.content("Upload timed out. Please redo the command"),
)
.await?;
None
}
}
};
if let Some(url) = attachment {
match Sound::create_anon(
&new_name,
url.as_str(),
invoke.guild_id().unwrap().0,
invoke.author_id().0,
pool,
)
.await
{
Ok(_) => {
invoke
.followup(
ctx.http.clone(),
CreateGenericResponse::new()
.content("Sound has been uploaded"),
)
.await?;
}
Err(e) => {
println!("Error occurred during upload: {:?}", e);
invoke
.followup(
ctx.http.clone(),
CreateGenericResponse::new()
.content("Sound failed to upload."),
)
.await?;
}
}
}
} else {
invoke.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(format!(
"You have reached the maximum number of sounds ({}). Either delete some with `?delete` or join our Patreon for unlimited uploads at **https://patreon.com/jellywx**",
*MAX_SOUNDS,
))).await?;
}
}
} else {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new()
.content("Please ensure the sound name contains a non-numerical character"),
)
.await?;
}
} else {
invoke.respond(ctx.http.clone(), CreateGenericResponse::new().content("Usage: `?upload <name>`. Please ensure the name provided is less than 20 characters in length")).await?;
}
Ok(())
}
#[command("delete")]
#[group("Manage")]
#[description("Delete a sound you have uploaded")]
#[arg(
name = "query",
description = "Delete sound with the specified name or ID",
kind = "String",
required = true
)]
#[example("`/delete beep` - delete the sound with the name \"beep\"")]
pub async fn delete_sound(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let uid = invoke.author_id().0;
let gid = invoke.guild_id().unwrap().0;
let name = args
.named("query")
.map(|s| s.to_owned())
.unwrap_or(String::new());
let sound_vec = Sound::search_for_sound(&name, gid, uid, pool.clone(), true).await?;
let sound_result = sound_vec.first();
match sound_result {
Some(sound) => {
if sound.uploader_id != Some(uid) && sound.server_id != gid {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(
"You can only delete sounds from this guild or that you have uploaded.",
),
)
.await?;
} else {
let has_perms = {
if let Ok(member) = invoke.member(&ctx).await {
if let Ok(perms) = member.permissions(&ctx) {
perms.manage_guild()
} else {
false
}
} else {
false
}
};
if sound.uploader_id == Some(uid) || has_perms {
sound.delete(pool).await?;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content("Sound has been deleted"),
)
.await?;
} else {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(
"Only server admins can delete sounds uploaded by other users.",
),
)
.await?;
}
}
}
None => {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content("Sound could not be found by that name."),
)
.await?;
}
}
Ok(())
}
#[command("public")]
#[group("Manage")]
#[description("Change a sound between public and private")]
#[arg(
name = "query",
kind = "String",
description = "Sound name or ID to change the privacy setting of",
required = true
)]
#[example("`/public 12` - change sound with ID 12 to private")]
#[example("`/public 12` - change sound with ID 12 back to public")]
pub async fn change_public(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let uid = invoke.author_id().as_u64().to_owned();
let name = args.named("query").unwrap();
let gid = *invoke.guild_id().unwrap().as_u64();
let mut sound_vec = Sound::search_for_sound(name, gid, uid, pool.clone(), true).await?;
let sound_result = sound_vec.first_mut();
match sound_result {
Some(sound) => {
if sound.uploader_id != Some(uid) {
invoke.respond(ctx.http.clone(), CreateGenericResponse::new().content("You can only change the visibility of sounds you have uploaded. Use `?list me` to view your sounds")).await?;
} else {
if sound.public {
sound.public = false;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new()
.content("Sound has been set to private 🔒"),
)
.await?;
} else {
sound.public = true;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content("Sound has been set to public 🔓"),
)
.await?;
}
sound.commit(pool).await?
}
}
None => {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content("Sound could not be found by that name."),
)
.await?;
}
}
Ok(())
}

6
src/cmds/mod.rs Normal file
View File

@ -0,0 +1,6 @@
pub mod info;
pub mod manage;
pub mod play;
pub mod search;
pub mod settings;
pub mod stop;

406
src/cmds/play.rs Normal file
View File

@ -0,0 +1,406 @@
use regex_command_attr::command;
use serenity::{
builder::CreateActionRow,
client::Context,
framework::standard::CommandResult,
model::interactions::{message_component::ButtonStyle, InteractionResponseType},
};
use songbird::{
create_player, ffmpeg,
input::{cached::Memory, Input},
Event,
};
use crate::{
event_handlers::RestartTrack,
framework::{Args, CommandInvoke, CreateGenericResponse},
guild_data::CtxGuildData,
join_channel, play_from_query,
sound::Sound,
AudioIndex, MySQL,
};
use std::{convert::TryFrom, time::Duration};
#[command]
#[aliases("p")]
#[required_permissions(Managed)]
#[group("Play")]
#[description("Play a sound in your current voice channel")]
#[arg(
name = "query",
description = "Play sound with the specified name or ID",
kind = "String",
required = true
)]
#[example("`/play ubercharge` - play sound with name \"ubercharge\" ")]
#[example("`/play 13002` - play sound with ID 13002")]
pub async fn play(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let guild = invoke.guild(ctx.cache.clone()).unwrap();
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new()
.content(play_from_query(ctx, guild, invoke.author_id(), args, false).await),
)
.await?;
Ok(())
}
#[command("loop")]
#[required_permissions(Managed)]
#[group("Play")]
#[description("Play a sound on loop in your current voice channel")]
#[arg(
name = "query",
description = "Play sound with the specified name or ID",
kind = "String",
required = true
)]
#[example("`/loop rain` - loop sound with name \"rain\" ")]
#[example("`/loop 13002` - play sound with ID 13002")]
pub async fn loop_play(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let guild = invoke.guild(ctx.cache.clone()).unwrap();
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new()
.content(play_from_query(ctx, guild, invoke.author_id(), args, true).await),
)
.await?;
Ok(())
}
#[command("ambience")]
#[required_permissions(Managed)]
#[group("Play")]
#[description("Play ambient sound in your current voice channel")]
#[arg(
name = "name",
description = "Play sound with the specified name",
kind = "String",
required = false
)]
#[example("`/ambience rain on tent` - play the ambient sound \"rain on tent\" ")]
pub async fn play_ambience(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let guild = invoke.guild(ctx.cache.clone()).unwrap();
let channel_to_join = guild
.voice_states
.get(&invoke.author_id())
.and_then(|voice_state| voice_state.channel_id);
match channel_to_join {
Some(user_channel) => {
let search_name = args.named("name").unwrap().to_lowercase();
let audio_index = ctx.data.read().await.get::<AudioIndex>().cloned().unwrap();
if let Some(filename) = audio_index.get(&search_name) {
let (track, track_handler) = create_player(
Input::try_from(
Memory::new(ffmpeg(format!("audio/{}", filename)).await.unwrap()).unwrap(),
)
.unwrap(),
);
let (call_handler, _) = join_channel(ctx, guild.clone(), user_channel).await;
let guild_data = ctx.guild_data(guild).await.unwrap();
{
let mut lock = call_handler.lock().await;
lock.play(track);
}
let _ = track_handler.set_volume(guild_data.read().await.volume as f32 / 100.0);
let _ = track_handler.add_event(
Event::Periodic(
track_handler.metadata().duration.unwrap() - Duration::from_millis(200),
None,
),
RestartTrack {},
);
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new()
.content(format!("Playing ambience **{}**", search_name)),
)
.await?;
} else {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().embed(|e| {
e.title("Not Found").description(format!(
"Could not find ambience sound by name **{}**
__Available ambience sounds:__
{}",
search_name,
audio_index
.keys()
.into_iter()
.map(|i| i.as_str())
.collect::<Vec<&str>>()
.join("\n")
))
}),
)
.await?;
}
}
None => {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content("You are not in a voice chat!"),
)
.await?;
}
}
Ok(())
}
#[command("soundboard")]
#[required_permissions(Managed)]
#[group("Play")]
#[kind(Slash)]
#[description("Get a menu of sounds with buttons to play them")]
#[arg(
name = "1",
description = "Query for sound button 1",
kind = "String",
required = true
)]
#[arg(
name = "2",
description = "Query for sound button 2",
kind = "String",
required = false
)]
#[arg(
name = "3",
description = "Query for sound button 3",
kind = "String",
required = false
)]
#[arg(
name = "4",
description = "Query for sound button 4",
kind = "String",
required = false
)]
#[arg(
name = "5",
description = "Query for sound button 5",
kind = "String",
required = false
)]
#[arg(
name = "6",
description = "Query for sound button 6",
kind = "String",
required = false
)]
#[arg(
name = "7",
description = "Query for sound button 7",
kind = "String",
required = false
)]
#[arg(
name = "8",
description = "Query for sound button 8",
kind = "String",
required = false
)]
#[arg(
name = "9",
description = "Query for sound button 9",
kind = "String",
required = false
)]
#[arg(
name = "10",
description = "Query for sound button 10",
kind = "String",
required = false
)]
#[arg(
name = "11",
description = "Query for sound button 11",
kind = "String",
required = false
)]
#[arg(
name = "12",
description = "Query for sound button 12",
kind = "String",
required = false
)]
#[arg(
name = "13",
description = "Query for sound button 13",
kind = "String",
required = false
)]
#[arg(
name = "14",
description = "Query for sound button 14",
kind = "String",
required = false
)]
#[arg(
name = "15",
description = "Query for sound button 15",
kind = "String",
required = false
)]
#[arg(
name = "16",
description = "Query for sound button 16",
kind = "String",
required = false
)]
#[arg(
name = "17",
description = "Query for sound button 17",
kind = "String",
required = false
)]
#[arg(
name = "18",
description = "Query for sound button 18",
kind = "String",
required = false
)]
#[arg(
name = "19",
description = "Query for sound button 19",
kind = "String",
required = false
)]
#[arg(
name = "20",
description = "Query for sound button 20",
kind = "String",
required = false
)]
#[arg(
name = "21",
description = "Query for sound button 21",
kind = "String",
required = false
)]
#[arg(
name = "22",
description = "Query for sound button 22",
kind = "String",
required = false
)]
#[arg(
name = "23",
description = "Query for sound button 23",
kind = "String",
required = false
)]
#[arg(
name = "24",
description = "Query for sound button 24",
kind = "String",
required = false
)]
#[arg(
name = "25",
description = "Query for sound button 25",
kind = "String",
required = false
)]
#[example("`/soundboard ubercharge` - create a soundboard with a button for the \"ubercharge\" sound effect")]
#[example("`/soundboard 57000 24119 2 1002 13202` - create a soundboard with 5 buttons, for sounds with the IDs presented")]
pub async fn soundboard(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
if let Some(interaction) = invoke.interaction() {
let _ = interaction
.create_interaction_response(&ctx, |r| {
r.kind(InteractionResponseType::DeferredChannelMessageWithSource)
})
.await;
}
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let mut sounds = vec![];
for n in 1..25 {
let search = Sound::search_for_sound(
args.named(&n.to_string()).unwrap_or(&"".to_string()),
invoke.guild_id().unwrap(),
invoke.author_id(),
pool.clone(),
true,
)
.await?;
if let Some(sound) = search.first() {
sounds.push(sound.clone());
}
}
invoke
.followup(
ctx.http.clone(),
CreateGenericResponse::new()
.content("**Play a sound:**")
.components(|c| {
for row in sounds.as_slice().chunks(5) {
let mut action_row: CreateActionRow = Default::default();
for sound in row {
action_row.create_button(|b| {
b.style(ButtonStyle::Primary)
.label(&sound.name)
.custom_id(sound.id)
});
}
c.add_action_row(action_row);
}
c
}),
)
.await?;
Ok(())
}

216
src/cmds/search.rs Normal file
View File

@ -0,0 +1,216 @@
use regex_command_attr::command;
use serenity::{client::Context, framework::standard::CommandResult};
use crate::{
framework::{Args, CommandInvoke, CreateGenericResponse},
sound::Sound,
MySQL,
};
fn format_search_results(search_results: Vec<Sound>) -> CreateGenericResponse {
let mut current_character_count = 0;
let title = "Public sounds matching filter:";
let field_iter = search_results
.iter()
.take(25)
.map(|item| {
(
&item.name,
format!("ID: {}\nPlays: {}", item.id, item.plays),
true,
)
})
.filter(|item| {
current_character_count += item.0.len() + item.1.len();
current_character_count <= serenity::constants::MESSAGE_CODE_LIMIT - title.len()
});
CreateGenericResponse::new().embed(|e| e.title(title).fields(field_iter))
}
#[command("list")]
#[group("Search")]
#[description("Show the sounds uploaded by you or to your server")]
#[arg(
name = "me",
description = "Whether to list your sounds or server sounds (default: server)",
kind = "Boolean",
required = false
)]
#[example("`/list` - list sounds uploaded to the server you're in")]
#[example("`/list [me: True]` - list sounds you have uploaded across all servers")]
pub async fn list_sounds(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let sounds;
let mut message_buffer;
if args.named("me").map(|i| i.to_owned()) == Some("me".to_string()) {
sounds = Sound::get_user_sounds(invoke.author_id(), pool).await?;
message_buffer = "All your sounds: ".to_string();
} else {
sounds = Sound::get_guild_sounds(invoke.guild_id().unwrap(), pool).await?;
message_buffer = "All sounds on this server: ".to_string();
}
for sound in sounds {
message_buffer.push_str(
format!(
"**{}** ({}), ",
sound.name,
if sound.public { "🔓" } else { "🔒" }
)
.as_str(),
);
if message_buffer.len() > 2000 {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(message_buffer),
)
.await?;
message_buffer = "".to_string();
}
}
if message_buffer.len() > 0 {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(message_buffer),
)
.await?;
}
Ok(())
}
#[command("search")]
#[group("Search")]
#[description("Search for sounds")]
#[arg(
name = "query",
kind = "String",
description = "Sound name to search for",
required = true
)]
pub async fn search_sounds(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let query = args.named("query").unwrap();
let search_results = Sound::search_for_sound(
query,
invoke.guild_id().unwrap(),
invoke.author_id(),
pool,
false,
)
.await?;
invoke
.respond(ctx.http.clone(), format_search_results(search_results))
.await?;
Ok(())
}
#[command("popular")]
#[group("Search")]
#[description("Show popular sounds")]
pub async fn show_popular_sounds(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
_args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let search_results = sqlx::query_as_unchecked!(
Sound,
"
SELECT name, id, plays, public, server_id, uploader_id
FROM sounds
WHERE public = 1
ORDER BY plays DESC
LIMIT 25
"
)
.fetch_all(&pool)
.await?;
invoke
.respond(ctx.http.clone(), format_search_results(search_results))
.await?;
Ok(())
}
#[command("random")]
#[group("Search")]
#[description("Show a page of random sounds")]
pub async fn show_random_sounds(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
_args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let search_results = sqlx::query_as_unchecked!(
Sound,
"
SELECT name, id, plays, public, server_id, uploader_id
FROM sounds
WHERE public = 1
ORDER BY rand()
LIMIT 25
"
)
.fetch_all(&pool)
.await
.unwrap();
invoke
.respond(ctx.http.clone(), format_search_results(search_results))
.await?;
Ok(())
}

364
src/cmds/settings.rs Normal file
View File

@ -0,0 +1,364 @@
use regex_command_attr::command;
use serenity::{client::Context, framework::standard::CommandResult};
use crate::{
framework::{Args, CommandInvoke, CreateGenericResponse},
guild_data::CtxGuildData,
sound::{JoinSoundCtx, Sound},
MySQL,
};
#[command("volume")]
#[aliases("vol")]
#[required_permissions(Managed)]
#[group("Settings")]
#[description("Change the bot's volume in this server")]
#[arg(
name = "volume",
description = "New volume for the bot to use",
kind = "Integer",
required = false
)]
#[example("`/volume` - check the volume on the current server")]
#[example("`/volume 100` - reset the volume on the current server")]
#[example("`/volume 10` - set the volume on the current server to 10%")]
pub async fn change_volume(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let guild_data_opt = ctx.guild_data(invoke.guild_id().unwrap()).await;
let guild_data = guild_data_opt.unwrap();
if let Some(volume) = args.named("volume").map(|i| i.parse::<u8>().ok()).flatten() {
guild_data.write().await.volume = volume;
guild_data.read().await.commit(pool).await?;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(format!("Volume changed to {}%", volume)),
)
.await?;
} else {
let read = guild_data.read().await;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(format!(
"Current server volume: {vol}%. Change the volume with `/volume <new volume>`",
vol = read.volume
)),
)
.await?;
}
Ok(())
}
#[command("prefix")]
#[required_permissions(Restricted)]
#[kind(Text)]
#[group("Settings")]
#[description("Change the prefix of the bot for using non-slash commands")]
#[arg(
name = "prefix",
kind = "String",
description = "The new prefix to use for the bot",
required = true
)]
pub async fn change_prefix(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let guild_data;
{
let guild_data_opt = ctx.guild_data(invoke.guild_id().unwrap()).await;
guild_data = guild_data_opt.unwrap();
}
if let Some(prefix) = args.named("prefix") {
if prefix.len() <= 5 && !prefix.is_empty() {
let reply = format!("Prefix changed to `{}`", prefix);
{
guild_data.write().await.prefix = prefix.to_string();
}
{
let read = guild_data.read().await;
read.commit(pool).await?;
}
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(reply),
)
.await?;
} else {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new()
.content("Prefix must be less than 5 characters long"),
)
.await?;
}
} else {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(format!(
"Usage: `{prefix}prefix <new prefix>`",
prefix = guild_data.read().await.prefix
)),
)
.await?;
}
Ok(())
}
#[command("roles")]
#[required_permissions(Restricted)]
#[kind(Text)]
#[group("Settings")]
#[description("Change the roles allowed to use the bot")]
#[arg(
name = "roles",
kind = "String",
description = "The role mentions to enlist",
required = true
)]
pub async fn set_allowed_roles(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let msg = invoke.msg().unwrap();
let guild_id = *msg.guild_id.unwrap().as_u64();
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
if args.is_empty() {
let roles = sqlx::query!(
"
SELECT role
FROM roles
WHERE guild_id = ?
",
guild_id
)
.fetch_all(&pool)
.await?;
let all_roles = roles
.iter()
.map(|i| format!("<@&{}>", i.role.to_string()))
.collect::<Vec<String>>()
.join(", ");
msg.channel_id.say(&ctx, format!("Usage: `?roles <role mentions or anything else to disable>`. Current roles: {}", all_roles)).await?;
} else {
sqlx::query!(
"
DELETE FROM roles
WHERE guild_id = ?
",
guild_id
)
.execute(&pool)
.await?;
if msg.mention_roles.len() > 0 {
for role in msg.mention_roles.iter().map(|r| *r.as_u64()) {
sqlx::query!(
"
INSERT INTO roles (guild_id, role)
VALUES
(?, ?)
",
guild_id,
role
)
.execute(&pool)
.await?;
}
msg.channel_id
.say(&ctx, "Specified roles whitelisted")
.await?;
} else {
sqlx::query!(
"
INSERT INTO roles (guild_id, role)
VALUES
(?, ?)
",
guild_id,
guild_id
)
.execute(&pool)
.await?;
msg.channel_id
.say(&ctx, "Role whitelisting disabled")
.await?;
}
}
Ok(())
}
#[command("greet")]
#[group("Settings")]
#[description("Set a join sound")]
#[arg(
name = "query",
kind = "String",
description = "Name or ID of sound to set as your greet sound",
required = false
)]
#[example("`/greet` - remove your join sound")]
#[example("`/greet 1523` - set your join sound to sound with ID 1523")]
pub async fn set_greet_sound(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not get SQLPool from data");
let query = args
.named("query")
.map(|s| s.to_owned())
.unwrap_or(String::new());
let user_id = invoke.author_id();
if query.len() == 0 {
ctx.update_join_sound(user_id, None).await;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content("Your greet sound has been unset."),
)
.await?;
} else {
let sound_vec = Sound::search_for_sound(
&query,
invoke.guild_id().unwrap(),
user_id,
pool.clone(),
true,
)
.await?;
match sound_vec.first() {
Some(sound) => {
ctx.update_join_sound(user_id, Some(sound.id)).await;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(format!(
"Greet sound has been set to {} (ID {})",
sound.name, sound.id
)),
)
.await?;
}
None => {
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new()
.content("Could not find a sound by that name."),
)
.await?;
}
}
}
Ok(())
}
#[command("allow_greet")]
#[group("Settings")]
#[description("Configure whether users should be able to use join sounds")]
#[required_permissions(Restricted)]
#[example("`/allow_greet` - disable greet sounds in the server")]
#[example("`/allow_greet` - re-enable greet sounds in the server")]
pub async fn allow_greet_sounds(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
_args: Args,
) -> CommandResult {
let pool = ctx
.data
.read()
.await
.get::<MySQL>()
.cloned()
.expect("Could not acquire SQL pool from data");
let guild_data_opt = ctx.guild_data(invoke.guild_id().unwrap()).await;
if let Ok(guild_data) = guild_data_opt {
let current = guild_data.read().await.allow_greets;
{
guild_data.write().await.allow_greets = !current;
}
guild_data.read().await.commit(pool).await?;
invoke
.respond(
ctx.http.clone(),
CreateGenericResponse::new().content(format!(
"Greet sounds have been {}abled in this server",
if !current { "en" } else { "dis" }
)),
)
.await?;
}
Ok(())
}

56
src/cmds/stop.rs Normal file
View File

@ -0,0 +1,56 @@
use regex_command_attr::command;
use serenity::{client::Context, framework::standard::CommandResult};
use crate::framework::{Args, CommandInvoke, CreateGenericResponse};
use songbird;
#[command("stop")]
#[required_permissions(Managed)]
#[group("Stop")]
#[description("Stop the bot from playing")]
pub async fn stop_playing(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
_args: Args,
) -> CommandResult {
let guild_id = invoke.guild_id().unwrap();
let songbird = songbird::get(ctx).await.unwrap();
let call_opt = songbird.get(guild_id);
if let Some(call) = call_opt {
let mut lock = call.lock().await;
lock.stop();
}
invoke
.respond(ctx.http.clone(), CreateGenericResponse::new().content("👍"))
.await?;
Ok(())
}
#[command]
#[aliases("dc")]
#[required_permissions(Managed)]
#[group("Stop")]
#[description("Disconnect the bot")]
pub async fn disconnect(
ctx: &Context,
invoke: &(dyn CommandInvoke + Sync + Send),
_args: Args,
) -> CommandResult {
let guild_id = invoke.guild_id().unwrap();
let songbird = songbird::get(ctx).await.unwrap();
let _ = songbird.leave(guild_id).await;
invoke
.respond(ctx.http.clone(), CreateGenericResponse::new().content("👍"))
.await?;
Ok(())
}

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
framework::RegexFramework, framework::RegexFramework,
guild_data::CtxGuildData, guild_data::CtxGuildData,
join_channel, play_audio, join_channel, play_audio, play_from_query,
sound::{JoinSoundCtx, Sound}, sound::{JoinSoundCtx, Sound},
MySQL, ReqwestClient, MySQL, ReqwestClient,
}; };
@ -14,7 +14,7 @@ use serenity::{
gateway::{Activity, Ready}, gateway::{Activity, Ready},
guild::Guild, guild::Guild,
id::GuildId, id::GuildId,
interactions::Interaction, interactions::{Interaction, InteractionResponseType},
voice::VoiceState, voice::VoiceState,
}, },
utils::shard_id, utils::shard_id,
@ -22,6 +22,8 @@ use serenity::{
use songbird::{Event, EventContext, EventHandler as SongbirdEventHandler}; use songbird::{Event, EventContext, EventHandler as SongbirdEventHandler};
use crate::framework::Args;
use std::{collections::HashMap, env}; use std::{collections::HashMap, env};
pub struct RestartTrack; pub struct RestartTrack;
@ -60,13 +62,12 @@ impl EventHandler for Handler {
async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) { async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) {
if is_new { if is_new {
if let Ok(token) = env::var("DISCORDBOTS_TOKEN") { if let Ok(token) = env::var("DISCORDBOTS_TOKEN") {
let shard_count = ctx.cache.shard_count().await; let shard_count = ctx.cache.shard_count();
let current_shard_id = shard_id(guild.id.as_u64().to_owned(), shard_count); let current_shard_id = shard_id(guild.id.as_u64().to_owned(), shard_count);
let guild_count = ctx let guild_count = ctx
.cache .cache
.guilds() .guilds()
.await
.iter() .iter()
.filter(|g| shard_id(g.as_u64().to_owned(), shard_count) == current_shard_id) .filter(|g| shard_id(g.as_u64().to_owned(), shard_count) == current_shard_id)
.count() as u64; .count() as u64;
@ -88,7 +89,7 @@ impl EventHandler for Handler {
.post( .post(
format!( format!(
"https://top.gg/api/bots/{}/stats", "https://top.gg/api/bots/{}/stats",
ctx.cache.current_user_id().await.as_u64() ctx.cache.current_user_id().as_u64()
) )
.as_str(), .as_str(),
) )
@ -114,8 +115,7 @@ impl EventHandler for Handler {
if let Some(past_state) = old { if let Some(past_state) = old {
if let (Some(guild_id), None) = (guild_id_opt, new.channel_id) { if let (Some(guild_id), None) = (guild_id_opt, new.channel_id) {
if let Some(channel_id) = past_state.channel_id { if let Some(channel_id) = past_state.channel_id {
if let Some(Channel::Guild(channel)) = channel_id.to_channel_cached(&ctx).await if let Some(Channel::Guild(channel)) = channel_id.to_channel_cached(&ctx) {
{
if channel.members(&ctx).await.map(|m| m.len()).unwrap_or(0) <= 1 { if channel.members(&ctx).await.map(|m| m.len()).unwrap_or(0) <= 1 {
let songbird = songbird::get(&ctx).await.unwrap(); let songbird = songbird::get(&ctx).await.unwrap();
@ -125,7 +125,7 @@ impl EventHandler for Handler {
} }
} }
} else if let (Some(guild_id), Some(user_channel)) = (guild_id_opt, new.channel_id) { } else if let (Some(guild_id), Some(user_channel)) = (guild_id_opt, new.channel_id) {
if let Some(guild) = ctx.cache.guild(guild_id).await { if let Some(guild) = ctx.cache.guild(guild_id) {
let pool = ctx let pool = ctx
.data .data
.read() .read()
@ -180,6 +180,12 @@ SELECT name, id, plays, public, server_id, uploader_id
} }
async fn interaction_create(&self, ctx: Context, interaction: Interaction) { async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
match interaction {
Interaction::ApplicationCommand(application_command) => {
if application_command.guild_id.is_none() {
return;
}
let framework = ctx let framework = ctx
.data .data
.read() .read()
@ -188,6 +194,36 @@ SELECT name, id, plays, public, server_id, uploader_id
.cloned() .cloned()
.expect("RegexFramework not found in context"); .expect("RegexFramework not found in context");
framework.execute(ctx, interaction).await; framework.execute(ctx, application_command).await;
}
Interaction::MessageComponent(component) => {
if component.guild_id.is_none() {
return;
}
let mut args = Args {
args: Default::default(),
};
args.args
.insert("query".to_string(), component.data.custom_id.clone());
play_from_query(
&ctx,
component.guild_id.unwrap().to_guild_cached(&ctx).unwrap(),
component.user.id,
args,
false,
)
.await;
component
.create_interaction_response(ctx, |r| {
r.kind(InteractionResponseType::DeferredUpdateMessage)
})
.await
.unwrap();
}
_ => {}
}
} }
} }

View File

@ -10,14 +10,18 @@ use serenity::{
channel::{Channel, GuildChannel, Message}, channel::{Channel, GuildChannel, Message},
guild::{Guild, Member}, guild::{Guild, Member},
id::{ChannelId, GuildId, UserId}, id::{ChannelId, GuildId, UserId},
interactions::{ApplicationCommand, Interaction, InteractionType}, interactions::{
prelude::{ApplicationCommandOptionType, InteractionResponseType}, application_command::{
ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType,
},
InteractionResponseType,
},
}, },
prelude::TypeMapKey, prelude::TypeMapKey,
Result as SerenityResult, Result as SerenityResult,
}; };
use log::{error, info, warn}; use log::{debug, error, info, warn};
use regex::{Match, Regex, RegexBuilder}; use regex::{Match, Regex, RegexBuilder};
@ -30,6 +34,7 @@ use std::{
use crate::{guild_data::CtxGuildData, MySQL}; use crate::{guild_data::CtxGuildData, MySQL};
use serde_json::Value; use serde_json::Value;
use serenity::builder::CreateComponents;
type CommandFn = for<'fut> fn( type CommandFn = for<'fut> fn(
&'fut Context, &'fut Context,
@ -38,7 +43,7 @@ type CommandFn = for<'fut> fn(
) -> BoxFuture<'fut, CommandResult>; ) -> BoxFuture<'fut, CommandResult>;
pub struct Args { pub struct Args {
args: HashMap<String, String>, pub args: HashMap<String, String>,
} }
impl Args { impl Args {
@ -69,10 +74,6 @@ impl Args {
Self { args } Self { args }
} }
pub fn len(&self) -> usize {
self.args.len()
}
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.args.is_empty() self.args.is_empty()
} }
@ -87,6 +88,7 @@ impl Args {
pub struct CreateGenericResponse { pub struct CreateGenericResponse {
content: String, content: String,
embed: Option<CreateEmbed>, embed: Option<CreateEmbed>,
components: Option<CreateComponents>,
} }
impl CreateGenericResponse { impl CreateGenericResponse {
@ -94,6 +96,7 @@ impl CreateGenericResponse {
Self { Self {
content: "".to_string(), content: "".to_string(),
embed: None, embed: None,
components: None,
} }
} }
@ -105,11 +108,20 @@ impl CreateGenericResponse {
pub fn embed<F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed>(mut self, f: F) -> Self { pub fn embed<F: FnOnce(&mut CreateEmbed) -> &mut CreateEmbed>(mut self, f: F) -> Self {
let mut embed = CreateEmbed::default(); let mut embed = CreateEmbed::default();
f(&mut embed); f(&mut embed);
self.embed = Some(embed); self.embed = Some(embed);
self
}
pub fn components<F: FnOnce(&mut CreateComponents) -> &mut CreateComponents>(
mut self,
f: F,
) -> Self {
let mut components = CreateComponents::default();
f(&mut components);
self.components = Some(components);
self self
} }
} }
@ -118,11 +130,11 @@ impl CreateGenericResponse {
pub trait CommandInvoke { pub trait CommandInvoke {
fn channel_id(&self) -> ChannelId; fn channel_id(&self) -> ChannelId;
fn guild_id(&self) -> Option<GuildId>; fn guild_id(&self) -> Option<GuildId>;
async fn guild(&self, cache: Arc<Cache>) -> Option<Guild>; fn guild(&self, cache: Arc<Cache>) -> Option<Guild>;
fn author_id(&self) -> UserId; fn author_id(&self) -> UserId;
async fn member(&self, context: &Context) -> SerenityResult<Member>; async fn member(&self, context: &Context) -> SerenityResult<Member>;
fn msg(&self) -> Option<Message>; fn msg(&self) -> Option<Message>;
fn interaction(&self) -> Option<Interaction>; fn interaction(&self) -> Option<ApplicationCommandInteraction>;
async fn respond( async fn respond(
&self, &self,
http: Arc<Http>, http: Arc<Http>,
@ -145,8 +157,8 @@ impl CommandInvoke for Message {
self.guild_id self.guild_id
} }
async fn guild(&self, cache: Arc<Cache>) -> Option<Guild> { fn guild(&self, cache: Arc<Cache>) -> Option<Guild> {
self.guild(cache).await self.guild(cache)
} }
fn author_id(&self) -> UserId { fn author_id(&self) -> UserId {
@ -161,7 +173,7 @@ impl CommandInvoke for Message {
Some(self.clone()) Some(self.clone())
} }
fn interaction(&self) -> Option<Interaction> { fn interaction(&self) -> Option<ApplicationCommandInteraction> {
None None
} }
@ -178,6 +190,13 @@ impl CommandInvoke for Message {
m.set_embed(embed.clone()); m.set_embed(embed.clone());
} }
if let Some(components) = generic_response.components {
m.components(|c| {
*c = components;
c
});
}
m m
}) })
.await .await
@ -197,6 +216,13 @@ impl CommandInvoke for Message {
m.set_embed(embed.clone()); m.set_embed(embed.clone());
} }
if let Some(components) = generic_response.components {
m.components(|c| {
*c = components;
c
});
}
m m
}) })
.await .await
@ -205,18 +231,18 @@ impl CommandInvoke for Message {
} }
#[async_trait] #[async_trait]
impl CommandInvoke for Interaction { impl CommandInvoke for ApplicationCommandInteraction {
fn channel_id(&self) -> ChannelId { fn channel_id(&self) -> ChannelId {
self.channel_id.unwrap() self.channel_id
} }
fn guild_id(&self) -> Option<GuildId> { fn guild_id(&self) -> Option<GuildId> {
self.guild_id self.guild_id
} }
async fn guild(&self, cache: Arc<Cache>) -> Option<Guild> { fn guild(&self, cache: Arc<Cache>) -> Option<Guild> {
if let Some(guild_id) = self.guild_id { if let Some(guild_id) = self.guild_id {
guild_id.to_guild_cached(cache).await guild_id.to_guild_cached(cache)
} else { } else {
None None
} }
@ -234,7 +260,7 @@ impl CommandInvoke for Interaction {
None None
} }
fn interaction(&self) -> Option<Interaction> { fn interaction(&self) -> Option<ApplicationCommandInteraction> {
Some(self.clone()) Some(self.clone())
} }
@ -249,7 +275,14 @@ impl CommandInvoke for Interaction {
d.content(generic_response.content); d.content(generic_response.content);
if let Some(embed) = generic_response.embed { if let Some(embed) = generic_response.embed {
d.set_embed(embed.clone()); d.add_embed(embed.clone());
}
if let Some(components) = generic_response.components {
d.components(|c| {
*c = components;
c
});
} }
d d
@ -268,7 +301,14 @@ impl CommandInvoke for Interaction {
d.content(generic_response.content); d.content(generic_response.content);
if let Some(embed) = generic_response.embed { if let Some(embed) = generic_response.embed {
d.set_embed(embed.clone()); d.add_embed(embed.clone());
}
if let Some(components) = generic_response.components {
d.components(|c| {
*c = components;
c
});
} }
d d
@ -285,6 +325,13 @@ pub enum PermissionLevel {
Restricted, Restricted,
} }
#[derive(Debug, PartialEq)]
pub enum CommandKind {
Slash,
Both,
Text,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Arg { pub struct Arg {
pub name: &'static str, pub name: &'static str,
@ -296,7 +343,7 @@ pub struct Arg {
impl Arg { impl Arg {
pub fn to_regex(&self) -> String { pub fn to_regex(&self) -> String {
match self.kind { match self.kind {
ApplicationCommandOptionType::String => format!(r#"(?P<{}>.*?)"#, self.name), ApplicationCommandOptionType::String => format!(r#"(?P<{}>.+?)"#, self.name),
ApplicationCommandOptionType::Integer => format!(r#"(?P<{}>\d+)"#, self.name), ApplicationCommandOptionType::Integer => format!(r#"(?P<{}>\d+)"#, self.name),
ApplicationCommandOptionType::Boolean => format!(r#"(?P<{0}>{0})?"#, self.name), ApplicationCommandOptionType::Boolean => format!(r#"(?P<{0}>{0})?"#, self.name),
ApplicationCommandOptionType::User => format!(r#"<(@|@!)(?P<{}>\d+)>"#, self.name), ApplicationCommandOptionType::User => format!(r#"<(@|@!)(?P<{}>\d+)>"#, self.name),
@ -312,12 +359,15 @@ impl Arg {
pub struct Command { pub struct Command {
pub fun: CommandFn, pub fun: CommandFn,
pub names: &'static [&'static str], pub names: &'static [&'static str],
pub desc: &'static str, pub desc: &'static str,
pub usage: Option<&'static str>,
pub examples: &'static [&'static str], pub examples: &'static [&'static str],
pub group: &'static str,
pub kind: CommandKind,
pub required_permissions: PermissionLevel, pub required_permissions: PermissionLevel,
pub allow_slash: bool,
pub args: &'static [&'static Arg], pub args: &'static [&'static Arg],
} }
@ -408,8 +458,8 @@ impl fmt::Debug for Command {
} }
pub struct RegexFramework { pub struct RegexFramework {
commands: HashMap<String, &'static Command>, pub commands: HashMap<String, &'static Command>,
commands_: HashSet<&'static Command>, pub commands_: HashSet<&'static Command>,
command_matcher: Regex, command_matcher: Regex,
default_prefix: String, default_prefix: String,
client_id: u64, client_id: u64,
@ -453,8 +503,6 @@ impl RegexFramework {
} }
pub fn add_command(mut self, command: &'static Command) -> Self { pub fn add_command(mut self, command: &'static Command) -> Self {
info!("{:?}", command);
self.commands_.insert(command); self.commands_.insert(command);
for name in command.names { for name in command.names {
@ -475,7 +523,7 @@ impl RegexFramework {
command_names = command_names_vec.join("|"); command_names = command_names_vec.join("|");
} }
info!("Command names: {}", command_names); debug!("Command names: {}", command_names);
{ {
let match_string = r#"^(?:(?:<@ID>\s*)|(?:<@!ID>\s*)|(?P<prefix>\S{1,5}?))(?P<cmd>COMMANDS)(?:$|\s+(?P<args>.*))$"# let match_string = r#"^(?:(?:<@ID>\s*)|(?:<@!ID>\s*)|(?P<prefix>\S{1,5}?))(?P<cmd>COMMANDS)(?:$|\s+(?P<args>.*))$"#
@ -503,7 +551,11 @@ impl RegexFramework {
.flatten() .flatten()
.map(|v| GuildId(v)) .map(|v| GuildId(v))
{ {
for command in self.commands_.iter().filter(|c| c.allow_slash) { for command in self
.commands_
.iter()
.filter(|c| c.kind != CommandKind::Text)
{
guild_id guild_id
.create_application_command(&http, |a| { .create_application_command(&http, |a| {
a.name(command.names[0]).description(command.desc); a.name(command.names[0]).description(command.desc);
@ -534,7 +586,7 @@ impl RegexFramework {
.await .await
.expect("Failed to fetch existing commands"); .expect("Failed to fetch existing commands");
info!("Existing commands: {:?}", current_commands); debug!("Existing commands: {:?}", current_commands);
// delete commands not in use // delete commands not in use
for command in &current_commands { for command in &current_commands {
@ -552,7 +604,11 @@ impl RegexFramework {
} }
} }
for command in self.commands_.iter().filter(|c| c.allow_slash) { for command in self
.commands_
.iter()
.filter(|c| c.kind != CommandKind::Text)
{
let already_created = if let Some(current_command) = current_commands let already_created = if let Some(current_command) = current_commands
.iter() .iter()
.find(|curr| curr.name == command.names[0]) .find(|curr| curr.name == command.names[0])
@ -612,29 +668,30 @@ impl RegexFramework {
info!("{} slash commands built! Ready to go", count); info!("{} slash commands built! Ready to go", count);
} }
pub async fn execute(&self, ctx: Context, interaction: Interaction) { pub async fn execute(&self, ctx: Context, interaction: ApplicationCommandInteraction) {
if interaction.kind == InteractionType::ApplicationCommand && interaction.guild_id.is_some()
{
if let Some(data) = interaction.data.clone() {
let command = { let command = {
let name = data.name; self.commands.get(&interaction.data.name).expect(&format!(
"Received invalid command: {}",
self.commands interaction.data.name
.get(&name) ))
.expect(&format!("Received invalid command: {}", name))
}; };
if command if command
.check_permissions( .check_permissions(
&ctx, &ctx,
&interaction.guild(ctx.cache.clone()).await.unwrap(), &interaction.guild(ctx.cache.clone()).unwrap(),
&interaction.member(&ctx).await.unwrap(), &interaction.clone().member.unwrap(),
) )
.await .await
{ {
let mut args = HashMap::new(); let mut args = HashMap::new();
for arg in data.options.iter().filter(|o| o.value.is_some()) { for arg in interaction
.data
.options
.iter()
.filter(|o| o.value.is_some())
{
args.insert( args.insert(
arg.name.clone(), arg.name.clone(),
match arg.value.clone().unwrap() { match arg.value.clone().unwrap() {
@ -666,15 +723,12 @@ impl RegexFramework {
let _ = interaction let _ = interaction
.respond( .respond(
ctx.http.clone(), ctx.http.clone(),
CreateGenericResponse::new() CreateGenericResponse::new().content("You must be an Admin to do this command"),
.content("You must be an Admin to do this command"),
) )
.await; .await;
} }
} }
} }
}
}
enum PermissionCheck { enum PermissionCheck {
None, // No permissions None, // No permissions
@ -688,9 +742,9 @@ impl Framework for RegexFramework {
ctx: &Context, ctx: &Context,
channel: &GuildChannel, channel: &GuildChannel,
) -> SerenityResult<PermissionCheck> { ) -> SerenityResult<PermissionCheck> {
let user_id = ctx.cache.current_user_id().await; let user_id = ctx.cache.current_user_id();
let channel_perms = channel.permissions_for_user(ctx, user_id).await?; let channel_perms = channel.permissions_for_user(ctx, user_id)?;
Ok( Ok(
if channel_perms.send_messages() && channel_perms.embed_links() { if channel_perms.send_messages() && channel_perms.embed_links() {
@ -717,8 +771,8 @@ impl Framework for RegexFramework {
if msg.author.bot || msg.content.is_empty() { if msg.author.bot || msg.content.is_empty() {
} }
// Guild Command // Guild Command
else if let (Some(guild), Some(Channel::Guild(channel))) = else if let (Some(guild), Ok(Channel::Guild(channel))) =
(msg.guild(&ctx).await, msg.channel(&ctx).await) (msg.guild(&ctx), msg.channel(&ctx).await)
{ {
if let Some(full_match) = self.command_matcher.captures(&msg.content) { if let Some(full_match) = self.command_matcher.captures(&msg.content) {
if check_prefix(&ctx, &guild, full_match.name("prefix")).await { if check_prefix(&ctx, &guild, full_match.name("prefix")).await {
@ -730,6 +784,7 @@ impl Framework for RegexFramework {
.get(&full_match.name("cmd").unwrap().as_str().to_lowercase()) .get(&full_match.name("cmd").unwrap().as_str().to_lowercase())
.unwrap(); .unwrap();
if command.kind != CommandKind::Slash {
let args = full_match let args = full_match
.name("args") .name("args")
.map(|m| m.as_str()) .map(|m| m.as_str())
@ -742,7 +797,9 @@ impl Framework for RegexFramework {
(command.fun)(&ctx, &msg, Args::from(&args, command.args)) (command.fun)(&ctx, &msg, Args::from(&args, command.args))
.await .await
.unwrap(); .unwrap();
} else if command.required_permissions == PermissionLevel::Managed { } else if command.required_permissions
== PermissionLevel::Managed
{
let _ = msg.channel_id.say(&ctx, "You must either be an Admin or have a role specified in `?roles` to do this command").await; let _ = msg.channel_id.say(&ctx, "You must either be an Admin or have a role specified in `?roles` to do this command").await;
} else if command.required_permissions } else if command.required_permissions
== PermissionLevel::Restricted == PermissionLevel::Restricted
@ -753,6 +810,7 @@ impl Framework for RegexFramework {
.await; .await;
} }
} }
}
PermissionCheck::None => { PermissionCheck::None => {
warn!("Missing enough permissions for guild {}", guild.id); warn!("Missing enough permissions for guild {}", guild.id);

File diff suppressed because it is too large Load Diff

View File

@ -111,6 +111,7 @@ WHERE
} }
} }
#[derive(Clone)]
pub struct Sound { pub struct Sound {
pub name: String, pub name: String,
pub id: u32, pub id: u32,