├── .github └── workflows │ └── rust.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── config.toml ├── rustfmt.toml ├── sqlx-data.json └── src ├── commands.rs ├── commands ├── admin.rs ├── admin │ ├── ban.rs │ └── kick.rs ├── games.rs ├── games │ ├── betroll.rs │ ├── flip.rs │ ├── give.rs │ ├── money.rs │ └── setmoney.rs ├── generic.rs ├── help.rs ├── roles.rs ├── roles │ ├── addjoinrole.rs │ ├── addreactrole.rs │ ├── removejoinrole.rs │ └── removereactrole.rs ├── settings.rs ├── settings │ ├── log.rs │ └── prefix.rs ├── utility.rs └── utility │ ├── answer.rs │ ├── avatar.rs │ ├── choose.rs │ ├── emoji.rs │ ├── guild.rs │ ├── leaderboard.rs │ ├── ping.rs │ └── user.rs ├── data.rs ├── data ├── cache.rs └── db.rs ├── db.rs ├── db ├── leaderboard.rs ├── log.rs ├── money.rs ├── prefix.rs └── reactionroles.rs ├── listeners.rs ├── listeners ├── cache_ready.rs ├── category_create.rs ├── category_delete.rs ├── channel_create.rs ├── channel_delete.rs ├── guild_ban_addition.rs ├── guild_member_addition.rs ├── guild_member_removal.rs ├── guild_member_update.rs ├── message.rs ├── message_delete.rs ├── message_update.rs ├── presence_update.rs ├── ready.rs └── voice_state_update.rs ├── main.rs ├── prelude.rs ├── utils.rs └── utils ├── framework.rs ├── macros.rs └── parse.rs /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | on: 3 | pull_request: 4 | branches: 5 | - master 6 | paths: 7 | - "**.rs" 8 | - "**Cargo.lock" 9 | - "**Cargo.toml" 10 | push: 11 | branches: 12 | - master 13 | paths: 14 | - "**.rs" 15 | - "**Cargo.lock" 16 | - "**Cargo.toml" 17 | 18 | jobs: 19 | clippy: 20 | needs: format 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v2 24 | - uses: Swatinem/rust-cache@v1 25 | - run: cargo clippy -- -D warnings 26 | 27 | stable: 28 | needs: format 29 | runs-on: ubuntu-latest 30 | steps: 31 | - uses: actions/checkout@v2 32 | - uses: Swatinem/rust-cache@v1 33 | - run: cargo test 34 | 35 | nightly: 36 | needs: format 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v2 40 | - run: rustup default nightly-2022-01-25 41 | - uses: Swatinem/rust-cache@v1 42 | - run: cargo test 43 | 44 | windows: 45 | needs: format 46 | runs-on: windows-latest 47 | steps: 48 | - uses: actions/checkout@v2 49 | - uses: Swatinem/rust-cache@v1 50 | - run: cargo test 51 | 52 | format: 53 | runs-on: ubuntu-latest 54 | steps: 55 | - uses: actions/checkout@v2 56 | - run: cargo fmt -- --check 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .env 3 | *.sqlite3* 4 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "adler" 7 | version = "1.0.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 10 | 11 | [[package]] 12 | name = "ahash" 13 | version = "0.7.6" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 16 | dependencies = [ 17 | "getrandom 0.2.4", 18 | "once_cell", 19 | "version_check", 20 | ] 21 | 22 | [[package]] 23 | name = "aho-corasick" 24 | version = "0.7.18" 25 | source = "registry+https://github.com/rust-lang/crates.io-index" 26 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 27 | dependencies = [ 28 | "memchr", 29 | ] 30 | 31 | [[package]] 32 | name = "anyhow" 33 | version = "1.0.53" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" 36 | 37 | [[package]] 38 | name = "arrayvec" 39 | version = "0.5.2" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" 42 | 43 | [[package]] 44 | name = "async-trait" 45 | version = "0.1.52" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" 48 | dependencies = [ 49 | "proc-macro2", 50 | "quote", 51 | "syn", 52 | ] 53 | 54 | [[package]] 55 | name = "async-tungstenite" 56 | version = "0.11.0" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "f7cc5408453d37e2b1c6f01d8078af1da58b6cfa6a80fa2ede3bd2b9a6ada9c4" 59 | dependencies = [ 60 | "futures-io", 61 | "futures-util", 62 | "log", 63 | "pin-project", 64 | "tokio", 65 | "tokio-rustls 0.22.0", 66 | "tungstenite", 67 | "webpki-roots 0.20.0", 68 | ] 69 | 70 | [[package]] 71 | name = "atoi" 72 | version = "0.4.0" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5" 75 | dependencies = [ 76 | "num-traits 0.2.14", 77 | ] 78 | 79 | [[package]] 80 | name = "atty" 81 | version = "0.2.14" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 84 | dependencies = [ 85 | "hermit-abi", 86 | "libc", 87 | "winapi", 88 | ] 89 | 90 | [[package]] 91 | name = "autocfg" 92 | version = "1.0.1" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 95 | 96 | [[package]] 97 | name = "base64" 98 | version = "0.12.3" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" 101 | 102 | [[package]] 103 | name = "base64" 104 | version = "0.13.0" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 107 | 108 | [[package]] 109 | name = "bitflags" 110 | version = "1.3.2" 111 | source = "registry+https://github.com/rust-lang/crates.io-index" 112 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 113 | 114 | [[package]] 115 | name = "block-buffer" 116 | version = "0.9.0" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" 119 | dependencies = [ 120 | "generic-array", 121 | ] 122 | 123 | [[package]] 124 | name = "bot" 125 | version = "0.1.0" 126 | dependencies = [ 127 | "anyhow", 128 | "config", 129 | "dotenv", 130 | "env_logger", 131 | "log", 132 | "rand 0.8.4", 133 | "serenity", 134 | "sqlx", 135 | "tokio", 136 | ] 137 | 138 | [[package]] 139 | name = "bumpalo" 140 | version = "3.9.1" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" 143 | 144 | [[package]] 145 | name = "byteorder" 146 | version = "1.4.3" 147 | source = "registry+https://github.com/rust-lang/crates.io-index" 148 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 149 | 150 | [[package]] 151 | name = "bytes" 152 | version = "0.5.6" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" 155 | 156 | [[package]] 157 | name = "bytes" 158 | version = "1.1.0" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" 161 | 162 | [[package]] 163 | name = "cc" 164 | version = "1.0.72" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" 167 | 168 | [[package]] 169 | name = "cfg-if" 170 | version = "1.0.0" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 173 | 174 | [[package]] 175 | name = "chrono" 176 | version = "0.4.19" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" 179 | dependencies = [ 180 | "libc", 181 | "num-integer", 182 | "num-traits 0.2.14", 183 | "serde 1.0.136", 184 | "winapi", 185 | ] 186 | 187 | [[package]] 188 | name = "command_attr" 189 | version = "0.3.8" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "9e74a021f9d0b577821bf9f5b1a2be88677e95ee05713e5d44fb4236cfa1744c" 192 | dependencies = [ 193 | "proc-macro2", 194 | "quote", 195 | "syn", 196 | ] 197 | 198 | [[package]] 199 | name = "config" 200 | version = "0.11.0" 201 | source = "registry+https://github.com/rust-lang/crates.io-index" 202 | checksum = "1b1b9d958c2b1368a663f05538fc1b5975adce1e19f435acceae987aceeeb369" 203 | dependencies = [ 204 | "lazy_static", 205 | "nom 5.1.2", 206 | "rust-ini", 207 | "serde 1.0.136", 208 | "serde-hjson", 209 | "serde_json", 210 | "toml", 211 | "yaml-rust", 212 | ] 213 | 214 | [[package]] 215 | name = "cpufeatures" 216 | version = "0.2.1" 217 | source = "registry+https://github.com/rust-lang/crates.io-index" 218 | checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" 219 | dependencies = [ 220 | "libc", 221 | ] 222 | 223 | [[package]] 224 | name = "crc" 225 | version = "2.1.0" 226 | source = "registry+https://github.com/rust-lang/crates.io-index" 227 | checksum = "49fc9a695bca7f35f5f4c15cddc84415f66a74ea78eef08e90c5024f2b540e23" 228 | dependencies = [ 229 | "crc-catalog", 230 | ] 231 | 232 | [[package]] 233 | name = "crc-catalog" 234 | version = "1.1.1" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" 237 | 238 | [[package]] 239 | name = "crc32fast" 240 | version = "1.3.1" 241 | source = "registry+https://github.com/rust-lang/crates.io-index" 242 | checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" 243 | dependencies = [ 244 | "cfg-if", 245 | ] 246 | 247 | [[package]] 248 | name = "crossbeam-channel" 249 | version = "0.5.2" 250 | source = "registry+https://github.com/rust-lang/crates.io-index" 251 | checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" 252 | dependencies = [ 253 | "cfg-if", 254 | "crossbeam-utils", 255 | ] 256 | 257 | [[package]] 258 | name = "crossbeam-queue" 259 | version = "0.3.3" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | checksum = "b979d76c9fcb84dffc80a73f7290da0f83e4c95773494674cb44b76d13a7a110" 262 | dependencies = [ 263 | "cfg-if", 264 | "crossbeam-utils", 265 | ] 266 | 267 | [[package]] 268 | name = "crossbeam-utils" 269 | version = "0.8.6" 270 | source = "registry+https://github.com/rust-lang/crates.io-index" 271 | checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" 272 | dependencies = [ 273 | "cfg-if", 274 | "lazy_static", 275 | ] 276 | 277 | [[package]] 278 | name = "digest" 279 | version = "0.9.0" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 282 | dependencies = [ 283 | "generic-array", 284 | ] 285 | 286 | [[package]] 287 | name = "dotenv" 288 | version = "0.15.0" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" 291 | 292 | [[package]] 293 | name = "either" 294 | version = "1.6.1" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 297 | dependencies = [ 298 | "serde 1.0.136", 299 | ] 300 | 301 | [[package]] 302 | name = "encoding_rs" 303 | version = "0.8.30" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" 306 | dependencies = [ 307 | "cfg-if", 308 | ] 309 | 310 | [[package]] 311 | name = "env_logger" 312 | version = "0.9.0" 313 | source = "registry+https://github.com/rust-lang/crates.io-index" 314 | checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" 315 | dependencies = [ 316 | "atty", 317 | "humantime", 318 | "log", 319 | "regex", 320 | "termcolor", 321 | ] 322 | 323 | [[package]] 324 | name = "flate2" 325 | version = "1.0.22" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" 328 | dependencies = [ 329 | "cfg-if", 330 | "crc32fast", 331 | "libc", 332 | "miniz_oxide", 333 | ] 334 | 335 | [[package]] 336 | name = "flume" 337 | version = "0.10.10" 338 | source = "registry+https://github.com/rust-lang/crates.io-index" 339 | checksum = "5d04dafd11240188e146b6f6476a898004cace3be31d4ec5e08e216bf4947ac0" 340 | dependencies = [ 341 | "futures-core", 342 | "futures-sink", 343 | "pin-project", 344 | "spin 0.9.2", 345 | ] 346 | 347 | [[package]] 348 | name = "fnv" 349 | version = "1.0.7" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 352 | 353 | [[package]] 354 | name = "form_urlencoded" 355 | version = "1.0.1" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 358 | dependencies = [ 359 | "matches", 360 | "percent-encoding", 361 | ] 362 | 363 | [[package]] 364 | name = "futures" 365 | version = "0.3.19" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" 368 | dependencies = [ 369 | "futures-channel", 370 | "futures-core", 371 | "futures-io", 372 | "futures-sink", 373 | "futures-task", 374 | "futures-util", 375 | ] 376 | 377 | [[package]] 378 | name = "futures-channel" 379 | version = "0.3.19" 380 | source = "registry+https://github.com/rust-lang/crates.io-index" 381 | checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" 382 | dependencies = [ 383 | "futures-core", 384 | "futures-sink", 385 | ] 386 | 387 | [[package]] 388 | name = "futures-core" 389 | version = "0.3.19" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" 392 | 393 | [[package]] 394 | name = "futures-executor" 395 | version = "0.3.19" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" 398 | dependencies = [ 399 | "futures-core", 400 | "futures-task", 401 | "futures-util", 402 | ] 403 | 404 | [[package]] 405 | name = "futures-intrusive" 406 | version = "0.4.0" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "62007592ac46aa7c2b6416f7deb9a8a8f63a01e0f1d6e1787d5630170db2b63e" 409 | dependencies = [ 410 | "futures-core", 411 | "lock_api", 412 | "parking_lot", 413 | ] 414 | 415 | [[package]] 416 | name = "futures-io" 417 | version = "0.3.19" 418 | source = "registry+https://github.com/rust-lang/crates.io-index" 419 | checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" 420 | 421 | [[package]] 422 | name = "futures-sink" 423 | version = "0.3.19" 424 | source = "registry+https://github.com/rust-lang/crates.io-index" 425 | checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" 426 | 427 | [[package]] 428 | name = "futures-task" 429 | version = "0.3.19" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" 432 | 433 | [[package]] 434 | name = "futures-util" 435 | version = "0.3.19" 436 | source = "registry+https://github.com/rust-lang/crates.io-index" 437 | checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" 438 | dependencies = [ 439 | "futures-channel", 440 | "futures-core", 441 | "futures-io", 442 | "futures-sink", 443 | "futures-task", 444 | "memchr", 445 | "pin-project-lite", 446 | "pin-utils", 447 | "slab", 448 | ] 449 | 450 | [[package]] 451 | name = "generic-array" 452 | version = "0.14.5" 453 | source = "registry+https://github.com/rust-lang/crates.io-index" 454 | checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" 455 | dependencies = [ 456 | "typenum", 457 | "version_check", 458 | ] 459 | 460 | [[package]] 461 | name = "getrandom" 462 | version = "0.1.16" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" 465 | dependencies = [ 466 | "cfg-if", 467 | "libc", 468 | "wasi 0.9.0+wasi-snapshot-preview1", 469 | ] 470 | 471 | [[package]] 472 | name = "getrandom" 473 | version = "0.2.4" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" 476 | dependencies = [ 477 | "cfg-if", 478 | "libc", 479 | "wasi 0.10.2+wasi-snapshot-preview1", 480 | ] 481 | 482 | [[package]] 483 | name = "h2" 484 | version = "0.3.11" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" 487 | dependencies = [ 488 | "bytes 1.1.0", 489 | "fnv", 490 | "futures-core", 491 | "futures-sink", 492 | "futures-util", 493 | "http", 494 | "indexmap", 495 | "slab", 496 | "tokio", 497 | "tokio-util", 498 | "tracing", 499 | ] 500 | 501 | [[package]] 502 | name = "hashbrown" 503 | version = "0.11.2" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 506 | dependencies = [ 507 | "ahash", 508 | ] 509 | 510 | [[package]] 511 | name = "hashlink" 512 | version = "0.7.0" 513 | source = "registry+https://github.com/rust-lang/crates.io-index" 514 | checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" 515 | dependencies = [ 516 | "hashbrown", 517 | ] 518 | 519 | [[package]] 520 | name = "heck" 521 | version = "0.3.3" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 524 | dependencies = [ 525 | "unicode-segmentation", 526 | ] 527 | 528 | [[package]] 529 | name = "hermit-abi" 530 | version = "0.1.19" 531 | source = "registry+https://github.com/rust-lang/crates.io-index" 532 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 533 | dependencies = [ 534 | "libc", 535 | ] 536 | 537 | [[package]] 538 | name = "hex" 539 | version = "0.4.3" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 542 | 543 | [[package]] 544 | name = "http" 545 | version = "0.2.6" 546 | source = "registry+https://github.com/rust-lang/crates.io-index" 547 | checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" 548 | dependencies = [ 549 | "bytes 1.1.0", 550 | "fnv", 551 | "itoa 1.0.1", 552 | ] 553 | 554 | [[package]] 555 | name = "http-body" 556 | version = "0.4.4" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" 559 | dependencies = [ 560 | "bytes 1.1.0", 561 | "http", 562 | "pin-project-lite", 563 | ] 564 | 565 | [[package]] 566 | name = "httparse" 567 | version = "1.5.1" 568 | source = "registry+https://github.com/rust-lang/crates.io-index" 569 | checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" 570 | 571 | [[package]] 572 | name = "httpdate" 573 | version = "1.0.2" 574 | source = "registry+https://github.com/rust-lang/crates.io-index" 575 | checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" 576 | 577 | [[package]] 578 | name = "humantime" 579 | version = "2.1.0" 580 | source = "registry+https://github.com/rust-lang/crates.io-index" 581 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 582 | 583 | [[package]] 584 | name = "hyper" 585 | version = "0.14.16" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" 588 | dependencies = [ 589 | "bytes 1.1.0", 590 | "futures-channel", 591 | "futures-core", 592 | "futures-util", 593 | "h2", 594 | "http", 595 | "http-body", 596 | "httparse", 597 | "httpdate", 598 | "itoa 0.4.8", 599 | "pin-project-lite", 600 | "socket2", 601 | "tokio", 602 | "tower-service", 603 | "tracing", 604 | "want", 605 | ] 606 | 607 | [[package]] 608 | name = "hyper-rustls" 609 | version = "0.23.0" 610 | source = "registry+https://github.com/rust-lang/crates.io-index" 611 | checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" 612 | dependencies = [ 613 | "http", 614 | "hyper", 615 | "rustls 0.20.2", 616 | "tokio", 617 | "tokio-rustls 0.23.2", 618 | ] 619 | 620 | [[package]] 621 | name = "idna" 622 | version = "0.2.3" 623 | source = "registry+https://github.com/rust-lang/crates.io-index" 624 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 625 | dependencies = [ 626 | "matches", 627 | "unicode-bidi", 628 | "unicode-normalization", 629 | ] 630 | 631 | [[package]] 632 | name = "indexmap" 633 | version = "1.8.0" 634 | source = "registry+https://github.com/rust-lang/crates.io-index" 635 | checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" 636 | dependencies = [ 637 | "autocfg", 638 | "hashbrown", 639 | ] 640 | 641 | [[package]] 642 | name = "input_buffer" 643 | version = "0.3.1" 644 | source = "registry+https://github.com/rust-lang/crates.io-index" 645 | checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754" 646 | dependencies = [ 647 | "bytes 0.5.6", 648 | ] 649 | 650 | [[package]] 651 | name = "instant" 652 | version = "0.1.12" 653 | source = "registry+https://github.com/rust-lang/crates.io-index" 654 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 655 | dependencies = [ 656 | "cfg-if", 657 | ] 658 | 659 | [[package]] 660 | name = "ipnet" 661 | version = "2.3.1" 662 | source = "registry+https://github.com/rust-lang/crates.io-index" 663 | checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" 664 | 665 | [[package]] 666 | name = "itertools" 667 | version = "0.10.3" 668 | source = "registry+https://github.com/rust-lang/crates.io-index" 669 | checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" 670 | dependencies = [ 671 | "either", 672 | ] 673 | 674 | [[package]] 675 | name = "itoa" 676 | version = "0.4.8" 677 | source = "registry+https://github.com/rust-lang/crates.io-index" 678 | checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" 679 | 680 | [[package]] 681 | name = "itoa" 682 | version = "1.0.1" 683 | source = "registry+https://github.com/rust-lang/crates.io-index" 684 | checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" 685 | 686 | [[package]] 687 | name = "js-sys" 688 | version = "0.3.56" 689 | source = "registry+https://github.com/rust-lang/crates.io-index" 690 | checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" 691 | dependencies = [ 692 | "wasm-bindgen", 693 | ] 694 | 695 | [[package]] 696 | name = "lazy_static" 697 | version = "1.4.0" 698 | source = "registry+https://github.com/rust-lang/crates.io-index" 699 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 700 | 701 | [[package]] 702 | name = "lexical-core" 703 | version = "0.7.6" 704 | source = "registry+https://github.com/rust-lang/crates.io-index" 705 | checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" 706 | dependencies = [ 707 | "arrayvec", 708 | "bitflags", 709 | "cfg-if", 710 | "ryu", 711 | "static_assertions", 712 | ] 713 | 714 | [[package]] 715 | name = "libc" 716 | version = "0.2.114" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "b0005d08a8f7b65fb8073cb697aa0b12b631ed251ce73d862ce50eeb52ce3b50" 719 | 720 | [[package]] 721 | name = "libsqlite3-sys" 722 | version = "0.23.2" 723 | source = "registry+https://github.com/rust-lang/crates.io-index" 724 | checksum = "d2cafc7c74096c336d9d27145f7ebd4f4b6f95ba16aa5a282387267e6925cb58" 725 | dependencies = [ 726 | "cc", 727 | "pkg-config", 728 | "vcpkg", 729 | ] 730 | 731 | [[package]] 732 | name = "linked-hash-map" 733 | version = "0.5.4" 734 | source = "registry+https://github.com/rust-lang/crates.io-index" 735 | checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" 736 | 737 | [[package]] 738 | name = "lock_api" 739 | version = "0.4.5" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" 742 | dependencies = [ 743 | "scopeguard", 744 | ] 745 | 746 | [[package]] 747 | name = "log" 748 | version = "0.4.14" 749 | source = "registry+https://github.com/rust-lang/crates.io-index" 750 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 751 | dependencies = [ 752 | "cfg-if", 753 | ] 754 | 755 | [[package]] 756 | name = "matches" 757 | version = "0.1.9" 758 | source = "registry+https://github.com/rust-lang/crates.io-index" 759 | checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" 760 | 761 | [[package]] 762 | name = "memchr" 763 | version = "2.4.1" 764 | source = "registry+https://github.com/rust-lang/crates.io-index" 765 | checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 766 | 767 | [[package]] 768 | name = "mime" 769 | version = "0.3.16" 770 | source = "registry+https://github.com/rust-lang/crates.io-index" 771 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 772 | 773 | [[package]] 774 | name = "mime_guess" 775 | version = "2.0.3" 776 | source = "registry+https://github.com/rust-lang/crates.io-index" 777 | checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" 778 | dependencies = [ 779 | "mime", 780 | "unicase", 781 | ] 782 | 783 | [[package]] 784 | name = "minimal-lexical" 785 | version = "0.2.1" 786 | source = "registry+https://github.com/rust-lang/crates.io-index" 787 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 788 | 789 | [[package]] 790 | name = "miniz_oxide" 791 | version = "0.4.4" 792 | source = "registry+https://github.com/rust-lang/crates.io-index" 793 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 794 | dependencies = [ 795 | "adler", 796 | "autocfg", 797 | ] 798 | 799 | [[package]] 800 | name = "mio" 801 | version = "0.7.14" 802 | source = "registry+https://github.com/rust-lang/crates.io-index" 803 | checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" 804 | dependencies = [ 805 | "libc", 806 | "log", 807 | "miow", 808 | "ntapi", 809 | "winapi", 810 | ] 811 | 812 | [[package]] 813 | name = "miow" 814 | version = "0.3.7" 815 | source = "registry+https://github.com/rust-lang/crates.io-index" 816 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 817 | dependencies = [ 818 | "winapi", 819 | ] 820 | 821 | [[package]] 822 | name = "nom" 823 | version = "5.1.2" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" 826 | dependencies = [ 827 | "lexical-core", 828 | "memchr", 829 | "version_check", 830 | ] 831 | 832 | [[package]] 833 | name = "nom" 834 | version = "7.1.0" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" 837 | dependencies = [ 838 | "memchr", 839 | "minimal-lexical", 840 | "version_check", 841 | ] 842 | 843 | [[package]] 844 | name = "ntapi" 845 | version = "0.3.6" 846 | source = "registry+https://github.com/rust-lang/crates.io-index" 847 | checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" 848 | dependencies = [ 849 | "winapi", 850 | ] 851 | 852 | [[package]] 853 | name = "num-integer" 854 | version = "0.1.44" 855 | source = "registry+https://github.com/rust-lang/crates.io-index" 856 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" 857 | dependencies = [ 858 | "autocfg", 859 | "num-traits 0.2.14", 860 | ] 861 | 862 | [[package]] 863 | name = "num-traits" 864 | version = "0.1.43" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" 867 | dependencies = [ 868 | "num-traits 0.2.14", 869 | ] 870 | 871 | [[package]] 872 | name = "num-traits" 873 | version = "0.2.14" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 876 | dependencies = [ 877 | "autocfg", 878 | ] 879 | 880 | [[package]] 881 | name = "num_cpus" 882 | version = "1.13.1" 883 | source = "registry+https://github.com/rust-lang/crates.io-index" 884 | checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" 885 | dependencies = [ 886 | "hermit-abi", 887 | "libc", 888 | ] 889 | 890 | [[package]] 891 | name = "once_cell" 892 | version = "1.9.0" 893 | source = "registry+https://github.com/rust-lang/crates.io-index" 894 | checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" 895 | 896 | [[package]] 897 | name = "opaque-debug" 898 | version = "0.3.0" 899 | source = "registry+https://github.com/rust-lang/crates.io-index" 900 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" 901 | 902 | [[package]] 903 | name = "parking_lot" 904 | version = "0.11.2" 905 | source = "registry+https://github.com/rust-lang/crates.io-index" 906 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 907 | dependencies = [ 908 | "instant", 909 | "lock_api", 910 | "parking_lot_core", 911 | ] 912 | 913 | [[package]] 914 | name = "parking_lot_core" 915 | version = "0.8.5" 916 | source = "registry+https://github.com/rust-lang/crates.io-index" 917 | checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" 918 | dependencies = [ 919 | "cfg-if", 920 | "instant", 921 | "libc", 922 | "redox_syscall", 923 | "smallvec", 924 | "winapi", 925 | ] 926 | 927 | [[package]] 928 | name = "percent-encoding" 929 | version = "2.1.0" 930 | source = "registry+https://github.com/rust-lang/crates.io-index" 931 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 932 | 933 | [[package]] 934 | name = "pin-project" 935 | version = "1.0.10" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" 938 | dependencies = [ 939 | "pin-project-internal", 940 | ] 941 | 942 | [[package]] 943 | name = "pin-project-internal" 944 | version = "1.0.10" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" 947 | dependencies = [ 948 | "proc-macro2", 949 | "quote", 950 | "syn", 951 | ] 952 | 953 | [[package]] 954 | name = "pin-project-lite" 955 | version = "0.2.8" 956 | source = "registry+https://github.com/rust-lang/crates.io-index" 957 | checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" 958 | 959 | [[package]] 960 | name = "pin-utils" 961 | version = "0.1.0" 962 | source = "registry+https://github.com/rust-lang/crates.io-index" 963 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 964 | 965 | [[package]] 966 | name = "pkg-config" 967 | version = "0.3.24" 968 | source = "registry+https://github.com/rust-lang/crates.io-index" 969 | checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" 970 | 971 | [[package]] 972 | name = "ppv-lite86" 973 | version = "0.2.16" 974 | source = "registry+https://github.com/rust-lang/crates.io-index" 975 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 976 | 977 | [[package]] 978 | name = "proc-macro2" 979 | version = "1.0.36" 980 | source = "registry+https://github.com/rust-lang/crates.io-index" 981 | checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" 982 | dependencies = [ 983 | "unicode-xid", 984 | ] 985 | 986 | [[package]] 987 | name = "quote" 988 | version = "1.0.15" 989 | source = "registry+https://github.com/rust-lang/crates.io-index" 990 | checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" 991 | dependencies = [ 992 | "proc-macro2", 993 | ] 994 | 995 | [[package]] 996 | name = "rand" 997 | version = "0.7.3" 998 | source = "registry+https://github.com/rust-lang/crates.io-index" 999 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" 1000 | dependencies = [ 1001 | "getrandom 0.1.16", 1002 | "libc", 1003 | "rand_chacha 0.2.2", 1004 | "rand_core 0.5.1", 1005 | "rand_hc 0.2.0", 1006 | ] 1007 | 1008 | [[package]] 1009 | name = "rand" 1010 | version = "0.8.4" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" 1013 | dependencies = [ 1014 | "libc", 1015 | "rand_chacha 0.3.1", 1016 | "rand_core 0.6.3", 1017 | "rand_hc 0.3.1", 1018 | ] 1019 | 1020 | [[package]] 1021 | name = "rand_chacha" 1022 | version = "0.2.2" 1023 | source = "registry+https://github.com/rust-lang/crates.io-index" 1024 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" 1025 | dependencies = [ 1026 | "ppv-lite86", 1027 | "rand_core 0.5.1", 1028 | ] 1029 | 1030 | [[package]] 1031 | name = "rand_chacha" 1032 | version = "0.3.1" 1033 | source = "registry+https://github.com/rust-lang/crates.io-index" 1034 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1035 | dependencies = [ 1036 | "ppv-lite86", 1037 | "rand_core 0.6.3", 1038 | ] 1039 | 1040 | [[package]] 1041 | name = "rand_core" 1042 | version = "0.5.1" 1043 | source = "registry+https://github.com/rust-lang/crates.io-index" 1044 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 1045 | dependencies = [ 1046 | "getrandom 0.1.16", 1047 | ] 1048 | 1049 | [[package]] 1050 | name = "rand_core" 1051 | version = "0.6.3" 1052 | source = "registry+https://github.com/rust-lang/crates.io-index" 1053 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 1054 | dependencies = [ 1055 | "getrandom 0.2.4", 1056 | ] 1057 | 1058 | [[package]] 1059 | name = "rand_hc" 1060 | version = "0.2.0" 1061 | source = "registry+https://github.com/rust-lang/crates.io-index" 1062 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 1063 | dependencies = [ 1064 | "rand_core 0.5.1", 1065 | ] 1066 | 1067 | [[package]] 1068 | name = "rand_hc" 1069 | version = "0.3.1" 1070 | source = "registry+https://github.com/rust-lang/crates.io-index" 1071 | checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" 1072 | dependencies = [ 1073 | "rand_core 0.6.3", 1074 | ] 1075 | 1076 | [[package]] 1077 | name = "redox_syscall" 1078 | version = "0.2.10" 1079 | source = "registry+https://github.com/rust-lang/crates.io-index" 1080 | checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" 1081 | dependencies = [ 1082 | "bitflags", 1083 | ] 1084 | 1085 | [[package]] 1086 | name = "regex" 1087 | version = "1.5.4" 1088 | source = "registry+https://github.com/rust-lang/crates.io-index" 1089 | checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" 1090 | dependencies = [ 1091 | "aho-corasick", 1092 | "memchr", 1093 | "regex-syntax", 1094 | ] 1095 | 1096 | [[package]] 1097 | name = "regex-syntax" 1098 | version = "0.6.25" 1099 | source = "registry+https://github.com/rust-lang/crates.io-index" 1100 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 1101 | 1102 | [[package]] 1103 | name = "reqwest" 1104 | version = "0.11.9" 1105 | source = "registry+https://github.com/rust-lang/crates.io-index" 1106 | checksum = "87f242f1488a539a79bac6dbe7c8609ae43b7914b7736210f239a37cccb32525" 1107 | dependencies = [ 1108 | "base64 0.13.0", 1109 | "bytes 1.1.0", 1110 | "encoding_rs", 1111 | "futures-core", 1112 | "futures-util", 1113 | "h2", 1114 | "http", 1115 | "http-body", 1116 | "hyper", 1117 | "hyper-rustls", 1118 | "ipnet", 1119 | "js-sys", 1120 | "lazy_static", 1121 | "log", 1122 | "mime", 1123 | "mime_guess", 1124 | "percent-encoding", 1125 | "pin-project-lite", 1126 | "rustls 0.20.2", 1127 | "rustls-pemfile", 1128 | "serde 1.0.136", 1129 | "serde_json", 1130 | "serde_urlencoded", 1131 | "tokio", 1132 | "tokio-rustls 0.23.2", 1133 | "tokio-util", 1134 | "url", 1135 | "wasm-bindgen", 1136 | "wasm-bindgen-futures", 1137 | "web-sys", 1138 | "webpki-roots 0.22.2", 1139 | "winreg", 1140 | ] 1141 | 1142 | [[package]] 1143 | name = "ring" 1144 | version = "0.16.20" 1145 | source = "registry+https://github.com/rust-lang/crates.io-index" 1146 | checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" 1147 | dependencies = [ 1148 | "cc", 1149 | "libc", 1150 | "once_cell", 1151 | "spin 0.5.2", 1152 | "untrusted", 1153 | "web-sys", 1154 | "winapi", 1155 | ] 1156 | 1157 | [[package]] 1158 | name = "rust-ini" 1159 | version = "0.13.0" 1160 | source = "registry+https://github.com/rust-lang/crates.io-index" 1161 | checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" 1162 | 1163 | [[package]] 1164 | name = "rustls" 1165 | version = "0.19.1" 1166 | source = "registry+https://github.com/rust-lang/crates.io-index" 1167 | checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" 1168 | dependencies = [ 1169 | "base64 0.13.0", 1170 | "log", 1171 | "ring", 1172 | "sct 0.6.1", 1173 | "webpki 0.21.4", 1174 | ] 1175 | 1176 | [[package]] 1177 | name = "rustls" 1178 | version = "0.20.2" 1179 | source = "registry+https://github.com/rust-lang/crates.io-index" 1180 | checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" 1181 | dependencies = [ 1182 | "log", 1183 | "ring", 1184 | "sct 0.7.0", 1185 | "webpki 0.22.0", 1186 | ] 1187 | 1188 | [[package]] 1189 | name = "rustls-pemfile" 1190 | version = "0.2.1" 1191 | source = "registry+https://github.com/rust-lang/crates.io-index" 1192 | checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" 1193 | dependencies = [ 1194 | "base64 0.13.0", 1195 | ] 1196 | 1197 | [[package]] 1198 | name = "ryu" 1199 | version = "1.0.9" 1200 | source = "registry+https://github.com/rust-lang/crates.io-index" 1201 | checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" 1202 | 1203 | [[package]] 1204 | name = "scopeguard" 1205 | version = "1.1.0" 1206 | source = "registry+https://github.com/rust-lang/crates.io-index" 1207 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1208 | 1209 | [[package]] 1210 | name = "sct" 1211 | version = "0.6.1" 1212 | source = "registry+https://github.com/rust-lang/crates.io-index" 1213 | checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" 1214 | dependencies = [ 1215 | "ring", 1216 | "untrusted", 1217 | ] 1218 | 1219 | [[package]] 1220 | name = "sct" 1221 | version = "0.7.0" 1222 | source = "registry+https://github.com/rust-lang/crates.io-index" 1223 | checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" 1224 | dependencies = [ 1225 | "ring", 1226 | "untrusted", 1227 | ] 1228 | 1229 | [[package]] 1230 | name = "serde" 1231 | version = "0.8.23" 1232 | source = "registry+https://github.com/rust-lang/crates.io-index" 1233 | checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" 1234 | 1235 | [[package]] 1236 | name = "serde" 1237 | version = "1.0.136" 1238 | source = "registry+https://github.com/rust-lang/crates.io-index" 1239 | checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" 1240 | dependencies = [ 1241 | "serde_derive", 1242 | ] 1243 | 1244 | [[package]] 1245 | name = "serde-hjson" 1246 | version = "0.9.1" 1247 | source = "registry+https://github.com/rust-lang/crates.io-index" 1248 | checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8" 1249 | dependencies = [ 1250 | "lazy_static", 1251 | "num-traits 0.1.43", 1252 | "regex", 1253 | "serde 0.8.23", 1254 | ] 1255 | 1256 | [[package]] 1257 | name = "serde_derive" 1258 | version = "1.0.136" 1259 | source = "registry+https://github.com/rust-lang/crates.io-index" 1260 | checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" 1261 | dependencies = [ 1262 | "proc-macro2", 1263 | "quote", 1264 | "syn", 1265 | ] 1266 | 1267 | [[package]] 1268 | name = "serde_json" 1269 | version = "1.0.78" 1270 | source = "registry+https://github.com/rust-lang/crates.io-index" 1271 | checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" 1272 | dependencies = [ 1273 | "indexmap", 1274 | "itoa 1.0.1", 1275 | "ryu", 1276 | "serde 1.0.136", 1277 | ] 1278 | 1279 | [[package]] 1280 | name = "serde_urlencoded" 1281 | version = "0.7.1" 1282 | source = "registry+https://github.com/rust-lang/crates.io-index" 1283 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 1284 | dependencies = [ 1285 | "form_urlencoded", 1286 | "itoa 1.0.1", 1287 | "ryu", 1288 | "serde 1.0.136", 1289 | ] 1290 | 1291 | [[package]] 1292 | name = "serenity" 1293 | version = "0.10.10" 1294 | source = "registry+https://github.com/rust-lang/crates.io-index" 1295 | checksum = "dde86919535c6047e055d512641c5241320c01cb8fee54f1e5ba77c939a0ec23" 1296 | dependencies = [ 1297 | "async-trait", 1298 | "async-tungstenite", 1299 | "base64 0.13.0", 1300 | "bitflags", 1301 | "bytes 1.1.0", 1302 | "chrono", 1303 | "command_attr", 1304 | "flate2", 1305 | "futures", 1306 | "percent-encoding", 1307 | "reqwest", 1308 | "serde 1.0.136", 1309 | "serde_json", 1310 | "static_assertions", 1311 | "tokio", 1312 | "tracing", 1313 | "typemap_rev", 1314 | "url", 1315 | "uwl", 1316 | ] 1317 | 1318 | [[package]] 1319 | name = "sha-1" 1320 | version = "0.9.8" 1321 | source = "registry+https://github.com/rust-lang/crates.io-index" 1322 | checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" 1323 | dependencies = [ 1324 | "block-buffer", 1325 | "cfg-if", 1326 | "cpufeatures", 1327 | "digest", 1328 | "opaque-debug", 1329 | ] 1330 | 1331 | [[package]] 1332 | name = "sha2" 1333 | version = "0.9.9" 1334 | source = "registry+https://github.com/rust-lang/crates.io-index" 1335 | checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" 1336 | dependencies = [ 1337 | "block-buffer", 1338 | "cfg-if", 1339 | "cpufeatures", 1340 | "digest", 1341 | "opaque-debug", 1342 | ] 1343 | 1344 | [[package]] 1345 | name = "slab" 1346 | version = "0.4.5" 1347 | source = "registry+https://github.com/rust-lang/crates.io-index" 1348 | checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" 1349 | 1350 | [[package]] 1351 | name = "smallvec" 1352 | version = "1.8.0" 1353 | source = "registry+https://github.com/rust-lang/crates.io-index" 1354 | checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" 1355 | 1356 | [[package]] 1357 | name = "socket2" 1358 | version = "0.4.3" 1359 | source = "registry+https://github.com/rust-lang/crates.io-index" 1360 | checksum = "0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b" 1361 | dependencies = [ 1362 | "libc", 1363 | "winapi", 1364 | ] 1365 | 1366 | [[package]] 1367 | name = "spin" 1368 | version = "0.5.2" 1369 | source = "registry+https://github.com/rust-lang/crates.io-index" 1370 | checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" 1371 | 1372 | [[package]] 1373 | name = "spin" 1374 | version = "0.9.2" 1375 | source = "registry+https://github.com/rust-lang/crates.io-index" 1376 | checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5" 1377 | dependencies = [ 1378 | "lock_api", 1379 | ] 1380 | 1381 | [[package]] 1382 | name = "sqlformat" 1383 | version = "0.1.8" 1384 | source = "registry+https://github.com/rust-lang/crates.io-index" 1385 | checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4" 1386 | dependencies = [ 1387 | "itertools", 1388 | "nom 7.1.0", 1389 | "unicode_categories", 1390 | ] 1391 | 1392 | [[package]] 1393 | name = "sqlx" 1394 | version = "0.5.10" 1395 | source = "registry+https://github.com/rust-lang/crates.io-index" 1396 | checksum = "692749de69603d81e016212199d73a2e14ee20e2def7d7914919e8db5d4d48b9" 1397 | dependencies = [ 1398 | "sqlx-core", 1399 | "sqlx-macros", 1400 | ] 1401 | 1402 | [[package]] 1403 | name = "sqlx-core" 1404 | version = "0.5.10" 1405 | source = "registry+https://github.com/rust-lang/crates.io-index" 1406 | checksum = "518be6f6fff5ca76f985d434f9c37f3662af279642acf730388f271dff7b9016" 1407 | dependencies = [ 1408 | "ahash", 1409 | "atoi", 1410 | "bitflags", 1411 | "byteorder", 1412 | "bytes 1.1.0", 1413 | "crc", 1414 | "crossbeam-channel", 1415 | "crossbeam-queue", 1416 | "crossbeam-utils", 1417 | "either", 1418 | "flume", 1419 | "futures-channel", 1420 | "futures-core", 1421 | "futures-executor", 1422 | "futures-intrusive", 1423 | "futures-util", 1424 | "hashlink", 1425 | "hex", 1426 | "indexmap", 1427 | "itoa 1.0.1", 1428 | "libc", 1429 | "libsqlite3-sys", 1430 | "log", 1431 | "memchr", 1432 | "once_cell", 1433 | "parking_lot", 1434 | "percent-encoding", 1435 | "rustls 0.19.1", 1436 | "serde 1.0.136", 1437 | "sha2", 1438 | "smallvec", 1439 | "sqlformat", 1440 | "sqlx-rt", 1441 | "stringprep", 1442 | "thiserror", 1443 | "tokio-stream", 1444 | "url", 1445 | "webpki 0.21.4", 1446 | "webpki-roots 0.21.1", 1447 | ] 1448 | 1449 | [[package]] 1450 | name = "sqlx-macros" 1451 | version = "0.5.10" 1452 | source = "registry+https://github.com/rust-lang/crates.io-index" 1453 | checksum = "38e45140529cf1f90a5e1c2e561500ca345821a1c513652c8f486bbf07407cc8" 1454 | dependencies = [ 1455 | "dotenv", 1456 | "either", 1457 | "heck", 1458 | "hex", 1459 | "once_cell", 1460 | "proc-macro2", 1461 | "quote", 1462 | "serde 1.0.136", 1463 | "serde_json", 1464 | "sha2", 1465 | "sqlx-core", 1466 | "sqlx-rt", 1467 | "syn", 1468 | "url", 1469 | ] 1470 | 1471 | [[package]] 1472 | name = "sqlx-rt" 1473 | version = "0.5.10" 1474 | source = "registry+https://github.com/rust-lang/crates.io-index" 1475 | checksum = "8061cbaa91ee75041514f67a09398c65a64efed72c90151ecd47593bad53da99" 1476 | dependencies = [ 1477 | "once_cell", 1478 | "tokio", 1479 | "tokio-rustls 0.22.0", 1480 | ] 1481 | 1482 | [[package]] 1483 | name = "static_assertions" 1484 | version = "1.1.0" 1485 | source = "registry+https://github.com/rust-lang/crates.io-index" 1486 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1487 | 1488 | [[package]] 1489 | name = "stringprep" 1490 | version = "0.1.2" 1491 | source = "registry+https://github.com/rust-lang/crates.io-index" 1492 | checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" 1493 | dependencies = [ 1494 | "unicode-bidi", 1495 | "unicode-normalization", 1496 | ] 1497 | 1498 | [[package]] 1499 | name = "syn" 1500 | version = "1.0.86" 1501 | source = "registry+https://github.com/rust-lang/crates.io-index" 1502 | checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" 1503 | dependencies = [ 1504 | "proc-macro2", 1505 | "quote", 1506 | "unicode-xid", 1507 | ] 1508 | 1509 | [[package]] 1510 | name = "termcolor" 1511 | version = "1.1.2" 1512 | source = "registry+https://github.com/rust-lang/crates.io-index" 1513 | checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" 1514 | dependencies = [ 1515 | "winapi-util", 1516 | ] 1517 | 1518 | [[package]] 1519 | name = "thiserror" 1520 | version = "1.0.30" 1521 | source = "registry+https://github.com/rust-lang/crates.io-index" 1522 | checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" 1523 | dependencies = [ 1524 | "thiserror-impl", 1525 | ] 1526 | 1527 | [[package]] 1528 | name = "thiserror-impl" 1529 | version = "1.0.30" 1530 | source = "registry+https://github.com/rust-lang/crates.io-index" 1531 | checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" 1532 | dependencies = [ 1533 | "proc-macro2", 1534 | "quote", 1535 | "syn", 1536 | ] 1537 | 1538 | [[package]] 1539 | name = "tinyvec" 1540 | version = "1.5.1" 1541 | source = "registry+https://github.com/rust-lang/crates.io-index" 1542 | checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" 1543 | dependencies = [ 1544 | "tinyvec_macros", 1545 | ] 1546 | 1547 | [[package]] 1548 | name = "tinyvec_macros" 1549 | version = "0.1.0" 1550 | source = "registry+https://github.com/rust-lang/crates.io-index" 1551 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 1552 | 1553 | [[package]] 1554 | name = "tokio" 1555 | version = "1.15.0" 1556 | source = "registry+https://github.com/rust-lang/crates.io-index" 1557 | checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" 1558 | dependencies = [ 1559 | "bytes 1.1.0", 1560 | "libc", 1561 | "memchr", 1562 | "mio", 1563 | "num_cpus", 1564 | "pin-project-lite", 1565 | "tokio-macros", 1566 | "winapi", 1567 | ] 1568 | 1569 | [[package]] 1570 | name = "tokio-macros" 1571 | version = "1.7.0" 1572 | source = "registry+https://github.com/rust-lang/crates.io-index" 1573 | checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" 1574 | dependencies = [ 1575 | "proc-macro2", 1576 | "quote", 1577 | "syn", 1578 | ] 1579 | 1580 | [[package]] 1581 | name = "tokio-rustls" 1582 | version = "0.22.0" 1583 | source = "registry+https://github.com/rust-lang/crates.io-index" 1584 | checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" 1585 | dependencies = [ 1586 | "rustls 0.19.1", 1587 | "tokio", 1588 | "webpki 0.21.4", 1589 | ] 1590 | 1591 | [[package]] 1592 | name = "tokio-rustls" 1593 | version = "0.23.2" 1594 | source = "registry+https://github.com/rust-lang/crates.io-index" 1595 | checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" 1596 | dependencies = [ 1597 | "rustls 0.20.2", 1598 | "tokio", 1599 | "webpki 0.22.0", 1600 | ] 1601 | 1602 | [[package]] 1603 | name = "tokio-stream" 1604 | version = "0.1.8" 1605 | source = "registry+https://github.com/rust-lang/crates.io-index" 1606 | checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3" 1607 | dependencies = [ 1608 | "futures-core", 1609 | "pin-project-lite", 1610 | "tokio", 1611 | ] 1612 | 1613 | [[package]] 1614 | name = "tokio-util" 1615 | version = "0.6.9" 1616 | source = "registry+https://github.com/rust-lang/crates.io-index" 1617 | checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" 1618 | dependencies = [ 1619 | "bytes 1.1.0", 1620 | "futures-core", 1621 | "futures-sink", 1622 | "log", 1623 | "pin-project-lite", 1624 | "tokio", 1625 | ] 1626 | 1627 | [[package]] 1628 | name = "toml" 1629 | version = "0.5.8" 1630 | source = "registry+https://github.com/rust-lang/crates.io-index" 1631 | checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" 1632 | dependencies = [ 1633 | "serde 1.0.136", 1634 | ] 1635 | 1636 | [[package]] 1637 | name = "tower-service" 1638 | version = "0.3.1" 1639 | source = "registry+https://github.com/rust-lang/crates.io-index" 1640 | checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" 1641 | 1642 | [[package]] 1643 | name = "tracing" 1644 | version = "0.1.29" 1645 | source = "registry+https://github.com/rust-lang/crates.io-index" 1646 | checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" 1647 | dependencies = [ 1648 | "cfg-if", 1649 | "log", 1650 | "pin-project-lite", 1651 | "tracing-attributes", 1652 | "tracing-core", 1653 | ] 1654 | 1655 | [[package]] 1656 | name = "tracing-attributes" 1657 | version = "0.1.18" 1658 | source = "registry+https://github.com/rust-lang/crates.io-index" 1659 | checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" 1660 | dependencies = [ 1661 | "proc-macro2", 1662 | "quote", 1663 | "syn", 1664 | ] 1665 | 1666 | [[package]] 1667 | name = "tracing-core" 1668 | version = "0.1.21" 1669 | source = "registry+https://github.com/rust-lang/crates.io-index" 1670 | checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" 1671 | dependencies = [ 1672 | "lazy_static", 1673 | ] 1674 | 1675 | [[package]] 1676 | name = "try-lock" 1677 | version = "0.2.3" 1678 | source = "registry+https://github.com/rust-lang/crates.io-index" 1679 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" 1680 | 1681 | [[package]] 1682 | name = "tungstenite" 1683 | version = "0.11.1" 1684 | source = "registry+https://github.com/rust-lang/crates.io-index" 1685 | checksum = "f0308d80d86700c5878b9ef6321f020f29b1bb9d5ff3cab25e75e23f3a492a23" 1686 | dependencies = [ 1687 | "base64 0.12.3", 1688 | "byteorder", 1689 | "bytes 0.5.6", 1690 | "http", 1691 | "httparse", 1692 | "input_buffer", 1693 | "log", 1694 | "rand 0.7.3", 1695 | "sha-1", 1696 | "url", 1697 | "utf-8", 1698 | ] 1699 | 1700 | [[package]] 1701 | name = "typemap_rev" 1702 | version = "0.1.5" 1703 | source = "registry+https://github.com/rust-lang/crates.io-index" 1704 | checksum = "ed5b74f0a24b5454580a79abb6994393b09adf0ab8070f15827cb666255de155" 1705 | 1706 | [[package]] 1707 | name = "typenum" 1708 | version = "1.15.0" 1709 | source = "registry+https://github.com/rust-lang/crates.io-index" 1710 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 1711 | 1712 | [[package]] 1713 | name = "unicase" 1714 | version = "2.6.0" 1715 | source = "registry+https://github.com/rust-lang/crates.io-index" 1716 | checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" 1717 | dependencies = [ 1718 | "version_check", 1719 | ] 1720 | 1721 | [[package]] 1722 | name = "unicode-bidi" 1723 | version = "0.3.7" 1724 | source = "registry+https://github.com/rust-lang/crates.io-index" 1725 | checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" 1726 | 1727 | [[package]] 1728 | name = "unicode-normalization" 1729 | version = "0.1.19" 1730 | source = "registry+https://github.com/rust-lang/crates.io-index" 1731 | checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" 1732 | dependencies = [ 1733 | "tinyvec", 1734 | ] 1735 | 1736 | [[package]] 1737 | name = "unicode-segmentation" 1738 | version = "1.8.0" 1739 | source = "registry+https://github.com/rust-lang/crates.io-index" 1740 | checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" 1741 | 1742 | [[package]] 1743 | name = "unicode-xid" 1744 | version = "0.2.2" 1745 | source = "registry+https://github.com/rust-lang/crates.io-index" 1746 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 1747 | 1748 | [[package]] 1749 | name = "unicode_categories" 1750 | version = "0.1.1" 1751 | source = "registry+https://github.com/rust-lang/crates.io-index" 1752 | checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" 1753 | 1754 | [[package]] 1755 | name = "untrusted" 1756 | version = "0.7.1" 1757 | source = "registry+https://github.com/rust-lang/crates.io-index" 1758 | checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" 1759 | 1760 | [[package]] 1761 | name = "url" 1762 | version = "2.2.2" 1763 | source = "registry+https://github.com/rust-lang/crates.io-index" 1764 | checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 1765 | dependencies = [ 1766 | "form_urlencoded", 1767 | "idna", 1768 | "matches", 1769 | "percent-encoding", 1770 | ] 1771 | 1772 | [[package]] 1773 | name = "utf-8" 1774 | version = "0.7.6" 1775 | source = "registry+https://github.com/rust-lang/crates.io-index" 1776 | checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" 1777 | 1778 | [[package]] 1779 | name = "uwl" 1780 | version = "0.6.0" 1781 | source = "registry+https://github.com/rust-lang/crates.io-index" 1782 | checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0" 1783 | 1784 | [[package]] 1785 | name = "vcpkg" 1786 | version = "0.2.15" 1787 | source = "registry+https://github.com/rust-lang/crates.io-index" 1788 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 1789 | 1790 | [[package]] 1791 | name = "version_check" 1792 | version = "0.9.4" 1793 | source = "registry+https://github.com/rust-lang/crates.io-index" 1794 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1795 | 1796 | [[package]] 1797 | name = "want" 1798 | version = "0.3.0" 1799 | source = "registry+https://github.com/rust-lang/crates.io-index" 1800 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 1801 | dependencies = [ 1802 | "log", 1803 | "try-lock", 1804 | ] 1805 | 1806 | [[package]] 1807 | name = "wasi" 1808 | version = "0.9.0+wasi-snapshot-preview1" 1809 | source = "registry+https://github.com/rust-lang/crates.io-index" 1810 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" 1811 | 1812 | [[package]] 1813 | name = "wasi" 1814 | version = "0.10.2+wasi-snapshot-preview1" 1815 | source = "registry+https://github.com/rust-lang/crates.io-index" 1816 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 1817 | 1818 | [[package]] 1819 | name = "wasm-bindgen" 1820 | version = "0.2.79" 1821 | source = "registry+https://github.com/rust-lang/crates.io-index" 1822 | checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" 1823 | dependencies = [ 1824 | "cfg-if", 1825 | "wasm-bindgen-macro", 1826 | ] 1827 | 1828 | [[package]] 1829 | name = "wasm-bindgen-backend" 1830 | version = "0.2.79" 1831 | source = "registry+https://github.com/rust-lang/crates.io-index" 1832 | checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" 1833 | dependencies = [ 1834 | "bumpalo", 1835 | "lazy_static", 1836 | "log", 1837 | "proc-macro2", 1838 | "quote", 1839 | "syn", 1840 | "wasm-bindgen-shared", 1841 | ] 1842 | 1843 | [[package]] 1844 | name = "wasm-bindgen-futures" 1845 | version = "0.4.29" 1846 | source = "registry+https://github.com/rust-lang/crates.io-index" 1847 | checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" 1848 | dependencies = [ 1849 | "cfg-if", 1850 | "js-sys", 1851 | "wasm-bindgen", 1852 | "web-sys", 1853 | ] 1854 | 1855 | [[package]] 1856 | name = "wasm-bindgen-macro" 1857 | version = "0.2.79" 1858 | source = "registry+https://github.com/rust-lang/crates.io-index" 1859 | checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" 1860 | dependencies = [ 1861 | "quote", 1862 | "wasm-bindgen-macro-support", 1863 | ] 1864 | 1865 | [[package]] 1866 | name = "wasm-bindgen-macro-support" 1867 | version = "0.2.79" 1868 | source = "registry+https://github.com/rust-lang/crates.io-index" 1869 | checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" 1870 | dependencies = [ 1871 | "proc-macro2", 1872 | "quote", 1873 | "syn", 1874 | "wasm-bindgen-backend", 1875 | "wasm-bindgen-shared", 1876 | ] 1877 | 1878 | [[package]] 1879 | name = "wasm-bindgen-shared" 1880 | version = "0.2.79" 1881 | source = "registry+https://github.com/rust-lang/crates.io-index" 1882 | checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" 1883 | 1884 | [[package]] 1885 | name = "web-sys" 1886 | version = "0.3.56" 1887 | source = "registry+https://github.com/rust-lang/crates.io-index" 1888 | checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" 1889 | dependencies = [ 1890 | "js-sys", 1891 | "wasm-bindgen", 1892 | ] 1893 | 1894 | [[package]] 1895 | name = "webpki" 1896 | version = "0.21.4" 1897 | source = "registry+https://github.com/rust-lang/crates.io-index" 1898 | checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" 1899 | dependencies = [ 1900 | "ring", 1901 | "untrusted", 1902 | ] 1903 | 1904 | [[package]] 1905 | name = "webpki" 1906 | version = "0.22.0" 1907 | source = "registry+https://github.com/rust-lang/crates.io-index" 1908 | checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" 1909 | dependencies = [ 1910 | "ring", 1911 | "untrusted", 1912 | ] 1913 | 1914 | [[package]] 1915 | name = "webpki-roots" 1916 | version = "0.20.0" 1917 | source = "registry+https://github.com/rust-lang/crates.io-index" 1918 | checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f" 1919 | dependencies = [ 1920 | "webpki 0.21.4", 1921 | ] 1922 | 1923 | [[package]] 1924 | name = "webpki-roots" 1925 | version = "0.21.1" 1926 | source = "registry+https://github.com/rust-lang/crates.io-index" 1927 | checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" 1928 | dependencies = [ 1929 | "webpki 0.21.4", 1930 | ] 1931 | 1932 | [[package]] 1933 | name = "webpki-roots" 1934 | version = "0.22.2" 1935 | source = "registry+https://github.com/rust-lang/crates.io-index" 1936 | checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" 1937 | dependencies = [ 1938 | "webpki 0.22.0", 1939 | ] 1940 | 1941 | [[package]] 1942 | name = "winapi" 1943 | version = "0.3.9" 1944 | source = "registry+https://github.com/rust-lang/crates.io-index" 1945 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1946 | dependencies = [ 1947 | "winapi-i686-pc-windows-gnu", 1948 | "winapi-x86_64-pc-windows-gnu", 1949 | ] 1950 | 1951 | [[package]] 1952 | name = "winapi-i686-pc-windows-gnu" 1953 | version = "0.4.0" 1954 | source = "registry+https://github.com/rust-lang/crates.io-index" 1955 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1956 | 1957 | [[package]] 1958 | name = "winapi-util" 1959 | version = "0.1.5" 1960 | source = "registry+https://github.com/rust-lang/crates.io-index" 1961 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1962 | dependencies = [ 1963 | "winapi", 1964 | ] 1965 | 1966 | [[package]] 1967 | name = "winapi-x86_64-pc-windows-gnu" 1968 | version = "0.4.0" 1969 | source = "registry+https://github.com/rust-lang/crates.io-index" 1970 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1971 | 1972 | [[package]] 1973 | name = "winreg" 1974 | version = "0.7.0" 1975 | source = "registry+https://github.com/rust-lang/crates.io-index" 1976 | checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" 1977 | dependencies = [ 1978 | "winapi", 1979 | ] 1980 | 1981 | [[package]] 1982 | name = "yaml-rust" 1983 | version = "0.4.5" 1984 | source = "registry+https://github.com/rust-lang/crates.io-index" 1985 | checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" 1986 | dependencies = [ 1987 | "linked-hash-map", 1988 | ] 1989 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bot" 3 | version = "0.1.0" 4 | authors = ["Elinvynia <59487684+Elinvynia@users.noreply.github.com>"] 5 | edition = "2021" 6 | 7 | 8 | [dependencies] 9 | serenity = { version = "0.10", features = ["collector"] } 10 | tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } 11 | sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "sqlite", "offline"] } 12 | anyhow = "1.0" 13 | 14 | # Utils 15 | rand = "0.8" 16 | 17 | # Logging 18 | dotenv = "0.15" 19 | config = "0.11" 20 | log = "0.4" 21 | env_logger = "0.9" 22 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2020 Elinvynia 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright 2020 Elinvynia 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![ci-badge]][ci] 2 | 3 | # Elin Bot 4 | 5 | A Discord bot written using the Serenity framework in Rust. With a focus on proper logging and zero embeds, this general purpose bot was made to fill in the gap in the market. Everyone is encouraged to run their own. 6 | 7 | ## Setup 8 | 1. Clone the repository. 9 | 2. `cargo build` to get the executable. 10 | 3. Open `config.toml` and insert your Discord bot token. 11 | 4. `cargo run` to run the bot. 12 | 13 | [ci]: https://github.com/Elinvynia/hnews/actions?query=workflow%3ARust 14 | [ci-badge]: https://img.shields.io/github/workflow/status/Elinvynia/hnews/Rust/master?style=flat-square 15 | -------------------------------------------------------------------------------- /config.toml: -------------------------------------------------------------------------------- 1 | default_prefix = "!" 2 | discord_token = "Please insert your Discord bot token here." 3 | bot_owners = [] 4 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 120 2 | -------------------------------------------------------------------------------- /sqlx-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "db": "SQLite", 3 | "0058e95a08844662b1425e9ab4df398ba2e626a268b21da0e26ca18070826173": { 4 | "query": "INSERT INTO money (guild_id, user_id) values (?1, ?2);", 5 | "describe": { 6 | "columns": [], 7 | "parameters": { 8 | "Right": 2 9 | }, 10 | "nullable": [] 11 | } 12 | }, 13 | "0089a3e1bd4fba764ebde4b6213666f966709fb28a3d726a68e4167eff424c36": { 14 | "query": "INSERT INTO leaderboard (guild_id, channel_id, user_id, points) VALUES (?1, ?2, ?3, ?4);", 15 | "describe": { 16 | "columns": [], 17 | "parameters": { 18 | "Right": 4 19 | }, 20 | "nullable": [] 21 | } 22 | }, 23 | "0b7a51dd40385778ddc576a8f2f03481bd41fcebb5188782ec96041c7cc57849": { 24 | "query": "SELECT prefix FROM prefix WHERE guild_id == ?1;", 25 | "describe": { 26 | "columns": [ 27 | { 28 | "name": "prefix", 29 | "ordinal": 0, 30 | "type_info": "Text" 31 | } 32 | ], 33 | "parameters": { 34 | "Right": 1 35 | }, 36 | "nullable": [ 37 | false 38 | ] 39 | } 40 | }, 41 | "14bdb08b4e4f194045cf603f73aa28e411de8bdb461b8a3b3d450c702f0d20a3": { 42 | "query": "UPDATE log SET log_type = ?1 WHERE guild_id = ?2;", 43 | "describe": { 44 | "columns": [], 45 | "parameters": { 46 | "Right": 2 47 | }, 48 | "nullable": [] 49 | } 50 | }, 51 | "1dfedc9c3a589107c1c57d05be67356604819e028936e758965e1c5326e6201b": { 52 | "query": "SELECT channel_id FROM log WHERE guild_id == ?1;", 53 | "describe": { 54 | "columns": [ 55 | { 56 | "name": "channel_id", 57 | "ordinal": 0, 58 | "type_info": "Text" 59 | } 60 | ], 61 | "parameters": { 62 | "Right": 1 63 | }, 64 | "nullable": [ 65 | false 66 | ] 67 | } 68 | }, 69 | "482be488ea24c257245c4c76d51549f4677c31f66051edc60fb61a3ca69f1c34": { 70 | "query": "DELETE FROM reactionroles WHERE reaction_id = ?1 AND guild_id = ?2", 71 | "describe": { 72 | "columns": [], 73 | "parameters": { 74 | "Right": 2 75 | }, 76 | "nullable": [] 77 | } 78 | }, 79 | "5454b5b6047281708b41cd1afb7bd0bb682111b78c480f0fe01d51beb5d201ab": { 80 | "query": "SELECT user_id, channel_id, points FROM leaderboard WHERE guild_id == ?1 AND user_id == ?2 ORDER BY points DESC;", 81 | "describe": { 82 | "columns": [ 83 | { 84 | "name": "user_id", 85 | "ordinal": 0, 86 | "type_info": "Text" 87 | }, 88 | { 89 | "name": "channel_id", 90 | "ordinal": 1, 91 | "type_info": "Text" 92 | }, 93 | { 94 | "name": "points", 95 | "ordinal": 2, 96 | "type_info": "Int64" 97 | } 98 | ], 99 | "parameters": { 100 | "Right": 2 101 | }, 102 | "nullable": [ 103 | false, 104 | false, 105 | false 106 | ] 107 | } 108 | }, 109 | "56bbefeb8382e9188480f7c5bd954bbe6db2eac5f0578fa9f7e58d373306b36c": { 110 | "query": "SELECT log_type FROM log WHERE guild_id == ?1;", 111 | "describe": { 112 | "columns": [ 113 | { 114 | "name": "log_type", 115 | "ordinal": 0, 116 | "type_info": "Text" 117 | } 118 | ], 119 | "parameters": { 120 | "Right": 1 121 | }, 122 | "nullable": [ 123 | false 124 | ] 125 | } 126 | }, 127 | "5bd263845be52169a7ed3471e65715571aafc59097c31b2b58d2804afbec0bbd": { 128 | "query": "CREATE TABLE IF NOT EXISTS prefix (guild_id TEXT PRIMARY KEY, prefix TEXT NOT NULL);", 129 | "describe": { 130 | "columns": [], 131 | "parameters": { 132 | "Right": 0 133 | }, 134 | "nullable": [] 135 | } 136 | }, 137 | "5cc455c1448ebe9b838acd87cdf2ae2bc77904e6045cda4e6650c4588d1de9e0": { 138 | "query": "SELECT message_id FROM reactionroles WHERE reaction_id = ?1 AND guild_id = ?2", 139 | "describe": { 140 | "columns": [ 141 | { 142 | "name": "message_id", 143 | "ordinal": 0, 144 | "type_info": "Text" 145 | } 146 | ], 147 | "parameters": { 148 | "Right": 2 149 | }, 150 | "nullable": [ 151 | false 152 | ] 153 | } 154 | }, 155 | "6051e5d58acc61a80d31bf7d43ce992f74536ef7af62ea9840221d0403493a6b": { 156 | "query": "INSERT INTO joinrole (guild_id, role_id) values (?1, ?2)", 157 | "describe": { 158 | "columns": [], 159 | "parameters": { 160 | "Right": 2 161 | }, 162 | "nullable": [] 163 | } 164 | }, 165 | "778613995fafbde4d2788eac7e14e3c8e41c53a255f4e25f0971fccc4f9f0246": { 166 | "query": "UPDATE leaderboard SET points = ?1 WHERE guild_id == ?2 AND channel_id == ?3 AND user_id == ?4;", 167 | "describe": { 168 | "columns": [], 169 | "parameters": { 170 | "Right": 4 171 | }, 172 | "nullable": [] 173 | } 174 | }, 175 | "7c93268302011492f9b4b6efde4ec64351edf4ef2577cdee17ff1da372522f4c": { 176 | "query": "CREATE TABLE IF NOT EXISTS joinrole (guild_id TEXT NOT NULL, role_id TEXT NOT NULL, PRIMARY KEY (guild_id, role_id));", 177 | "describe": { 178 | "columns": [], 179 | "parameters": { 180 | "Right": 0 181 | }, 182 | "nullable": [] 183 | } 184 | }, 185 | "82b42439de0f711db49123d1503c7c3bd91f3476109b4daa008fff5a949d98cc": { 186 | "query": "CREATE TABLE IF NOT EXISTS reactionroles (guild_id TEXT NOT NULL, message_id TEXT NOT NULL, role_id TEXT NOT NULL, reaction_id TEXT NOT NULL, PRIMARY KEY (guild_id, message_id, role_id, reaction_id));", 187 | "describe": { 188 | "columns": [], 189 | "parameters": { 190 | "Right": 0 191 | }, 192 | "nullable": [] 193 | } 194 | }, 195 | "8376391c9b758d658c33b6e9d883c7720c415311f01c701e6cb2be225269375c": { 196 | "query": "SELECT money FROM money WHERE guild_id == ?1 AND user_id == ?2;", 197 | "describe": { 198 | "columns": [ 199 | { 200 | "name": "money", 201 | "ordinal": 0, 202 | "type_info": "Int64" 203 | } 204 | ], 205 | "parameters": { 206 | "Right": 2 207 | }, 208 | "nullable": [ 209 | false 210 | ] 211 | } 212 | }, 213 | "8aa33ebfddf08af77b5d9b5f22066b9eae7e325ba48b672895f31a65e3843729": { 214 | "query": "SELECT points FROM leaderboard WHERE guild_id == ?1 AND channel_id == ?2 AND user_id == ?3;", 215 | "describe": { 216 | "columns": [ 217 | { 218 | "name": "points", 219 | "ordinal": 0, 220 | "type_info": "Int64" 221 | } 222 | ], 223 | "parameters": { 224 | "Right": 3 225 | }, 226 | "nullable": [ 227 | false 228 | ] 229 | } 230 | }, 231 | "a20273424638f557183f0ff917fb994c323e645dc0a6ab3a77a4cfb2909d04ca": { 232 | "query": "INSERT INTO reactionroles (guild_id, message_id, role_id, reaction_id) values (?1, ?2, ?3, ?4)", 233 | "describe": { 234 | "columns": [], 235 | "parameters": { 236 | "Right": 4 237 | }, 238 | "nullable": [] 239 | } 240 | }, 241 | "a4f34748e49ccb57e121756f45e887fa5da60d148dc190204ee6b31610e49d6d": { 242 | "query": "SELECT message_id, role_id, reaction_id FROM reactionroles", 243 | "describe": { 244 | "columns": [ 245 | { 246 | "name": "message_id", 247 | "ordinal": 0, 248 | "type_info": "Text" 249 | }, 250 | { 251 | "name": "role_id", 252 | "ordinal": 1, 253 | "type_info": "Text" 254 | }, 255 | { 256 | "name": "reaction_id", 257 | "ordinal": 2, 258 | "type_info": "Text" 259 | } 260 | ], 261 | "parameters": { 262 | "Right": 0 263 | }, 264 | "nullable": [ 265 | false, 266 | false, 267 | false 268 | ] 269 | } 270 | }, 271 | "a9d8fa717a04fec476ce5dea60f17ae0f9507296155ade60c7cafec4bc3a2f87": { 272 | "query": "INSERT INTO log (guild_id, channel_id, log_type) values (?1, ?2, ?3)", 273 | "describe": { 274 | "columns": [], 275 | "parameters": { 276 | "Right": 3 277 | }, 278 | "nullable": [] 279 | } 280 | }, 281 | "afb0536b8a870a51b48c76771a5d4bff8d9c562b2dd5d2749a5d718f6cbe3651": { 282 | "query": "SELECT user_id, SUM(points) as \"points!: i64\" FROM leaderboard WHERE guild_id == ?1 GROUP BY user_id ORDER BY \"points!: i64\" DESC;", 283 | "describe": { 284 | "columns": [ 285 | { 286 | "name": "user_id", 287 | "ordinal": 0, 288 | "type_info": "Text" 289 | }, 290 | { 291 | "name": "points!: i64", 292 | "ordinal": 1, 293 | "type_info": "Null" 294 | } 295 | ], 296 | "parameters": { 297 | "Right": 1 298 | }, 299 | "nullable": [ 300 | false, 301 | null 302 | ] 303 | } 304 | }, 305 | "bd2e3b92573f374e79776d1fa2246ecb71d53f0bce6dadd19d5829ba51460096": { 306 | "query": "DELETE FROM joinrole WHERE guild_id = ?1;", 307 | "describe": { 308 | "columns": [], 309 | "parameters": { 310 | "Right": 1 311 | }, 312 | "nullable": [] 313 | } 314 | }, 315 | "c1367685c928e2322fa0a41c2f379a39bf6eec83238d59f47b3237b4ee5cbe9e": { 316 | "query": "SELECT role_id FROM joinrole WHERE guild_id = ?1", 317 | "describe": { 318 | "columns": [ 319 | { 320 | "name": "role_id", 321 | "ordinal": 0, 322 | "type_info": "Text" 323 | } 324 | ], 325 | "parameters": { 326 | "Right": 1 327 | }, 328 | "nullable": [ 329 | false 330 | ] 331 | } 332 | }, 333 | "c295bf6c333e8ae774d9a3cf94f7517fb4cefdc5274a2dc270247f7466fc60fd": { 334 | "query": "CREATE TABLE IF NOT EXISTS log (guild_id TEXT PRIMARY KEY, channel_id TEXT NOT NULL, log_type TEXT NOT NULL);", 335 | "describe": { 336 | "columns": [], 337 | "parameters": { 338 | "Right": 0 339 | }, 340 | "nullable": [] 341 | } 342 | }, 343 | "d2c92a89316104faacf2d3ed62f38155c672f7a73d87f36631cbf3ee18d83fe8": { 344 | "query": "CREATE TABLE IF NOT EXISTS leaderboard (guild_id TEXT NOT NULL, user_id TEXT NOT NULL, channel_id TEXT NOT NULL, points INTEGER DEFAULT 0 NOT NULL, PRIMARY KEY (guild_id, user_id, channel_id));", 345 | "describe": { 346 | "columns": [], 347 | "parameters": { 348 | "Right": 0 349 | }, 350 | "nullable": [] 351 | } 352 | }, 353 | "dc3dd3dbb5b9e19d1ca905b0c9b0875b9810dab4ebeb013987197c887858f759": { 354 | "query": "UPDATE log SET channel_id = ?1 WHERE guild_id == ?2;", 355 | "describe": { 356 | "columns": [], 357 | "parameters": { 358 | "Right": 2 359 | }, 360 | "nullable": [] 361 | } 362 | }, 363 | "dd425c960cbf5cf12ebcf81353821daf1a44bb6893425c4a3edb5fb68ac5f77b": { 364 | "query": "INSERT OR REPLACE INTO prefix (guild_id, prefix) values (?1, ?2)", 365 | "describe": { 366 | "columns": [], 367 | "parameters": { 368 | "Right": 2 369 | }, 370 | "nullable": [] 371 | } 372 | }, 373 | "e8fc61e4c3727cc2489f678361c44e0c57d81ea8045c630d255e756ee2a748cf": { 374 | "query": "INSERT OR REPLACE INTO money (guild_id, user_id, money) values (?1, ?2, ?3);", 375 | "describe": { 376 | "columns": [], 377 | "parameters": { 378 | "Right": 3 379 | }, 380 | "nullable": [] 381 | } 382 | }, 383 | "e9f67106e6575f0afd5abd0be5dfaeb2371865220bdd1c3812535bc2c644278b": { 384 | "query": "CREATE TABLE IF NOT EXISTS money (guild_id TEXT NOT NULL, user_id TEXT NOT NULL, money INTEGER DEFAULT 0 NOT NULL, PRIMARY KEY (guild_id, user_id));", 385 | "describe": { 386 | "columns": [], 387 | "parameters": { 388 | "Right": 0 389 | }, 390 | "nullable": [] 391 | } 392 | }, 393 | "eea69ed7a41a87deccb209230551e308eb558074507f824d72637e96f8247bde": { 394 | "query": "SELECT user_id, channel_id, points FROM leaderboard WHERE guild_id == ?1 AND channel_id == ?2 ORDER BY points DESC;", 395 | "describe": { 396 | "columns": [ 397 | { 398 | "name": "user_id", 399 | "ordinal": 0, 400 | "type_info": "Text" 401 | }, 402 | { 403 | "name": "channel_id", 404 | "ordinal": 1, 405 | "type_info": "Text" 406 | }, 407 | { 408 | "name": "points", 409 | "ordinal": 2, 410 | "type_info": "Int64" 411 | } 412 | ], 413 | "parameters": { 414 | "Right": 2 415 | }, 416 | "nullable": [ 417 | false, 418 | false, 419 | false 420 | ] 421 | } 422 | } 423 | } -------------------------------------------------------------------------------- /src/commands.rs: -------------------------------------------------------------------------------- 1 | use serenity::framework::standard::macros::group; 2 | pub mod help; 3 | pub use help::*; 4 | 5 | pub mod generic; 6 | pub use generic::*; 7 | 8 | pub mod admin; 9 | pub use admin::*; 10 | #[group] 11 | #[commands(ban, kick)] 12 | struct Admin; 13 | 14 | pub mod games; 15 | pub use games::*; 16 | #[group] 17 | #[commands(setmoney, betroll, money, flip, give)] 18 | struct Gambling; 19 | 20 | pub mod roles; 21 | pub use roles::*; 22 | #[group] 23 | #[commands(addreactrole, removereactrole, addjoinrole, removejoinrole)] 24 | struct Roles; 25 | 26 | pub mod settings; 27 | pub use settings::*; 28 | #[group] 29 | #[commands(log, prefix)] 30 | struct Settings; 31 | 32 | pub mod utility; 33 | pub use utility::*; 34 | #[group] 35 | #[commands(avatar, user, leaderboard, guild, emoji, choose, ping, hug, answer, headpat, bonk)] 36 | struct Utility; 37 | -------------------------------------------------------------------------------- /src/commands/admin.rs: -------------------------------------------------------------------------------- 1 | pub mod ban; 2 | pub mod kick; 3 | pub use ban::*; 4 | pub use kick::*; 5 | -------------------------------------------------------------------------------- /src/commands/admin/ban.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[required_permissions(BAN_MEMBERS)] 11 | #[min_args(1)] 12 | #[max_args(2)] 13 | #[description("Bans a user from the server.")] 14 | #[usage("ban ")] 15 | #[example("ban @Elinvynia \"Abusive language\"")] 16 | async fn ban(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 17 | args.quoted(); 18 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 19 | 20 | let banned_arg: String = error_return_ok!(args.single()); 21 | let banned_id = none_return_ok!(parse_user(&banned_arg, Some(&guild_id), Some(ctx)).await); 22 | 23 | let banned = banned_id.to_user(ctx).await?; 24 | let reason = format!("Eli Bot | {}", args.single::().unwrap_or_else(|_| "".into())); 25 | let channel = banned.create_dm_channel(&ctx).await?; 26 | let guild = msg 27 | .guild(&ctx.cache) 28 | .await 29 | .ok_or_else(|| anyhow!("Guild not found in cache."))?; 30 | 31 | guild_id.ban_with_reason(&ctx, banned, 0, &reason).await?; 32 | 33 | let banned_message = format!("You have been banned from {}\nReason: {}", guild.name, &reason); 34 | channel.say(&ctx, banned_message).await?; 35 | 36 | Ok(()) 37 | } 38 | -------------------------------------------------------------------------------- /src/commands/admin/kick.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[required_permissions(KICK_MEMBERS)] 11 | #[min_args(1)] 12 | #[max_args(2)] 13 | #[description("Kicks a user from the server.")] 14 | #[usage("kick ")] 15 | #[example("kick @Elinvynia \"Abusive language\"")] 16 | async fn kick(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 17 | args.quoted(); 18 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 19 | 20 | let kicked_arg: String = error_return_ok!(args.single()); 21 | let kicked_id = none_return_ok!(parse_user(&kicked_arg, Some(&guild_id), Some(ctx)).await); 22 | 23 | let kicked = kicked_id.to_user(ctx).await?; 24 | let reason = format!("Eli Bot | {}", args.single::().unwrap_or_else(|_| "".into())); 25 | let channel = kicked.create_dm_channel(&ctx).await?; 26 | let guild = msg 27 | .guild(&ctx.cache) 28 | .await 29 | .ok_or_else(|| anyhow!("Guild not found in cache."))?; 30 | 31 | guild_id.kick_with_reason(&ctx, kicked, &reason).await?; 32 | 33 | let kicked_message = format!("You have been kicked from {}\nReason: {}", &guild.name, &reason); 34 | channel.say(&ctx, kicked_message).await?; 35 | 36 | Ok(()) 37 | } 38 | -------------------------------------------------------------------------------- /src/commands/games.rs: -------------------------------------------------------------------------------- 1 | pub mod betroll; 2 | pub mod flip; 3 | pub mod give; 4 | pub mod money; 5 | pub mod setmoney; 6 | pub use betroll::*; 7 | pub use flip::*; 8 | pub use give::*; 9 | pub use money::*; 10 | pub use setmoney::*; 11 | -------------------------------------------------------------------------------- /src/commands/games/betroll.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use rand::prelude::*; 3 | use serenity::{ 4 | framework::standard::{macros::command, Args, CommandResult}, 5 | model::prelude::*, 6 | prelude::*, 7 | }; 8 | 9 | #[command] 10 | #[only_in(guilds)] 11 | #[num_args(1)] 12 | #[description("Bets a certain amount of currency and rolls a dice. Rolling over 66 yields x2 of your currency, over 90 - x4 and 100 x10.")] 13 | #[usage("betroll ")] 14 | #[example("betroll 100")] 15 | async fn betroll(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | let guildid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 17 | let userid = msg.author.id; 18 | 19 | let money = get_user_money(guildid, userid).await?; 20 | let bet: u64 = error_return_ok!(args.single()); 21 | 22 | if bet == 0 { 23 | return Ok(()); 24 | }; 25 | 26 | if bet > money { 27 | msg.channel_id.say(&ctx, "You don't have enough money!").await?; 28 | return Ok(()); 29 | }; 30 | 31 | let roll: i64 = rand::thread_rng().gen_range(1..=100); 32 | let new_amount; 33 | 34 | if roll == 100 { 35 | new_amount = money + (bet * 10); 36 | set_user_money(guildid, userid, new_amount).await?; 37 | } else if roll > 90 { 38 | new_amount = money + (bet * 4); 39 | set_user_money(guildid, userid, new_amount).await?; 40 | } else if roll > 66 { 41 | new_amount = money + (bet * 2); 42 | set_user_money(guildid, userid, new_amount).await?; 43 | } else { 44 | new_amount = money - bet; 45 | set_user_money(guildid, userid, new_amount).await?; 46 | } 47 | 48 | msg.channel_id 49 | .say(&ctx, &format!("Roll: {}\nYou now have: **{}**", roll, new_amount)) 50 | .await?; 51 | 52 | Ok(()) 53 | } 54 | -------------------------------------------------------------------------------- /src/commands/games/flip.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use rand::prelude::*; 3 | use serenity::{ 4 | framework::standard::{macros::command, Args, CommandResult}, 5 | model::prelude::*, 6 | prelude::*, 7 | }; 8 | 9 | #[command] 10 | #[only_in(guilds)] 11 | #[num_args(2)] 12 | #[description("Bets a certain amount of currency and rolls a dice. Rolling over 66 yields x2 of your currency, over 90 - x4 and 100 x10.")] 13 | #[usage("flip ")] 14 | #[example("flip 100 heads")] 15 | async fn flip(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | let guildid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 17 | let userid = msg.author.id; 18 | 19 | let money = get_user_money(guildid, userid).await?; 20 | let bet: u64 = error_return_ok!(args.single()); 21 | 22 | let coin = match &args.single::()?[..] { 23 | "h" | "heads" => Coin::Heads, 24 | "t" | "tails" => Coin::Tails, 25 | _ => return Ok(()), 26 | }; 27 | 28 | if bet == 0 { 29 | return Ok(()); 30 | }; 31 | 32 | if bet > money { 33 | msg.channel_id.say(&ctx, "You don't have enough money!").await?; 34 | return Ok(()); 35 | }; 36 | 37 | let roll: bool = rand::thread_rng().gen(); 38 | let roll_coin: bool = coin.into(); 39 | 40 | let new_amount = if roll == roll_coin { 41 | money + (bet * 2) 42 | } else { 43 | money - bet 44 | }; 45 | 46 | let rolled: Coin = roll.into(); 47 | 48 | set_user_money(guildid, userid, new_amount).await?; 49 | 50 | msg.channel_id 51 | .say( 52 | &ctx, 53 | &format!("Your Side: {}\nRolled: {}\nYou now have: {}", coin, rolled, new_amount), 54 | ) 55 | .await?; 56 | 57 | Ok(()) 58 | } 59 | 60 | #[derive(Debug, Copy, Clone)] 61 | enum Coin { 62 | Heads, 63 | Tails, 64 | } 65 | 66 | impl From for Coin { 67 | fn from(b: bool) -> Self { 68 | match b { 69 | true => Coin::Heads, 70 | false => Coin::Tails, 71 | } 72 | } 73 | } 74 | 75 | impl From for bool { 76 | fn from(coin: Coin) -> Self { 77 | match coin { 78 | Coin::Heads => true, 79 | Coin::Tails => false, 80 | } 81 | } 82 | } 83 | 84 | impl std::fmt::Display for Coin { 85 | fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { 86 | match *self { 87 | Coin::Heads => write!(fmt, "Heads"), 88 | Coin::Tails => write!(fmt, "Tails"), 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/commands/games/give.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[num_args(2)] 11 | #[description("Gives a certain amount of money to a user.")] 12 | #[usage("give ")] 13 | #[example("give Elinvynia 1000")] 14 | async fn give(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 15 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 16 | let user_arg: String = error_return_ok!(args.single()); 17 | let user_id = none_return_ok!(parse_user(&user_arg, Some(&guild_id), Some(ctx)).await); 18 | let amount: u64 = error_return_ok!(args.single()); 19 | 20 | let author = guild_id.member(&ctx, msg.author.id).await?; 21 | { 22 | remove_user_money(guild_id, msg.author.id, amount).await?; 23 | } 24 | 25 | let member = guild_id.member(&ctx, user_id).await?; 26 | { 27 | add_user_money(guild_id, user_id, amount).await?; 28 | } 29 | 30 | msg.channel_id 31 | .say( 32 | &ctx, 33 | &format!( 34 | "**{}** has given **{}** **{}**", 35 | author.display_name(), 36 | member.display_name(), 37 | amount 38 | ), 39 | ) 40 | .await?; 41 | 42 | Ok(()) 43 | } 44 | -------------------------------------------------------------------------------- /src/commands/games/money.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[min_args(0)] 10 | #[max_args(1)] 11 | #[only_in(guilds)] 12 | #[description("Retrieves how much money a user has.")] 13 | #[usage("money ")] 14 | #[example("money Elinvynia")] 15 | async fn money(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 17 | 18 | let user_id = if !args.is_empty() { 19 | let name: String = error_return_ok!(args.single()); 20 | none_return_ok!(parse_user(&name, Some(&guild_id), Some(ctx)).await) 21 | } else { 22 | msg.author.id 23 | }; 24 | 25 | let money = get_user_money(guild_id, user_id).await?; 26 | let member = guild_id.member(&ctx, user_id).await?; 27 | 28 | let message = format!("**{}** has **{}**", member.display_name(), money); 29 | 30 | msg.channel_id.say(&ctx, message).await?; 31 | 32 | Ok(()) 33 | } 34 | -------------------------------------------------------------------------------- /src/commands/games/setmoney.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[owners_only] 11 | #[num_args(2)] 12 | #[description("Sets the amount of money for a user.")] 13 | #[usage("setmoney ")] 14 | #[example("setmoney Elinvynia 1000")] 15 | async fn setmoney(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 17 | let user_arg: String = error_return_ok!(args.single()); 18 | let user_id = none_return_ok!(parse_user(&user_arg, Some(&guild_id), Some(ctx)).await); 19 | 20 | let amount: u64 = error_return_ok!(args.single()); 21 | let member = guild_id.member(&ctx, user_id).await?; 22 | 23 | set_user_money(guild_id, user_id, amount).await?; 24 | 25 | msg.channel_id 26 | .say(&ctx, &format!("**{}** now has **{}**", member.display_name(), amount)) 27 | .await?; 28 | 29 | Ok(()) 30 | } 31 | -------------------------------------------------------------------------------- /src/commands/generic.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | macro_rules! text_command { 9 | ($cname:ident, $action:expr, $desc:expr, $usage:expr, $example:expr, $extra:expr) => { 10 | #[command] 11 | #[only_in(guilds)] 12 | #[num_args(1)] 13 | #[description($desc)] 14 | #[usage($usage)] 15 | #[example($example)] 16 | async fn $cname(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 17 | let gid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 18 | 19 | let user_id = none_return_ok!(parse_user(&args.single::()?, Some(&gid), Some(&ctx)).await); 20 | let author = gid.member(&ctx, msg.author.id).await?; 21 | let member = gid.member(&ctx, user_id).await?; 22 | 23 | msg.channel_id 24 | .say( 25 | &ctx, 26 | format!( 27 | "***{}** {} **{}**{}*", 28 | author.display_name(), 29 | $action, 30 | member.display_name(), 31 | $extra 32 | ), 33 | ) 34 | .await?; 35 | 36 | Ok(()) 37 | } 38 | }; 39 | } 40 | 41 | text_command!(hug, "hugs", "Hugs another user.", "hug ", "hug Elinvynia", ""); 42 | text_command!( 43 | headpat, 44 | "headpats", 45 | "Headpats another user.", 46 | "headpat ", 47 | "headpat Elinvynia", 48 | "" 49 | ); 50 | text_command!( 51 | bonk, 52 | "bonks", 53 | "Bonks another user to horny jail.", 54 | "bonk ", 55 | "bonk Elinvynia", 56 | ". Go to horny jail!" 57 | ); 58 | -------------------------------------------------------------------------------- /src/commands/help.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | client::Context, 4 | framework::standard::{macros::help, Args, Command, CommandGroup, CommandResult, HelpOptions, OnlyIn}, 5 | model::prelude::*, 6 | }; 7 | use std::collections::HashSet; 8 | 9 | #[help] 10 | async fn help( 11 | ctx: &Context, 12 | msg: &Message, 13 | args: Args, 14 | _help_options: &'static HelpOptions, 15 | groups: &[&'static CommandGroup], 16 | owners: HashSet, 17 | ) -> CommandResult { 18 | let mut help_string = String::new(); 19 | 20 | match args.len() { 21 | 0 => help_string += &command_list(ctx, groups, msg, owners).await?, 22 | 1 => { 23 | help_string += &command_help( 24 | ctx, 25 | groups, 26 | args.current() 27 | .ok_or_else(|| anyhow!("Arguments not found."))? 28 | .to_string(), 29 | msg, 30 | owners, 31 | ) 32 | .await? 33 | } 34 | _ => help_string += "Too many arguments.", 35 | }; 36 | 37 | msg.channel_id.say(&ctx, &help_string).await?; 38 | 39 | Ok(()) 40 | } 41 | 42 | async fn command_list( 43 | ctx: &Context, 44 | groups: &[&'static CommandGroup], 45 | msg: &Message, 46 | owners: HashSet, 47 | ) -> Result { 48 | let mut help_list = "Bot made by @Elinvynia".to_string(); 49 | help_list += "\n\n"; 50 | 51 | let is_owner = owners.get(&msg.author.id).is_some(); 52 | 53 | for group in groups { 54 | if group.options.commands.is_empty() { 55 | continue; 56 | } 57 | let mut group_string = format!("**{}:** ", group.name); 58 | for command in group.options.commands { 59 | let name = command 60 | .options 61 | .names 62 | .first() 63 | .ok_or_else(|| anyhow!("Command name not found."))?; 64 | let mut got_permission = false; 65 | 66 | if let Some(gid) = msg.guild_id { 67 | let guild = match gid.to_guild_cached(&ctx).await { 68 | Some(g) => g, 69 | None => return Err(anyhow!("Guild not found in cache.")), 70 | }; 71 | let member = match guild.member(&ctx, msg.author.id).await { 72 | Ok(m) => m, 73 | Err(_) => return Err(anyhow!("Guild member not found.")), 74 | }; 75 | let rid = match member.highest_role_info(&ctx).await { 76 | Some(id) => id, 77 | None => return Err(anyhow!("Highest role info not found.")), 78 | }; 79 | let role = match rid.0.to_role_cached(&ctx).await { 80 | Some(r) => r, 81 | None => return Err(anyhow!("Role not found in cache.")), 82 | }; 83 | got_permission = role.permissions.contains(command.options.required_permissions); 84 | }; 85 | 86 | #[allow(clippy::if_same_then_else)] 87 | if command.options.owners_only && !is_owner { 88 | group_string += &format!("~~{}~~, ", &name); 89 | } else if command.options.only_in == OnlyIn::Guild && msg.guild_id.is_none() { 90 | group_string += &format!("~~{}~~, ", &name); 91 | } else if !got_permission && msg.guild_id.is_some() { 92 | group_string += &format!("~~{}~~, ", &name); 93 | } else { 94 | group_string += &format!("{}, ", &name); 95 | } 96 | } 97 | group_string += "\n"; 98 | help_list += &group_string; 99 | help_list.remove(help_list.len() - 3); 100 | } 101 | help_list += "\n"; 102 | help_list += "source @ "; 103 | Ok(help_list) 104 | } 105 | 106 | async fn command_help( 107 | ctx: &Context, 108 | groups: &[&'static CommandGroup], 109 | arg: String, 110 | msg: &Message, 111 | owners: HashSet, 112 | ) -> Result { 113 | let mut help_command = String::new(); 114 | 115 | let is_owner = owners.get(&msg.author.id).is_some(); 116 | 117 | let mut matched_command: Option<&Command> = None; 118 | for group in groups { 119 | for command in group.options.commands { 120 | let name = command 121 | .options 122 | .names 123 | .first() 124 | .ok_or_else(|| anyhow!("Command name not found."))?; 125 | if name == &arg { 126 | matched_command = Some(command); 127 | } 128 | } 129 | } 130 | 131 | let command = match matched_command { 132 | Some(c) => c, 133 | None => { 134 | help_command += "No command found."; 135 | return Ok(help_command); 136 | } 137 | }; 138 | 139 | let mut got_permission = false; 140 | 141 | if let Some(gid) = msg.guild_id { 142 | let guild = match gid.to_guild_cached(&ctx).await { 143 | Some(g) => g, 144 | None => return Ok(help_command), 145 | }; 146 | let member = match guild.member(&ctx, msg.author.id).await { 147 | Ok(m) => m, 148 | Err(_) => return Ok(help_command), 149 | }; 150 | let rid = match member.highest_role_info(&ctx).await { 151 | Some(id) => id, 152 | None => return Ok(help_command), 153 | }; 154 | let role = match rid.0.to_role_cached(&ctx).await { 155 | Some(r) => r, 156 | None => return Ok(help_command), 157 | }; 158 | got_permission = role.permissions.contains(command.options.required_permissions); 159 | }; 160 | 161 | help_command += &format!( 162 | "**Command:** __{}__", 163 | command 164 | .options 165 | .names 166 | .first() 167 | .ok_or_else(|| anyhow!("Command name not found."))? 168 | ); 169 | 170 | help_command += "\n"; 171 | if let Some(description) = command.options.desc { 172 | help_command += &format!("**Description:** {}", description); 173 | } else { 174 | help_command += "No description available."; 175 | } 176 | 177 | help_command += "\n"; 178 | if let Some(usage) = command.options.usage { 179 | help_command += &format!("**Usage:** {}", usage); 180 | } else { 181 | help_command += "No usage available."; 182 | } 183 | 184 | help_command += "\n"; 185 | if !command.options.examples.is_empty() { 186 | help_command += "**Examples:** "; 187 | for example in command.options.examples { 188 | help_command += example; 189 | } 190 | } else { 191 | help_command += "No examples available."; 192 | } 193 | 194 | help_command += "\n"; 195 | if command.options.owners_only && !is_owner { 196 | help_command += "You need to be an owner to use this command."; 197 | } else if command.options.only_in == OnlyIn::Guild { 198 | if msg.guild_id.is_none() { 199 | help_command += "This command can only be used in a guild."; 200 | } else if !got_permission { 201 | help_command += "You don't have the permissions to use this command."; 202 | } 203 | }; 204 | 205 | Ok(help_command) 206 | } 207 | -------------------------------------------------------------------------------- /src/commands/roles.rs: -------------------------------------------------------------------------------- 1 | pub mod addjoinrole; 2 | pub mod addreactrole; 3 | pub mod removejoinrole; 4 | pub mod removereactrole; 5 | pub use addjoinrole::*; 6 | pub use addreactrole::*; 7 | pub use removejoinrole::*; 8 | pub use removereactrole::*; 9 | -------------------------------------------------------------------------------- /src/commands/roles/addjoinrole.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[owners_only] 11 | #[num_args(1)] 12 | #[description("Automatically adds a role to newly joined users in the current guild.")] 13 | #[usage("addjoinrole ")] 14 | #[example("addjoinrole New")] 15 | async fn addjoinrole(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | let mut conn = connect().await?; 17 | let gid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 18 | 19 | let role = match parse_rol(&args.single::()?, Some(&gid), Some(ctx)).await { 20 | Some(rid) => rid 21 | .to_role_cached(&ctx.cache) 22 | .await 23 | .ok_or_else(|| anyhow!("Role not found in cache"))?, 24 | None => return Ok(()), 25 | }; 26 | 27 | let (gid, rid) = (gid.to_string(), role.id.to_string()); 28 | sqlx::query!("INSERT INTO joinrole (guild_id, role_id) values (?1, ?2)", gid, rid) 29 | .execute(&mut conn) 30 | .await?; 31 | 32 | msg.channel_id 33 | .say(&ctx, format!("Join role {} added!", role.name)) 34 | .await?; 35 | 36 | Ok(()) 37 | } 38 | -------------------------------------------------------------------------------- /src/commands/roles/addreactrole.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | collector::*, 4 | framework::standard::{macros::command, Args, CommandResult}, 5 | futures::StreamExt, 6 | model::prelude::*, 7 | prelude::*, 8 | }; 9 | 10 | #[command] 11 | #[only_in(guilds)] 12 | #[owners_only] 13 | #[num_args(2)] 14 | #[description("Makes the reaction to the message above add the role to a user.")] 15 | #[usage("addreactrole ")] 16 | #[example("addreactrole :heart: Admin")] 17 | async fn addreactrole(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 18 | let mut conn = connect().await?; 19 | let x = msg 20 | .channel(ctx) 21 | .await 22 | .ok_or_else(|| anyhow!("Channel not found."))? 23 | .guild() 24 | .ok_or_else(|| anyhow!("Guild not found."))? 25 | .messages(ctx, |builder| builder.before(msg.id).limit(1)) 26 | .await?; 27 | 28 | if x.is_empty() { 29 | return Ok(()); 30 | }; 31 | 32 | let gid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 33 | 34 | let reaction = match parse_reaction(&args.single::()?, &gid, ctx).await { 35 | Some(r) => r, 36 | None => return Ok(()), 37 | }; 38 | 39 | let role = match parse_rol(&args.single::()?, Some(&gid), Some(ctx)).await { 40 | Some(rid) => match rid.to_role_cached(&ctx.cache).await { 41 | Some(r) => r, 42 | None => return Ok(()), 43 | }, 44 | None => return Ok(()), 45 | }; 46 | 47 | let reactionid = reaction.id; 48 | let parent_msg = x.get(0).ok_or_else(|| anyhow!("Parent message not found."))?.clone(); 49 | parent_msg.react(&ctx, reaction).await?; 50 | 51 | let role_id = role.id; 52 | let mut collector = ReactionCollectorBuilder::new(&ctx) 53 | .message_id(parent_msg.id) 54 | .removed(true) 55 | .filter(move |reaction| match reaction.as_ref().emoji { 56 | ReactionType::Custom { id, .. } => id == reactionid, 57 | _ => false, 58 | }) 59 | .await; 60 | 61 | msg.delete(&ctx).await?; 62 | 63 | let (gid, msgid, rid, reaid) = ( 64 | gid.to_string(), 65 | parent_msg.id.to_string(), 66 | role_id.to_string(), 67 | reactionid.to_string(), 68 | ); 69 | sqlx::query!( 70 | "INSERT INTO reactionroles (guild_id, message_id, role_id, reaction_id) values (?1, ?2, ?3, ?4)", 71 | gid, 72 | msgid, 73 | rid, 74 | reaid 75 | ) 76 | .execute(&mut conn) 77 | .await?; 78 | 79 | let ctx = ctx.clone(); 80 | tokio::spawn(async move { 81 | let http = &ctx.http; 82 | while let Some(event) = collector.next().await { 83 | if let ReactionAction::Added(a) = event.as_ref() { 84 | let uid = match a.user_id { 85 | Some(id) => id, 86 | None => continue, 87 | }; 88 | let gid = match a.guild_id { 89 | Some(id) => id, 90 | None => continue, 91 | }; 92 | let guild = match gid.to_partial_guild(&http).await { 93 | Ok(g) => g, 94 | Err(_) => continue, 95 | }; 96 | let mut member = match guild.member(&ctx, uid).await { 97 | Ok(m) => m, 98 | Err(_) => continue, 99 | }; 100 | let roles = match member.roles(&ctx).await { 101 | Some(r) => r, 102 | None => continue, 103 | }; 104 | if roles.iter().any(|role| role.id == role_id) { 105 | let _ = member.remove_role(&http, role_id).await; 106 | } else { 107 | let _ = member.add_role(&http, role_id).await; 108 | } 109 | let _ = a.delete(&ctx.http).await; 110 | }; 111 | } 112 | }); 113 | 114 | Ok(()) 115 | } 116 | -------------------------------------------------------------------------------- /src/commands/roles/removejoinrole.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[owners_only] 11 | #[description("Removes a join role from the current guild.")] 12 | #[usage("removejoinrole")] 13 | #[example("removejoinrole")] 14 | async fn removejoinrole(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { 15 | let mut conn = connect().await?; 16 | let gid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 17 | 18 | let gid = gid.to_string(); 19 | sqlx::query!("DELETE FROM joinrole WHERE guild_id = ?1;", gid) 20 | .execute(&mut conn) 21 | .await?; 22 | 23 | msg.channel_id.say(&ctx, "Join role removed!").await?; 24 | 25 | Ok(()) 26 | } 27 | -------------------------------------------------------------------------------- /src/commands/roles/removereactrole.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[owners_only] 11 | #[num_args(1)] 12 | #[description("Makes the reaction to the message above no longer add the role to a user.")] 13 | #[usage("removereactrole ")] 14 | #[example("removereactrole :heart:")] 15 | async fn removereactrole(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | let mut conn = connect().await?; 17 | let gid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 18 | 19 | let reaction = match parse_reaction(&args.single::()?, &gid, ctx).await { 20 | Some(r) => r, 21 | None => return Ok(()), 22 | }; 23 | 24 | let (rid, gid) = (reaction.id.to_string(), gid.to_string()); 25 | let result = sqlx::query!( 26 | "SELECT message_id FROM reactionroles WHERE reaction_id = ?1 AND guild_id = ?2", 27 | rid, 28 | gid 29 | ) 30 | .fetch_one(&mut conn) 31 | .await?; 32 | 33 | if let Ok(m) = ctx 34 | .http 35 | .get_message(*msg.channel_id.as_u64(), result.message_id.parse()?) 36 | .await 37 | { 38 | m.delete(&ctx).await?; 39 | } 40 | 41 | sqlx::query!( 42 | "DELETE FROM reactionroles WHERE reaction_id = ?1 AND guild_id = ?2", 43 | rid, 44 | gid 45 | ) 46 | .execute(&mut conn) 47 | .await?; 48 | 49 | msg.channel_id.say(&ctx, "Reaction role removed!").await?; 50 | 51 | Ok(()) 52 | } 53 | -------------------------------------------------------------------------------- /src/commands/settings.rs: -------------------------------------------------------------------------------- 1 | pub mod log; 2 | pub mod prefix; 3 | pub use self::log::*; 4 | pub use prefix::*; 5 | -------------------------------------------------------------------------------- /src/commands/settings/log.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | use std::convert::TryInto; 8 | 9 | #[command] 10 | #[only_in(guilds)] 11 | #[owners_only] 12 | #[min_args(0)] 13 | #[max_args(2)] 14 | #[description = "Sets the log channel. | Toggles which type of event is logged in the log channel."] 15 | #[usage = "log | log "] 16 | #[example = "log enable join"] 17 | async fn log(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 18 | let mut conn = connect().await?; 19 | 20 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found"))?; 21 | let channel_id = msg.channel_id.to_string(); 22 | 23 | if args.is_empty() { 24 | return log_channel(ctx, msg, conn, guild_id, channel_id).await; 25 | } 26 | 27 | if args.len() == 1 { 28 | return Ok(()); 29 | } 30 | 31 | let mut log_type = get_log_type(guild_id).await?; 32 | 33 | let on_off = args.single::()?; 34 | let log_kind = args.single::()?; 35 | let message: String; 36 | 37 | match &on_off[..] { 38 | "enable" => { 39 | let kind: LogType = log_kind.try_into()?; 40 | if kind == LogType::All { 41 | log_type = LogType::All as i64 42 | } else { 43 | log_type |= kind as i64; 44 | } 45 | message = format!("{} messages will now be logged!", kind); 46 | } 47 | "disable" => { 48 | let kind: LogType = log_kind.try_into()?; 49 | if kind == LogType::All { 50 | log_type = 0_i64; 51 | } else { 52 | log_type &= !(kind as i64); 53 | } 54 | message = format!("{} messages will no longer be logged!", kind); 55 | } 56 | _ => return Ok(()), 57 | } 58 | 59 | let gid = guild_id.to_string(); 60 | sqlx::query!("UPDATE log SET log_type = ?1 WHERE guild_id = ?2;", log_type, gid) 61 | .execute(&mut conn) 62 | .await?; 63 | 64 | log_channel_say(ctx, guild_id, &message).await?; 65 | 66 | Ok(()) 67 | } 68 | 69 | async fn log_channel( 70 | ctx: &Context, 71 | msg: &Message, 72 | mut conn: SqliteConnection, 73 | guild_id: GuildId, 74 | cid: String, 75 | ) -> CommandResult { 76 | let gid = guild_id.to_string(); 77 | if get_log_channel(guild_id).await.is_ok() { 78 | sqlx::query!("UPDATE log SET channel_id = ?1 WHERE guild_id == ?2;", cid, gid) 79 | .execute(&mut conn) 80 | .await?; 81 | log_channel_say(ctx, guild_id, "Log channel updated!").await?; 82 | } else { 83 | sqlx::query!( 84 | "INSERT INTO log (guild_id, channel_id, log_type) values (?1, ?2, ?3)", 85 | gid, 86 | cid, 87 | LogType::All as i64 88 | ) 89 | .execute(&mut conn) 90 | .await?; 91 | msg.channel_id.say(&ctx, "Log channel set!").await?; 92 | }; 93 | Ok(()) 94 | } 95 | -------------------------------------------------------------------------------- /src/commands/settings/prefix.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[owners_only] 11 | #[num_args(1)] 12 | #[description = "Sets the prefix for the current server."] 13 | #[usage = "prefix "] 14 | #[example = "prefix !"] 15 | async fn prefix(ctx: &Context, msg: &Message, args: Args) -> CommandResult { 16 | let mut conn = connect().await?; 17 | let guildid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 18 | let pref = args.current().unwrap_or("!"); 19 | 20 | let gid = guildid.to_string(); 21 | sqlx::query!( 22 | "INSERT OR REPLACE INTO prefix (guild_id, prefix) values (?1, ?2)", 23 | gid, 24 | pref 25 | ) 26 | .execute(&mut conn) 27 | .await?; 28 | 29 | { 30 | let mut data = ctx.data.write().await; 31 | let prefixes = data 32 | .get_mut::() 33 | .ok_or_else(|| anyhow!("Guild prefix not found."))?; 34 | prefixes.insert(guildid, pref.to_string()); 35 | } 36 | 37 | msg.channel_id 38 | .say(&ctx.http, format!("The prefix has been set to: `{}`", pref)) 39 | .await?; 40 | 41 | Ok(()) 42 | } 43 | -------------------------------------------------------------------------------- /src/commands/utility.rs: -------------------------------------------------------------------------------- 1 | pub mod answer; 2 | pub mod avatar; 3 | pub mod choose; 4 | pub mod emoji; 5 | pub mod guild; 6 | pub mod leaderboard; 7 | pub mod ping; 8 | pub mod user; 9 | pub use answer::*; 10 | pub use avatar::*; 11 | pub use choose::*; 12 | pub use emoji::*; 13 | pub use guild::*; 14 | pub use leaderboard::*; 15 | pub use ping::*; 16 | pub use user::*; 17 | -------------------------------------------------------------------------------- /src/commands/utility/answer.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use rand::prelude::*; 3 | use serenity::{ 4 | framework::standard::{macros::command, Args, CommandResult}, 5 | model::prelude::*, 6 | prelude::*, 7 | }; 8 | 9 | #[command] 10 | #[min_args(1)] 11 | #[max_args(99)] 12 | #[description("Answers either yes or no to a question.")] 13 | #[usage("answer ")] 14 | #[example("answer ")] 15 | async fn answer(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { 16 | let answer = ["Yes", "No"] 17 | .choose(&mut rand::thread_rng()) 18 | .ok_or_else(|| anyhow!("Failed to choose an option."))?; 19 | 20 | msg.channel_id.say(&ctx, answer).await?; 21 | 22 | Ok(()) 23 | } 24 | -------------------------------------------------------------------------------- /src/commands/utility/avatar.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[min_args(0)] 10 | #[max_args(1)] 11 | #[description("Retrieves the avatar of a person.")] 12 | #[usage("avatar ")] 13 | #[example("avatar Elinvynia")] 14 | async fn avatar(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 15 | let user_id = if args.len() == 1 && msg.guild_id.is_some() { 16 | let arg: String = error_return_ok!(args.quoted().single()); 17 | none_return_ok!(parse_user(&arg, msg.guild_id.as_ref(), Some(ctx)).await) 18 | } else { 19 | msg.author.id 20 | }; 21 | 22 | let user = user_id.to_user(ctx).await?; 23 | let avatar = user.face(); 24 | 25 | msg.channel_id 26 | .send_message(&ctx.http, |message| { 27 | message.content(format!("{} avatar", user.tag())); 28 | message.add_file(avatar.as_str()); 29 | message 30 | }) 31 | .await?; 32 | 33 | Ok(()) 34 | } 35 | -------------------------------------------------------------------------------- /src/commands/utility/choose.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use rand::prelude::*; 3 | use serenity::{ 4 | framework::standard::{macros::command, Args, CommandResult}, 5 | model::prelude::*, 6 | prelude::*, 7 | }; 8 | 9 | #[command] 10 | #[min_args(1)] 11 | #[max_args(99)] 12 | #[description("Chooses one option from a list.")] 13 | #[usage("choose ")] 14 | #[example("choose \"have dinner\" \"go to sleep\"")] 15 | async fn choose(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | let parsed_args: Result, _> = args.quoted().iter().quoted().collect(); 17 | let options = error_return_ok!(parsed_args); 18 | 19 | let chosen = options 20 | .choose(&mut rand::thread_rng()) 21 | .ok_or_else(|| anyhow!("Failed to choose an option"))?; 22 | 23 | msg.channel_id.say(&ctx, chosen).await?; 24 | 25 | Ok(()) 26 | } 27 | -------------------------------------------------------------------------------- /src/commands/utility/emoji.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[num_args(1)] 11 | #[description("Sends an emoji as an enlargened image.")] 12 | #[usage("emoji ")] 13 | #[example("emoji :HeyGuys:")] 14 | async fn emoji(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 15 | let gid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 16 | 17 | let emoji = none_return_ok!(parse_reaction(&args.single::()?, &gid, ctx).await); 18 | let url = emoji.url(); 19 | 20 | msg.channel_id 21 | .send_message(&ctx, |msg| { 22 | msg.add_file(url.as_str()); 23 | msg 24 | }) 25 | .await?; 26 | 27 | Ok(()) 28 | } 29 | -------------------------------------------------------------------------------- /src/commands/utility/guild.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[description("Retrieves current server information.")] 11 | #[usage("guild")] 12 | #[example("guild")] 13 | async fn guild(ctx: &Context, msg: &Message) -> CommandResult { 14 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 15 | let guild = guild_id 16 | .to_guild_cached(&ctx) 17 | .await 18 | .ok_or_else(|| anyhow!("Guild not found in cache."))?; 19 | 20 | let owner = guild 21 | .owner_id 22 | .to_user(ctx) 23 | .await 24 | .map_or("Owner information not found.".to_string(), |user| user.tag()); 25 | 26 | let filter = match guild.explicit_content_filter { 27 | ExplicitContentFilter::None => "Don't scan any messages.", 28 | ExplicitContentFilter::WithoutRole => "Scan messages from members without a role.", 29 | ExplicitContentFilter::All => "Scan messages sent by all members.", 30 | _ => "ERROR", 31 | }; 32 | 33 | let notifications = match guild.default_message_notifications { 34 | DefaultMessageNotificationLevel::All => "Receive notifications for everything.", 35 | DefaultMessageNotificationLevel::Mentions => "Receive only mentions.", 36 | _ => "ERROR", 37 | }; 38 | 39 | let verification = match guild.verification_level { 40 | VerificationLevel::None => "Does not require any verification.", 41 | VerificationLevel::Low => "Must have a verified email on the user's Discord account.", 42 | VerificationLevel::Medium => "Must also be a registered user on Discord for longer than 5 minutes.", 43 | VerificationLevel::High => "Must also be a member of the guild for longer than 10 minutes.", 44 | VerificationLevel::Higher => "Must have a verified phone on the user's Discord account.", 45 | _ => "ERROR", 46 | }; 47 | 48 | let tier = match guild.premium_tier { 49 | PremiumTier::Tier0 => "Tier 0", 50 | PremiumTier::Tier1 => "Tier 1", 51 | PremiumTier::Tier2 => "Tier 2", 52 | PremiumTier::Tier3 => "Tier 3", 53 | _ => "ERROR", 54 | }; 55 | 56 | let mut message = format!("__**{}**__\n\n", guild.name); 57 | message += &format!("**ID:** {}\n", guild.id); 58 | message += &format!( 59 | "**Description:** {}\n", 60 | guild.description.unwrap_or_else(|| "None.".into()) 61 | ); 62 | message += &format!("**Members:** {}\n", guild.member_count); 63 | message += &format!("**Created At:** {}\n", guild_id.created_at()); 64 | message += &format!("**Large:** {}\n", guild.large); 65 | message += &format!("**Premium Tier:** {}\n", tier); 66 | message += &format!("**Boosters:** {}\n", guild.premium_subscription_count); 67 | message += &format!("**Owner:** {}\n", owner); 68 | message += &format!("**Content Filter:** {}\n", filter); 69 | message += &format!("**Notification Level:** {}\n", notifications); 70 | message += &format!("**Verification Level:** {}\n", verification); 71 | 72 | msg.channel_id.say(&ctx.http, message).await?; 73 | 74 | Ok(()) 75 | } 76 | -------------------------------------------------------------------------------- /src/commands/utility/leaderboard.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[only_in(guilds)] 10 | #[min_args(0)] 11 | #[max_args(1)] 12 | #[description("Retrieves the leaderboard (of a channel/user).")] 13 | #[usage("leaderboard ")] 14 | #[example("leaderboard #general")] 15 | async fn leaderboard(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 16 | if args.len() == 1 { 17 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 18 | if let Some(uid) = parse_user( 19 | args.quoted().current().ok_or_else(|| anyhow!("Argument not found."))?, 20 | Some(&guild_id), 21 | Some(ctx), 22 | ) 23 | .await 24 | { 25 | return parse_user_score(ctx, msg, uid).await; 26 | }; 27 | if let Some(chid) = parse_chan( 28 | args.quoted().current().ok_or_else(|| anyhow!("Argument not found."))?, 29 | Some(&guild_id), 30 | Some(ctx), 31 | ) 32 | .await 33 | { 34 | return parse_channel_score(ctx, msg, chid).await; 35 | }; 36 | Ok(()) 37 | } else { 38 | return parse_total_score(ctx, msg).await; 39 | } 40 | } 41 | 42 | async fn parse_user_score(ctx: &Context, msg: &Message, user_id: UserId) -> CommandResult { 43 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 44 | let rows = get_single_scores(guild_id, user_id).await?; 45 | let member = guild_id.member(ctx, user_id).await?; 46 | 47 | let mut processed = 0; 48 | let mut result = String::new(); 49 | for row in rows { 50 | if processed == 10 { 51 | break; 52 | } 53 | let cid = match parse_chan(&row.channel_id, Some(&guild_id), Some(ctx)).await { 54 | Some(id) => id, 55 | None => continue, 56 | }; 57 | let channel = match cid.to_channel(&ctx).await { 58 | Ok(c) => c, 59 | Err(_) => continue, 60 | }; 61 | result += &format!("{} - {}\n", channel, row.points)[..]; 62 | processed += 1; 63 | } 64 | 65 | msg.channel_id 66 | .say(&ctx, format!("**Leaderboard** - {}\n{}", member.display_name(), result)) 67 | .await?; 68 | 69 | Ok(()) 70 | } 71 | 72 | async fn parse_channel_score(ctx: &Context, msg: &Message, channel_id: ChannelId) -> CommandResult { 73 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 74 | let channel = channel_id.to_channel_cached(&ctx).await.ok_or("Channel not found.")?; 75 | let rows = get_channel_scores(guild_id, channel_id).await?; 76 | let mut result = String::new(); 77 | 78 | let mut user_found = false; 79 | let mut processed = 0; 80 | for x in rows.iter() { 81 | if processed >= 10 && user_found { 82 | break; 83 | }; 84 | let id = x.user_id.parse::()?; 85 | let member = match guild_id.member(ctx, id).await { 86 | Ok(m) => m, 87 | Err(_) => continue, 88 | }; 89 | if processed < 10 { 90 | result += &format!("{}. {} - {}\n", processed + 1, member.display_name(), x.points)[..]; 91 | if member.user == msg.author { 92 | user_found = true; 93 | }; 94 | } else if member.user == msg.author { 95 | result += "...\n"; 96 | result += &format!("{}. {} - {}\n", processed + 1, member.display_name(), x.points)[..]; 97 | break; 98 | } 99 | processed += 1; 100 | } 101 | 102 | msg.channel_id 103 | .say(&ctx, format!("**Leaderboard** - {} - Top 10\n{}", channel, result)) 104 | .await?; 105 | 106 | Ok(()) 107 | } 108 | 109 | async fn parse_total_score(ctx: &Context, msg: &Message) -> CommandResult { 110 | let guild_id = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 111 | let rows = get_user_scores(guild_id).await?; 112 | let mut result = String::new(); 113 | 114 | let mut user_found = false; 115 | let mut processed = 0; 116 | for x in rows.iter() { 117 | if processed >= 10 && user_found { 118 | break; 119 | }; 120 | let id = x.user_id.parse::()?; 121 | let member = match guild_id.member(ctx, id).await { 122 | Ok(m) => m, 123 | Err(_) => continue, 124 | }; 125 | if processed < 10 { 126 | result += &format!("{}. {} - {}\n", processed + 1, member.display_name(), x.points)[..]; 127 | if member.user == msg.author { 128 | user_found = true; 129 | }; 130 | } else if member.user == msg.author { 131 | result += "...\n"; 132 | result += &format!("{}. {} - {}\n", processed + 1, member.display_name(), x.points)[..]; 133 | break; 134 | } 135 | processed += 1; 136 | } 137 | 138 | msg.channel_id 139 | .say(&ctx, format!("**Leaderboard** - Top 10\n{}", result)) 140 | .await?; 141 | Ok(()) 142 | } 143 | -------------------------------------------------------------------------------- /src/commands/utility/ping.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | client::bridge::gateway::ShardId, 4 | framework::standard::{macros::command, CommandResult}, 5 | model::prelude::*, 6 | prelude::*, 7 | }; 8 | 9 | #[command] 10 | #[description = "Retrieves the current shard latency."] 11 | #[usage = "ping"] 12 | #[example = "ping"] 13 | async fn ping(ctx: &Context, msg: &Message) -> CommandResult { 14 | let data = ctx.data.read().await; 15 | let shard_manager = data 16 | .get::() 17 | .ok_or_else(|| anyhow!("Shard manager container not found."))?; 18 | 19 | let manager = shard_manager.lock().await; 20 | let runners = manager.runners.lock().await; 21 | let runner = runners 22 | .get(&ShardId(ctx.shard_id)) 23 | .ok_or_else(|| anyhow!("Shard not found."))?; 24 | 25 | match runner.latency { 26 | Some(x) => { 27 | msg.channel_id 28 | .say(&ctx, &format!("The shard latency is {}ms.", x.as_millis())) 29 | .await?; 30 | } 31 | None => { 32 | msg.channel_id 33 | .say(&ctx, "Please wait until the shard measures the latency.") 34 | .await?; 35 | } 36 | }; 37 | 38 | Ok(()) 39 | } 40 | -------------------------------------------------------------------------------- /src/commands/utility/user.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::command, Args, CommandResult}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | #[command] 9 | #[min_args(0)] 10 | #[max_args(1)] 11 | #[description("Retrieves information about a user.")] 12 | #[usage("user ")] 13 | #[example("user Elinvynia")] 14 | async fn user(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { 15 | let user_id = if !args.is_empty() && msg.guild_id.is_some() { 16 | let name: String = error_return_ok!(args.single()); 17 | let gid = msg.guild_id.ok_or_else(|| anyhow!("Guild ID not found."))?; 18 | none_return_ok!(parse_user(&name, Some(&gid), Some(ctx)).await) 19 | } else { 20 | msg.author.id 21 | }; 22 | 23 | let user = user_id.to_user(ctx).await?; 24 | let mut message = String::from("User found!\n"); 25 | message += &format!("**Tag:** {}\n", user.tag()); 26 | message += &format!("**ID:** {}\n", user.id); 27 | message += &format!("**Created At:** {}\n", user.id.created_at().format("%F %T")); 28 | 29 | if let Some(guild) = msg.guild(&ctx).await { 30 | if let Ok(member) = guild.member(&ctx, user_id).await { 31 | message += &format!( 32 | "**Joined At:** {}\n", 33 | member.joined_at.ok_or("Member join time not found.")?.format("%F %T") 34 | ); 35 | message += &format!("**Nickname:** {}\n", member.nick.unwrap_or_else(|| "None.".into())); 36 | 37 | let mut roles = vec![]; 38 | for role in member.roles { 39 | roles.push( 40 | role.to_role_cached(&ctx) 41 | .await 42 | .ok_or_else(|| anyhow!("Role not found in cache."))? 43 | .name, 44 | ) 45 | } 46 | message += &format!("**Roles:** {}\n", roles.join(", ")) 47 | }; 48 | }; 49 | 50 | msg.channel_id.say(&ctx, message).await?; 51 | 52 | Ok(()) 53 | } 54 | -------------------------------------------------------------------------------- /src/data.rs: -------------------------------------------------------------------------------- 1 | pub mod cache; 2 | pub mod db; 3 | -------------------------------------------------------------------------------- /src/data/cache.rs: -------------------------------------------------------------------------------- 1 | use serenity::{client::bridge::gateway::ShardManager, model::prelude::*, prelude::*}; 2 | use std::{collections::HashMap, sync::Arc}; 3 | 4 | pub struct BotOwners; 5 | impl TypeMapKey for BotOwners { 6 | type Value = Vec; 7 | } 8 | 9 | pub struct BotId; 10 | impl TypeMapKey for BotId { 11 | type Value = UserId; 12 | } 13 | 14 | pub struct ShardManagerContainer; 15 | impl TypeMapKey for ShardManagerContainer { 16 | type Value = Arc>; 17 | } 18 | 19 | pub struct DefaultPrefix; 20 | impl TypeMapKey for DefaultPrefix { 21 | type Value = String; 22 | } 23 | 24 | pub struct GuildPrefixes; 25 | impl TypeMapKey for GuildPrefixes { 26 | type Value = HashMap; 27 | } 28 | 29 | pub struct Presences; 30 | impl TypeMapKey for Presences { 31 | type Value = HashMap; 32 | } 33 | -------------------------------------------------------------------------------- /src/data/db.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use std::convert::TryFrom; 3 | 4 | #[derive(Debug, Clone, Copy, PartialEq)] 5 | pub enum LogType { 6 | MessageDeleted = 1 << 1, 7 | MessageEdited = 1 << 2, 8 | UserJoined = 1 << 3, 9 | UserLeft = 1 << 4, 10 | UserBanned = 1 << 5, 11 | ChannelCreated = 1 << 6, 12 | ChannelDeleted = 1 << 7, 13 | CategoryCreated = 1 << 8, 14 | CategoryDeleted = 1 << 9, 15 | UserUpdated = 1 << 10, 16 | VoiceUpdate = 1 << 11, 17 | PresenceUpdate = 1 << 12, 18 | All = (1 << 13) - 1, 19 | } 20 | 21 | impl std::fmt::Display for LogType { 22 | fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { 23 | let msg = match self { 24 | LogType::MessageDeleted => "Deleted", 25 | LogType::MessageEdited => "Edited", 26 | LogType::UserJoined => "User join", 27 | LogType::UserLeft => "User leave", 28 | LogType::UserBanned => "User ban", 29 | LogType::ChannelCreated => "Channel creations", 30 | LogType::ChannelDeleted => "Channel deletion", 31 | LogType::CategoryCreated => "Category creation", 32 | LogType::CategoryDeleted => "Category deletion", 33 | LogType::UserUpdated => "User update", 34 | LogType::VoiceUpdate => "Voice update", 35 | LogType::PresenceUpdate => "Prese update", 36 | LogType::All => "All", 37 | }; 38 | write!(fmt, "{}", msg) 39 | } 40 | } 41 | 42 | impl TryFrom for LogType { 43 | type Error = anyhow::Error; 44 | fn try_from(s: String) -> Result { 45 | match s.as_str() { 46 | "delete" => Ok(LogType::MessageDeleted), 47 | "edit" => Ok(LogType::MessageEdited), 48 | "join" => Ok(LogType::UserJoined), 49 | "ban" => Ok(LogType::UserBanned), 50 | "chancreate" => Ok(LogType::ChannelCreated), 51 | "chandelete" => Ok(LogType::ChannelDeleted), 52 | "catcreate" => Ok(LogType::CategoryCreated), 53 | "catdelete" => Ok(LogType::CategoryDeleted), 54 | "update" => Ok(LogType::UserUpdated), 55 | "voiceupdate" => Ok(LogType::VoiceUpdate), 56 | "presenceupdate" => Ok(LogType::PresenceUpdate), 57 | "all" => Ok(LogType::All), 58 | _ => Err(anyhow!("Log type not found")), 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/db.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use std::{fs::File, path::Path}; 3 | 4 | pub mod leaderboard; 5 | pub mod log; 6 | pub mod money; 7 | pub mod prefix; 8 | pub mod reactionroles; 9 | 10 | pub async fn setup_db() -> Result<()> { 11 | let mut conn = connect().await?; 12 | sqlx::query!( 13 | "CREATE TABLE IF NOT EXISTS log (guild_id TEXT PRIMARY KEY, channel_id TEXT NOT NULL, log_type TEXT NOT NULL);" 14 | ) 15 | .execute(&mut conn) 16 | .await?; 17 | sqlx::query!("CREATE TABLE IF NOT EXISTS prefix (guild_id TEXT PRIMARY KEY, prefix TEXT NOT NULL);") 18 | .execute(&mut conn) 19 | .await?; 20 | sqlx::query!("CREATE TABLE IF NOT EXISTS leaderboard (guild_id TEXT NOT NULL, user_id TEXT NOT NULL, channel_id TEXT NOT NULL, points INTEGER DEFAULT 0 NOT NULL, PRIMARY KEY (guild_id, user_id, channel_id));") 21 | .execute(&mut conn).await?; 22 | sqlx::query!("CREATE TABLE IF NOT EXISTS money (guild_id TEXT NOT NULL, user_id TEXT NOT NULL, money INTEGER DEFAULT 0 NOT NULL, PRIMARY KEY (guild_id, user_id));") 23 | .execute(&mut conn).await?; 24 | sqlx::query!( 25 | "CREATE TABLE IF NOT EXISTS reactionroles (guild_id TEXT NOT NULL, message_id TEXT NOT NULL, role_id TEXT NOT NULL, reaction_id TEXT NOT NULL, PRIMARY KEY (guild_id, message_id, role_id, reaction_id));") 26 | .execute(&mut conn).await?; 27 | sqlx::query!( 28 | "CREATE TABLE IF NOT EXISTS joinrole (guild_id TEXT NOT NULL, role_id TEXT NOT NULL, PRIMARY KEY (guild_id, role_id));") 29 | .execute(&mut conn).await?; 30 | Ok(()) 31 | } 32 | 33 | pub async fn connect() -> Result { 34 | let db = Path::new("db.sqlite3"); 35 | if !db.exists() { 36 | File::create(&db)?; 37 | }; 38 | Ok(SqliteConnection::connect("sqlite://db.sqlite3").await?) 39 | } 40 | -------------------------------------------------------------------------------- /src/db/leaderboard.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::futures::TryStreamExt; 3 | use serenity::model::prelude::*; 4 | 5 | #[derive(Debug)] 6 | pub struct LeaderboardEntry { 7 | pub user_id: String, 8 | pub channel_id: String, 9 | pub points: i64, 10 | } 11 | 12 | pub async fn get_user_score(guildid: GuildId, channelid: ChannelId, userid: UserId) -> Result { 13 | let mut conn = connect().await?; 14 | 15 | let (gid, cid, uid) = (guildid.to_string(), channelid.to_string(), userid.to_string()); 16 | let result = sqlx::query!( 17 | "SELECT points FROM leaderboard WHERE guild_id == ?1 AND channel_id == ?2 AND user_id == ?3;", 18 | gid, 19 | cid, 20 | uid 21 | ) 22 | .fetch_optional(&mut conn) 23 | .await?; 24 | 25 | match result { 26 | Some(row) => Ok(row.points), 27 | None => { 28 | sqlx::query!( 29 | "INSERT INTO leaderboard (guild_id, channel_id, user_id, points) VALUES (?1, ?2, ?3, ?4);", 30 | gid, 31 | cid, 32 | uid, 33 | 1 34 | ) 35 | .execute(&mut conn) 36 | .await?; 37 | Ok(1) 38 | } 39 | } 40 | } 41 | 42 | pub async fn add_user_score(guildid: GuildId, channelid: ChannelId, userid: UserId, amount: i64) -> Result<()> { 43 | let score = get_user_score(guildid, channelid, userid).await?; 44 | let mut conn = connect().await?; 45 | 46 | let (change, gid, cid, uid) = ( 47 | score + amount, 48 | guildid.to_string(), 49 | channelid.to_string(), 50 | userid.to_string(), 51 | ); 52 | sqlx::query!( 53 | "UPDATE leaderboard SET points = ?1 WHERE guild_id == ?2 AND channel_id == ?3 AND user_id == ?4;", 54 | change, 55 | gid, 56 | cid, 57 | uid 58 | ) 59 | .execute(&mut conn) 60 | .await?; 61 | Ok(()) 62 | } 63 | 64 | pub async fn inc_user_score(guildid: GuildId, channelid: ChannelId, userid: UserId) -> Result<()> { 65 | add_user_score(guildid, channelid, userid, 1).await 66 | } 67 | 68 | pub async fn get_single_scores(guildid: GuildId, userid: UserId) -> Result> { 69 | let mut conn = connect().await?; 70 | 71 | let (gid, uid) = (guildid.to_string(), userid.to_string()); 72 | let mut result = sqlx::query!("SELECT user_id, channel_id, points FROM leaderboard WHERE guild_id == ?1 AND user_id == ?2 ORDER BY points DESC;", 73 | gid, uid).fetch(&mut conn); 74 | 75 | let mut rows = vec![]; 76 | while let Ok(Some(row)) = result.try_next().await { 77 | rows.push(LeaderboardEntry { 78 | user_id: row.user_id, 79 | channel_id: row.channel_id, 80 | points: row.points, 81 | }) 82 | } 83 | 84 | Ok(rows) 85 | } 86 | 87 | pub async fn get_user_scores(guildid: GuildId) -> Result> { 88 | let mut conn = connect().await?; 89 | 90 | let gid = guildid.to_string(); 91 | let mut result = sqlx::query!(r#"SELECT user_id, SUM(points) as "points!: i64" FROM leaderboard WHERE guild_id == ?1 GROUP BY user_id ORDER BY "points!: i64" DESC;"#, 92 | gid).fetch(&mut conn); 93 | 94 | let mut rows = vec![]; 95 | while let Ok(Some(row)) = result.try_next().await { 96 | rows.push(LeaderboardEntry { 97 | user_id: row.user_id, 98 | channel_id: "".into(), 99 | points: row.points, 100 | }) 101 | } 102 | 103 | Ok(rows) 104 | } 105 | 106 | pub async fn get_channel_scores(guildid: GuildId, channelid: ChannelId) -> Result> { 107 | let mut conn = connect().await?; 108 | 109 | let (gid, cid) = (guildid.to_string(), channelid.to_string()); 110 | let mut result = sqlx::query!("SELECT user_id, channel_id, points FROM leaderboard WHERE guild_id == ?1 AND channel_id == ?2 ORDER BY points DESC;", 111 | gid, cid).fetch(&mut conn); 112 | 113 | let mut rows = vec![]; 114 | while let Ok(Some(row)) = result.try_next().await { 115 | rows.push(LeaderboardEntry { 116 | user_id: row.user_id, 117 | channel_id: row.channel_id, 118 | points: row.points, 119 | }) 120 | } 121 | 122 | Ok(rows) 123 | } 124 | -------------------------------------------------------------------------------- /src/db/log.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn check_log_type(log_type: LogType, guildid: GuildId) -> Result<()> { 5 | let _ = get_log_channel(guildid).await?; 6 | let enabled_log_type = get_log_type(guildid).await?; 7 | let converted_log_type = log_type as i64; 8 | 9 | if enabled_log_type & converted_log_type != converted_log_type { 10 | return Err(anyhow!("Log type disabled.")); 11 | } 12 | 13 | Ok(()) 14 | } 15 | 16 | pub async fn log_channel_say(ctx: &Context, guildid: GuildId, message: &str) -> Result<()> { 17 | let log_channel = get_log_channel(guildid).await?; 18 | log_channel 19 | .send_message(ctx, |m| { 20 | m.content(message); 21 | m.allowed_mentions(|am| { 22 | am.empty_parse(); 23 | am 24 | }); 25 | m 26 | }) 27 | .await?; 28 | Ok(()) 29 | } 30 | 31 | pub async fn get_log_channel(guildid: GuildId) -> Result { 32 | let mut conn = connect().await?; 33 | let gid = guildid.to_string(); 34 | let row = sqlx::query!("SELECT channel_id FROM log WHERE guild_id == ?1;", gid) 35 | .fetch_one(&mut conn) 36 | .await?; 37 | Ok(ChannelId(row.channel_id.parse().unwrap())) 38 | } 39 | 40 | pub async fn get_log_type(guildid: GuildId) -> Result { 41 | let mut conn = connect().await?; 42 | let gid = guildid.to_string(); 43 | let row = sqlx::query!("SELECT log_type FROM log WHERE guild_id == ?1;", gid) 44 | .fetch_one(&mut conn) 45 | .await?; 46 | Ok(row.log_type.parse().unwrap()) 47 | } 48 | -------------------------------------------------------------------------------- /src/db/money.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::model::prelude::*; 3 | 4 | pub async fn get_user_money(guildid: GuildId, userid: UserId) -> Result { 5 | let mut conn = connect().await?; 6 | let gid: i64 = guildid.into(); 7 | let uid: i64 = userid.into(); 8 | 9 | let result = sqlx::query!( 10 | "SELECT money FROM money WHERE guild_id == ?1 AND user_id == ?2;", 11 | gid, 12 | uid 13 | ) 14 | .fetch_optional(&mut conn) 15 | .await?; 16 | 17 | match result { 18 | Some(row) => Ok(row.money as u64), 19 | None => { 20 | sqlx::query!("INSERT INTO money (guild_id, user_id) values (?1, ?2);", gid, uid) 21 | .execute(&mut conn) 22 | .await?; 23 | Ok(0) 24 | } 25 | } 26 | } 27 | 28 | pub async fn set_user_money(guildid: GuildId, userid: UserId, amount: u64) -> Result<()> { 29 | let mut conn = connect().await?; 30 | let gid: i64 = guildid.into(); 31 | let uid: i64 = userid.into(); 32 | 33 | let converted = amount as i64; 34 | sqlx::query!( 35 | "INSERT OR REPLACE INTO money (guild_id, user_id, money) values (?1, ?2, ?3);", 36 | gid, 37 | uid, 38 | converted 39 | ) 40 | .execute(&mut conn) 41 | .await?; 42 | 43 | Ok(()) 44 | } 45 | 46 | pub async fn add_user_money(guildid: GuildId, userid: UserId, amount: u64) -> Result<()> { 47 | let money = get_user_money(guildid, userid).await?; 48 | 49 | let mut conn = connect().await?; 50 | let gid: i64 = guildid.into(); 51 | let uid: i64 = userid.into(); 52 | 53 | let change = (money + amount) as i64; 54 | sqlx::query!( 55 | "INSERT OR REPLACE INTO money (guild_id, user_id, money) values (?1, ?2, ?3);", 56 | gid, 57 | uid, 58 | change 59 | ) 60 | .execute(&mut conn) 61 | .await?; 62 | 63 | Ok(()) 64 | } 65 | 66 | pub async fn remove_user_money(guildid: GuildId, userid: UserId, amount: u64) -> Result<()> { 67 | let money = get_user_money(guildid, userid).await?; 68 | 69 | if amount > money { 70 | return Err(anyhow!("Negative money")); 71 | }; 72 | 73 | let mut conn = connect().await?; 74 | let gid: i64 = guildid.into(); 75 | let uid: i64 = userid.into(); 76 | 77 | let change = (money - amount) as i64; 78 | sqlx::query!( 79 | "INSERT OR REPLACE INTO money (guild_id, user_id, money) values (?1, ?2, ?3);", 80 | gid, 81 | uid, 82 | change 83 | ) 84 | .execute(&mut conn) 85 | .await?; 86 | 87 | Ok(()) 88 | } 89 | 90 | pub async fn inc_user_money(guildid: GuildId, userid: UserId) -> Result<()> { 91 | add_user_money(guildid, userid, 1).await 92 | } 93 | -------------------------------------------------------------------------------- /src/db/prefix.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::model::prelude::*; 3 | 4 | pub async fn get_prefix(guildid: GuildId) -> Result { 5 | let mut conn = connect().await?; 6 | let gid = guildid.to_string(); 7 | 8 | let r = sqlx::query!("SELECT prefix FROM prefix WHERE guild_id == ?1;", gid) 9 | .fetch_one(&mut conn) 10 | .await?; 11 | Ok(r.prefix) 12 | } 13 | -------------------------------------------------------------------------------- /src/db/reactionroles.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::futures::{StreamExt, TryStreamExt}; 3 | use serenity::{collector::*, model::prelude::*, prelude::*}; 4 | 5 | pub async fn start_reactions(ctx: &Context) -> Result<()> { 6 | let mut conn = connect().await?; 7 | 8 | let mut rows = sqlx::query!("SELECT message_id, role_id, reaction_id FROM reactionroles").fetch(&mut conn); 9 | 10 | while let Ok(Some(row)) = rows.try_next().await { 11 | let message_id: u64 = match row.message_id.parse() { 12 | Ok(id) => id, 13 | Err(_) => continue, 14 | }; 15 | let message_id = MessageId(message_id); 16 | 17 | let role_id: u64 = match row.role_id.parse() { 18 | Ok(id) => id, 19 | Err(_) => continue, 20 | }; 21 | let role_id = RoleId(role_id); 22 | 23 | let reaction_id: u64 = match row.reaction_id.parse() { 24 | Ok(id) => id, 25 | Err(_) => continue, 26 | }; 27 | let reaction_id = EmojiId(reaction_id); 28 | 29 | let mut collector = ReactionCollectorBuilder::new(&ctx) 30 | .message_id(message_id) 31 | .removed(true) 32 | .filter(move |reaction| match reaction.as_ref().emoji { 33 | ReactionType::Custom { id, .. } => id == reaction_id, 34 | _ => false, 35 | }) 36 | .await; 37 | 38 | let ctx = ctx.clone(); 39 | tokio::spawn(async move { 40 | let http = &ctx.http; 41 | while let Some(event) = collector.next().await { 42 | if let ReactionAction::Added(a) = event.as_ref() { 43 | let uid = match a.user_id { 44 | Some(id) => id, 45 | None => continue, 46 | }; 47 | let gid = match a.guild_id { 48 | Some(id) => id, 49 | None => continue, 50 | }; 51 | let guild = match gid.to_partial_guild(&http).await { 52 | Ok(g) => g, 53 | Err(_) => continue, 54 | }; 55 | let mut member = match guild.member(&ctx, uid).await { 56 | Ok(m) => m, 57 | Err(_) => continue, 58 | }; 59 | let roles = match member.roles(&ctx).await { 60 | Some(r) => r, 61 | None => continue, 62 | }; 63 | if roles.iter().any(|role| role.id == role_id) { 64 | let _ = member.remove_role(&http, role_id).await; 65 | } else { 66 | let _ = member.add_role(&http, role_id).await; 67 | } 68 | let _ = a.delete(&ctx).await; 69 | }; 70 | } 71 | }); 72 | } 73 | 74 | info!("Reaction roles started."); 75 | Ok(()) 76 | } 77 | -------------------------------------------------------------------------------- /src/listeners.rs: -------------------------------------------------------------------------------- 1 | use serenity::{async_trait, model::prelude::*, prelude::*}; 2 | 3 | pub mod cache_ready; 4 | pub mod category_create; 5 | pub mod category_delete; 6 | pub mod channel_create; 7 | pub mod channel_delete; 8 | pub mod guild_ban_addition; 9 | pub mod guild_member_addition; 10 | pub mod guild_member_removal; 11 | pub mod guild_member_update; 12 | pub mod message; 13 | pub mod message_delete; 14 | pub mod message_update; 15 | pub mod presence_update; 16 | pub mod ready; 17 | pub mod voice_state_update; 18 | 19 | pub struct Handler; 20 | 21 | #[async_trait] 22 | impl EventHandler for Handler { 23 | async fn cache_ready(&self, ctx: Context, guilds: Vec) { 24 | cache_ready::cache_ready(ctx, guilds).await 25 | } 26 | 27 | async fn category_create(&self, ctx: Context, category: &ChannelCategory) { 28 | category_create::category_create(ctx, category).await 29 | } 30 | 31 | async fn category_delete(&self, ctx: Context, category: &ChannelCategory) { 32 | category_delete::category_delete(ctx, category).await 33 | } 34 | 35 | async fn channel_create(&self, ctx: Context, channel: &GuildChannel) { 36 | channel_create::channel_create(ctx, channel).await 37 | } 38 | 39 | async fn channel_delete(&self, ctx: Context, channel: &GuildChannel) { 40 | channel_delete::channel_delete(ctx, channel).await 41 | } 42 | 43 | async fn guild_ban_addition(&self, ctx: Context, guildid: GuildId, user: User) { 44 | guild_ban_addition::guild_ban_addition(ctx, guildid, user).await 45 | } 46 | 47 | async fn guild_member_addition(&self, ctx: Context, guildid: GuildId, new_member: Member) { 48 | guild_member_addition::guild_member_addition(ctx, guildid, new_member).await 49 | } 50 | 51 | async fn guild_member_removal(&self, ctx: Context, gid: GuildId, user: User, member: Option) { 52 | guild_member_removal::guild_member_removal(ctx, gid, user, member).await 53 | } 54 | 55 | async fn guild_member_update(&self, ctx: Context, old_if_available: Option, new: Member) { 56 | guild_member_update::guild_member_update(ctx, old_if_available, new).await 57 | } 58 | 59 | async fn message(&self, _ctx: Context, new_message: Message) { 60 | message::message(new_message).await 61 | } 62 | 63 | async fn message_delete( 64 | &self, 65 | ctx: Context, 66 | channel: ChannelId, 67 | deleted_message_id: MessageId, 68 | guild_id: Option, 69 | ) { 70 | message_delete::message_delete(ctx, channel, deleted_message_id, guild_id).await 71 | } 72 | 73 | async fn message_update( 74 | &self, 75 | ctx: Context, 76 | old: Option, 77 | new: Option, 78 | event: MessageUpdateEvent, 79 | ) { 80 | message_update::message_update(ctx, old, new, event).await 81 | } 82 | 83 | async fn presence_update(&self, ctx: Context, new_data: PresenceUpdateEvent) { 84 | presence_update::presence_update(ctx, new_data).await 85 | } 86 | 87 | async fn ready(&self, ctx: Context, ready: Ready) { 88 | ready::ready(ctx, ready).await 89 | } 90 | 91 | async fn voice_state_update(&self, ctx: Context, gid: Option, old: Option, new: VoiceState) { 92 | voice_state_update::voice_state_update(ctx, gid, old, new).await 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/listeners/cache_ready.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | use std::collections::HashMap; 4 | 5 | pub async fn cache_ready(ctx: Context, guilds: Vec) { 6 | info!("Cache ready: {:?}", guilds); 7 | 8 | let mut presences: HashMap = HashMap::new(); 9 | 10 | for g in guilds { 11 | let guild = match g.to_guild_cached(&ctx).await { 12 | Some(guild) => guild, 13 | None => return, 14 | }; 15 | 16 | presences.extend(guild.presences); 17 | } 18 | 19 | info!("Presences loaded: {:?}", &presences.len()); 20 | 21 | { 22 | let mut data = ctx.data.write().await; 23 | data.insert::(presences); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/listeners/category_create.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn category_create(ctx: Context, category: &ChannelCategory) { 5 | let guildid = category.guild_id; 6 | 7 | if check_log_type(LogType::CategoryCreated, guildid).await.is_err() { 8 | return; 9 | } 10 | 11 | let mut msg = String::from("**Category Created**\n"); 12 | msg += &format!("ID: {}\n", category.id); 13 | msg += &format!("Name: {}\n", category.name); 14 | msg += &format!("NSFW: {}\n", category.nsfw); 15 | 16 | let _ = log_channel_say(&ctx, guildid, &msg).await; 17 | } 18 | -------------------------------------------------------------------------------- /src/listeners/category_delete.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn category_delete(ctx: Context, category: &ChannelCategory) { 5 | let guildid = category.guild_id; 6 | 7 | if check_log_type(LogType::CategoryDeleted, guildid).await.is_err() { 8 | return; 9 | } 10 | 11 | let mut msg = String::from("**Category Deleted**\n"); 12 | msg += &format!("ID: {}\n", category.id); 13 | msg += &format!("Name: {}\n", category.name); 14 | msg += &format!("NSFW: {}\n", category.nsfw); 15 | 16 | let _ = log_channel_say(&ctx, guildid, &msg).await; 17 | } 18 | -------------------------------------------------------------------------------- /src/listeners/channel_create.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn channel_create(ctx: Context, channel: &GuildChannel) { 5 | let guildid = channel.guild_id; 6 | 7 | if check_log_type(LogType::ChannelCreated, guildid).await.is_err() { 8 | return; 9 | } 10 | 11 | let mut msg = String::from("**Channel Created**\n"); 12 | msg += &format!("ID: {}\n", channel.id); 13 | msg += &format!("Name: {}\n", channel.name); 14 | msg += &format!("NSFW: {}\n", channel.nsfw); 15 | 16 | let _ = log_channel_say(&ctx, guildid, &msg).await; 17 | } 18 | -------------------------------------------------------------------------------- /src/listeners/channel_delete.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn channel_delete(ctx: Context, channel: &GuildChannel) { 5 | let guildid = channel.guild_id; 6 | 7 | if check_log_type(LogType::ChannelDeleted, guildid).await.is_err() { 8 | return; 9 | } 10 | 11 | let mut msg = String::from("**Channel Deleted**\n"); 12 | msg += &format!("ID: {}\n", channel.id); 13 | msg += &format!("Name: {}\n", channel.name); 14 | msg += &format!("NSFW: {}\n", channel.nsfw); 15 | 16 | let _ = log_channel_say(&ctx, guildid, &msg).await; 17 | } 18 | -------------------------------------------------------------------------------- /src/listeners/guild_ban_addition.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn guild_ban_addition(ctx: Context, guildid: GuildId, user: User) { 5 | if check_log_type(LogType::UserBanned, guildid).await.is_err() { 6 | return; 7 | } 8 | 9 | let log_channel = match get_log_channel(guildid).await { 10 | Ok(c) => c, 11 | Err(_) => return, 12 | }; 13 | 14 | let avatar = user.face().replace("size=1024", "size=128"); 15 | let mut msg = String::from("**User Banned**\n"); 16 | msg += &format!("ID: {}\n", user.id); 17 | msg += &format!("Tag: {}\n", user.tag()); 18 | msg += &format!("Ping: {}\n", user.mention()); 19 | 20 | let _ = log_channel 21 | .send_message(&ctx, |message| { 22 | message.content(msg); 23 | message.add_file(&avatar[..]); 24 | message 25 | }) 26 | .await; 27 | } 28 | -------------------------------------------------------------------------------- /src/listeners/guild_member_addition.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::futures::TryStreamExt; 3 | use serenity::{model::prelude::*, prelude::*}; 4 | 5 | pub async fn guild_member_addition(ctx: Context, guildid: GuildId, mut new_member: Member) { 6 | if check_log_type(LogType::UserJoined, guildid).await.is_err() { 7 | return; 8 | } 9 | 10 | let log_channel = match get_log_channel(guildid).await { 11 | Ok(c) => c, 12 | Err(_) => return, 13 | }; 14 | 15 | let user = new_member.clone().user; 16 | let avatar = user.face().replace("size=1024", "size=128"); 17 | let mut msg = String::from("**User Joined**\n"); 18 | msg += &format!("ID: {}\n", user.id); 19 | msg += &format!("Tag: {}\n", user.tag()); 20 | msg += &format!("Ping: {}\n", user.mention()); 21 | 22 | let _ = log_channel 23 | .send_message(&ctx.http, |message| { 24 | message.content(msg); 25 | message.add_file(&avatar[..]); 26 | message 27 | }) 28 | .await; 29 | 30 | let mut conn = match connect().await { 31 | Ok(c) => c, 32 | Err(_) => return, 33 | }; 34 | 35 | let gid = guildid.to_string(); 36 | let mut result = sqlx::query!("SELECT role_id FROM joinrole WHERE guild_id = ?1", gid).fetch(&mut conn); 37 | 38 | while let Ok(Some(row)) = result.try_next().await { 39 | let _ = new_member.add_role(&ctx, row.role_id.parse::().unwrap()).await; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/listeners/guild_member_removal.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn guild_member_removal(ctx: Context, guildid: GuildId, user: User, _member: Option) { 5 | if check_log_type(LogType::UserLeft, guildid).await.is_err() { 6 | return; 7 | } 8 | 9 | let log_channel = match get_log_channel(guildid).await { 10 | Ok(c) => c, 11 | Err(_) => return, 12 | }; 13 | 14 | let avatar = user.face().replace("size=1024", "size=128"); 15 | let mut msg = String::from("**User Left**\n"); 16 | msg += &format!("ID: {}\n", user.id); 17 | msg += &format!("Tag: {}\n", user.tag()); 18 | msg += &format!("Ping: {}\n", user.mention()); 19 | 20 | let _ = log_channel 21 | .send_message(&ctx.http, |message| { 22 | message.content(msg); 23 | message.add_file(&avatar[..]); 24 | message 25 | }) 26 | .await; 27 | } 28 | -------------------------------------------------------------------------------- /src/listeners/guild_member_update.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn guild_member_update(ctx: Context, old_if_available: Option, new: Member) { 5 | let old = match old_if_available { 6 | Some(m) => m, 7 | None => return, 8 | }; 9 | let guildid = new.guild_id; 10 | 11 | if check_log_type(LogType::UserUpdated, guildid).await.is_err() { 12 | return; 13 | } 14 | 15 | let log_channel = match get_log_channel(guildid).await { 16 | Ok(c) => c, 17 | Err(_) => return, 18 | }; 19 | 20 | let username_changed = old.user.name != new.user.name; 21 | let nickname_changed = old.nick != new.nick; 22 | let avatar_changed = old.user.avatar != new.user.avatar; 23 | 24 | if !username_changed && !nickname_changed && !avatar_changed { 25 | return; 26 | }; 27 | 28 | let url = match new.user.avatar_url() { 29 | Some(u) => u, 30 | None => return, 31 | }; 32 | 33 | let _ = log_channel 34 | .send_message(&ctx, |message| { 35 | let mut content = String::from("**User Updated**\n"); 36 | content += &format!("Username: {}\n", new.user.name); 37 | content += &format!("ID: {}\n", new.user.id); 38 | content += &format!("Tag: {}\n", new.user.tag()); 39 | content += &format!("Ping: {}\n", new.user.mention()); 40 | if username_changed { 41 | content += &format!("Username changed: {} to {}\n", old.user.name, new.user.name); 42 | }; 43 | if nickname_changed { 44 | content += &format!( 45 | "Nickname changed: {} to {}\n", 46 | old.nick.unwrap_or_else(|| "None".into()), 47 | new.nick.unwrap_or_else(|| "None".into()) 48 | ); 49 | }; 50 | if avatar_changed { 51 | content += "Avatar changed.\n"; 52 | message.add_file(url.as_str()); 53 | }; 54 | message.content(content); 55 | message.allowed_mentions(|am| { 56 | am.empty_parse(); 57 | am 58 | }); 59 | message 60 | }) 61 | .await; 62 | } 63 | -------------------------------------------------------------------------------- /src/listeners/message.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::model::prelude::*; 3 | 4 | pub async fn message(new_message: Message) { 5 | let guild_id = match new_message.guild_id { 6 | Some(g) => g, 7 | None => return, 8 | }; 9 | 10 | if new_message.author.bot { 11 | return; 12 | } 13 | 14 | let prefix = match get_prefix(guild_id).await { 15 | Ok(p) => p, 16 | Err(_) => "!".into(), 17 | }; 18 | 19 | if new_message.content.starts_with(&prefix) { 20 | return; 21 | }; 22 | 23 | let _ = inc_user_score(guild_id, new_message.channel_id, new_message.author.id).await; 24 | let _ = inc_user_money(guild_id, new_message.author.id).await; 25 | } 26 | -------------------------------------------------------------------------------- /src/listeners/message_delete.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn message_delete( 5 | ctx: Context, 6 | channel: ChannelId, 7 | deleted_message_id: MessageId, 8 | guild_id: Option, 9 | ) { 10 | let channel: Channel = match channel.to_channel(&ctx).await { 11 | Ok(c) => c, 12 | Err(_) => return, 13 | }; 14 | 15 | let guildid = match guild_id { 16 | Some(g) => g, 17 | None => return, 18 | }; 19 | 20 | if check_log_type(LogType::MessageDeleted, guildid).await.is_err() { 21 | return; 22 | } 23 | 24 | let message = match ctx.cache.message(&channel.id(), &deleted_message_id).await { 25 | Some(msg) => { 26 | let data = ctx.data.read().await; 27 | let botid = match data.get::() { 28 | Some(id) => id, 29 | None => return, 30 | }; 31 | if &msg.author.id == botid { 32 | return; 33 | }; 34 | let channel = match msg.channel(&ctx.cache).await { 35 | Some(c) => c, 36 | None => return, 37 | }; 38 | let mut message = String::from("**Message Deleted**\n"); 39 | message += &format!("ID: {}\n", msg.author.id); 40 | message += &format!("Tag: {}\n", msg.author.tag()); 41 | message += &format!("Ping: {}\n", msg.author.mention()); 42 | message += &format!("Channel: {}\n", channel); 43 | message += &format!("Content: \n{}\n", msg.content); 44 | message 45 | } 46 | None => { 47 | let mut message = String::from("**Message Deleted**\n"); 48 | message += &format!("Message ID: {}\n", deleted_message_id); 49 | message 50 | } 51 | }; 52 | 53 | let _ = log_channel_say(&ctx, guildid, &message).await; 54 | } 55 | -------------------------------------------------------------------------------- /src/listeners/message_update.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn message_update(ctx: Context, old: Option, new: Option, _: MessageUpdateEvent) { 5 | let old_m = match old { 6 | Some(m) => m, 7 | None => return, 8 | }; 9 | 10 | let new_m = match new { 11 | Some(m) => m, 12 | None => return, 13 | }; 14 | 15 | let guildid = match new_m.guild_id { 16 | Some(gid) => gid, 17 | None => return, 18 | }; 19 | 20 | let data = ctx.data.read().await; 21 | let botid = match data.get::() { 22 | Some(bid) => bid, 23 | None => return, 24 | }; 25 | 26 | if &new_m.author.id == botid { 27 | return; 28 | } 29 | 30 | if let Ok(user) = new_m.author.id.to_user(&ctx).await { 31 | if user.bot { 32 | return; 33 | }; 34 | }; 35 | 36 | if check_log_type(LogType::MessageEdited, guildid).await.is_err() { 37 | return; 38 | } 39 | 40 | let channel = match new_m.channel(&ctx.cache).await { 41 | Some(c) => c, 42 | None => return, 43 | }; 44 | 45 | if old_m.content == new_m.content { 46 | return; 47 | } 48 | 49 | let mut message = String::from("**Message Updated**\n"); 50 | message += &format!("ID: {}\n", new_m.author.id); 51 | message += &format!("Tag: {}\n", new_m.author.tag()); 52 | message += &format!("Ping: {}\n", new_m.author.mention()); 53 | message += &format!("Channel: {}\n", channel); 54 | message += &format!("Old Message: \n{}\n", old_m.content); 55 | message += "---\n"; 56 | message += &format!("New Message: \n{}\n", new_m.content); 57 | 58 | let _ = log_channel_say(&ctx, guildid, &message).await; 59 | } 60 | -------------------------------------------------------------------------------- /src/listeners/presence_update.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn presence_update(ctx: Context, new_data: PresenceUpdateEvent) { 5 | let gid = match new_data.guild_id { 6 | Some(id) => id, 7 | None => return, 8 | }; 9 | 10 | if check_log_type(LogType::PresenceUpdate, gid).await.is_err() { 11 | return; 12 | } 13 | 14 | let uid = new_data.presence.user_id; 15 | let new_presence = new_data.presence; 16 | 17 | let user = match uid.to_user_cached(&ctx).await { 18 | Some(u) => u, 19 | None => return, 20 | }; 21 | 22 | // Fetch the old presence for comparison. 23 | let old_presence; 24 | { 25 | let data = ctx.data.read().await; 26 | let presences = match data.get::() { 27 | Some(p) => p, 28 | None => return, 29 | }; 30 | old_presence = match presences.get(&uid) { 31 | Some(p) => p.clone(), 32 | None => return, 33 | }; 34 | } 35 | 36 | // Update the cache with the new presence. 37 | { 38 | let mut data = ctx.data.write().await; 39 | let presences = match data.get_mut::() { 40 | Some(p) => p, 41 | None => return, 42 | }; 43 | presences.insert(uid, new_presence.clone()); 44 | } 45 | 46 | let mut message = String::from("Presence Update\n"); 47 | message += &format!("ID: {}\n", user.id); 48 | message += &format!("Username: {}\n", user.tag()); 49 | 50 | let mut change = false; 51 | if old_presence.status != new_presence.status { 52 | message += &format!("Status is now {:?} ", new_presence.status); 53 | match new_presence.client_status { 54 | Some(ClientStatus { desktop: Some(_), .. }) => message += "on Desktop", 55 | Some(ClientStatus { mobile: Some(_), .. }) => message += "on Mobile", 56 | Some(ClientStatus { web: Some(_), .. }) => message += "on Web", 57 | _ => {} 58 | }; 59 | message += "\n"; 60 | change = true; 61 | }; 62 | 63 | if !change { 64 | return; 65 | }; 66 | 67 | let _ = log_channel_say(&ctx, gid, &message).await; 68 | } 69 | -------------------------------------------------------------------------------- /src/listeners/ready.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn ready(ctx: Context, ready: Ready) { 5 | info!("Connected as {}", ready.user.name); 6 | 7 | start_reactions(&ctx).await.expect("Failed to start reaction roles"); 8 | } 9 | -------------------------------------------------------------------------------- /src/listeners/voice_state_update.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{model::prelude::*, prelude::*}; 3 | 4 | pub async fn voice_state_update(ctx: Context, gid: Option, old: Option, new: VoiceState) { 5 | let gid = match gid { 6 | Some(id) => id, 7 | None => return, 8 | }; 9 | 10 | if check_log_type(LogType::VoiceUpdate, gid).await.is_err() { 11 | return; 12 | }; 13 | 14 | let user = match new.user_id.to_user_cached(&ctx).await { 15 | Some(u) => u, 16 | None => return, 17 | }; 18 | 19 | let mut message = String::from("**Voice State Updated**\n"); 20 | message += &format!("ID: {}\n", user.id); 21 | message += &format!("Tag: {}\n", user.tag()); 22 | message += &format!("Ping: {}\n", user.mention()); 23 | 24 | let old = match old { 25 | Some(o) => o, 26 | None => { 27 | if let Some(vc) = new.channel_id { 28 | let channel = vc 29 | .to_channel(&ctx) 30 | .await 31 | .ok() 32 | .map_or("Failed to get channel name.".to_string(), |c| c.to_string()); 33 | message += &format!("Joined voice channel: {}\n", channel); 34 | let _ = log_channel_say(&ctx, gid, &message).await; 35 | }; 36 | return; 37 | } 38 | }; 39 | 40 | if old.deaf != new.deaf { 41 | if old.deaf { 42 | message += "User is no longer deafened.\n"; 43 | } else { 44 | message += "User has been deafened.\n"; 45 | } 46 | }; 47 | 48 | if old.mute != new.mute { 49 | if old.mute { 50 | message += "User is no longer muted.\n"; 51 | } else { 52 | message += "User has been muted.\n"; 53 | } 54 | }; 55 | 56 | if old.self_deaf != new.self_deaf { 57 | if old.self_deaf { 58 | message += "User is no longer self-deafened.\n"; 59 | } else { 60 | message += "User has been self-deafened.\n"; 61 | } 62 | }; 63 | 64 | if old.self_mute != new.self_mute { 65 | if old.self_mute { 66 | message += "User is no longer self-muted.\n"; 67 | } else { 68 | message += "User has been self-muted.\n"; 69 | } 70 | }; 71 | 72 | if old.suppress != new.suppress { 73 | if old.suppress { 74 | message += "User is no longer suppressed.\n"; 75 | } else { 76 | message += "User has been suppressed.\n"; 77 | } 78 | }; 79 | 80 | if old.channel_id != new.channel_id { 81 | if new.channel_id.is_none() { 82 | let cid = match old.channel_id { 83 | Some(id) => id, 84 | None => return, 85 | }; 86 | let channel = cid 87 | .to_channel(&ctx) 88 | .await 89 | .ok() 90 | .map_or("Failed to get channel name".to_string(), |c| c.to_string()); 91 | message += &format!("User left voice channel: {}\n", channel); 92 | }; 93 | 94 | if let Some(oid) = old.channel_id { 95 | if let Some(nid) = new.channel_id { 96 | let old_channel = oid 97 | .to_channel(&ctx) 98 | .await 99 | .ok() 100 | .map_or("Failed to get channel name".to_string(), |c| c.to_string()); 101 | let new_channel = nid 102 | .to_channel(&ctx) 103 | .await 104 | .ok() 105 | .map_or("Failed to get channel name".to_string(), |c| c.to_string()); 106 | message += &format!("User moved from channel {} to channel {}\n", old_channel, new_channel); 107 | } 108 | } 109 | }; 110 | 111 | let _ = log_channel_say(&ctx, gid, &message).await; 112 | } 113 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use crate::{commands::*, db::setup_db, listeners::Handler, prelude::*, utils::framework::*}; 2 | use serenity::{ 3 | client::bridge::gateway::GatewayIntents, framework::StandardFramework, http::Http, model::prelude::*, prelude::*, 4 | }; 5 | use std::{ 6 | collections::{HashMap, HashSet}, 7 | env, 8 | sync::Arc, 9 | }; 10 | 11 | pub mod commands; 12 | pub mod data; 13 | pub mod db; 14 | pub mod listeners; 15 | pub mod prelude; 16 | pub mod utils; 17 | 18 | #[tokio::main] 19 | async fn main() { 20 | dotenv::dotenv().expect("Failed to initialize dotenv."); 21 | env_logger::init(); 22 | 23 | let mut settings = config::Config::default(); 24 | settings 25 | .merge(config::File::with_name("config")) 26 | .expect("Failed to open the config file."); 27 | 28 | setup_db().await.expect("Failed to set up database."); 29 | 30 | //If a token exists in the dotenv, prefer to use that. 31 | let token = if let Ok(x) = env::var("DISCORD_TOKEN") { 32 | x 33 | } else { 34 | settings 35 | .get_str("discord_token") 36 | .expect("discord_token not found in config.") 37 | }; 38 | 39 | let http = Http::new_with_token(&token); 40 | 41 | //Get the application info to use for later. 42 | let (owners, botid, ownerid) = match http.get_current_application_info().await { 43 | Ok(info) => { 44 | let mut owners = HashSet::new(); 45 | owners.insert(info.owner.id); 46 | 47 | (owners, info.id, info.owner.id) 48 | } 49 | Err(why) => panic!("Couldn't get application info: {:?}", why), 50 | }; 51 | 52 | let framework = StandardFramework::new() 53 | .configure(|c| c.owners(owners).on_mention(Some(botid)).dynamic_prefix(dynamic_prefix)) 54 | .on_dispatch_error(dispatch_error) 55 | .after(after) 56 | .normal_message(log_dm) 57 | .help(&HELP) 58 | .group(&ADMIN_GROUP) 59 | .group(&GAMBLING_GROUP) 60 | .group(&ROLES_GROUP) 61 | .group(&SETTINGS_GROUP) 62 | .group(&UTILITY_GROUP); 63 | 64 | let mut client = Client::builder(&token) 65 | .intents(GatewayIntents::all()) 66 | .event_handler(Handler) 67 | .framework(framework) 68 | .await 69 | .expect("Error creating the client."); 70 | 71 | //Set the cache for each channel to 10000 messages. 72 | client.cache_and_http.cache.set_max_messages(10000).await; 73 | 74 | //Collect the bot owners. 75 | let mut bot_owners: Vec = settings 76 | .get_array("bot_owners") 77 | .expect("bot_owners not found in config.") 78 | .into_iter() 79 | .map(|x| UserId(x.try_into::().expect("Failed to decode owner ID into UserId."))) 80 | .collect(); 81 | bot_owners.push(ownerid); 82 | 83 | //Fill the data with previously gathered and default values. 84 | { 85 | let mut data = client.data.write().await; 86 | data.insert::(Arc::clone(&client.shard_manager)); 87 | data.insert::(botid); 88 | data.insert::(bot_owners); 89 | data.insert::( 90 | settings 91 | .get_str("default_prefix") 92 | .expect("default_prefix not found in config."), 93 | ); 94 | let map = HashMap::new(); 95 | data.insert::(map); 96 | } 97 | 98 | client.start_autosharded().await.expect("Failed to start the client."); 99 | } 100 | -------------------------------------------------------------------------------- /src/prelude.rs: -------------------------------------------------------------------------------- 1 | pub use crate::data::{cache::*, db::*}; 2 | pub use crate::db::{connect, leaderboard::*, log::*, money::*, prefix::*, reactionroles::*}; 3 | pub use crate::utils::parse::*; 4 | pub use crate::{error_return, error_return_ok, none_return, none_return_ok}; 5 | pub use anyhow::{anyhow, Result}; 6 | pub use log::{error, info}; 7 | pub use sqlx::*; 8 | -------------------------------------------------------------------------------- /src/utils.rs: -------------------------------------------------------------------------------- 1 | pub mod framework; 2 | pub mod macros; 3 | pub mod parse; 4 | -------------------------------------------------------------------------------- /src/utils/framework.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use serenity::{ 3 | framework::standard::{macros::hook, CommandError, DispatchError}, 4 | model::prelude::*, 5 | prelude::*, 6 | }; 7 | 8 | //Sends non-command DMs from regular users to the bot owners. 9 | #[hook] 10 | pub async fn log_dm(ctx: &Context, message: &Message) { 11 | if message.guild_id.is_some() { 12 | return; 13 | } 14 | 15 | let data = ctx.data.read().await; 16 | let bot_id = match data.get::() { 17 | Some(id) => id, 18 | None => return, 19 | }; 20 | 21 | if &message.author.id == bot_id { 22 | return; 23 | }; 24 | 25 | let owner_ids = match data.get::() { 26 | Some(o) => o, 27 | None => return, 28 | }; 29 | 30 | for owner_id in owner_ids.iter() { 31 | if &message.author.id == owner_id { 32 | continue; 33 | } 34 | if let Ok(user) = owner_id.to_user(ctx).await { 35 | if let Ok(chan) = user.create_dm_channel(ctx).await { 36 | let _ = chan.say(&ctx.http, format!("DM from {}:\n{}", &message.author, &message.content)); 37 | }; 38 | }; 39 | } 40 | } 41 | 42 | //Generic handling of common user errors. 43 | #[hook] 44 | pub async fn dispatch_error(context: &Context, msg: &Message, error: DispatchError) { 45 | match error { 46 | DispatchError::NotEnoughArguments { min, given } => { 47 | let _ = msg 48 | .channel_id 49 | .say( 50 | &context.http, 51 | format!("Need {} arguments, but only got {}.", min, given), 52 | ) 53 | .await; 54 | } 55 | DispatchError::TooManyArguments { max, given } => { 56 | let _ = msg 57 | .channel_id 58 | .say( 59 | &context.http, 60 | format!("Max arguments allowed is {}, but got {}.", max, given), 61 | ) 62 | .await; 63 | } 64 | _ => error!("Unhandled dispatch error. {:?}", error), 65 | } 66 | } 67 | 68 | //Logs every command that errored, should only be used for bot failures and not user failures. 69 | #[hook] 70 | pub async fn after(_ctx: &Context, _msg: &Message, _cmd_name: &str, error: Result<(), CommandError>) { 71 | if let Err(why) = error { 72 | error!("{:?}", why); 73 | } 74 | } 75 | 76 | //Allows the use of a per-guild prefix with a default one set using the config file. 77 | #[hook] 78 | pub async fn dynamic_prefix(ctx: &Context, msg: &Message) -> Option { 79 | let default_prefix: String; 80 | 81 | { 82 | let data = ctx.data.read(); 83 | default_prefix = match data.await.get::() { 84 | Some(p) => p.clone(), 85 | None => return None, 86 | }; 87 | } 88 | 89 | // Private messages use the default prefix. 90 | if msg.is_private() || msg.guild_id.is_none() { 91 | return Some(default_prefix.to_string()); 92 | } 93 | 94 | let guildid = match msg.guild_id { 95 | Some(gid) => gid, 96 | None => return None, 97 | }; 98 | 99 | // If the guild prefix is already retrieved, use it. 100 | { 101 | let data = ctx.data.read().await; 102 | let prefixes = match data.get::() { 103 | Some(p) => p, 104 | None => return None, 105 | }; 106 | if let Some(x) = prefixes.get(&guildid) { 107 | return Some(x.to_string()); 108 | } 109 | } 110 | 111 | // Otherwise, fetch it from the db. 112 | if let Ok(prefix) = get_prefix(guildid).await { 113 | { 114 | let mut data = ctx.data.write().await; 115 | let prefixes = match data.get_mut::() { 116 | Some(p) => p, 117 | None => return None, 118 | }; 119 | prefixes.insert(guildid, prefix.clone()); 120 | } 121 | return Some(prefix); 122 | } 123 | 124 | // If there is no prefix set, use the default one. 125 | Some(default_prefix) 126 | } 127 | -------------------------------------------------------------------------------- /src/utils/macros.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! error_return { 3 | ($e:expr) => { 4 | match $e { 5 | Ok(o) => o, 6 | Err(_) => return, 7 | } 8 | }; 9 | } 10 | 11 | #[macro_export] 12 | macro_rules! none_return { 13 | ($e:expr) => { 14 | match $e { 15 | Some(s) => s, 16 | None => return, 17 | } 18 | }; 19 | } 20 | 21 | #[macro_export] 22 | macro_rules! error_return_ok { 23 | ($e:expr) => { 24 | match $e { 25 | Ok(o) => o, 26 | Err(_) => return Ok(()), 27 | } 28 | }; 29 | } 30 | 31 | #[macro_export] 32 | macro_rules! none_return_ok { 33 | ($e:expr) => { 34 | match $e { 35 | Some(s) => s, 36 | None => return Ok(()), 37 | } 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /src/utils/parse.rs: -------------------------------------------------------------------------------- 1 | use serenity::{ 2 | model::prelude::*, 3 | prelude::*, 4 | utils::{parse_channel, parse_emoji, parse_role, parse_username}, 5 | }; 6 | 7 | // A more detailed user parsing function 8 | // Priority of parsing: 9 | // 1. Mention 10 | // 2. User ID 11 | // 3. User name 12 | // 4. User name starting with 13 | // 5. User name containing 14 | pub async fn parse_user(name: &str, optional_gid: Option<&GuildId>, optional_ctx: Option<&Context>) -> Option { 15 | if let Some(x) = parse_username(&name) { 16 | return Some(UserId(x)); 17 | } 18 | 19 | let gid = match optional_gid { 20 | Some(g) => g, 21 | None => return None, 22 | }; 23 | 24 | let ctx = match optional_ctx { 25 | Some(c) => c, 26 | None => return None, 27 | }; 28 | 29 | let guild = match gid.to_guild_cached(&ctx).await { 30 | Some(g) => g, 31 | None => return None, 32 | }; 33 | 34 | if let Ok(id) = name.parse::() { 35 | if let Ok(m) = guild.member(ctx, id).await { 36 | return Some(m.user.id); 37 | } 38 | } 39 | 40 | if let Some(m) = guild.member_named(name) { 41 | return Some(m.user.id); 42 | } 43 | 44 | if let Some(m) = guild.members_starting_with(name, false, true).await.get(0) { 45 | let (mem, _) = m; 46 | return Some(mem.user.id); 47 | } 48 | 49 | if let Some(m) = guild.members_containing(name, false, true).await.get(0) { 50 | let (mem, _) = m; 51 | return Some(mem.user.id); 52 | } 53 | 54 | None 55 | } 56 | 57 | // A more detailed channel parsing function 58 | // Priority of parsing: 59 | // 1. Mention 60 | // 2. Channel ID 61 | // 3. Channel name 62 | // 4. Part of a channel name 63 | pub async fn parse_chan( 64 | name: &str, 65 | optional_gid: Option<&GuildId>, 66 | optional_ctx: Option<&Context>, 67 | ) -> Option { 68 | if let Some(x) = parse_channel(&name) { 69 | return Some(ChannelId(x)); 70 | } 71 | 72 | let gid = match optional_gid { 73 | Some(g) => g, 74 | None => return None, 75 | }; 76 | 77 | let ctx = match optional_ctx { 78 | Some(c) => c, 79 | None => return None, 80 | }; 81 | 82 | if let Ok(id) = name.parse::() { 83 | if let Some(x) = ChannelId(id).to_channel_cached(&ctx).await { 84 | return Some(x.id()); 85 | } 86 | } 87 | 88 | let guild = match gid.to_guild_cached(&ctx).await { 89 | Some(g) => g, 90 | None => return None, 91 | }; 92 | 93 | for (key, value) in guild.channels.iter() { 94 | let cname = &value.name; 95 | if cname == name { 96 | return Some(*key); 97 | } 98 | } 99 | 100 | for (key, value) in guild.channels.iter() { 101 | let cname = &value.name; 102 | if cname.contains(name) { 103 | return Some(*key); 104 | } 105 | } 106 | 107 | None 108 | } 109 | 110 | // A more detailed role parsing function 111 | // Priority of parsing: 112 | // 1. Mention 113 | // 2. Role ID 114 | // 3. Role name 115 | // 4. Part of a role name 116 | pub async fn parse_rol(name: &str, optional_gid: Option<&GuildId>, optional_ctx: Option<&Context>) -> Option { 117 | if let Some(x) = parse_role(&name) { 118 | return Some(RoleId(x)); 119 | } 120 | 121 | if optional_gid.is_none() || optional_ctx.is_none() { 122 | return None; 123 | } 124 | 125 | let gid = match optional_gid { 126 | Some(g) => g, 127 | None => return None, 128 | }; 129 | 130 | let ctx = match optional_ctx { 131 | Some(c) => c, 132 | None => return None, 133 | }; 134 | 135 | if let Ok(id) = name.parse::() { 136 | if let Some(x) = RoleId(id).to_role_cached(&ctx).await { 137 | return Some(x.id); 138 | } 139 | } 140 | 141 | let guild = match gid.to_guild_cached(&ctx).await { 142 | Some(g) => g, 143 | None => return None, 144 | }; 145 | 146 | for (key, value) in guild.roles.iter() { 147 | let rname = &value.name; 148 | if rname == name { 149 | return Some(*key); 150 | } 151 | } 152 | 153 | for (key, value) in guild.roles.iter() { 154 | let rname = &value.name; 155 | if rname.contains(name) { 156 | return Some(*key); 157 | } 158 | } 159 | 160 | None 161 | } 162 | 163 | // A more detailed reaction parsing function 164 | // Priority of parsing: 165 | // 1. Reaction 166 | // 2. Reaction ID 167 | // 3. Reaction name 168 | // 4. Part of a reaction name 169 | pub async fn parse_reaction(name: &str, gid: &GuildId, ctx: &Context) -> Option { 170 | let guild = match gid.to_guild_cached(&ctx).await { 171 | Some(g) => g, 172 | None => return None, 173 | }; 174 | 175 | if let Some(x) = parse_emoji(name) { 176 | for (_key, value) in guild.emojis.iter() { 177 | let ename = &value.name; 178 | if ename == &x.name { 179 | return Some(value.clone()); 180 | } 181 | } 182 | } 183 | 184 | if let Ok(id) = name.parse::() { 185 | for (_key, value) in guild.emojis.iter() { 186 | let eid = value.id.as_u64(); 187 | if eid == &id { 188 | return Some(value.clone()); 189 | } 190 | } 191 | } 192 | 193 | for (_key, value) in guild.emojis.iter() { 194 | let ename = &value.name; 195 | if ename == name { 196 | return Some(value.clone()); 197 | } 198 | } 199 | 200 | for (_key, value) in guild.emojis.iter() { 201 | let ename = &value.name; 202 | if ename.contains(name) { 203 | return Some(value.clone()); 204 | } 205 | } 206 | 207 | None 208 | } 209 | --------------------------------------------------------------------------------