removed standard_framework completely

This commit is contained in:
2020-10-26 11:10:00 +00:00
parent 19b3eb067e
commit 3e490bb5c4
10 changed files with 77 additions and 249 deletions

View File

@ -1,6 +1,6 @@
use regex_command_attr::command;
use serenity::{client::Context, framework::standard::CommandResult, model::channel::Message};
use serenity::{client::Context, model::channel::Message};
use chrono::offset::Utc;
@ -14,7 +14,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
#[command]
#[can_blacklist(false)]
async fn ping(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
async fn ping(ctx: &Context, msg: &Message, _args: String) {
let now = SystemTime::now();
let since_epoch = now
.duration_since(UNIX_EPOCH)
@ -26,13 +26,11 @@ async fn ping(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
.channel_id
.say(&ctx, format!("Time taken to receive message: {}ms", delta))
.await;
Ok(())
}
#[command]
#[can_blacklist(false)]
async fn help(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
async fn help(ctx: &Context, msg: &Message, _args: String) {
let pool = ctx
.data
.read()
@ -44,7 +42,8 @@ async fn help(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
let desc = user_data.response(&pool, "help").await;
msg.channel_id
let _ = msg
.channel_id
.send_message(ctx, |m| {
m.embed(move |e| {
e.title("Help")
@ -59,13 +58,11 @@ async fn help(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
.color(*THEME_COLOR)
})
})
.await?;
Ok(())
.await;
}
#[command]
async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
async fn info(ctx: &Context, msg: &Message, _args: String) {
let pool = ctx
.data
.read()
@ -86,7 +83,8 @@ async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
.replace("{default_prefix}", &*DEFAULT_PREFIX)
.replace("{prefix}", &guild_data.prefix);
msg.channel_id
let _ = msg
.channel_id
.send_message(ctx, |m| {
m.embed(move |e| {
e.title("Info")
@ -101,13 +99,11 @@ async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
.color(*THEME_COLOR)
})
})
.await?;
Ok(())
.await;
}
#[command]
async fn donate(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
async fn donate(ctx: &Context, msg: &Message, _args: String) {
let pool = ctx
.data
.read()
@ -119,7 +115,8 @@ async fn donate(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
let desc = user_data.response(&pool, "donate").await;
msg.channel_id
let _ = msg
.channel_id
.send_message(ctx, |m| {
m.embed(move |e| {
e.title("Donate")
@ -134,14 +131,13 @@ async fn donate(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
.color(*THEME_COLOR)
})
})
.await?;
Ok(())
.await;
}
#[command]
async fn dashboard(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
msg.channel_id
async fn dashboard(ctx: &Context, msg: &Message, _args: String) {
let _ = msg
.channel_id
.send_message(ctx, |m| {
m.embed(move |e| {
e.title("Dashboard")
@ -156,13 +152,11 @@ async fn dashboard(ctx: &Context, msg: &Message, _args: String) -> CommandResult
.color(*THEME_COLOR)
})
})
.await?;
Ok(())
.await;
}
#[command]
async fn clock(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn clock(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -200,6 +194,4 @@ async fn clock(ctx: &Context, msg: &Message, args: String) -> CommandResult {
)
.await;
}
Ok(())
}

View File

@ -2,7 +2,7 @@ use regex_command_attr::command;
use serenity::{
client::Context,
framework::{standard::CommandResult, Framework},
framework::Framework,
model::{channel::Message, id::RoleId},
};
@ -25,7 +25,7 @@ use std::iter;
#[supports_dm(false)]
#[permission_level(Restricted)]
#[can_blacklist(false)]
async fn blacklist(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn blacklist(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -57,12 +57,10 @@ async fn blacklist(ctx: &Context, msg: &Message, args: String) -> CommandResult
} else {
let _ = msg.channel_id.say(&ctx, "Unblacklisted").await;
}
Ok(())
}
#[command]
async fn timezone(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn timezone(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -112,12 +110,10 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) -> CommandResult {
let _ = msg.channel_id.say(&ctx, content).await;
}
Ok(())
}
#[command]
async fn language(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn language(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -174,14 +170,12 @@ SELECT code FROM languages WHERE code = ? OR name = ?
let _ = msg.channel_id.say(&ctx, content).await;
}
}
Ok(())
}
#[command]
#[supports_dm(false)]
#[permission_level(Restricted)]
async fn prefix(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn prefix(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -217,14 +211,12 @@ async fn prefix(ctx: &Context, msg: &Message, args: String) -> CommandResult {
let _ = msg.channel_id.say(&ctx, content).await;
}
Ok(())
}
#[command]
#[supports_dm(false)]
#[permission_level(Restricted)]
async fn restrict(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn restrict(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -345,14 +337,12 @@ WHERE
.say(&ctx, user_data.response(&pool, "restrict/help").await)
.await;
}
Ok(())
}
#[command]
#[supports_dm(false)]
#[permission_level(Managed)]
async fn alias(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn alias(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -488,6 +478,4 @@ SELECT command FROM command_aliases WHERE guild_id = (SELECT id FROM guilds WHER
let _ = msg.channel_id.say(&ctx, content).await;
}
Ok(())
}

View File

@ -5,7 +5,6 @@ use regex_command_attr::command;
use serenity::{
cache::Cache,
client::Context,
framework::standard::CommandResult,
http::CacheHttp,
model::{
channel::GuildChannel,
@ -113,7 +112,7 @@ async fn create_webhook(
#[command]
#[supports_dm(false)]
#[permission_level(Restricted)]
async fn pause(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn pause(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -172,13 +171,11 @@ async fn pause(ctx: &Context, msg: &Message, args: String) -> CommandResult {
}
}
}
Ok(())
}
#[command]
#[permission_level(Restricted)]
async fn offset(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn offset(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -243,13 +240,11 @@ UPDATE reminders SET `time` = `time` + ? WHERE reminders.channel_id = ?
.await;
}
}
Ok(())
}
#[command]
#[permission_level(Restricted)]
async fn nudge(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn nudge(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -304,8 +299,6 @@ async fn nudge(ctx: &Context, msg: &Message, args: String) -> CommandResult {
}
}
}
Ok(())
}
enum TimeDisplayType {
@ -372,7 +365,7 @@ struct LookReminder {
#[command]
#[permission_level(Managed)]
async fn look(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn look(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -482,13 +475,11 @@ LIMIT
let _ = msg.channel_id.say_lines(&ctx, display).await;
}
Ok(())
}
#[command]
#[permission_level(Managed)]
async fn delete(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
async fn delete(ctx: &Context, msg: &Message, _args: String) {
let pool = ctx
.data
.read()
@ -650,13 +641,11 @@ INSERT INTO events (event_name, bulk_count, guild_id, user_id) VALUES ('delete',
let _ = msg.channel_id.say(&ctx, content).await;
}
}
Ok(())
}
#[command]
#[permission_level(Managed)]
async fn timer(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn timer(ctx: &Context, msg: &Message, args: String) {
fn time_difference(start_time: NaiveDateTime) -> String {
let unix_time = SystemTime::now()
.duration_since(UNIX_EPOCH)
@ -777,8 +766,6 @@ DELETE FROM timers WHERE owner = ? AND name = ?
.await;
}
}
Ok(())
}
#[derive(PartialEq)]
@ -880,18 +867,14 @@ fn generate_uid() -> String {
#[command]
#[permission_level(Managed)]
async fn remind(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn remind(ctx: &Context, msg: &Message, args: String) {
remind_command(ctx, msg, args, RemindCommand::Remind).await;
Ok(())
}
#[command]
#[permission_level(Managed)]
async fn interval(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn interval(ctx: &Context, msg: &Message, args: String) {
remind_command(ctx, msg, args, RemindCommand::Interval).await;
Ok(())
}
async fn remind_command(ctx: &Context, msg: &Message, args: String, command: RemindCommand) {
@ -1030,7 +1013,7 @@ async fn remind_command(ctx: &Context, msg: &Message, args: String, command: Rem
#[command]
#[permission_level(Managed)]
async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn natural(ctx: &Context, msg: &Message, args: String) {
let pool = ctx
.data
.read()
@ -1217,8 +1200,6 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
.send_message(&ctx, |m| m.embed(|e| e.description(resp)))
.await;
}
Ok(())
}
async fn create_reminder<T: TryInto<i64>, S: ToString + Type<MySql> + Encode<MySql>>(

View File

@ -3,7 +3,6 @@ use regex_command_attr::command;
use serenity::{
client::Context,
constants::MESSAGE_CODE_LIMIT,
framework::standard::CommandResult,
model::{
channel::Message,
id::{ChannelId, GuildId, UserId},
@ -382,7 +381,7 @@ impl Execute for Result<SubCommand, ()> {
#[command]
#[permission_level(Managed)]
async fn todo_user(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn todo_user(ctx: &Context, msg: &Message, args: String) {
let mut split = args.split(' ');
let target = TodoTarget {
@ -396,14 +395,12 @@ async fn todo_user(ctx: &Context, msg: &Message, args: String) -> CommandResult
subcommand_opt
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
.await;
Ok(())
}
#[command]
#[supports_dm(false)]
#[permission_level(Managed)]
async fn todo_channel(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn todo_channel(ctx: &Context, msg: &Message, args: String) {
let mut split = args.split(' ');
let target = TodoTarget {
@ -417,14 +414,12 @@ async fn todo_channel(ctx: &Context, msg: &Message, args: String) -> CommandResu
subcommand_opt
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
.await;
Ok(())
}
#[command]
#[supports_dm(false)]
#[permission_level(Managed)]
async fn todo_guild(ctx: &Context, msg: &Message, args: String) -> CommandResult {
async fn todo_guild(ctx: &Context, msg: &Message, args: String) {
let mut split = args.split(' ');
let target = TodoTarget {
@ -438,8 +433,6 @@ async fn todo_guild(ctx: &Context, msg: &Message, args: String) -> CommandResult
subcommand_opt
.execute(ctx, msg, split.collect::<Vec<&str>>().join(" "), target)
.await;
Ok(())
}
async fn show_help(ctx: &Context, msg: &Message, target: Option<TodoTarget>) {