Compare commits
1 Commits
master
...
experiment
Author | SHA1 | Date | |
---|---|---|---|
b9816fab96 |
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -1473,6 +1473,7 @@ dependencies = [
|
||||
"rand",
|
||||
"reqwest",
|
||||
"rustbot_lib",
|
||||
"rustbot_tokens",
|
||||
"serde",
|
||||
"sysinfo",
|
||||
"uptime_lib",
|
||||
@ -1668,9 +1669,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.135"
|
||||
version = "1.0.136"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
|
||||
checksum = "336a0c23cf42a38d9eaa7cd22c7040d04e1228a19a933890805ffd00a16437d2"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
@ -1702,7 +1703,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "serenity"
|
||||
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 = [
|
||||
"aformat",
|
||||
"arrayvec",
|
||||
|
@ -17,25 +17,29 @@ cargo_toml = "0.21.0"
|
||||
poise = "0.6.1"
|
||||
regex = "1.11.1"
|
||||
serde = "1.0.217"
|
||||
rand = "0.9.0"
|
||||
rand = "0.8.5"
|
||||
sysinfo = "0.33.1"
|
||||
time = "0.3.37"
|
||||
uptime_lib = "0.3.1"
|
||||
tokio = { version = "1.43.0", features = ["macros", "signal", "rt-multi-thread"] }
|
||||
reqwest = { version = "0.12.12", features = ["native-tls-vendored"] }
|
||||
rustbot_lib = { path = "library" }
|
||||
rustbot_tokens = { path = "tsclient" }
|
||||
|
||||
[dependencies]
|
||||
poise = { workspace = true }
|
||||
rustbot_cmds = { path = "cmds" }
|
||||
rustbot_events = { path = "events" }
|
||||
rustbot_lib = { workspace = true }
|
||||
rustbot_tokens = { path = "tsclient" }
|
||||
rustbot_tokens = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
||||
[patch.crates-io]
|
||||
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]
|
||||
production = ["rustbot_lib/production", "rustbot_events/production"]
|
||||
not_ready = ["rustbot_lib/not_ready"]
|
||||
|
@ -8,6 +8,7 @@ poise = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
reqwest = { workspace = true }
|
||||
rustbot_lib = { workspace = true }
|
||||
rustbot_tokens = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
sysinfo = { workspace = true }
|
||||
uptime_lib = { workspace = true }
|
||||
|
@ -1,12 +1,14 @@
|
||||
mod dev;
|
||||
mod eightball;
|
||||
mod ping;
|
||||
mod role_test;
|
||||
mod uptime;
|
||||
|
||||
pub use {
|
||||
dev::dev,
|
||||
eightball::eightball,
|
||||
ping::ping,
|
||||
role_test::role_test,
|
||||
uptime::uptime
|
||||
};
|
||||
|
||||
@ -21,6 +23,7 @@ macro_rules! collect {
|
||||
$crate::uptime(),
|
||||
// Unsorted mess
|
||||
$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