Want to contribute? Fork me on Codeberg.org!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.4 KiB

#![allow(non_snake_case)]
use crate::Context;
use crate::Error;
use poise::command;
3 years ago
use serde_json::json;
3 years ago
use std::env;
use crate::utils::*;
#[command(prefix_command, slash_command, hide_in_help, ephemeral, owners_only)]
pub async fn sleep(ctx: Context<'_>) -> Result<(), crate::Error> {
ctx.say("Good night!").await?;
2 years ago
ctx.framework()
.shard_manager
.lock()
.await
.shutdown_all()
.await;
Ok(())
3 years ago
}
#[command(prefix_command, slash_command, hide_in_help, ephemeral, owners_only)]
pub async fn setsubmissionchannel(ctx: Context<'_>) -> Result<(), Error> {
let mut guild_data = get_guild_data();
let guild = ctx.guild_id().unwrap().as_u64().to_string();
let channel = ctx.channel_id().as_u64().to_string();
if guild_data.contains_key(&guild) {
let mut current_guild_data = guild_data[&guild].as_object().unwrap().clone();
if current_guild_data.contains_key("submissionChannel") {
current_guild_data["submissionChannel"] = channel.into();
} else {
current_guild_data.insert(String::from("submissionChannel"), channel.into());
}
guild_data[&guild] = current_guild_data.into();
} else {
3 years ago
guild_data.insert(guild, json!({ "submissionChannel": channel }));
}
set_guild_data(guild_data);
2 years ago
ctx.say(format!(
"Submission channel for **{}** set to <#{}>.",
ctx.guild().unwrap().name,
ctx.channel_id()
))
3 years ago
.await?;
Ok(())
3 years ago
}
#[command(prefix_command, slash_command, hide_in_help, ephemeral, owners_only)]
pub async fn setsuggestionchannel(ctx: Context<'_>) -> Result<(), Error> {
let channel = ctx.channel_id().as_u64().to_string();
let message = format!("Submission channel set to <#{}>.", channel);
let mut guild_data = get_guild_data();
if guild_data.contains_key("submissionChannel") {
guild_data["suggestionChannel"] = channel.into();
} else {
guild_data.insert(String::from("suggestionChannel"), channel.into());
}
set_guild_data(guild_data);
ctx.say(message).await?;
Ok(())
}
#[command(prefix_command, slash_command, hide_in_help, ephemeral, owners_only)]
#[allow(non_snake_case)]
pub async fn setannouncementrole(
ctx: Context<'_>,
2 years ago
#[description = "Announcement role ID"] role: u64,
) -> Result<(), Error> {
let mut guild_data = get_guild_data();
let guild = ctx.guild_id().unwrap().as_u64().to_string();
if guild_data.contains_key(&guild) {
let mut current_guild_data = guild_data[&guild].as_object().unwrap().clone();
if current_guild_data.contains_key("announcementRole") {
current_guild_data["announcementRole"] = role.into();
} else {
current_guild_data.insert(String::from("announcementRole"), role.into());
}
guild_data[&guild] = current_guild_data.into();
} else {
guild_data.insert(guild, json!({ "announcementRole": role }));
}
set_guild_data(guild_data);
ctx.say("Announcement role set.").await?;
Ok(())
}
#[command(prefix_command, slash_command, hide_in_help, ephemeral, owners_only)]
pub async fn announce(
ctx: Context<'_>,
2 years ago
#[description = "Announcement text"] announcement: String,
) -> Result<(), Error> {
send(ctx, &announcement, true, false).await
}
#[command(prefix_command, slash_command, hide_in_help, ephemeral, owners_only)]
pub async fn announcechallenge(ctx: Context<'_>) -> Result<(), Error> {
let challenge_number = get_challenge_number();
let message = format!("Welcome to the **{n}{th}** weekly **Tegaki Tuesday** () handwriting challenge! :pen_fountain: The prompt is available in both Japanese and English on the website at <https://tegakituesday.com/{n}>.
You can make submissions in both languages, but please submit in your target language first. Submissions can be submitted by uploading the image to this channel along with the `{p}submit` command. By submitting, you agree to having your work posted to the website under the Attribution-ShareAlike 4.0 Unported (CC BY-SA 4.0) license, attributed to your Discord account. (<https://creativecommons.org/licenses/by-sa/4.0>).",
n = challenge_number,
th = match challenge_number % 10 {
1 => "ˢᵗ",
2 => "ⁿᵈ",
3 => "ʳᵈ",
_ => "ᵗʰ"
},
p = env::var("PREFIX").unwrap()
);
send(ctx, &message, true, false).await?;
ctx.say("Announced!").await?;
Ok(())
3 years ago
}