50 lines
No EOL
1.4 KiB
Rust
50 lines
No EOL
1.4 KiB
Rust
use std::sync::Arc;
|
|
|
|
use serenity::http::Http;
|
|
|
|
pub async fn send_error(_http: Arc<Http>, msg: String) -> anyhow::Result<()> {
|
|
println!("ERROR: {msg}");
|
|
|
|
#[cfg(feature="RELEASE")] {
|
|
use serenity::all::ChannelId;
|
|
use std::process::exit;
|
|
use std::env;
|
|
use anyhow::Context;
|
|
|
|
let channel_id: String = env::var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
|
match ChannelId::new(channel_id.parse::<u64>().unwrap())
|
|
.say(_http, msg).await {
|
|
Ok(_) => { return Ok(()); }
|
|
Err(_) => { exit(-1) }
|
|
};
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(feature="RELEASE")]
|
|
pub async fn hello(http: Arc<Http>) -> anyhow::Result<()> {
|
|
use serenity::all::ChannelId;
|
|
use anyhow::Context;
|
|
use std::env;
|
|
|
|
let messages = [
|
|
"AAAAAAAAAAAAAAAAAAAA",
|
|
"Henlooo",
|
|
"Good day y'all!",
|
|
"May have crashed...",
|
|
"MOOOooo",
|
|
"Heyyyyy!",
|
|
"I'm baaaaack!",
|
|
"Whom'st have summoned the ancient one?",
|
|
];
|
|
|
|
let num = rand::random::<usize>() % messages.len();
|
|
|
|
let channel_id: String = env::var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
|
let channel = ChannelId::new(channel_id.parse::<u64>().unwrap());
|
|
if let Err(why) = channel.say(http, messages[num]).await {
|
|
print!("Error sending message: {:?}", why);
|
|
};
|
|
|
|
Ok(())
|
|
} |