Compare commits
1 Commits
master
...
experiment
Author | SHA1 | Date | |
---|---|---|---|
b9816fab96 |
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -1473,6 +1473,7 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rustbot_lib",
|
"rustbot_lib",
|
||||||
|
"rustbot_tokens",
|
||||||
"serde",
|
"serde",
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
"uptime_lib",
|
"uptime_lib",
|
||||||
@ -1668,9 +1669,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.135"
|
version = "1.0.136"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
|
checksum = "336a0c23cf42a38d9eaa7cd22c7040d04e1228a19a933890805ffd00a16437d2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -1702,7 +1703,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "serenity"
|
name = "serenity"
|
||||||
version = "0.12.4"
|
version = "0.12.4"
|
||||||
source = "git+https://github.com/serenity-rs/serenity?branch=next#45fb401e38c61e84b08ed368ac61a1d92805d949"
|
source = "git+https://github.com/nwerosama/serenity?branch=update-emoji#ef416bf3ff8b9423bb5bba9e44d2ba3192e8db02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aformat",
|
"aformat",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
|
@ -24,18 +24,22 @@ uptime_lib = "0.3.1"
|
|||||||
tokio = { version = "1.43.0", features = ["macros", "signal", "rt-multi-thread"] }
|
tokio = { version = "1.43.0", features = ["macros", "signal", "rt-multi-thread"] }
|
||||||
reqwest = { version = "0.12.12", features = ["native-tls-vendored"] }
|
reqwest = { version = "0.12.12", features = ["native-tls-vendored"] }
|
||||||
rustbot_lib = { path = "library" }
|
rustbot_lib = { path = "library" }
|
||||||
|
rustbot_tokens = { path = "tsclient" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
poise = { workspace = true }
|
poise = { workspace = true }
|
||||||
rustbot_cmds = { path = "cmds" }
|
rustbot_cmds = { path = "cmds" }
|
||||||
rustbot_events = { path = "events" }
|
rustbot_events = { path = "events" }
|
||||||
rustbot_lib = { workspace = true }
|
rustbot_lib = { workspace = true }
|
||||||
rustbot_tokens = { path = "tsclient" }
|
rustbot_tokens = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
poise = { git = "https://github.com/serenity-rs/poise", branch = "serenity-next" }
|
poise = { git = "https://github.com/serenity-rs/poise", branch = "serenity-next" }
|
||||||
|
|
||||||
|
[patch."https://github.com/serenity-rs/serenity"]
|
||||||
|
serenity = { git = "https://github.com/nwerosama/serenity", branch = "update-emoji" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
production = ["rustbot_lib/production", "rustbot_events/production"]
|
production = ["rustbot_lib/production", "rustbot_events/production"]
|
||||||
not_ready = ["rustbot_lib/not_ready"]
|
not_ready = ["rustbot_lib/not_ready"]
|
||||||
|
@ -8,6 +8,7 @@ poise = { workspace = true }
|
|||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
reqwest = { workspace = true }
|
reqwest = { workspace = true }
|
||||||
rustbot_lib = { workspace = true }
|
rustbot_lib = { workspace = true }
|
||||||
|
rustbot_tokens = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
sysinfo = { workspace = true }
|
sysinfo = { workspace = true }
|
||||||
uptime_lib = { workspace = true }
|
uptime_lib = { workspace = true }
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
mod dev;
|
mod dev;
|
||||||
mod eightball;
|
mod eightball;
|
||||||
mod ping;
|
mod ping;
|
||||||
|
mod role_test;
|
||||||
mod uptime;
|
mod uptime;
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
dev::dev,
|
dev::dev,
|
||||||
eightball::eightball,
|
eightball::eightball,
|
||||||
ping::ping,
|
ping::ping,
|
||||||
|
role_test::role_test,
|
||||||
uptime::uptime
|
uptime::uptime
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -21,6 +23,7 @@ macro_rules! collect {
|
|||||||
$crate::uptime(),
|
$crate::uptime(),
|
||||||
// Unsorted mess
|
// Unsorted mess
|
||||||
$crate::eightball(),
|
$crate::eightball(),
|
||||||
|
$crate::role_test(),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
66
cmds/src/dispatch/role_test.rs
Normal file
66
cmds/src/dispatch/role_test.rs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
use {
|
||||||
|
poise::serenity_prelude::{
|
||||||
|
Attachment,
|
||||||
|
CreateAttachment,
|
||||||
|
EmojiId,
|
||||||
|
RoleId
|
||||||
|
},
|
||||||
|
rustbot_lib::{
|
||||||
|
RustbotContext,
|
||||||
|
RustbotResult
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fn extract_role_id(input: &str) -> Option<u64> {
|
||||||
|
let trimmed = input.trim();
|
||||||
|
if trimmed.starts_with("<@&") && trimmed.ends_with(">") {
|
||||||
|
trimmed[3..trimmed.len() - 1].parse().ok()
|
||||||
|
} else {
|
||||||
|
trimmed.parse().ok()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Role test
|
||||||
|
#[poise::command(slash_command, subcommands("create", "edit"), install_context = "Guild", interaction_context = "Guild")]
|
||||||
|
pub async fn role_test(_: RustbotContext<'_>) -> RustbotResult<()> { Ok(()) }
|
||||||
|
|
||||||
|
/// Role test create
|
||||||
|
#[poise::command(slash_command, install_context = "Guild", interaction_context = "Guild")]
|
||||||
|
pub async fn create(
|
||||||
|
ctx: RustbotContext<'_>,
|
||||||
|
img: Attachment
|
||||||
|
) -> RustbotResult<()> {
|
||||||
|
ctx.defer().await?;
|
||||||
|
|
||||||
|
let attachment = CreateAttachment::url(ctx.http(), img.url.to_string(), img.filename).await?;
|
||||||
|
|
||||||
|
let e = ctx
|
||||||
|
.guild_id()
|
||||||
|
.unwrap()
|
||||||
|
.create_emoji(ctx.http(), "nep", &attachment.to_base64(), vec![RoleId::new(1292024065170608150)], None)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
ctx.reply(format!("{} = {:?}", e.name, e.roles)).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Role test edit
|
||||||
|
#[poise::command(slash_command, install_context = "Guild", interaction_context = "Guild")]
|
||||||
|
pub async fn edit(
|
||||||
|
ctx: RustbotContext<'_>,
|
||||||
|
emoji_id: String,
|
||||||
|
roles: String
|
||||||
|
) -> RustbotResult<()> {
|
||||||
|
ctx.defer().await?;
|
||||||
|
|
||||||
|
let role_vec: Vec<RoleId> = roles.split(',').filter_map(extract_role_id).map(RoleId::new).collect();
|
||||||
|
|
||||||
|
let e = ctx
|
||||||
|
.guild_id()
|
||||||
|
.unwrap()
|
||||||
|
.edit_emoji(ctx.http(), EmojiId::new(emoji_id.parse().unwrap()), "nep", Some(role_vec), None)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
ctx.reply(format!("{} = {:?}", e.name, e.roles)).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user