set poise version to git

This commit is contained in:
Stachelbeere1248 2024-12-15 21:26:07 +01:00
parent 03de111842
commit b97e70bfe0
Signed by: Stachelbeere1248
SSH key fingerprint: SHA256:IozEKdw2dB8TZxkpPdMxcWSoWTIMwoLaCcZJ1AJnY2o
10 changed files with 152 additions and 203 deletions

163
Cargo.lock generated
View file

@ -59,61 +59,6 @@ dependencies = [
"libc",
]
[[package]]
name = "anstream"
version = "0.6.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]]
name = "anstyle-parse"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
]
[[package]]
name = "anyhow"
version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
[[package]]
name = "arrayvec"
version = "0.7.6"
@ -296,10 +241,15 @@ dependencies = [
]
[[package]]
name = "colorchoice"
version = "1.0.2"
name = "command_attr"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
checksum = "6fcc89439e1bb4e19050a9586a767781a3060000d2f3296fd2a40597ad9421c5"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "concurrent-queue"
@ -522,29 +472,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "env_filter"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d"
dependencies = [
"anstream",
"anstyle",
"env_filter",
"humantime",
"log",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@ -966,12 +893,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "hyper"
version = "0.14.30"
@ -1137,12 +1058,6 @@ version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itoa"
version = "1.0.11"
@ -1167,6 +1082,12 @@ dependencies = [
"spin",
]
[[package]]
name = "levenshtein"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
[[package]]
name = "libc"
version = "0.2.159"
@ -1517,25 +1438,25 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "poise"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1819d5a45e3590ef33754abce46432570c54a120798bdbf893112b4211fa09a6"
source = "git+https://github.com/serenity-rs/poise#22b5b01ba54f7eb74f8fd2f3d52032fd7ef2dc01"
dependencies = [
"async-trait",
"derivative",
"futures-util",
"indexmap",
"parking_lot",
"poise_macros",
"regex",
"serenity",
"tokio",
"tracing",
"trim-in-place",
]
[[package]]
name = "poise_macros"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fa2c123c961e78315cd3deac7663177f12be4460f5440dbf62a7ed37b1effea"
source = "git+https://github.com/serenity-rs/poise#22b5b01ba54f7eb74f8fd2f3d52032fd7ef2dc01"
dependencies = [
"darling",
"proc-macro2",
@ -1701,9 +1622,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.12.8"
version = "0.12.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b"
checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f"
dependencies = [
"base64 0.22.1",
"bytes",
@ -1964,9 +1885,9 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.214"
version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
dependencies = [
"serde_derive",
]
@ -1982,9 +1903,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.214"
version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
dependencies = [
"proc-macro2",
"quote",
@ -1993,9 +1914,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.132"
version = "1.0.133"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
dependencies = [
"itoa",
"memchr",
@ -2017,9 +1938,9 @@ dependencies = [
[[package]]
name = "serenity"
version = "0.12.2"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "880a04106592d0a8f5bdacb1d935889bfbccb4a14f7074984d9cd857235d34ac"
checksum = "3d72ec4323681bf9a3cabe40fd080abc2435859b502a1b5aa9bf693f125bfa76"
dependencies = [
"arrayvec",
"async-trait",
@ -2027,10 +1948,12 @@ dependencies = [
"bitflags 2.6.0",
"bytes",
"chrono",
"command_attr",
"dashmap",
"flate2",
"futures",
"fxhash",
"levenshtein",
"mime_guess",
"parking_lot",
"percent-encoding",
@ -2039,6 +1962,7 @@ dependencies = [
"serde",
"serde_cow",
"serde_json",
"static_assertions",
"time",
"tokio",
"tokio-tungstenite",
@ -2046,6 +1970,7 @@ dependencies = [
"typemap_rev",
"typesize",
"url",
"uwl",
]
[[package]]
@ -2352,6 +2277,12 @@ dependencies = [
"url",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "stringprep"
version = "0.1.5"
@ -2686,6 +2617,12 @@ dependencies = [
"once_cell",
]
[[package]]
name = "trim-in-place"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc"
[[package]]
name = "triomphe"
version = "0.1.14"
@ -2827,10 +2764,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "utf8parse"
version = "0.2.2"
name = "uwl"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0"
[[package]]
name = "vcpkg"
@ -3227,13 +3164,9 @@ checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
name = "zmp-bot"
version = "0.1.0"
dependencies = [
"anyhow",
"env_logger",
"poise",
"regex",
"reqwest 0.12.8",
"reqwest 0.12.9",
"serde",
"serde_json",
"serenity",
"sqlx",
"tokio",

View file

@ -6,14 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
poise = "0.6.1"
serenity = { version = "0.12.1", default-features = false, features = ["client", "gateway", "model", "rustls_backend", "utils", "framework"] }
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "rt"] }
env_logger = "0.11.3"
anyhow = "1.0.93"
tracing = "0.1.40"
regex = "1.11.1"
poise = { git = "https://github.com/serenity-rs/poise" }
serenity = { version = "0.12.4" }
serde = { version = "1.0.215", features = ["derive"] }
reqwest = { version = "0.12.9", features = ["json"] }
tokio = { version = "1.41.1", features = ["rt-multi-thread"] }
tracing = { version = "0.1.40" }
sqlx = { version = "0.8.2", features = ["sqlite", "sqlx-sqlite", "runtime-tokio"]}
reqwest = { version = "0.12.5" }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = { version = "1.0.132" }

View file

@ -3,9 +3,8 @@ use reqwest::{Client, Response};
use serde::Deserialize;
use serenity::{
all::{ChannelId, CreateActionRow, CreateAllowedMentions, CreateButton, CreateMessage, ReactionType, User},
json::JsonError,
};
use serenity::all::{ButtonStyle, Message};
use serenity::all::{ButtonStyle};
use sqlx::{Pool, query_as, Sqlite};
use crate::commands::command_helper::cooldown;
@ -45,34 +44,21 @@ impl Uuid {
fn get(&self) -> &str {
self.uuid.as_str()
}
async fn fetch(ign: &str) -> Result<Self, Error> {
async fn for_ign(ign: &str) -> Result<Self, Error> {
let url: String = format!("https://api.mojang.com/users/profiles/minecraft/{ign}");
let response: Response = reqwest::get(url).await?;
let response_text = response.error_for_status()?.text().await.unwrap();
let uuid = (serde_json::from_str(response_text.as_str()) as Result<MojangPlayer, JsonError>)
.map(|mojang_player: MojangPlayer| Uuid { uuid: mojang_player.id })?;
let response_400: Response = reqwest::get(url).await?.error_for_status()?;
let deserialized = response_400.json::<MojangPlayer>().await?;
let uuid = Uuid {
uuid: deserialized.id,
};
Ok(uuid)
/*match response.error_for_status() {
Ok(res) => {
let response_text = res.text().await.unwrap();
let uuid = (serde_json::from_str(response_text.as_str())
as Result<MojangPlayer, JsonError>)
.map(|mojang_player: MojangPlayer| Uuid { uuid: mojang_player.id })?;
Ok(uuid)
}
Err(why) => Err(Error::from(format!(
"Mojang returned an error. Please make sure to enter a valid Minecraft username.\n\n\
Details: {}", why).as_str())),
}*/
}
async fn ign(&self) -> Result<String, Error> {
let url: String = format!("https://sessionserver.mojang.com/session/minecraft/profile/{}", self.uuid);
let response: Response = reqwest::get(url).await?;
let response_text = response.error_for_status()?.text().await.unwrap();
let ign = (serde_json::from_str(response_text.as_str()) as Result<MojangPlayer, JsonError>)
.map(|mojang_player: MojangPlayer| mojang_player.name)?;
Ok(ign)
let response_400: Response = reqwest::get(url).await?.error_for_status()?;
let deserialized = response_400.json::<MojangPlayer>().await?;
Ok(deserialized.name)
}
}
#[derive(PartialEq)]
@ -82,10 +68,9 @@ struct DiscordId {
impl DiscordId {
async fn matches_fetch(user: &User, uuid: &str, client: &Client) -> Result<bool, Error> {
let url: String = format!("https://api.hypixel.net/v2/player?uuid={}", uuid);
let response: Response = client.get(url).send().await?;
let response_text = response.error_for_status()?.text().await.unwrap();
let matches = (serde_json::from_str(response_text.as_str()) as Result<HypixelResponse, JsonError>)
.map(|hypixel_response: HypixelResponse| user.name == hypixel_response.player.social_media.links.discord)?;
let response_400: Response = client.get(url).send().await?.error_for_status()?;
let deserialized = response_400.json::<HypixelResponse>().await?;
let matches = deserialized.player.social_media.links.discord == user.name;
Ok(matches)
}
}
@ -137,7 +122,12 @@ pub(crate) async fn account(_ctx: Context<'_>) -> Result<(), Error> {
unreachable!()
}
#[poise::command(slash_command)]
#[poise::command(
slash_command,
install_context = "User|Guild",
interaction_context = "Guild|BotDm|PrivateChannel",
ephemeral = "false",
)]
pub(crate) async fn add<'a>(
ctx: Context<'_>,
#[description = "Minecraft username"]
@ -149,7 +139,7 @@ pub(crate) async fn add<'a>(
) -> Result<(), Error> {
ctx.defer_ephemeral().await?;
let user: User = user.unwrap_or(ctx.author().clone());
let uuid: Uuid = Uuid::fetch(ign.as_str()).await?;
let uuid: Uuid = Uuid::for_ign(ign.as_str()).await?;
let force: bool = force.unwrap_or(false) && ctx.framework().options.owners.contains(&ctx.author().id);
match DiscordId::matches_fetch(&user, uuid.get(), &ctx.data().hypixel_api_client).await? || force {
true => {
@ -215,17 +205,17 @@ pub(crate) async fn add<'a>(
.components(vec![CreateActionRow::Buttons(vec![
CreateButton::new("accept_verification")
.emoji(ReactionType::from('✅'))
.style(ButtonStyle::Primary),
.style(ButtonStyle::Secondary),
CreateButton::new("deny_verification")
.emoji(ReactionType::from('❌'))
.style(ButtonStyle::Primary),
.style(ButtonStyle::Secondary),
CreateButton::new("list_accounts")
.emoji(ReactionType::from('📜'))
.style(ButtonStyle::Secondary),
.style(ButtonStyle::Primary),
])]),
)
.await?;
ctx.send(CreateReply::default().ephemeral(false).content(status)).await?;
ctx.send(CreateReply::default().content(status)).await?;
Ok(())
}
false => Err(Error::Other(format!(
@ -236,7 +226,12 @@ pub(crate) async fn add<'a>(
}
}
#[poise::command(slash_command)]
#[poise::command(
slash_command,
install_context = "User|Guild",
interaction_context = "Guild|BotDm|PrivateChannel",
ephemeral = "false",
)]
pub(crate) async fn list(ctx: Context<'_>, user: Option<User>) -> Result<(), Error> {
ctx.defer_ephemeral().await?;
cooldown(&ctx, 600, 300)?;
@ -252,7 +247,13 @@ pub(crate) async fn list(ctx: Context<'_>, user: Option<User>) -> Result<(), Err
Ok(())
}
#[poise::command(context_menu_command="Account list")]
#[poise::command(
slash_command,
install_context = "User|Guild",
interaction_context = "Guild|PrivateChannel",
ephemeral = "false",
context_menu_command="Account list"
)]
pub(crate) async fn context_list(ctx: Context<'_>, u: User) -> Result<(), Error> {
ctx.defer_ephemeral().await?;
cooldown(&ctx, 600, 300)?;
@ -290,7 +291,7 @@ pub(crate) async fn list_string(pool: &Pool<Sqlite>, user: &User) -> Result<Stri
#[poise::command(slash_command)]
pub(crate) async fn remove(_ctx: Context<'_>) -> Result<(), Error> {
unimplemented!()
todo!()
}
async fn link_id_from_minecraft(pool: &Pool<Sqlite>, minecraft_uuid: &str) -> Option<u16> {

View file

@ -5,7 +5,13 @@ use poise::CreateReply;
use crate::Context;
use crate::error::Error;
#[poise::command(slash_command, guild_only, owners_only)]
#[poise::command(
slash_command,
owners_only,
install_context = "User",
interaction_context = "Guild|BotDm|PrivateChannel",
ephemeral = "false",
)]
pub(crate) async fn bots(
ctx: Context<'_>,
#[min = 0_u8]
@ -15,6 +21,6 @@ pub(crate) async fn bots(
ctx.defer_ephemeral().await?;
*ctx.data().bots.write().await = bots;
let content = format!("{} bots are now registered as available", bots).to_string();
ctx.send(CreateReply::default().content(content).ephemeral(true)).await?;
ctx.send(CreateReply::default().content(content)).await?;
Ok(())
}

View file

@ -5,7 +5,12 @@ use crate::commands::command_helper;
use crate::Context;
use crate::error::Error;
#[poise::command(slash_command, guild_only)]
#[poise::command(
slash_command,
install_context = "Guild",
interaction_context = "Guild",
ephemeral = "false",
)]
pub(crate) async fn helpstart(
ctx: Context<'_>,
#[min = 1_u8]
@ -34,8 +39,6 @@ pub(crate) async fn helpstart(
.ephemeral(false)
.allowed_mentions(CreateAllowedMentions::new().roles(vec![ping]))
};
if let Err(why) = ctx.send(reply).await {
println!("Error sending message: {why}")
}
ctx.send(reply).await?;
Ok(())
}

View file

@ -43,7 +43,12 @@ pub enum Difficulty {
#[name = "R.I.P."]
Rip,
}
#[poise::command(slash_command, guild_only)]
#[poise::command(
slash_command,
install_context = "Guild",
interaction_context = "Guild",
ephemeral = "false",
)]
pub(crate) async fn lfg(
ctx: Context<'_>,
#[rename = "map"] map: Map,
@ -115,9 +120,7 @@ pub(crate) async fn lfg(
.ephemeral(false)
.allowed_mentions(CreateAllowedMentions::new().roles(vec![ping]));
if let Err(why) = ctx.send(reply).await {
println!("Error sending message: {why}");
}
ctx.send(reply).await?;
Ok(())
}
#[derive(Debug, poise::ChoiceParameter)]
@ -133,7 +136,13 @@ enum ExpertMap {
#[name = "Speedrun"]
Speedrun,
}
#[poise::command(slash_command, guild_only, rename = "lfg-expert")]
#[poise::command(
slash_command,
install_context = "Guild",
interaction_context = "Guild",
ephemeral = "false",
rename = "lfg-expert"
)]
pub(crate) async fn expert(
ctx: Context<'_>,
#[rename = "map"] mode: ExpertMap,
@ -192,9 +201,7 @@ pub(crate) async fn expert(
.content("You do not have any of the required expert ranks.")
.ephemeral(true),
};
if let Err(why) = ctx.send(reply).await {
println!("Error sending message: {why}");
}
ctx.send(reply).await?;
Ok(())
}
@ -203,7 +210,13 @@ enum OtherPing {
#[name = "GeoGuessr"]
GeoGuessr,
}
#[poise::command(slash_command, guild_only, rename = "lfg-other")]
#[poise::command(
slash_command,
install_context = "Guild",
interaction_context = "Guild",
ephemeral = "false",
rename = "lfg-other"
)]
pub(crate) async fn other(
ctx: Context<'_>,
#[rename = "game"] game: OtherPing,
@ -231,9 +244,7 @@ pub(crate) async fn other(
.ephemeral(false)
.allowed_mentions(CreateAllowedMentions::new().roles(vec![ping]));
if let Err(why) = ctx.send(reply).await {
println!("Error sending message: {why}");
}
ctx.send(reply).await?;
Ok(())
}

View file

@ -10,7 +10,13 @@ const XD: &str = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
\n\n\
\n";
#[poise::command(slash_command)]
#[poise::command(
slash_command,
owners_only,
install_context = "User|Guild",
interaction_context = "Guild|BotDm|PrivateChannel",
ephemeral = "false",
)]
pub(crate) async fn xd(ctx: Context<'_>) -> Result<(), Error> {
ctx.defer_ephemeral().await?;
ctx.say(XD).await?;

View file

@ -14,7 +14,6 @@ macro_rules! reply_fail_handler {
pub enum Error {
SqlxError(sqlx::Error),
HttpsError(reqwest::Error),
ParsingError(serde_json::Error),
SerenityError(serenity::Error),
OnCooldown(std::time::Duration),
Other(String),
@ -25,11 +24,8 @@ impl std::fmt::Display for Error {
match self {
Error::SqlxError(e) => write!(f, "SQLx Error: {}", e),
Error::HttpsError(e) => write!(f, "HTTPS Error (Hypixel / Mojang API):\n{}", e),
Error::ParsingError(e) => write!(f, "Parsing Error:\n {}", e),
Error::SerenityError(e) => write!(f, "Discord Error:\n {}", e),
Error::OnCooldown(d) => {
write!(f, "This command is on cooldown. {}s remaining.", d.as_secs())
}
Error::OnCooldown(d) => write!(f, "This command is on cooldown. {}s remaining.", d.as_secs()),
Error::Other(s) => write!(f, "{}", s),
}
}
@ -47,12 +43,6 @@ impl From<reqwest::Error> for Error {
}
}
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
Error::ParsingError(error)
}
}
impl From<serenity::Error> for Error {
fn from(error: serenity::Error) -> Self {
Error::SerenityError(error)

View file

@ -1,4 +1,3 @@
use serenity::all::{ButtonStyle, ComponentInteraction};
use serenity::all::ButtonStyle::Success;
use serenity::all::ComponentInteractionDataKind;
use serenity::all::Context;
@ -12,9 +11,10 @@ use serenity::all::GuildId;
use serenity::all::Interaction;
use serenity::all::ReactionType;
use serenity::all::RoleId;
use serenity::all::{ButtonStyle, ComponentInteraction};
use crate::Data;
use crate::error::Error;
use crate::Data;
pub(crate) async fn component(ctx: &Context, interaction: &Interaction, data: &Data) -> Result<(), Error> {
let component = interaction.clone().message_component().unwrap();
@ -29,9 +29,6 @@ async fn button(ctx: &Context, mut interaction: ComponentInteraction, data: &Dat
let u = m.mentions.first().expect("Message did not mention a user.");
match interaction.data.custom_id.as_str() {
"accept_verification" => {
let _dm = u
.direct_message(ctx, CreateMessage::new().content("Your verified minecraft account was approved."))
.await?;
let member = m
.guild_id
.unwrap_or(GuildId::new(1256217633959841853_u64))
@ -39,6 +36,9 @@ async fn button(ctx: &Context, mut interaction: ComponentInteraction, data: &Dat
.await?;
member.add_role(ctx, RoleId::new(1256218805911425066_u64)).await?;
member.remove_role(ctx, RoleId::new(1256253358701023232_u64)).await?;
let _dm = u
.direct_message(ctx, CreateMessage::new().content("Your verified minecraft account was approved."))
.await?;
interaction
.message
.edit(
@ -52,7 +52,9 @@ async fn button(ctx: &Context, mut interaction: ComponentInteraction, data: &Dat
.emoji(ReactionType::from('❌'))
.style(ButtonStyle::Secondary)
.disabled(true),
CreateButton::new("list_accounts").emoji(ReactionType::from('📜')),
CreateButton::new("list_accounts")
.emoji(ReactionType::from('📜'))
.style(ButtonStyle::Primary),
])]),
)
.await?;
@ -75,7 +77,9 @@ async fn button(ctx: &Context, mut interaction: ComponentInteraction, data: &Dat
.emoji(ReactionType::from('❌'))
.style(ButtonStyle::Danger)
.disabled(true),
CreateButton::new("list_accounts").emoji(ReactionType::from('📜')),
CreateButton::new("list_accounts")
.emoji(ReactionType::from('📜'))
.style(ButtonStyle::Primary),
])]),
)
.await?;

View file

@ -96,13 +96,11 @@ async fn event_handler(
) -> Result<(), Error> {
match event {
FullEvent::Ready { data_about_bot, .. } => {
println!("Logged in as {}", data_about_bot.user.name);
println!("Logged in as '{}'!", data_about_bot.user.name);
},
FullEvent::GuildMemberAddition { new_member } => {
println!("join event");
if new_member.guild_id.get() == 1256217633959841853_u64 {
new_member.add_role(ctx, RoleId::new(1256253358701023232_u64)).await?;
println!("gave member role");
}
}
FullEvent::InteractionCreate { interaction } => {