Improve submission command with slash command, embeds, crossposting
This commit is contained in:
parent
ebcb6e2ff7
commit
fc9a9a9d49
2 changed files with 117 additions and 34 deletions
12
src/utils.rs
12
src/utils.rs
|
@ -1,6 +1,6 @@
|
|||
use crate::serenity;
|
||||
use crate::Error;
|
||||
use crate::{Context, PrefixContext};
|
||||
use crate::Context;
|
||||
use rand::seq::IteratorRandom;
|
||||
use serde_json::Map;
|
||||
use serde_json::Value;
|
||||
|
@ -154,7 +154,7 @@ pub fn set_guild_data(guild_data: Map<String, Value>) {
|
|||
|
||||
pub async fn send(ctx: Context<'_>, message: &str, ping: bool, pin: bool) -> Result<(), Error> {
|
||||
let guild_data = get_guild_data();
|
||||
let mut announcements_count = 0;
|
||||
// let mut announcements_count = 0;
|
||||
for (_guild, data) in guild_data.iter() {
|
||||
let data = data.as_object().unwrap();
|
||||
if !data.contains_key("submissionChannel") {
|
||||
|
@ -191,14 +191,16 @@ pub async fn send(ctx: Context<'_>, message: &str, ping: bool, pin: bool) -> Res
|
|||
Err(_) => (),
|
||||
};
|
||||
}
|
||||
announcements_count += 1;
|
||||
// announcements_count += 1;
|
||||
}
|
||||
/*
|
||||
ctx.say(format!(
|
||||
"Announced to {} server{}!",
|
||||
announcements_count,
|
||||
if announcements_count == 1 { "" } else { "s" }
|
||||
))
|
||||
.await?;
|
||||
*/
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -351,7 +353,7 @@ pub fn get_avatar(user: &serenity::User) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn leaderboard(ctx: &PrefixContext<'_>) -> Result<(), Error> {
|
||||
pub async fn leaderboard(ctx: &Context<'_>) -> Result<(), Error> {
|
||||
const LENGTH: usize = 10;
|
||||
let mut submission_counts: HashMap<String, u32> = HashMap::new();
|
||||
for challenge in 1..get_challenge_number() + 1 {
|
||||
|
@ -371,7 +373,7 @@ pub async fn leaderboard(ctx: &PrefixContext<'_>) -> Result<(), Error> {
|
|||
for (i, (id, count)) in top_submitters[0..LENGTH].iter().enumerate() {
|
||||
let place = i + 1;
|
||||
let user = serenity::UserId(id.parse::<u64>().unwrap())
|
||||
.to_user(&ctx.discord.http)
|
||||
.to_user(&ctx.discord().http)
|
||||
.await?;
|
||||
let avatar = get_avatar(&user);
|
||||
let profile = format!("https://discord.com/users/{id}");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue