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H7UELYMTXRBYCVE6R4QC
UA6AQUK37FVMQHXLMRAEEKV4JF6CHJI5Y72G2HSJX4HGY42AVAVAC
VX4LH5RUBCNCHN4VIKMMHSXMFSZBVKFTHSHLKSBMRCVA2G76GUQQC
YB7CE4K6TTEZXSEPLWT4NZ5ZMDRIXYFH6XQSAZ57SBKVDYJSRF6QC
WEIOXVYOMZTAICR67QS6DF3SPSORCI6A6NC6LZCKJYFNLQRMI3VQC
RMDIMY3MH33WIWBBF53RHT26PALCFY6QUNNS735XGFTWPMZ2FTFAC
BV2FJEVMVJOC5XDAUJQE27ZW3MPA56EIJAQBRA56MLGJ37XQ7MDQC
P5J5K557OJ5TDY5GLKE74QGCIVI34FI2ANAIBVVRW7NJG5I76VWAC
OV3C6S74AWVASSPK763KMCFHN3YPF4WBW7IJ7BC3HL5ZFZ4DCXHQC
35EVA5MHEJMVJWQUXIJWAX43LJZ7YLE5Y4YN5T2SOSTBTQB6HTTQC
anyhow = "*"
pub fn big(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
let message = crate::utils::find_relative_content(ctx, msg, args)?;
pub async fn big(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let message = crate::utils::find_relative_content(ctx, msg, args).await?;
let mut rng = data.get::<crate::Random>().unwrap().lock().unwrap();
let choice = rng.gen_range(0, nb_choice);
let mut rng = data.get::<crate::Random>().unwrap().lock().await;
let choice = rng.gen_range(0..nb_choice);
pub fn cat(ctx: &mut Context, msg: &Message, _args: Args) -> CommandResult {
let data = ctx.data.read();
let mut rng = data.get::<crate::Random>().unwrap().lock().unwrap();
pub async fn cat(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let data = ctx.data.read().await;
let mut rng = data.get::<crate::Random>().unwrap().lock().await;
let _ = msg.reply(
&ctx,
format!(
"Catto express: was not able to deliver you cat: {}\n{}",
e,
"https://i.redd.it/4q32jedhkgi31.jpg" // crying catto
),
);
let _ = msg
.reply(
&ctx,
format!(
"Catto express: was not able to deliver you cat: {}\n{}",
e,
"https://i.redd.it/4q32jedhkgi31.jpg" // crying catto
),
)
.await?;
fn fetch_cat_page(rng: &mut impl Rng) -> Result<String, Box<dyn std::error::Error>> {
let cat_id = rng.gen_range(0, 1677);
Ok(Client::new()
.get(&format!("http://random.cat/view/{}", cat_id))
.send()?
.text()?)
async fn fetch_cat_page(rng: &mut impl Rng) -> Result<String> {
let cat_id: usize = rng.gen_range(0..1677);
Ok(reqwest::get(&format!("http://random.cat/view/{}", cat_id))
.await?
.text()
.await?)
Ok(url) => msg
.channel_id
.send_files(&ctx, vec![url.as_str()], |m| m.content(&msg.author)),
Err(annoncement) => msg.reply(&ctx, format!("Doggo express: {}", annoncement)),
Ok(url) => {
msg.channel_id
.send_files(&ctx, vec![url.as_str()], |m| m.content(&msg.author))
.await?
}
Err(annoncement) => {
msg.reply(&ctx, format!("Doggo express: {}", annoncement))
.await?
}
let resp: serde_json::Value = Client::new()
.get(&format!(
"https://dog.ceo/api/breed/{}/images/random",
breed
))
.send()?
.json()?;
let resp: serde_json::Value = reqwest::get(&format!(
"https://dog.ceo/api/breed/{}/images/random",
breed
))
.await?
.json()
.await?;
fn fetch_random_dog_url() -> Result<String, Box<dyn std::error::Error>> {
let page = fetch_dog_page()?;
let url = fetch_url_in_dog_page(page).ok_or("your doggo got lost :pensive:")?;
async fn fetch_random_dog_url() -> Result<String> {
let page = fetch_dog_page().await?;
let url = fetch_url_in_dog_page(page).ok_or(anyhow!("your doggo got lost :pensive:"))?;
fn fetch_dog_page() -> Result<String, Box<dyn std::error::Error>> {
Ok(Client::new().get("https://random.dog").send()?.text()?)
async fn fetch_dog_page() -> Result<String> {
Ok(reqwest::get("https://random.dog").await?.text().await?)
pub fn mock(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
let message = crate::utils::find_relative_content(ctx, msg, args)?;
pub async fn mock(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let message = crate::utils::find_relative_content(ctx, msg, args).await?;
pub fn roasted(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
let message = crate::utils::find_relative_content(ctx, msg, args)?;
if let Ok(url) = crate::imgflip::generate_image_url(None, Some(&message), "122616222") {
let _ = msg
.channel_id
.send_files(&ctx, vec![url.as_str()], |m| m.content(&msg.author));
pub async fn roasted(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
let message = crate::utils::find_relative_content(ctx, msg, args).await?;
if let Ok(url) = crate::imgflip::generate_image_url(None, Some(&message), "122616222").await {
msg.channel_id
.send_files(&ctx, vec![url.as_str()], |m| m.content(&msg.author))
.await?;
pub fn roll(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
let data = ctx.data.read();
let mut rng = data.get::<crate::Random>().unwrap().lock().unwrap();
pub async fn roll(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let data = ctx.data.read().await;
let mut rng = data.get::<crate::Random>().unwrap().lock().await;
pub fn tg(ctx: &mut Context, msg: &Message, _args: Args) -> CommandResult {
let data = ctx.data.read();
pub async fn tg(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let data = ctx.data.read().await;
let mut client = Client::new(&token, Handler).expect("Err creating client");
let framework = StandardFramework::new()
.configure(|c| c.prefix("!").delimiters(vec![", ", ",", " "]))
.group(&GENERAL_GROUP)
.group(&CUTE_GROUP)
.help(&MY_HELP);
let mut client = Client::builder(&token)
.framework(framework)
.event_handler(Handler)
.await
.expect("Err creating client");
{
let mut data = client.data.write().await;
data.insert::<ShardManagerContainer>(client.shard_manager.clone());
}
let mut data = client.data.write();
data.insert::<commands::Tg>(Mutex::new(commands::init_tg(&mut rng)));
data.insert::<Random>(Mutex::new(rng));
let mut data = client.data.write().await;
data.insert::<commands::Tg>(Arc::new(Mutex::new(commands::init_tg(&mut rng))));
data.insert::<Random>(Arc::new(Mutex::new(rng)));
client.with_framework(
StandardFramework::new()
.configure(|c| c.prefix("!").delimiters(vec![", ", ",", " "]))
.group(&GENERAL_GROUP)
.group(&CUTE_GROUP)
.help(&MY_HELP),
);
let shard_manager = client.shard_manager.clone();
tokio::spawn(async move {
tokio::signal::ctrl_c()
.await
.expect("Could not register ctrl+c handler");
shard_manager.lock().await.shutdown_all().await;
});