diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml
index ea20568..355980b 100644
--- a/.idea/sqldialects.xml
+++ b/.idea/sqldialects.xml
@@ -1,7 +1,7 @@
-
+
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index ad59cf8..f9baebc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aead"
-version = "0.4.2"
+version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e3e798aa0c8239776f54415bc06f3d74b1850f3f830b45c35cfc80556973f70"
+checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877"
dependencies = [
"generic-array",
"rand_core",
@@ -47,12 +47,6 @@ dependencies = [
"nodrop",
]
-[[package]]
-name = "arrayvec"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
-
[[package]]
name = "async-trait"
version = "0.1.51"
@@ -80,6 +74,22 @@ dependencies = [
"webpki-roots",
]
+[[package]]
+name = "async-tungstenite"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8645e929ec7964448a901db9da30cd2ae8c7fecf4d6176af427837531dbbb63b"
+dependencies = [
+ "futures-io",
+ "futures-util",
+ "log",
+ "pin-project-lite",
+ "tokio",
+ "tokio-rustls",
+ "tungstenite",
+ "webpki-roots",
+]
+
[[package]]
name = "atoi"
version = "0.4.0"
@@ -139,32 +149,20 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bigdecimal"
-version = "0.2.0"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc403c26e6b03005522e6e8053384c4e881dfe5b2bf041c0c2c49be33d64a539"
+checksum = "d1e50562e37200edf7c6c43e54a08e64a5553bfb59d9c297d5572512aa517256"
dependencies = [
- "num-bigint 0.3.2",
+ "num-bigint 0.3.3",
"num-integer",
"num-traits 0.2.14",
]
[[package]]
name = "bitflags"
-version = "1.3.1"
+version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1"
-
-[[package]]
-name = "bitvec"
-version = "0.19.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321"
-dependencies = [
- "funty",
- "radium",
- "tap",
- "wyz",
-]
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
@@ -189,15 +187,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
-version = "1.0.1"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
+checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cc"
-version = "1.0.69"
+version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
+checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0"
[[package]]
name = "cfg-if"
@@ -237,7 +235,7 @@ dependencies = [
[[package]]
name = "command_attr"
version = "0.3.7"
-source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
+source = "git+https://github.com/serenity-rs/serenity?branch=next#723749c43182838925dd89ac90b93dd2a837261d"
dependencies = [
"proc-macro2",
"quote",
@@ -262,9 +260,9 @@ checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
[[package]]
name = "cpufeatures"
-version = "0.1.5"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef"
+checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469"
dependencies = [
"libc",
]
@@ -285,7 +283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
dependencies = [
"cfg-if 1.0.0",
- "crossbeam-utils 0.8.5",
+ "crossbeam-utils",
]
[[package]]
@@ -295,17 +293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9"
dependencies = [
"cfg-if 1.0.0",
- "crossbeam-utils 0.8.5",
-]
-
-[[package]]
-name = "crossbeam-utils"
-version = "0.7.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
-dependencies = [
- "autocfg 1.0.1",
- "cfg-if 0.1.10",
+ "crossbeam-utils",
]
[[package]]
@@ -393,9 +381,9 @@ dependencies = [
[[package]]
name = "flate2"
-version = "1.0.20"
+version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0"
+checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
dependencies = [
"cfg-if 1.0.0",
"crc32fast",
@@ -405,15 +393,15 @@ dependencies = [
[[package]]
name = "flume"
-version = "0.10.8"
+version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e90cc80fad5bb391b38127896b0fa27d97e7fef74742797f4da518d67e1292f"
+checksum = "24c3fd473b3a903a62609e413ed7538f99e10b665ecb502b5e481a95283f8ab4"
dependencies = [
"futures-core",
"futures-sink",
"nanorand",
"pin-project",
- "spinning_top",
+ "spin 0.9.2",
]
[[package]]
@@ -447,17 +435,11 @@ dependencies = [
"percent-encoding",
]
-[[package]]
-name = "funty"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
-
[[package]]
name = "futures"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b"
+checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca"
dependencies = [
"futures-channel",
"futures-core",
@@ -470,9 +452,9 @@ dependencies = [
[[package]]
name = "futures-channel"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9"
+checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888"
dependencies = [
"futures-core",
"futures-sink",
@@ -480,15 +462,15 @@ dependencies = [
[[package]]
name = "futures-core"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99"
+checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d"
[[package]]
name = "futures-executor"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c"
+checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c"
dependencies = [
"futures-core",
"futures-task",
@@ -496,16 +478,27 @@ dependencies = [
]
[[package]]
-name = "futures-io"
-version = "0.3.16"
+name = "futures-intrusive"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582"
+checksum = "62007592ac46aa7c2b6416f7deb9a8a8f63a01e0f1d6e1787d5630170db2b63e"
+dependencies = [
+ "futures-core",
+ "lock_api",
+ "parking_lot",
+]
+
+[[package]]
+name = "futures-io"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377"
[[package]]
name = "futures-macro"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57"
+checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
dependencies = [
"autocfg 1.0.1",
"proc-macro-hack",
@@ -516,21 +509,21 @@ dependencies = [
[[package]]
name = "futures-sink"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53"
+checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11"
[[package]]
name = "futures-task"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2"
+checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99"
[[package]]
name = "futures-util"
-version = "0.3.16"
+version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78"
+checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481"
dependencies = [
"autocfg 1.0.1",
"futures-channel",
@@ -585,9 +578,9 @@ dependencies = [
[[package]]
name = "h2"
-version = "0.3.3"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726"
+checksum = "d7f3675cfef6a30c8031cf9e6493ebdc3bb3272a3fea3923c4210d1830e6a472"
dependencies = [
"bytes",
"fnv",
@@ -668,9 +661,9 @@ dependencies = [
[[package]]
name = "httparse"
-version = "1.4.1"
+version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68"
+checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503"
[[package]]
name = "httpdate"
@@ -686,9 +679,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "hyper"
-version = "0.14.11"
+version = "0.14.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b61cf2d1aebcf6e6352c97b81dc2244ca29194be1b276f5d8ad5c6330fffb11"
+checksum = "15d1cfb9e4f68655fa04c01f59edb405b6074a0f7118ea881e5026e4a1cd8593"
dependencies = [
"bytes",
"futures-channel",
@@ -782,16 +775,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"
[[package]]
-name = "itoa"
-version = "0.4.7"
+name = "itertools"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
+checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "js-sys"
-version = "0.3.52"
+version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce791b7ca6638aae45be056e068fc756d871eb3b3b10b8efa62d1c9cec616752"
+checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84"
dependencies = [
"wasm-bindgen",
]
@@ -802,27 +804,14 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
dependencies = [
- "spin",
-]
-
-[[package]]
-name = "lexical-core"
-version = "0.7.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
-dependencies = [
- "arrayvec 0.5.2",
- "bitflags",
- "cfg-if 1.0.0",
- "ryu",
- "static_assertions",
+ "spin 0.5.2",
]
[[package]]
name = "libc"
-version = "0.2.99"
+version = "0.2.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765"
+checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"
[[package]]
name = "libm"
@@ -832,9 +821,9 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
[[package]]
name = "lock_api"
-version = "0.4.4"
+version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
+checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
dependencies = [
"scopeguard",
]
@@ -861,12 +850,6 @@ dependencies = [
"serde_json",
]
-[[package]]
-name = "maplit"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
-
[[package]]
name = "matches"
version = "0.1.9"
@@ -875,9 +858,9 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "memchr"
-version = "2.4.0"
+version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
+checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "mime"
@@ -895,6 +878,12 @@ dependencies = [
"unicase",
]
+[[package]]
+name = "minimal-lexical"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c835948974f68e0bd58636fc6c5b1fbff7b297e3046f11b3b3c18bbac012c6d"
+
[[package]]
name = "miniz_oxide"
version = "0.4.4"
@@ -962,14 +951,12 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "nom"
-version = "6.1.2"
+version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2"
+checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1"
dependencies = [
- "bitvec",
- "funty",
- "lexical-core",
"memchr",
+ "minimal-lexical",
"version_check",
]
@@ -984,9 +971,9 @@ dependencies = [
[[package]]
name = "num-bigint"
-version = "0.3.2"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d0a3d5e207573f948a9e5376662aa743a2ea13f7c50a554d7af443a73fbfeba"
+checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3"
dependencies = [
"autocfg 1.0.1",
"num-integer",
@@ -995,9 +982,9 @@ dependencies = [
[[package]]
name = "num-bigint"
-version = "0.4.0"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512"
+checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535"
dependencies = [
"autocfg 1.0.1",
"num-integer",
@@ -1086,9 +1073,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
-version = "0.10.35"
+version = "0.10.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885"
+checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
@@ -1106,9 +1093,9 @@ checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a"
[[package]]
name = "openssl-sys"
-version = "0.9.65"
+version = "0.9.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d"
+checksum = "1996d2d305e561b70d1ee0c53f1542833f4e1ac6ce9a6708b6ff2738ca67dc82"
dependencies = [
"autocfg 1.0.1",
"cc",
@@ -1119,9 +1106,9 @@ dependencies = [
[[package]]
name = "parking_lot"
-version = "0.11.1"
+version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
+checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [
"instant",
"lock_api",
@@ -1130,9 +1117,9 @@ dependencies = [
[[package]]
name = "parking_lot_core"
-version = "0.8.3"
+version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
+checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [
"cfg-if 1.0.0",
"instant",
@@ -1226,9 +1213,9 @@ dependencies = [
[[package]]
name = "poly1305"
-version = "0.7.1"
+version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9fcffab1f78ebbdf4b93b68c1ffebc24037eedf271edaca795732b24e5e4e349"
+checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede"
dependencies = [
"cpufeatures",
"opaque-debug",
@@ -1255,9 +1242,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]]
name = "proc-macro2"
-version = "1.0.28"
+version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"
+checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
dependencies = [
"unicode-xid",
]
@@ -1271,12 +1258,6 @@ dependencies = [
"proc-macro2",
]
-[[package]]
-name = "radium"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
-
[[package]]
name = "rand"
version = "0.8.4"
@@ -1410,7 +1391,7 @@ dependencies = [
"cc",
"libc",
"once_cell",
- "spin",
+ "spin 0.5.2",
"untrusted",
"web-sys",
"winapi",
@@ -1505,9 +1486,9 @@ dependencies = [
[[package]]
name = "security-framework"
-version = "2.3.1"
+version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467"
+checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87"
dependencies = [
"bitflags",
"core-foundation",
@@ -1518,9 +1499,9 @@ dependencies = [
[[package]]
name = "security-framework-sys"
-version = "2.3.0"
+version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284"
+checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e"
dependencies = [
"core-foundation-sys",
"libc",
@@ -1528,18 +1509,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.127"
+version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8"
+checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.127"
+version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc"
+checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [
"proc-macro2",
"quote",
@@ -1548,9 +1529,9 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.66"
+version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127"
+checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
dependencies = [
"itoa",
"ryu",
@@ -1582,11 +1563,11 @@ dependencies = [
[[package]]
name = "serenity"
-version = "0.10.8"
-source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
+version = "0.10.9"
+source = "git+https://github.com/serenity-rs/serenity?branch=next#723749c43182838925dd89ac90b93dd2a837261d"
dependencies = [
"async-trait",
- "async-tungstenite",
+ "async-tungstenite 0.13.1",
"base64",
"bitflags",
"bytes",
@@ -1613,7 +1594,7 @@ dependencies = [
[[package]]
name = "serenity-voice-model"
version = "0.1.0"
-source = "git+https://github.com/serenity-rs/serenity?branch=next#4d431726f4eb2f29a040b83fb4a18a459427c1b2"
+source = "git+https://github.com/serenity-rs/serenity?branch=next#723749c43182838925dd89ac90b93dd2a837261d"
dependencies = [
"bitflags",
"enum_primitive",
@@ -1624,9 +1605,9 @@ dependencies = [
[[package]]
name = "sha-1"
-version = "0.9.7"
+version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81"
+checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
dependencies = [
"block-buffer",
"cfg-if 1.0.0",
@@ -1637,9 +1618,9 @@ dependencies = [
[[package]]
name = "sha2"
-version = "0.9.5"
+version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12"
+checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa"
dependencies = [
"block-buffer",
"cfg-if 1.0.0",
@@ -1664,7 +1645,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eb4ea60fb301dc81dfc113df680571045d375ab7345d171c5dc7d7e13107a80"
dependencies = [
"chrono",
- "num-bigint 0.4.0",
+ "num-bigint 0.4.2",
"num-traits 0.2.14",
"thiserror",
]
@@ -1683,9 +1664,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "socket2"
-version = "0.4.1"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad"
+checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516"
dependencies = [
"libc",
"winapi",
@@ -1693,11 +1674,11 @@ dependencies = [
[[package]]
name = "songbird"
-version = "0.2.0-beta.4"
-source = "git+https://github.com/serenity-rs/songbird?branch=next#2a2543ebc830ba442bcd836733d52114fd1b3f8a"
+version = "0.2.0"
+source = "git+https://github.com/serenity-rs/songbird?branch=next#a953430810cc3f08d609ad6f76f7708f457703fc"
dependencies = [
"async-trait",
- "async-tungstenite",
+ "async-tungstenite 0.14.0",
"audiopus",
"byteorder",
"dashmap",
@@ -1725,7 +1706,7 @@ dependencies = [
[[package]]
name = "soundfx-rs"
-version = "1.4.0"
+version = "1.4.3"
dependencies = [
"dashmap",
"dotenv",
@@ -1748,6 +1729,15 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
+[[package]]
+name = "spin"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5"
+dependencies = [
+ "lock_api",
+]
+
[[package]]
name = "spin_sleep"
version = "1.0.0"
@@ -1758,33 +1748,22 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "spinning_top"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75adad84ee84b521fb2cca2d4fd0f1dab1d8d026bda3c5bea4ca63b5f9f9293c"
-dependencies = [
- "lock_api",
-]
-
[[package]]
name = "sqlformat"
-version = "0.1.6"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d86e3c77ff882a828346ba401a7ef4b8e440df804491c6064fe8295765de71c"
+checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4"
dependencies = [
- "lazy_static",
- "maplit",
+ "itertools",
"nom",
- "regex",
"unicode_categories",
]
[[package]]
name = "sqlx"
-version = "0.5.5"
+version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba82f79b31f30acebf19905bcd8b978f46891b9d0723f578447361a8910b6584"
+checksum = "0e4b94ab0f8c21ee4899b93b06451ef5d965f1a355982ee73684338228498440"
dependencies = [
"sqlx-core",
"sqlx-macros",
@@ -1792,9 +1771,9 @@ dependencies = [
[[package]]
name = "sqlx-core"
-version = "0.5.5"
+version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f23af36748ec8ea8d49ef8499839907be41b0b1178a4e82b8cb45d29f531dc9"
+checksum = "ec28b91a01e1fe286d6ba66f68289a2286df023fc97444e1fd86c2fd6d5dc026"
dependencies = [
"ahash",
"atoi",
@@ -1805,11 +1784,12 @@ dependencies = [
"bytes",
"crossbeam-channel",
"crossbeam-queue",
- "crossbeam-utils 0.8.5",
+ "crossbeam-utils",
"digest",
"either",
"futures-channel",
"futures-core",
+ "futures-intrusive",
"futures-util",
"generic-array",
"hashlink",
@@ -1818,7 +1798,7 @@ dependencies = [
"libc",
"log",
"memchr",
- "num-bigint 0.3.2",
+ "num-bigint 0.3.3",
"once_cell",
"parking_lot",
"percent-encoding",
@@ -1841,9 +1821,9 @@ dependencies = [
[[package]]
name = "sqlx-macros"
-version = "0.5.5"
+version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "47e4a2349d1ffd60a03ca0de3f116ba55d7f406e55a0d84c64a5590866d94c06"
+checksum = "4dc33c35d54774eed73d54568d47a6ac099aed8af5e1556a017c131be88217d5"
dependencies = [
"dotenv",
"either",
@@ -1860,9 +1840,9 @@ dependencies = [
[[package]]
name = "sqlx-rt"
-version = "0.5.5"
+version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057"
+checksum = "14302b678d9c76b28f2e60115211e25e0aabc938269991745a169753dc00e35c"
dependencies = [
"once_cell",
"tokio",
@@ -1877,11 +1857,11 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "streamcatcher"
-version = "0.1.0"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa50ae63198c9af3ffb3a1fa8877d54bb1a569a2a61cb519097c7989f1a151ff"
+checksum = "9501b1be04455a53f782940f7ca17050482de0a6e322c1ff606afc0ebbc62674"
dependencies = [
- "crossbeam-utils 0.7.2",
+ "crossbeam-utils",
"futures-util",
"loom",
]
@@ -1908,7 +1888,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e32b956473d98c601dac257fab8a7700d42e49fdd7a33432dd5dc7fdd2448dd"
dependencies = [
- "arrayvec 0.4.12",
+ "arrayvec",
"bitflags",
"byteorder",
"lazy_static",
@@ -1917,9 +1897,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.74"
+version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c"
+checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
dependencies = [
"proc-macro2",
"quote",
@@ -1938,12 +1918,6 @@ dependencies = [
"unicode-xid",
]
-[[package]]
-name = "tap"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
-
[[package]]
name = "tempfile"
version = "3.2.0"
@@ -1969,18 +1943,18 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.26"
+version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
+checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.26"
+version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
+checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c"
dependencies = [
"proc-macro2",
"quote",
@@ -1999,9 +1973,9 @@ dependencies = [
[[package]]
name = "tinyvec"
-version = "1.3.1"
+version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338"
+checksum = "5241dd6f21443a3606b432718b166d3cedc962fd4b8bea54a8bc7f514ebda986"
dependencies = [
"tinyvec_macros",
]
@@ -2014,9 +1988,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
-version = "1.10.0"
+version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01cf844b23c6131f624accf65ce0e4e9956a8bb329400ea5bcc26ae3a5c20b0b"
+checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce"
dependencies = [
"autocfg 1.0.1",
"bytes",
@@ -2076,9 +2050,9 @@ dependencies = [
[[package]]
name = "tokio-util"
-version = "0.6.7"
+version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592"
+checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd"
dependencies = [
"bytes",
"futures-core",
@@ -2096,9 +2070,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
[[package]]
name = "tracing"
-version = "0.1.26"
+version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d"
+checksum = "c2ba9ab62b7d6497a8638dfda5e5c4fb3b2d5a7fca4118f2b96151c8ef1a437e"
dependencies = [
"cfg-if 1.0.0",
"log",
@@ -2109,9 +2083,9 @@ dependencies = [
[[package]]
name = "tracing-attributes"
-version = "0.1.15"
+version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2"
+checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77"
dependencies = [
"proc-macro2",
"quote",
@@ -2120,9 +2094,9 @@ dependencies = [
[[package]]
name = "tracing-core"
-version = "0.1.18"
+version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052"
+checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf"
dependencies = [
"lazy_static",
]
@@ -2174,9 +2148,9 @@ checksum = "ed5b74f0a24b5454580a79abb6994393b09adf0ab8070f15827cb666255de155"
[[package]]
name = "typenum"
-version = "1.13.0"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
+checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"
[[package]]
name = "unicase"
@@ -2300,9 +2274,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm-bindgen"
-version = "0.2.75"
+version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586"
+checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce"
dependencies = [
"cfg-if 1.0.0",
"serde",
@@ -2312,9 +2286,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
-version = "0.2.75"
+version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f"
+checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b"
dependencies = [
"bumpalo",
"lazy_static",
@@ -2327,9 +2301,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
-version = "0.4.25"
+version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16646b21c3add8e13fdb8f20172f8a28c3dbf62f45406bcff0233188226cfe0c"
+checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
@@ -2339,9 +2313,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.75"
+version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c"
+checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -2349,9 +2323,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.75"
+version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f"
+checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
dependencies = [
"proc-macro2",
"quote",
@@ -2362,15 +2336,15 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.75"
+version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2"
+checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc"
[[package]]
name = "web-sys"
-version = "0.3.52"
+version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01c70a82d842c9979078c772d4a1344685045f1a5628f677c2b2eab4dd7d2696"
+checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -2397,9 +2371,9 @@ dependencies = [
[[package]]
name = "whoami"
-version = "1.1.2"
+version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4abacf325c958dfeaf1046931d37f2a901b6dfe0968ee965a29e94c6766b2af6"
+checksum = "f7741161a40200a867c96dfa5574544efa4178cf4c8f770b62dd1cc0362d7ae1"
dependencies = [
"wasm-bindgen",
"web-sys",
@@ -2445,12 +2419,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "wyz"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
-
[[package]]
name = "xsalsa20poly1305"
version = "0.7.2"
diff --git a/Cargo.toml b/Cargo.toml
index c39a27a..ed3dd3b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "soundfx-rs"
-version = "1.4.0"
+version = "1.4.3"
authors = ["jellywx "]
edition = "2018"
diff --git a/migrations/01-move-roles.sql b/migrations/01-move-roles.sql
new file mode 100644
index 0000000..47a25c5
--- /dev/null
+++ b/migrations/01-move-roles.sql
@@ -0,0 +1,2 @@
+ALTER TABLE servers ADD COLUMN allowed_role BIGINT;
+ALTER TABLE servers DROP COLUMN name;
diff --git a/create.sql b/migrations/create.sql
similarity index 100%
rename from create.sql
rename to migrations/create.sql
diff --git a/rustfmt.toml b/rustfmt.toml
new file mode 100644
index 0000000..455c820
--- /dev/null
+++ b/rustfmt.toml
@@ -0,0 +1,2 @@
+imports_granularity = "Crate"
+group_imports = "StdExternalCrate"
diff --git a/src/cmds/info.rs b/src/cmds/info.rs
index cf0a876..1931699 100644
--- a/src/cmds/info.rs
+++ b/src/cmds/info.rs
@@ -1,15 +1,13 @@
-use regex_command_attr::command;
+use std::{collections::HashMap, sync::Arc};
+use regex_command_attr::command;
use serenity::{client::Context, framework::standard::CommandResult};
use crate::{
- framework::{Args, CommandInvoke, CreateGenericResponse, RegexFramework},
+ framework::{Args, CommandInvoke, CommandKind, 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")]
@@ -147,7 +145,7 @@ pub async fn help(
CreateGenericResponse::new().embed(|e| {
e.title("Invalid Command")
.color(THEME_COLOR)
- .description("Type `/help command` to view help about a command below:")
+ .description("Type `/help command` to view more about a command below:")
.fields(groups_iter)
}),
)
@@ -173,7 +171,10 @@ pub async fn help(
CreateGenericResponse::new().embed(|e| {
e.title("Help")
.color(THEME_COLOR)
- .description("Type `/help command` to view help about a command below:")
+ .description("**Welcome to SoundFX!**
+To get started, upload a sound with `/upload`, or use `/search` and `/play` to look at some of the public sounds
+
+Type `/help command` to view help about a command below:")
.fields(groups_iter)
}),
)
diff --git a/src/cmds/manage.rs b/src/cmds/manage.rs
index 8b1356c..6406629 100644
--- a/src/cmds/manage.rs
+++ b/src/cmds/manage.rs
@@ -1,5 +1,6 @@
-use regex_command_attr::command;
+use std::time::Duration;
+use regex_command_attr::command;
use serenity::{
client::Context,
framework::standard::CommandResult,
@@ -12,8 +13,6 @@ use crate::{
MySQL, MAX_SOUNDS, PATREON_GUILD, PATREON_ROLE,
};
-use std::time::Duration;
-
#[command("upload")]
#[group("Manage")]
#[description("Upload a new sound to the bot")]
@@ -156,7 +155,7 @@ pub async fn upload_new_sound(
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**",
+ "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?;
}
@@ -171,7 +170,7 @@ pub async fn upload_new_sound(
.await?;
}
} else {
- invoke.respond(ctx.http.clone(), CreateGenericResponse::new().content("Usage: `?upload `. Please ensure the name provided is less than 20 characters in length")).await?;
+ invoke.respond(ctx.http.clone(), CreateGenericResponse::new().content("Usage: `/upload `. Please ensure the name provided is less than 20 characters in length")).await?;
}
Ok(())
diff --git a/src/cmds/play.rs b/src/cmds/play.rs
index 7f3bcf9..397c518 100644
--- a/src/cmds/play.rs
+++ b/src/cmds/play.rs
@@ -1,12 +1,12 @@
-use regex_command_attr::command;
+use std::{convert::TryFrom, time::Duration};
+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},
@@ -22,8 +22,6 @@ use crate::{
AudioIndex, MySQL,
};
-use std::{convert::TryFrom, time::Duration};
-
#[command]
#[aliases("p")]
#[required_permissions(Managed)]
@@ -110,60 +108,78 @@ pub async fn play_ambience(
match channel_to_join {
Some(user_channel) => {
- let search_name = args.named("name").unwrap().to_lowercase();
let audio_index = ctx.data.read().await.get::().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(),
- );
+ if let Some(search_name) = args.named("name") {
+ 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 (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;
+ {
+ let mut lock = call_handler.lock().await;
- lock.play(track);
+ 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::>()
+ .join("\n")
+ ))
+ }),
+ )
+ .await?;
}
-
- 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,
+ e.title("Available Sounds").description(
audio_index
.keys()
.into_iter()
.map(|i| i.as_str())
.collect::>()
- .join("\n")
- ))
+ .join("\n"),
+ )
}),
)
.await?;
@@ -374,7 +390,9 @@ pub async fn soundboard(
.await?;
if let Some(sound) = search.first() {
- sounds.push(sound.clone());
+ if !sounds.contains(sound) {
+ sounds.push(sound.clone());
+ }
}
}
diff --git a/src/cmds/search.rs b/src/cmds/search.rs
index 9a77985..2fc468a 100644
--- a/src/cmds/search.rs
+++ b/src/cmds/search.rs
@@ -1,5 +1,4 @@
use regex_command_attr::command;
-
use serenity::{client::Context, framework::standard::CommandResult};
use crate::{
@@ -15,13 +14,7 @@ fn format_search_results(search_results: Vec) -> CreateGenericResponse {
let field_iter = search_results
.iter()
.take(25)
- .map(|item| {
- (
- &item.name,
- format!("ID: {}\nPlays: {}", item.id, item.plays),
- true,
- )
- })
+ .map(|item| (&item.name, format!("ID: {}", item.id), true))
.filter(|item| {
current_character_count += item.0.len() + item.1.len();
@@ -59,11 +52,11 @@ pub async fn list_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?;
+ sounds = Sound::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?;
+ sounds = Sound::guild_sounds(invoke.guild_id().unwrap(), pool).await?;
message_buffer = "All sounds on this server: ".to_string();
}
@@ -142,42 +135,6 @@ pub async fn search_sounds(
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::()
- .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")]
@@ -197,7 +154,7 @@ pub async fn show_random_sounds(
let search_results = sqlx::query_as_unchecked!(
Sound,
"
-SELECT name, id, plays, public, server_id, uploader_id
+SELECT name, id, public, server_id, uploader_id
FROM sounds
WHERE public = 1
ORDER BY rand()
diff --git a/src/cmds/settings.rs b/src/cmds/settings.rs
index 3149a6c..9e15556 100644
--- a/src/cmds/settings.rs
+++ b/src/cmds/settings.rs
@@ -1,5 +1,4 @@
use regex_command_attr::command;
-
use serenity::{client::Context, framework::standard::CommandResult};
use crate::{
@@ -145,23 +144,21 @@ pub async fn change_prefix(
#[command("roles")]
#[required_permissions(Restricted)]
-#[kind(Text)]
#[group("Settings")]
-#[description("Change the roles allowed to use the bot")]
+#[description("Change the role allowed to use the bot")]
#[arg(
- name = "roles",
- kind = "String",
- description = "The role mentions to enlist",
+ name = "role",
+ kind = "Role",
+ description = "A role to allow to use the bot. Use @everyone to allow all server members",
required = true
)]
+#[example("`/roles @everyone` - allow all server members to use the bot")]
+#[example("`/roles @DJ` - allow only server members with the 'DJ' role to use the bot")]
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()
@@ -170,73 +167,19 @@ pub async fn set_allowed_roles(
.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
+ let role_id = args.named("role").unwrap().parse::().unwrap();
+ let guild_data = ctx.guild_data(invoke.guild_id().unwrap()).await.unwrap();
+
+ guild_data.write().await.allowed_role = Some(role_id);
+ guild_data.read().await.commit(pool).await?;
+
+ invoke
+ .respond(
+ ctx.http.clone(),
+ CreateGenericResponse::new().content(format!("Allowed role set to <@&{}>", role_id)),
)
- .fetch_all(&pool)
.await?;
- let all_roles = roles
- .iter()
- .map(|i| format!("<@&{}>", i.role.to_string()))
- .collect::>()
- .join(", ");
-
- msg.channel_id.say(&ctx, format!("Usage: `?roles `. 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(())
}
diff --git a/src/cmds/stop.rs b/src/cmds/stop.rs
index eac7e5c..dccc318 100644
--- a/src/cmds/stop.rs
+++ b/src/cmds/stop.rs
@@ -1,11 +1,9 @@
use regex_command_attr::command;
-
use serenity::{client::Context, framework::standard::CommandResult};
+use songbird;
use crate::framework::{Args, CommandInvoke, CreateGenericResponse};
-use songbird;
-
#[command("stop")]
#[required_permissions(Managed)]
#[group("Stop")]
diff --git a/src/event_handlers.rs b/src/event_handlers.rs
index d6609b2..d39554e 100644
--- a/src/event_handlers.rs
+++ b/src/event_handlers.rs
@@ -1,10 +1,4 @@
-use crate::{
- framework::RegexFramework,
- guild_data::CtxGuildData,
- join_channel, play_audio, play_from_query,
- sound::{JoinSoundCtx, Sound},
- MySQL, ReqwestClient,
-};
+use std::{collections::HashMap, env};
use serenity::{
async_trait,
@@ -19,12 +13,15 @@ use serenity::{
},
utils::shard_id,
};
-
use songbird::{Event, EventContext, EventHandler as SongbirdEventHandler};
-use crate::framework::Args;
-
-use std::{collections::HashMap, env};
+use crate::{
+ framework::{Args, RegexFramework},
+ guild_data::CtxGuildData,
+ join_channel, play_audio, play_from_query,
+ sound::{JoinSoundCtx, Sound},
+ MySQL, ReqwestClient,
+};
pub struct RestartTrack;
@@ -47,18 +44,6 @@ impl EventHandler for Handler {
ctx.set_activity(Activity::watching("for /play")).await;
}
- async fn cache_ready(&self, ctx: Context, _: Vec) {
- let framework = ctx
- .data
- .read()
- .await
- .get::()
- .cloned()
- .expect("RegexFramework not found in context");
-
- framework.build_slash(ctx).await;
- }
-
async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) {
if is_new {
if let Ok(token) = env::var("DISCORDBOTS_TOKEN") {
@@ -152,7 +137,7 @@ impl EventHandler for Handler {
let mut sound = sqlx::query_as_unchecked!(
Sound,
"
-SELECT name, id, plays, public, server_id, uploader_id
+SELECT name, id, public, server_id, uploader_id
FROM sounds
WHERE id = ?
",
diff --git a/src/framework.rs b/src/framework.rs
index 974693e..777fee9 100644
--- a/src/framework.rs
+++ b/src/framework.rs
@@ -1,6 +1,16 @@
+use std::{
+ collections::{HashMap, HashSet},
+ env, fmt,
+ hash::{Hash, Hasher},
+ sync::Arc,
+};
+
+use log::{debug, error, info, warn};
+use regex::{Match, Regex, RegexBuilder};
+use serde_json::Value;
use serenity::{
async_trait,
- builder::CreateEmbed,
+ builder::{CreateApplicationCommands, CreateComponents, CreateEmbed},
cache::Cache,
client::Context,
framework::{standard::CommandResult, Framework},
@@ -9,7 +19,7 @@ use serenity::{
model::{
channel::{Channel, GuildChannel, Message},
guild::{Guild, Member},
- id::{ChannelId, GuildId, UserId},
+ id::{ChannelId, GuildId, RoleId, UserId},
interactions::{
application_command::{
ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType,
@@ -21,20 +31,7 @@ use serenity::{
Result as SerenityResult,
};
-use log::{debug, error, info, warn};
-
-use regex::{Match, Regex, RegexBuilder};
-
-use std::{
- collections::{HashMap, HashSet},
- env, fmt,
- hash::{Hash, Hasher},
- sync::Arc,
-};
-
-use crate::{guild_data::CtxGuildData, MySQL};
-use serde_json::Value;
-use serenity::builder::CreateComponents;
+use crate::guild_data::CtxGuildData;
type CommandFn = for<'fut> fn(
&'fut Context,
@@ -74,10 +71,6 @@ impl Args {
Self { args }
}
- pub fn is_empty(&self) -> bool {
- self.args.is_empty()
- }
-
pub fn named(&self, name: D) -> Option<&String> {
let name = name.to_string();
@@ -397,42 +390,14 @@ impl Command {
}
if self.required_permissions == PermissionLevel::Managed {
- let pool = ctx
- .data
- .read()
- .await
- .get::()
- .cloned()
- .expect("Could not get SQLPool from data");
+ match ctx.guild_data(guild.id).await {
+ Ok(guild_data) => guild_data.read().await.allowed_role.map_or(true, |role| {
+ role == guild.id.0 || {
+ let role_id = RoleId(role);
- match sqlx::query!(
- "
-SELECT role
- FROM roles
- WHERE guild_id = ?
- ",
- guild.id.as_u64()
- )
- .fetch_all(&pool)
- .await
- {
- Ok(rows) => {
- let role_ids = member
- .roles
- .iter()
- .map(|r| *r.as_u64())
- .collect::>();
-
- for row in rows {
- if role_ids.contains(&row.role) || &row.role == guild.id.as_u64() {
- return true;
- }
+ member.roles.contains(&role_id)
}
-
- false
- }
-
- Err(sqlx::Error::RowNotFound) => false,
+ }),
Err(e) => {
warn!("Unexpected error occurred querying roles: {:?}", e);
@@ -540,132 +505,55 @@ impl RegexFramework {
self
}
+ fn _populate_commands<'a>(
+ &self,
+ commands: &'a mut CreateApplicationCommands,
+ ) -> &'a mut CreateApplicationCommands {
+ for command in &self.commands_ {
+ commands.create_application_command(|c| {
+ c.name(command.names[0]).description(command.desc);
+
+ for arg in command.args {
+ c.create_option(|o| {
+ o.name(arg.name)
+ .description(arg.description)
+ .kind(arg.kind)
+ .required(arg.required)
+ });
+ }
+
+ c
+ });
+ }
+
+ commands
+ }
+
pub async fn build_slash(&self, http: impl AsRef) {
info!("Building slash commands...");
- let mut count = 0;
-
- if let Some(guild_id) = env::var("TEST_GUILD")
- .map(|v| v.parse::().ok())
+ match env::var("TEST_GUILD")
+ .map(|i| i.parse::().ok())
.ok()
.flatten()
- .map(|v| GuildId(v))
+ .map(|i| GuildId(i))
{
- for command in self
- .commands_
- .iter()
- .filter(|c| c.kind != CommandKind::Text)
- {
- guild_id
- .create_application_command(&http, |a| {
- a.name(command.names[0]).description(command.desc);
-
- for arg in command.args {
- a.create_option(|o| {
- o.name(arg.name)
- .description(arg.description)
- .kind(arg.kind)
- .required(arg.required)
- });
- }
-
- a
- })
- .await
- .expect(&format!(
- "Failed to create application command for {}",
- command.names[0]
- ));
-
- count += 1;
- }
- } else {
- info!("Checking for existing commands...");
-
- let current_commands = ApplicationCommand::get_global_application_commands(&http)
+ None => {
+ ApplicationCommand::set_global_application_commands(&http, |c| {
+ self._populate_commands(c)
+ })
.await
- .expect("Failed to fetch existing commands");
-
- debug!("Existing commands: {:?}", current_commands);
-
- // delete commands not in use
- for command in ¤t_commands {
- if self
- .commands_
- .iter()
- .find(|c| c.names[0] == command.name)
- .is_none()
- {
- info!("Deleting command {}", command.name);
-
- ApplicationCommand::delete_global_application_command(&http, command.id)
- .await
- .expect("Failed to delete an unused command");
- }
+ .unwrap();
}
-
- for command in self
- .commands_
- .iter()
- .filter(|c| c.kind != CommandKind::Text)
- {
- let already_created = if let Some(current_command) = current_commands
- .iter()
- .find(|curr| curr.name == command.names[0])
- {
- if current_command.description == command.desc
- && current_command.options.len() == command.args.len()
- {
- let mut has_different_arg = false;
-
- for (arg, option) in
- command.args.iter().zip(current_command.options.clone())
- {
- if arg.required != option.required
- || arg.name != option.name
- || arg.description != option.description
- || arg.kind != option.kind
- {
- has_different_arg = true;
- break;
- }
- }
-
- !has_different_arg
- } else {
- false
- }
- } else {
- false
- };
-
- if !already_created {
- ApplicationCommand::create_global_application_command(&http, |a| {
- a.name(command.names[0]).description(command.desc);
-
- for arg in command.args {
- a.create_option(|o| {
- o.name(arg.name)
- .description(arg.description)
- .kind(arg.kind)
- .required(arg.required)
- });
- }
-
- a
- })
+ Some(debug_guild) => {
+ debug_guild
+ .set_application_commands(&http, |c| self._populate_commands(c))
.await
- .expect(&format!(
- "Failed to create application command for {}",
- command.names[0]
- ));
-
- count += 1;
- }
+ .unwrap();
}
}
- info!("{} slash commands built! Ready to go", count);
+ info!("Slash commands built!");
}
pub async fn execute(&self, ctx: Context, interaction: ApplicationCommandInteraction) {
@@ -709,6 +597,14 @@ impl RegexFramework {
);
}
+ info!(
+ "[Shard {}] [Guild {}] /{} {:?}",
+ ctx.shard_id,
+ interaction.guild_id.unwrap(),
+ interaction.data.name,
+ args
+ );
+
(command.fun)(&ctx, &interaction, Args { args })
.await
.unwrap();
@@ -716,7 +612,7 @@ impl RegexFramework {
let _ = interaction
.respond(
ctx.http.clone(),
- CreateGenericResponse::new().content("You must either be an Admin or have a role specified in `?roles` to do this command")
+ CreateGenericResponse::new().content("You must either be an Admin or have a role specified by `/roles` to do this command")
)
.await;
} else if command.required_permissions == PermissionLevel::Restricted {
@@ -794,6 +690,14 @@ impl Framework for RegexFramework {
let member = guild.member(&ctx, &msg.author).await.unwrap();
if command.check_permissions(&ctx, &guild, &member).await {
+ let _ = msg.channel_id.say(
+ &ctx,
+ format!(
+ "You **must** begin to switch to slash commands. All commands are available via slash commands now. If slash commands don't display in your server, please use this link: https://discord.com/api/oauth2/authorize?client_id={}&permissions=3165184&scope=applications.commands%20bot",
+ ctx.cache.current_user().id
+ )
+ ).await;
+
(command.fun)(&ctx, &msg, Args::from(&args, command.args))
.await
.unwrap();
diff --git a/src/guild_data.rs b/src/guild_data.rs
index d42309b..4dad567 100644
--- a/src/guild_data.rs
+++ b/src/guild_data.rs
@@ -1,15 +1,18 @@
-use crate::{GuildDataCache, MySQL};
+use std::sync::Arc;
+
use serenity::{async_trait, model::id::GuildId, prelude::Context};
use sqlx::mysql::MySqlPool;
-use std::sync::Arc;
use tokio::sync::RwLock;
+use crate::{GuildDataCache, MySQL};
+
#[derive(Clone)]
pub struct GuildData {
pub id: u64,
pub prefix: String,
pub volume: u8,
pub allow_greets: bool,
+ pub allowed_role: Option,
}
#[async_trait]
@@ -41,7 +44,7 @@ impl CtxGuildData for Context {
} else {
let pool = self.data.read().await.get::().cloned().unwrap();
- match GuildData::get_from_id(guild_id, pool).await {
+ match GuildData::from_id(guild_id, pool).await {
Ok(d) => {
let lock = Arc::new(RwLock::new(d));
@@ -59,7 +62,7 @@ impl CtxGuildData for Context {
}
impl GuildData {
- pub async fn get_from_id>(
+ pub async fn from_id>(
guild_id: G,
db_pool: MySqlPool,
) -> Result {
@@ -68,7 +71,7 @@ impl GuildData {
let guild_data = sqlx::query_as_unchecked!(
GuildData,
"
-SELECT id, prefix, volume, allow_greets
+SELECT id, prefix, volume, allow_greets, allowed_role
FROM servers
WHERE id = ?
",
@@ -102,22 +105,12 @@ INSERT INTO servers (id)
.execute(&db_pool)
.await?;
- sqlx::query!(
- "
-INSERT IGNORE INTO roles (guild_id, role)
- VALUES (?, ?)
- ",
- guild_id.as_u64(),
- guild_id.as_u64()
- )
- .execute(&db_pool)
- .await?;
-
Ok(GuildData {
id: guild_id.as_u64().to_owned(),
prefix: String::from("?"),
volume: 100,
allow_greets: true,
+ allowed_role: None,
})
}
@@ -131,13 +124,15 @@ UPDATE servers
SET
prefix = ?,
volume = ?,
- allow_greets = ?
+ allow_greets = ?,
+ allowed_role = ?
WHERE
id = ?
",
self.prefix,
self.volume,
self.allow_greets,
+ self.allowed_role,
self.id
)
.execute(&db_pool)
diff --git a/src/main.rs b/src/main.rs
index 5546331..f2ca6e8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,15 +8,11 @@ mod framework;
mod guild_data;
mod sound;
-use crate::{
- event_handlers::Handler,
- framework::{Args, RegexFramework},
- guild_data::{CtxGuildData, GuildData},
- sound::Sound,
-};
+use std::{collections::HashMap, env, sync::Arc};
+use dashmap::DashMap;
+use dotenv::dotenv;
use log::info;
-
use serenity::{
client::{bridge::gateway::GatewayIntents, Client, Context},
http::Http,
@@ -27,19 +23,17 @@ use serenity::{
},
prelude::{Mutex, TypeMapKey},
};
-
use songbird::{create_player, error::JoinResult, tracks::TrackHandle, Call, SerenityInit};
-
use sqlx::mysql::MySqlPool;
-
-use dotenv::dotenv;
-
-use dashmap::DashMap;
-
-use std::{collections::HashMap, env, sync::Arc};
-
use tokio::sync::{MutexGuard, RwLock};
+use crate::{
+ event_handlers::Handler,
+ framework::{Args, RegexFramework},
+ guild_data::{CtxGuildData, GuildData},
+ sound::Sound,
+};
+
struct MySQL;
impl TypeMapKey for MySQL {
@@ -98,9 +92,6 @@ async fn play_audio(
call_handler.play(track);
- sound.plays += 1;
- sound.commit(mysql_pool).await?;
-
Ok(track_handler)
}
@@ -268,7 +259,6 @@ async fn main() -> Result<(), Box> {
// search commands
.add_command(&cmds::search::LIST_SOUNDS_COMMAND)
.add_command(&cmds::search::SEARCH_SOUNDS_COMMAND)
- .add_command(&cmds::search::SHOW_POPULAR_SOUNDS_COMMAND)
.add_command(&cmds::search::SHOW_RANDOM_SOUNDS_COMMAND);
if audio_index.is_some() {
@@ -314,6 +304,8 @@ async fn main() -> Result<(), Box> {
}
}
+ framework_arc.build_slash(&client.cache_and_http.http).await;
+
if let Ok((Some(lower), Some(upper))) = env::var("SHARD_RANGE").map(|sr| {
let mut split = sr
.split(',')
diff --git a/src/sound.rs b/src/sound.rs
index 6e86c11..d44c426 100644
--- a/src/sound.rs
+++ b/src/sound.rs
@@ -1,15 +1,12 @@
-use super::error::ErrorTypes;
-
-use sqlx::mysql::MySqlPool;
-
-use tokio::{fs::File, io::AsyncWriteExt, process::Command};
-
-use songbird::input::restartable::Restartable;
-
use std::{env, path::Path};
-use crate::{JoinSoundCache, MySQL};
use serenity::{async_trait, model::id::UserId, prelude::Context};
+use songbird::input::restartable::Restartable;
+use sqlx::mysql::MySqlPool;
+use tokio::{fs::File, io::AsyncWriteExt, process::Command};
+
+use super::error::ErrorTypes;
+use crate::{JoinSoundCache, MySQL};
#[async_trait]
pub trait JoinSoundCtx {
@@ -83,17 +80,15 @@ SELECT join_sound_id
let pool = self.data.read().await.get::().cloned().unwrap();
- if join_sound_cache.get(&user_id).is_none() {
- let _ = sqlx::query!(
- "
+ let _ = sqlx::query!(
+ "
INSERT IGNORE INTO users (user)
VALUES (?)
",
- user_id.as_u64()
- )
- .execute(&pool)
- .await;
- }
+ user_id.as_u64()
+ )
+ .execute(&pool)
+ .await;
let _ = sqlx::query!(
"
@@ -115,12 +110,17 @@ WHERE
pub struct Sound {
pub name: String,
pub id: u32,
- pub plays: u32,
pub public: bool,
pub server_id: u64,
pub uploader_id: Option,
}
+impl PartialEq for Sound {
+ fn eq(&self, other: &Self) -> bool {
+ self.id == other.id
+ }
+}
+
impl Sound {
pub async fn search_for_sound, U: Into>(
query: &str,
@@ -150,7 +150,7 @@ impl Sound {
let sound = sqlx::query_as_unchecked!(
Self,
"
-SELECT name, id, plays, public, server_id, uploader_id
+SELECT name, id, public, server_id, uploader_id
FROM sounds
WHERE id = ? AND (
public = 1 OR
@@ -174,7 +174,7 @@ SELECT name, id, plays, public, server_id, uploader_id
sound = sqlx::query_as_unchecked!(
Self,
"
-SELECT name, id, plays, public, server_id, uploader_id
+SELECT name, id, public, server_id, uploader_id
FROM sounds
WHERE name = ? AND (
public = 1 OR
@@ -195,7 +195,7 @@ SELECT name, id, plays, public, server_id, uploader_id
sound = sqlx::query_as_unchecked!(
Self,
"
-SELECT name, id, plays, public, server_id, uploader_id
+SELECT name, id, public, server_id, uploader_id
FROM sounds
WHERE name LIKE CONCAT('%', ?, '%') AND (
public = 1 OR
@@ -310,12 +310,10 @@ SELECT COUNT(1) as count
"
UPDATE sounds
SET
- plays = ?,
public = ?
WHERE
id = ?
",
- self.plays,
self.public,
self.id
)
@@ -407,14 +405,14 @@ INSERT INTO sounds (name, server_id, uploader_id, public, src)
}
}
- pub async fn get_user_sounds>(
+ pub async fn user_sounds>(
user_id: U,
db_pool: MySqlPool,
) -> Result, Box> {
let sounds = sqlx::query_as_unchecked!(
Sound,
"
-SELECT name, id, plays, public, server_id, uploader_id
+SELECT name, id, public, server_id, uploader_id
FROM sounds
WHERE uploader_id = ?
",
@@ -426,14 +424,14 @@ SELECT name, id, plays, public, server_id, uploader_id
Ok(sounds)
}
- pub async fn get_guild_sounds>(
+ pub async fn guild_sounds>(
guild_id: G,
db_pool: MySqlPool,
) -> Result, Box> {
let sounds = sqlx::query_as_unchecked!(
Sound,
"
-SELECT name, id, plays, public, server_id, uploader_id
+SELECT name, id, public, server_id, uploader_id
FROM sounds
WHERE server_id = ?
",