serenity 0.11->0.12

This commit is contained in:
nora 2024-07-06 15:33:19 +02:00
parent 5cebd44efd
commit 79e1d92139
5 changed files with 224 additions and 177 deletions

317
Cargo.lock generated
View file

@ -35,6 +35,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "arrayvec"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
dependencies = [
"serde",
]
[[package]]
name = "async-trait"
version = "0.1.80"
@ -46,22 +55,6 @@ dependencies = [
"syn 2.0.68",
]
[[package]]
name = "async-tungstenite"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1b71b31561643aa8e7df3effe284fa83ab1a840e52294c5f4bd7bfd8b2becbb"
dependencies = [
"futures-io",
"futures-util",
"log",
"pin-project-lite",
"tokio",
"tokio-rustls 0.23.4",
"tungstenite",
"webpki-roots 0.22.6",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -94,18 +87,18 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bit-set"
version = "0.5.3"
@ -189,9 +182,9 @@ dependencies = [
[[package]]
name = "command_attr"
version = "0.4.2"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07b787d19b9806dd4c9c34b2b4147d1a61d6120d93ee289521ab9b0294d198e4"
checksum = "88da8d7e9fe6f30d8e3fcf72d0f84102b49de70fece952633e8439e89bdc7631"
dependencies = [
"proc-macro2",
"quote",
@ -256,6 +249,12 @@ dependencies = [
"serde",
]
[[package]]
name = "data-encoding"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
[[package]]
name = "deranged"
version = "0.3.11"
@ -403,6 +402,15 @@ dependencies = [
"slab",
]
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
dependencies = [
"byteorder",
]
[[package]]
name = "generic-array"
version = "0.14.7"
@ -441,7 +449,7 @@ dependencies = [
"futures-core",
"futures-sink",
"futures-util",
"http",
"http 0.2.12",
"indexmap",
"slab",
"tokio",
@ -481,6 +489,17 @@ dependencies = [
"itoa",
]
[[package]]
name = "http"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]]
name = "http-body"
version = "0.4.6"
@ -488,7 +507,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
"http",
"http 0.2.12",
"pin-project-lite",
]
@ -515,7 +534,7 @@ dependencies = [
"futures-core",
"futures-util",
"h2",
"http",
"http 0.2.12",
"http-body",
"httparse",
"httpdate",
@ -535,7 +554,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
dependencies = [
"futures-util",
"http",
"http 0.2.12",
"hyper",
"rustls 0.21.12",
"tokio",
@ -674,15 +693,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.16.0"
@ -708,15 +718,6 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "ordered-float"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c"
dependencies = [
"num-traits",
]
[[package]]
name = "owo-colors"
version = "1.3.0"
@ -908,7 +909,7 @@ dependencies = [
"futures-core",
"futures-util",
"h2",
"http",
"http 0.2.12",
"http-body",
"hyper",
"hyper-rustls",
@ -940,21 +941,6 @@ dependencies = [
"winreg",
]
[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"cc",
"libc",
"once_cell",
"spin 0.5.2",
"untrusted 0.7.1",
"web-sys",
"winapi",
]
[[package]]
name = "ring"
version = "0.17.8"
@ -965,8 +951,8 @@ dependencies = [
"cfg-if",
"getrandom",
"libc",
"spin 0.9.8",
"untrusted 0.9.0",
"spin",
"untrusted",
"windows-sys 0.52.0",
]
@ -976,18 +962,6 @@ version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "rustls"
version = "0.20.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99"
dependencies = [
"log",
"ring 0.16.20",
"sct",
"webpki",
]
[[package]]
name = "rustls"
version = "0.21.12"
@ -995,11 +969,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
dependencies = [
"log",
"ring 0.17.8",
"rustls-webpki",
"ring",
"rustls-webpki 0.101.7",
"sct",
]
[[package]]
name = "rustls"
version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432"
dependencies = [
"log",
"ring",
"rustls-pki-types",
"rustls-webpki 0.102.5",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pemfile"
version = "1.0.4"
@ -1009,14 +997,31 @@ dependencies = [
"base64 0.21.7",
]
[[package]]
name = "rustls-pki-types"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d"
[[package]]
name = "rustls-webpki"
version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
dependencies = [
"ring 0.17.8",
"untrusted 0.9.0",
"ring",
"untrusted",
]
[[package]]
name = "rustls-webpki"
version = "0.102.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78"
dependencies = [
"ring",
"rustls-pki-types",
"untrusted",
]
[[package]]
@ -1037,8 +1042,18 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
dependencies = [
"ring 0.17.8",
"untrusted 0.9.0",
"ring",
"untrusted",
]
[[package]]
name = "secrecy"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e"
dependencies = [
"serde",
"zeroize",
]
[[package]]
@ -1051,12 +1066,11 @@ dependencies = [
]
[[package]]
name = "serde-value"
version = "0.7.0"
name = "serde_cow"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
checksum = "64e84ce5596a72f0c4c60759a10ff8c22d5eaf227b0dc2789c8746193309058b"
dependencies = [
"ordered-float",
"serde",
]
@ -1096,32 +1110,33 @@ dependencies = [
[[package]]
name = "serenity"
version = "0.11.7"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a7a89cef23483fc9d4caf2df41e6d3928e18aada84c56abd237439d929622c6"
checksum = "880a04106592d0a8f5bdacb1d935889bfbccb4a14f7074984d9cd857235d34ac"
dependencies = [
"arrayvec",
"async-trait",
"async-tungstenite",
"base64 0.21.7",
"bitflags 1.3.2",
"base64 0.22.1",
"bitflags 2.6.0",
"bytes",
"cfg-if",
"command_attr",
"dashmap",
"flate2",
"futures",
"fxhash",
"levenshtein",
"mime",
"mime_guess",
"parking_lot 0.12.3",
"percent-encoding",
"reqwest",
"secrecy",
"serde",
"serde-value",
"serde_cow",
"serde_json",
"static_assertions",
"time",
"tokio",
"tokio-tungstenite",
"tracing",
"typemap_rev",
"url",
@ -1129,10 +1144,10 @@ dependencies = [
]
[[package]]
name = "sha-1"
version = "0.10.1"
name = "sha1"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
"cpufeatures",
@ -1164,12 +1179,6 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "spin"
version = "0.9.8"
@ -1188,6 +1197,12 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "subtle"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
version = "1.0.109"
@ -1340,17 +1355,6 @@ dependencies = [
"syn 2.0.68",
]
[[package]]
name = "tokio-rustls"
version = "0.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
dependencies = [
"rustls 0.20.9",
"tokio",
"webpki",
]
[[package]]
name = "tokio-rustls"
version = "0.24.1"
@ -1361,6 +1365,33 @@ dependencies = [
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
dependencies = [
"rustls 0.22.4",
"rustls-pki-types",
"tokio",
]
[[package]]
name = "tokio-tungstenite"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38"
dependencies = [
"futures-util",
"log",
"rustls 0.22.4",
"rustls-pki-types",
"tokio",
"tokio-rustls 0.25.0",
"tungstenite",
"webpki-roots 0.26.3",
]
[[package]]
name = "tokio-util"
version = "0.7.11"
@ -1429,30 +1460,30 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "tungstenite"
version = "0.17.3"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0"
checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1"
dependencies = [
"base64 0.13.1",
"byteorder",
"bytes",
"http",
"data-encoding",
"http 1.1.0",
"httparse",
"log",
"rand",
"rustls 0.20.9",
"sha-1",
"rustls 0.22.4",
"rustls-pki-types",
"sha1",
"thiserror",
"url",
"utf-8",
"webpki",
]
[[package]]
name = "typemap_rev"
version = "0.1.5"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5b74f0a24b5454580a79abb6994393b09adf0ab8070f15827cb666255de155"
checksum = "74b08b0c1257381af16a5c3605254d529d3e7e109f3c62befc5d168968192998"
[[package]]
name = "typenum"
@ -1496,12 +1527,6 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "untrusted"
version = "0.9.0"
@ -1660,31 +1685,21 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "webpki"
version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53"
dependencies = [
"ring 0.17.8",
"untrusted 0.9.0",
]
[[package]]
name = "webpki-roots"
version = "0.22.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
dependencies = [
"webpki",
]
[[package]]
name = "webpki-roots"
version = "0.25.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1"
[[package]]
name = "webpki-roots"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "widertom"
version = "0.1.0"
@ -1869,3 +1884,9 @@ dependencies = [
"cfg-if",
"windows-sys 0.48.0",
]
[[package]]
name = "zeroize"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"

View file

@ -16,6 +16,6 @@ fancy-regex = "0.5.0"
rand = "0.8.3"
[dependencies.serenity]
version = "0.11.0"
version = "0.12.0"
default-features = false
features = ["client", "gateway", "rustls_backend", "model", "framework", "standard_framework", "cache", "http", "utils"]

View file

@ -2,15 +2,20 @@ use std::collections::HashSet;
use lazy_static::lazy_static;
use rand::Rng;
use serenity::all::{CreateEmbed, CreateMessage};
use serenity::client::Context;
use serenity::framework::standard::{Args, CommandGroup, CommandResult, help_commands, HelpOptions, macros::{command, group, help}};
use serenity::framework::standard::{
help_commands,
macros::{command, group, help},
Args, CommandGroup, CommandResult, HelpOptions,
};
use serenity::model::channel::Message;
use serenity::model::id::UserId;
use serenity::utils::{content_safe, ContentSafeOptions};
use toml::Value;
use uwuifier::uwuify_str_sse;
use crate::general::{REACTION_EMOTES, CONFIG, CONFIG_ERR, reply};
use crate::general::{reply, CONFIG, CONFIG_ERR, REACTION_EMOTES};
use crate::LastMessageInChannel;
#[group]
@ -29,19 +34,21 @@ struct Meme;
#[description = "bot admin commands"]
struct Admin;
#[command]
#[description("lists all the commands")]
async fn list(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
msg.channel_id.send_message(&ctx.http, |msg| {
msg.embed(|e| {
e.title("Widetom reaction emotes");
e.fields(REACTION_EMOTES.iter()
.map(|em| (em.0, format!("<:{}:{}>", em.0, em.1.0), false))
);
e
})
}).await?;
msg.channel_id
.send_message(
&ctx.http,
CreateMessage::new().embed(
CreateEmbed::new().title("Widetom reaction emotes").fields(
REACTION_EMOTES
.iter()
.map(|em| (em.0, format!("<:{}:{}>", em.0, em.1.get()), false)),
),
),
)
.await?;
Ok(())
}
@ -72,7 +79,9 @@ async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
msg.channel_id.say(&ctx.http, uwu).await?;
} else if args.is_empty() {
let mut data = ctx.data.write().await;
let map = data.get_mut::<LastMessageInChannel>().expect("No LastMessageInChannel in TypeMap");
let map = data
.get_mut::<LastMessageInChannel>()
.expect("No LastMessageInChannel in TypeMap");
let old_message = map.get(&msg.channel_id);
match old_message {
Some(s) => {
@ -80,7 +89,9 @@ async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
msg.channel_id.say(&ctx.http, uwu).await?;
}
None => {
msg.channel_id.say(&ctx.http, "Could not find last message.").await?;
msg.channel_id
.say(&ctx.http, "Could not find last message.")
.await?;
}
}
} else {
@ -93,16 +104,24 @@ async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
#[command]
#[description("end tom")]
async fn shutdown(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
reply("<:tom:811324632082415626> bye <:tom:811324632082415626>", &msg, &ctx).await;
reply(
"<:tom:811324632082415626> bye <:tom:811324632082415626>",
&msg,
&ctx,
)
.await;
std::process::exit(0);
}
#[command]
#[description("display a random answer from the xp support applications")]
async fn xp(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
lazy_static! {
static ref XP_RESPONSES: &'static Vec<Value> = CONFIG.get("xp").expect(CONFIG_ERR).as_array().expect(CONFIG_ERR);
static ref XP_RESPONSES: &'static Vec<Value> = CONFIG
.get("xp")
.expect(CONFIG_ERR)
.as_array()
.expect(CONFIG_ERR);
}
let index = rand::thread_rng().gen_range(0..XP_RESPONSES.len());
let random_value = XP_RESPONSES[index].as_str().expect(CONFIG_ERR);
@ -111,8 +130,7 @@ async fn xp(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
}
#[help]
#[individual_command_tip =
"w i d e t o m\n\n\
#[individual_command_tip = "w i d e t o m\n\n\
tom moment."]
#[command_not_found_text = "Could not find: `{}`."]
#[max_levenshtein_distance(3)]

View file

@ -27,7 +27,7 @@ lazy_static! {
for v in emotes.as_array().expect(CONFIG_ERR) {
let name = v[0].as_str().expect(CONFIG_ERR).to_string();
let id = EmojiId(v[1].as_integer().expect(CONFIG_ERR).clone() as u64);
let id = EmojiId::new(v[1].as_integer().expect(CONFIG_ERR).clone() as u64);
m.insert(name, id);
}
m

View file

@ -1,6 +1,10 @@
// FIXME: Remove this allow and migrate to poise.
#![allow(deprecated)]
use std::collections::{HashMap, HashSet};
use std::fs;
use serenity::all::standard::Configuration;
use serenity::client::Context;
use serenity::framework::StandardFramework;
use serenity::http::Http;
@ -45,21 +49,25 @@ async fn main() {
.expect("could not access the bot ID")
.id;
let owners = HashSet::from([UserId(414755070161453076), UserId(265849018662387712)]);
let owners = HashSet::from([
UserId::new(414755070161453076),
UserId::new(265849018662387712),
]);
let framework = StandardFramework::new()
.configure(|c| {
c.with_whitespace(false)
.on_mention(Some(bot_id))
.prefix("<:tom:811324632082415626> ")
.delimiter(" ")
.owners(owners)
})
.normal_message(normal_message)
.help(&MY_HELP)
.group(&GENERAL_GROUP)
.group(&MEME_GROUP)
.group(&ADMIN_GROUP);
framework.configure(
Configuration::new()
.with_whitespace(false)
.on_mention(Some(bot_id))
.prefix("<:tom:811324632082415626> ")
.delimiter(" ")
.owners(owners),
);
// We don't really need all intents, but this is a small bot so we don't care.
let intents = GatewayIntents::all();