removed standard_framework completely
This commit is contained in:
parent
19b3eb067e
commit
3e490bb5c4
67
Cargo.lock
generated
67
Cargo.lock
generated
@ -203,6 +203,12 @@ version = "0.1.10"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.19"
|
version = "0.4.19"
|
||||||
@ -227,16 +233,6 @@ dependencies = [
|
|||||||
"parse-zoneinfo",
|
"parse-zoneinfo",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "command_attr"
|
|
||||||
version = "0.3.0-rc.3"
|
|
||||||
source = "git+https://github.com/jellywx/serenity?branch=jellywx-member_permissions#6d96e6837bbbc09127bd728b80daccce538daf09"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@ -261,11 +257,11 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -274,7 +270,7 @@ version = "0.2.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
|
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
"maybe-uninit",
|
"maybe-uninit",
|
||||||
]
|
]
|
||||||
@ -286,7 +282,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -332,7 +328,7 @@ version = "0.8.24"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2"
|
checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -360,7 +356,7 @@ version = "1.0.18"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee"
|
checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"libc",
|
"libc",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
@ -523,7 +519,7 @@ version = "0.1.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
|
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||||
]
|
]
|
||||||
@ -757,7 +753,7 @@ version = "0.4.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -816,7 +812,7 @@ version = "0.6.22"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430"
|
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"fuchsia-zircon",
|
"fuchsia-zircon",
|
||||||
"fuchsia-zircon-sys",
|
"fuchsia-zircon-sys",
|
||||||
"iovec",
|
"iovec",
|
||||||
@ -898,7 +894,7 @@ version = "0.2.35"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853"
|
checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
@ -968,7 +964,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
|
checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"foreign-types",
|
"foreign-types",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
@ -1383,19 +1379,16 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"command_attr",
|
|
||||||
"flate2",
|
"flate2",
|
||||||
"futures",
|
"futures",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"static_assertions",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-futures",
|
"tracing-futures",
|
||||||
"typemap_rev",
|
"typemap_rev",
|
||||||
"url",
|
"url",
|
||||||
"uwl",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1417,7 +1410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770"
|
checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer 0.9.0",
|
"block-buffer 0.9.0",
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"cpuid-bool",
|
"cpuid-bool",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"opaque-debug 0.3.0",
|
"opaque-debug 0.3.0",
|
||||||
@ -1457,7 +1450,7 @@ version = "0.3.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44"
|
checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
@ -1542,12 +1535,6 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "static_assertions"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.45"
|
version = "1.0.45"
|
||||||
@ -1565,7 +1552,7 @@ version = "3.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
"rand",
|
"rand",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
@ -1711,7 +1698,7 @@ version = "0.1.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27"
|
checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"log",
|
"log",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tracing-attributes",
|
"tracing-attributes",
|
||||||
@ -1847,12 +1834,6 @@ version = "0.7.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
|
checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "uwl"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vcpkg"
|
name = "vcpkg"
|
||||||
version = "0.2.10"
|
version = "0.2.10"
|
||||||
@ -1893,7 +1874,7 @@ version = "0.2.68"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42"
|
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
@ -1920,7 +1901,7 @@ version = "0.4.18"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da"
|
checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if 0.1.10",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
|
@ -5,7 +5,6 @@ authors = ["jellywx <judesouthworth@pm.me>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serenity = { git = "https://github.com/jellywx/serenity", branch = "jellywx-member_permissions", features = ["collector", "rustls_backend"] }
|
|
||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
tokio = { version = "0.2", features = ["process"] }
|
tokio = { version = "0.2", features = ["process"] }
|
||||||
reqwest = { version = "0.10", features = ["rustls-tls"] }
|
reqwest = { version = "0.10", features = ["rustls-tls"] }
|
||||||
@ -25,5 +24,11 @@ serde_json = "1.0"
|
|||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
|
|
||||||
|
[dependencies.serenity]
|
||||||
|
git = "https://github.com/jellywx/serenity"
|
||||||
|
branch = "jellywx-member_permissions"
|
||||||
|
default-features = false
|
||||||
|
features = ["builder", "client", "framework", "cache", "gateway", "http", "model", "utils", "rustls_backend", "collector"]
|
||||||
|
|
||||||
[dependencies.regex_command_attr]
|
[dependencies.regex_command_attr]
|
||||||
path = "./regex_command_attr"
|
path = "./regex_command_attr"
|
||||||
|
@ -8,12 +8,7 @@ extern crate proc_macro;
|
|||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::{
|
use syn::{parse::Error, parse_macro_input, spanned::Spanned, Lit};
|
||||||
parse::Error,
|
|
||||||
parse_macro_input, parse_quote,
|
|
||||||
spanned::Spanned,
|
|
||||||
Lit,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(crate) mod attributes;
|
pub(crate) mod attributes;
|
||||||
pub(crate) mod consts;
|
pub(crate) mod consts;
|
||||||
@ -74,15 +69,9 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
|
|||||||
can_blacklist,
|
can_blacklist,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
propagate_err!(create_declaration_validations(&mut fun, DeclarFor::Command));
|
|
||||||
|
|
||||||
let res = parse_quote!(serenity::framework::standard::CommandResult);
|
|
||||||
create_return_type_validation(&mut fun, res);
|
|
||||||
|
|
||||||
let visibility = fun.visibility;
|
let visibility = fun.visibility;
|
||||||
let name = fun.name.clone();
|
let name = fun.name.clone();
|
||||||
let body = fun.body;
|
let body = fun.body;
|
||||||
let ret = fun.ret;
|
|
||||||
|
|
||||||
let n = name.with_suffix(COMMAND);
|
let n = name.with_suffix(COMMAND);
|
||||||
|
|
||||||
@ -103,7 +92,7 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
|
|||||||
can_blacklist: #can_blacklist,
|
can_blacklist: #can_blacklist,
|
||||||
};
|
};
|
||||||
|
|
||||||
#visibility fn #name<'fut> (#(#args),*) -> ::serenity::futures::future::BoxFuture<'fut, #ret> {
|
#visibility fn #name<'fut> (#(#args),*) -> ::serenity::futures::future::BoxFuture<'fut, ()> {
|
||||||
use ::serenity::futures::future::FutureExt;
|
use ::serenity::futures::future::FutureExt;
|
||||||
|
|
||||||
async move { #(#body)* }.boxed()
|
async move { #(#body)* }.boxed()
|
||||||
|
@ -6,8 +6,7 @@ use syn::{
|
|||||||
braced,
|
braced,
|
||||||
parse::{Error, Parse, ParseStream, Result},
|
parse::{Error, Parse, ParseStream, Result},
|
||||||
spanned::Spanned,
|
spanned::Spanned,
|
||||||
Attribute, Block, FnArg, Ident, Pat, Path, PathSegment, ReturnType, Stmt,
|
Attribute, Block, FnArg, Ident, Pat, Path, PathSegment, Stmt, Token, Visibility,
|
||||||
Token, Type, Visibility,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn parse_argument(arg: FnArg) -> Result<Argument> {
|
fn parse_argument(arg: FnArg) -> Result<Argument> {
|
||||||
@ -54,15 +53,7 @@ fn parse_argument(arg: FnArg) -> Result<Argument> {
|
|||||||
/// Test if the attribute is cooked.
|
/// Test if the attribute is cooked.
|
||||||
fn is_cooked(attr: &Attribute) -> bool {
|
fn is_cooked(attr: &Attribute) -> bool {
|
||||||
const COOKED_ATTRIBUTE_NAMES: &[&str] = &[
|
const COOKED_ATTRIBUTE_NAMES: &[&str] = &[
|
||||||
"cfg",
|
"cfg", "cfg_attr", "doc", "derive", "inline", "allow", "warn", "deny", "forbid",
|
||||||
"cfg_attr",
|
|
||||||
"doc",
|
|
||||||
"derive",
|
|
||||||
"inline",
|
|
||||||
"allow",
|
|
||||||
"warn",
|
|
||||||
"deny",
|
|
||||||
"forbid",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
COOKED_ATTRIBUTE_NAMES.iter().any(|n| attr.path.is_ident(n))
|
COOKED_ATTRIBUTE_NAMES.iter().any(|n| attr.path.is_ident(n))
|
||||||
@ -100,7 +91,6 @@ pub struct CommandFun {
|
|||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub args: Vec<Argument>,
|
pub args: Vec<Argument>,
|
||||||
pub ret: Type,
|
|
||||||
pub body: Vec<Stmt>,
|
pub body: Vec<Stmt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,14 +121,6 @@ impl Parse for CommandFun {
|
|||||||
// (...)
|
// (...)
|
||||||
let Parenthesised(args) = input.parse::<Parenthesised<FnArg>>()?;
|
let Parenthesised(args) = input.parse::<Parenthesised<FnArg>>()?;
|
||||||
|
|
||||||
let ret = match input.parse::<ReturnType>()? {
|
|
||||||
ReturnType::Type(_, t) => (*t).clone(),
|
|
||||||
ReturnType::Default => {
|
|
||||||
return Err(input
|
|
||||||
.error("expected a result type of either `CommandResult` or `CheckResult`"))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// { ... }
|
// { ... }
|
||||||
let bcont;
|
let bcont;
|
||||||
braced!(bcont in input);
|
braced!(bcont in input);
|
||||||
@ -155,7 +137,6 @@ impl Parse for CommandFun {
|
|||||||
visibility,
|
visibility,
|
||||||
name,
|
name,
|
||||||
args,
|
args,
|
||||||
ret,
|
|
||||||
body,
|
body,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -169,13 +150,12 @@ impl ToTokens for CommandFun {
|
|||||||
visibility,
|
visibility,
|
||||||
name,
|
name,
|
||||||
args,
|
args,
|
||||||
ret,
|
|
||||||
body,
|
body,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
stream.extend(quote! {
|
stream.extend(quote! {
|
||||||
#(#cooked)*
|
#(#cooked)*
|
||||||
#visibility async fn #name (#(#args),*) -> #ret {
|
#visibility async fn #name (#(#args),*) -> () {
|
||||||
#(#body)*
|
#(#body)*
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use crate::structures::CommandFun;
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use proc_macro2::Span;
|
use proc_macro2::Span;
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
@ -6,9 +5,7 @@ use quote::{format_ident, quote, ToTokens};
|
|||||||
use syn::{
|
use syn::{
|
||||||
braced, bracketed, parenthesized,
|
braced, bracketed, parenthesized,
|
||||||
parse::{Error, Parse, ParseStream, Result as SynResult},
|
parse::{Error, Parse, ParseStream, Result as SynResult},
|
||||||
parse_quote,
|
|
||||||
punctuated::Punctuated,
|
punctuated::Punctuated,
|
||||||
spanned::Spanned,
|
|
||||||
token::{Comma, Mut},
|
token::{Comma, Mut},
|
||||||
Ident, Lifetime, Lit, Type,
|
Ident, Lifetime, Lit, Type,
|
||||||
};
|
};
|
||||||
@ -153,83 +150,6 @@ impl ToTokens for Argument {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn generate_type_validation(have: Type, expect: Type) -> syn::Stmt {
|
|
||||||
parse_quote! {
|
|
||||||
serenity::static_assertions::assert_type_eq_all!(#have, #expect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub enum DeclarFor {
|
|
||||||
Command,
|
|
||||||
Help,
|
|
||||||
Check,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn create_declaration_validations(fun: &mut CommandFun, dec_for: DeclarFor) -> SynResult<()> {
|
|
||||||
let len = match dec_for {
|
|
||||||
DeclarFor::Command => 3,
|
|
||||||
DeclarFor::Help => 6,
|
|
||||||
DeclarFor::Check => 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
if fun.args.len() > len {
|
|
||||||
return Err(Error::new(
|
|
||||||
fun.args.last().unwrap().span(),
|
|
||||||
format_args!("function's arity exceeds more than {} arguments", len),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let context: Type = parse_quote!(&serenity::client::Context);
|
|
||||||
let message: Type = parse_quote!(&serenity::model::channel::Message);
|
|
||||||
let args: Type = parse_quote!(String);
|
|
||||||
let options: Type = parse_quote!(&serenity::framework::standard::CommandOptions);
|
|
||||||
let hoptions: Type = parse_quote!(&'static serenity::framework::standard::HelpOptions);
|
|
||||||
let groups: Type = parse_quote!(&[&'static serenity::framework::standard::CommandGroup]);
|
|
||||||
let owners: Type = parse_quote!(std::collections::HashSet<serenity::model::id::UserId>);
|
|
||||||
|
|
||||||
let mut index = 0;
|
|
||||||
|
|
||||||
let mut spoof_or_check = |kind: Type, name: &str| {
|
|
||||||
match fun.args.get(index) {
|
|
||||||
Some(x) => fun.body.insert(0, generate_type_validation(x.kind.clone(), kind)),
|
|
||||||
None => fun.args.push(Argument {
|
|
||||||
mutable: None,
|
|
||||||
name: Ident::new(name, Span::call_site()),
|
|
||||||
kind,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
|
|
||||||
index += 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
spoof_or_check(context, "_ctx");
|
|
||||||
spoof_or_check(message, "_msg");
|
|
||||||
|
|
||||||
if dec_for == DeclarFor::Check {
|
|
||||||
spoof_or_check(options, "_options");
|
|
||||||
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
spoof_or_check(args, "_args");
|
|
||||||
|
|
||||||
if dec_for == DeclarFor::Help {
|
|
||||||
spoof_or_check(hoptions, "_hoptions");
|
|
||||||
spoof_or_check(groups, "_groups");
|
|
||||||
spoof_or_check(owners, "_owners");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn create_return_type_validation(r#fn: &mut CommandFun, expect: Type) {
|
|
||||||
let stmt = generate_type_validation(r#fn.ret.clone(), expect);
|
|
||||||
r#fn.body.insert(0, stmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn populate_fut_lifetimes_on_refs(args: &mut Vec<Argument>) {
|
pub fn populate_fut_lifetimes_on_refs(args: &mut Vec<Argument>) {
|
||||||
for arg in args {
|
for arg in args {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use regex_command_attr::command;
|
use regex_command_attr::command;
|
||||||
|
|
||||||
use serenity::{client::Context, framework::standard::CommandResult, model::channel::Message};
|
use serenity::{client::Context, model::channel::Message};
|
||||||
|
|
||||||
use chrono::offset::Utc;
|
use chrono::offset::Utc;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
|||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[can_blacklist(false)]
|
#[can_blacklist(false)]
|
||||||
async fn ping(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
async fn ping(ctx: &Context, msg: &Message, _args: String) {
|
||||||
let now = SystemTime::now();
|
let now = SystemTime::now();
|
||||||
let since_epoch = now
|
let since_epoch = now
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
@ -26,13 +26,11 @@ async fn ping(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
|||||||
.channel_id
|
.channel_id
|
||||||
.say(&ctx, format!("Time taken to receive message: {}ms", delta))
|
.say(&ctx, format!("Time taken to receive message: {}ms", delta))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[can_blacklist(false)]
|
#[can_blacklist(false)]
|
||||||
async fn help(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
async fn help(ctx: &Context, msg: &Message, _args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -44,7 +42,8 @@ async fn help(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
|||||||
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
|
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
|
||||||
let desc = user_data.response(&pool, "help").await;
|
let desc = user_data.response(&pool, "help").await;
|
||||||
|
|
||||||
msg.channel_id
|
let _ = msg
|
||||||
|
.channel_id
|
||||||
.send_message(ctx, |m| {
|
.send_message(ctx, |m| {
|
||||||
m.embed(move |e| {
|
m.embed(move |e| {
|
||||||
e.title("Help")
|
e.title("Help")
|
||||||
@ -59,13 +58,11 @@ async fn help(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
|||||||
.color(*THEME_COLOR)
|
.color(*THEME_COLOR)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
async fn info(ctx: &Context, msg: &Message, _args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -86,7 +83,8 @@ async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
|||||||
.replace("{default_prefix}", &*DEFAULT_PREFIX)
|
.replace("{default_prefix}", &*DEFAULT_PREFIX)
|
||||||
.replace("{prefix}", &guild_data.prefix);
|
.replace("{prefix}", &guild_data.prefix);
|
||||||
|
|
||||||
msg.channel_id
|
let _ = msg
|
||||||
|
.channel_id
|
||||||
.send_message(ctx, |m| {
|
.send_message(ctx, |m| {
|
||||||
m.embed(move |e| {
|
m.embed(move |e| {
|
||||||
e.title("Info")
|
e.title("Info")
|
||||||
@ -101,13 +99,11 @@ async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
|||||||
.color(*THEME_COLOR)
|
.color(*THEME_COLOR)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn donate(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
async fn donate(ctx: &Context, msg: &Message, _args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -119,7 +115,8 @@ async fn donate(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
|||||||
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
|
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
|
||||||
let desc = user_data.response(&pool, "donate").await;
|
let desc = user_data.response(&pool, "donate").await;
|
||||||
|
|
||||||
msg.channel_id
|
let _ = msg
|
||||||
|
.channel_id
|
||||||
.send_message(ctx, |m| {
|
.send_message(ctx, |m| {
|
||||||
m.embed(move |e| {
|
m.embed(move |e| {
|
||||||
e.title("Donate")
|
e.title("Donate")
|
||||||
@ -134,14 +131,13 @@ async fn donate(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
|||||||
.color(*THEME_COLOR)
|
.color(*THEME_COLOR)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn dashboard(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
async fn dashboard(ctx: &Context, msg: &Message, _args: String) {
|
||||||
msg.channel_id
|
let _ = msg
|
||||||
|
.channel_id
|
||||||
.send_message(ctx, |m| {
|
.send_message(ctx, |m| {
|
||||||
m.embed(move |e| {
|
m.embed(move |e| {
|
||||||
e.title("Dashboard")
|
e.title("Dashboard")
|
||||||
@ -156,13 +152,11 @@ async fn dashboard(ctx: &Context, msg: &Message, _args: String) -> CommandResult
|
|||||||
.color(*THEME_COLOR)
|
.color(*THEME_COLOR)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn clock(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn clock(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -200,6 +194,4 @@ async fn clock(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use regex_command_attr::command;
|
|||||||
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
client::Context,
|
client::Context,
|
||||||
framework::{standard::CommandResult, Framework},
|
framework::Framework,
|
||||||
model::{channel::Message, id::RoleId},
|
model::{channel::Message, id::RoleId},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ use std::iter;
|
|||||||
#[supports_dm(false)]
|
#[supports_dm(false)]
|
||||||
#[permission_level(Restricted)]
|
#[permission_level(Restricted)]
|
||||||
#[can_blacklist(false)]
|
#[can_blacklist(false)]
|
||||||
async fn blacklist(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn blacklist(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -57,12 +57,10 @@ async fn blacklist(ctx: &Context, msg: &Message, args: String) -> CommandResult
|
|||||||
} else {
|
} else {
|
||||||
let _ = msg.channel_id.say(&ctx, "Unblacklisted").await;
|
let _ = msg.channel_id.say(&ctx, "Unblacklisted").await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn timezone(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn timezone(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -112,12 +110,10 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
|
|
||||||
let _ = msg.channel_id.say(&ctx, content).await;
|
let _ = msg.channel_id.say(&ctx, content).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn language(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn language(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -174,14 +170,12 @@ SELECT code FROM languages WHERE code = ? OR name = ?
|
|||||||
let _ = msg.channel_id.say(&ctx, content).await;
|
let _ = msg.channel_id.say(&ctx, content).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[supports_dm(false)]
|
#[supports_dm(false)]
|
||||||
#[permission_level(Restricted)]
|
#[permission_level(Restricted)]
|
||||||
async fn prefix(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn prefix(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -217,14 +211,12 @@ async fn prefix(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
|
|
||||||
let _ = msg.channel_id.say(&ctx, content).await;
|
let _ = msg.channel_id.say(&ctx, content).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[supports_dm(false)]
|
#[supports_dm(false)]
|
||||||
#[permission_level(Restricted)]
|
#[permission_level(Restricted)]
|
||||||
async fn restrict(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn restrict(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -345,14 +337,12 @@ WHERE
|
|||||||
.say(&ctx, user_data.response(&pool, "restrict/help").await)
|
.say(&ctx, user_data.response(&pool, "restrict/help").await)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[supports_dm(false)]
|
#[supports_dm(false)]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn alias(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn alias(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -488,6 +478,4 @@ SELECT command FROM command_aliases WHERE guild_id = (SELECT id FROM guilds WHER
|
|||||||
|
|
||||||
let _ = msg.channel_id.say(&ctx, content).await;
|
let _ = msg.channel_id.say(&ctx, content).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ use regex_command_attr::command;
|
|||||||
use serenity::{
|
use serenity::{
|
||||||
cache::Cache,
|
cache::Cache,
|
||||||
client::Context,
|
client::Context,
|
||||||
framework::standard::CommandResult,
|
|
||||||
http::CacheHttp,
|
http::CacheHttp,
|
||||||
model::{
|
model::{
|
||||||
channel::GuildChannel,
|
channel::GuildChannel,
|
||||||
@ -113,7 +112,7 @@ async fn create_webhook(
|
|||||||
#[command]
|
#[command]
|
||||||
#[supports_dm(false)]
|
#[supports_dm(false)]
|
||||||
#[permission_level(Restricted)]
|
#[permission_level(Restricted)]
|
||||||
async fn pause(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn pause(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -172,13 +171,11 @@ async fn pause(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Restricted)]
|
#[permission_level(Restricted)]
|
||||||
async fn offset(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn offset(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -243,13 +240,11 @@ UPDATE reminders SET `time` = `time` + ? WHERE reminders.channel_id = ?
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Restricted)]
|
#[permission_level(Restricted)]
|
||||||
async fn nudge(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn nudge(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -304,8 +299,6 @@ async fn nudge(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TimeDisplayType {
|
enum TimeDisplayType {
|
||||||
@ -372,7 +365,7 @@ struct LookReminder {
|
|||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn look(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn look(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -482,13 +475,11 @@ LIMIT
|
|||||||
|
|
||||||
let _ = msg.channel_id.say_lines(&ctx, display).await;
|
let _ = msg.channel_id.say_lines(&ctx, display).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn delete(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
async fn delete(ctx: &Context, msg: &Message, _args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -650,13 +641,11 @@ INSERT INTO events (event_name, bulk_count, guild_id, user_id) VALUES ('delete',
|
|||||||
let _ = msg.channel_id.say(&ctx, content).await;
|
let _ = msg.channel_id.say(&ctx, content).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn timer(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn timer(ctx: &Context, msg: &Message, args: String) {
|
||||||
fn time_difference(start_time: NaiveDateTime) -> String {
|
fn time_difference(start_time: NaiveDateTime) -> String {
|
||||||
let unix_time = SystemTime::now()
|
let unix_time = SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
@ -777,8 +766,6 @@ DELETE FROM timers WHERE owner = ? AND name = ?
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
@ -880,18 +867,14 @@ fn generate_uid() -> String {
|
|||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn remind(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn remind(ctx: &Context, msg: &Message, args: String) {
|
||||||
remind_command(ctx, msg, args, RemindCommand::Remind).await;
|
remind_command(ctx, msg, args, RemindCommand::Remind).await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn interval(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn interval(ctx: &Context, msg: &Message, args: String) {
|
||||||
remind_command(ctx, msg, args, RemindCommand::Interval).await;
|
remind_command(ctx, msg, args, RemindCommand::Interval).await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn remind_command(ctx: &Context, msg: &Message, args: String, command: RemindCommand) {
|
async fn remind_command(ctx: &Context, msg: &Message, args: String, command: RemindCommand) {
|
||||||
@ -1030,7 +1013,7 @@ async fn remind_command(ctx: &Context, msg: &Message, args: String, command: Rem
|
|||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn natural(ctx: &Context, msg: &Message, args: String) {
|
||||||
let pool = ctx
|
let pool = ctx
|
||||||
.data
|
.data
|
||||||
.read()
|
.read()
|
||||||
@ -1217,8 +1200,6 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
.send_message(&ctx, |m| m.embed(|e| e.description(resp)))
|
.send_message(&ctx, |m| m.embed(|e| e.description(resp)))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_reminder<T: TryInto<i64>, S: ToString + Type<MySql> + Encode<MySql>>(
|
async fn create_reminder<T: TryInto<i64>, S: ToString + Type<MySql> + Encode<MySql>>(
|
||||||
|
@ -3,7 +3,6 @@ use regex_command_attr::command;
|
|||||||
use serenity::{
|
use serenity::{
|
||||||
client::Context,
|
client::Context,
|
||||||
constants::MESSAGE_CODE_LIMIT,
|
constants::MESSAGE_CODE_LIMIT,
|
||||||
framework::standard::CommandResult,
|
|
||||||
model::{
|
model::{
|
||||||
channel::Message,
|
channel::Message,
|
||||||
id::{ChannelId, GuildId, UserId},
|
id::{ChannelId, GuildId, UserId},
|
||||||
@ -382,7 +381,7 @@ impl Execute for Result<SubCommand, ()> {
|
|||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn todo_user(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn todo_user(ctx: &Context, msg: &Message, args: String) {
|
||||||
let mut split = args.split(' ');
|
let mut split = args.split(' ');
|
||||||
|
|
||||||
let target = TodoTarget {
|
let target = TodoTarget {
|
||||||
@ -396,14 +395,12 @@ async fn todo_user(ctx: &Context, msg: &Message, args: String) -> CommandResult
|
|||||||
subcommand_opt
|
subcommand_opt
|
||||||
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
|
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[supports_dm(false)]
|
#[supports_dm(false)]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn todo_channel(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn todo_channel(ctx: &Context, msg: &Message, args: String) {
|
||||||
let mut split = args.split(' ');
|
let mut split = args.split(' ');
|
||||||
|
|
||||||
let target = TodoTarget {
|
let target = TodoTarget {
|
||||||
@ -417,14 +414,12 @@ async fn todo_channel(ctx: &Context, msg: &Message, args: String) -> CommandResu
|
|||||||
subcommand_opt
|
subcommand_opt
|
||||||
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
|
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
#[supports_dm(false)]
|
#[supports_dm(false)]
|
||||||
#[permission_level(Managed)]
|
#[permission_level(Managed)]
|
||||||
async fn todo_guild(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn todo_guild(ctx: &Context, msg: &Message, args: String) {
|
||||||
let mut split = args.split(' ');
|
let mut split = args.split(' ');
|
||||||
|
|
||||||
let target = TodoTarget {
|
let target = TodoTarget {
|
||||||
@ -438,8 +433,6 @@ async fn todo_guild(ctx: &Context, msg: &Message, args: String) -> CommandResult
|
|||||||
subcommand_opt
|
subcommand_opt
|
||||||
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
|
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn show_help(ctx: &Context, msg: &Message, target: Option<TodoTarget>) {
|
async fn show_help(ctx: &Context, msg: &Message, target: Option<TodoTarget>) {
|
||||||
|
@ -3,7 +3,7 @@ use async_trait::async_trait;
|
|||||||
use serenity::{
|
use serenity::{
|
||||||
client::Context,
|
client::Context,
|
||||||
constants::MESSAGE_CODE_LIMIT,
|
constants::MESSAGE_CODE_LIMIT,
|
||||||
framework::{standard::CommandResult, Framework},
|
framework::Framework,
|
||||||
futures::prelude::future::BoxFuture,
|
futures::prelude::future::BoxFuture,
|
||||||
http::Http,
|
http::Http,
|
||||||
model::{
|
model::{
|
||||||
@ -23,8 +23,7 @@ use std::{collections::HashMap, fmt};
|
|||||||
use crate::models::{GuildData, UserData};
|
use crate::models::{GuildData, UserData};
|
||||||
use crate::{models::ChannelData, SQLPool};
|
use crate::{models::ChannelData, SQLPool};
|
||||||
|
|
||||||
type CommandFn =
|
type CommandFn = for<'fut> fn(&'fut Context, &'fut Message, String) -> BoxFuture<'fut, ()>;
|
||||||
for<'fut> fn(&'fut Context, &'fut Message, String) -> BoxFuture<'fut, CommandResult>;
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum PermissionLevel {
|
pub enum PermissionLevel {
|
||||||
@ -387,7 +386,7 @@ impl Framework for RegexFramework {
|
|||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
if command.check_permissions(&ctx, &guild, &member).await {
|
if command.check_permissions(&ctx, &guild, &member).await {
|
||||||
(command.func)(&ctx, &msg, args).await.unwrap();
|
(command.func)(&ctx, &msg, args).await;
|
||||||
} else if command.required_perms == PermissionLevel::Restricted
|
} else if command.required_perms == PermissionLevel::Restricted
|
||||||
{
|
{
|
||||||
let _ = msg
|
let _ = msg
|
||||||
@ -455,7 +454,7 @@ impl Framework for RegexFramework {
|
|||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
(command.func)(&ctx, &msg, args).await.unwrap();
|
(command.func)(&ctx, &msg, args).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user