starting other commands
This commit is contained in:
parent
d95652a605
commit
e69264d726
@ -3,6 +3,7 @@
|
|||||||
<words>
|
<words>
|
||||||
<w>reqwest</w>
|
<w>reqwest</w>
|
||||||
<w>todos</w>
|
<w>todos</w>
|
||||||
|
<w>webhook</w>
|
||||||
<w>webhooks</w>
|
<w>webhooks</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
|
21
Cargo.lock
generated
21
Cargo.lock
generated
@ -205,6 +205,16 @@ dependencies = [
|
|||||||
"time",
|
"time",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono-tz"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "65d96be7c3e993c9ee4356442db24ba364c924b6b8331866be6b6952bfe74b9d"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"parse-zoneinfo",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "command_attr"
|
name = "command_attr"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@ -912,6 +922,15 @@ dependencies = [
|
|||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parse-zoneinfo"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41"
|
||||||
|
dependencies = [
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
@ -1071,6 +1090,8 @@ name = "reminder_rs"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
"chrono",
|
||||||
|
"chrono-tz",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
|
@ -13,6 +13,8 @@ sqlx = {version = "0.3.5", default-features = false, features = ["runtime-tokio"
|
|||||||
regex = "1.3.9"
|
regex = "1.3.9"
|
||||||
async-trait = "0.1.36"
|
async-trait = "0.1.36"
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
|
chrono = "0.4"
|
||||||
|
chrono-tz = "0.5"
|
||||||
|
|
||||||
[dependencies.regex_command_attr]
|
[dependencies.regex_command_attr]
|
||||||
path = "./regex_command_attr"
|
path = "./regex_command_attr"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
pub mod info_cmds;
|
pub mod info_cmds;
|
||||||
pub mod reminder_cmds;
|
pub mod reminder_cmds;
|
||||||
pub mod todo_cmds;
|
pub mod todo_cmds;
|
||||||
|
pub mod moderation_cmds;
|
||||||
|
25
src/commands/moderation_cmds.rs
Normal file
25
src/commands/moderation_cmds.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
use regex_command_attr::command;
|
||||||
|
|
||||||
|
use serenity::{
|
||||||
|
client::Context,
|
||||||
|
model::{
|
||||||
|
channel::{
|
||||||
|
Message,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
framework::standard::CommandResult,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::SQLPool;
|
||||||
|
|
||||||
|
#[command]
|
||||||
|
#[supports_dm(false)]
|
||||||
|
#[permission_level(Restricted)]
|
||||||
|
async fn blacklist(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||||
|
let pool = ctx.data.read().await
|
||||||
|
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||||
|
|
||||||
|
if
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -179,6 +179,7 @@ enum SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
#[permission_level(Managed)]
|
||||||
async fn todo_parse(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
async fn todo_parse(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||||
|
|
||||||
let mut split = args.split(" ");
|
let mut split = args.split(" ");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
mod models;
|
||||||
mod framework;
|
mod framework;
|
||||||
mod commands;
|
mod commands;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ use crate::commands::{
|
|||||||
info_cmds,
|
info_cmds,
|
||||||
reminder_cmds,
|
reminder_cmds,
|
||||||
todo_cmds,
|
todo_cmds,
|
||||||
|
moderation_cmds,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SQLPool;
|
struct SQLPool;
|
||||||
@ -56,6 +58,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
.add_command("info", &info_cmds::INFO_COMMAND)
|
.add_command("info", &info_cmds::INFO_COMMAND)
|
||||||
.add_command("donate", &info_cmds::DONATE_COMMAND)
|
.add_command("donate", &info_cmds::DONATE_COMMAND)
|
||||||
.add_command("todo", &todo_cmds::TODO_PARSE_COMMAND)
|
.add_command("todo", &todo_cmds::TODO_PARSE_COMMAND)
|
||||||
|
.add_command("blacklist", &moderation_cmds::BLACKLIST_COMMAND)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment"))
|
let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment"))
|
||||||
|
37
src/models.rs
Normal file
37
src/models.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
use sqlx::MySqlPool;
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
|
|
||||||
|
struct Channel {
|
||||||
|
id: u32,
|
||||||
|
channel: u64,
|
||||||
|
name: String,
|
||||||
|
nudge: i16,
|
||||||
|
blacklisted: bool,
|
||||||
|
webhook_id: u64,
|
||||||
|
webhook_token: String,
|
||||||
|
paused: bool,
|
||||||
|
paused_until: NaiveDateTime,
|
||||||
|
guild_id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Channel {
|
||||||
|
async fn from_id(channel: u64, pool: MySqlPool) -> Result<Channel, Box<dyn std::error::Error + Sync + Send>> {
|
||||||
|
if let Some(c) = sqlx::query_as!(Self,
|
||||||
|
"
|
||||||
|
SELECT * FROM channels WHERE channel = ?
|
||||||
|
", channel)
|
||||||
|
.fetch_one(&pool)
|
||||||
|
.await? {
|
||||||
|
|
||||||
|
c
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sqlx::query!(
|
||||||
|
"
|
||||||
|
INSERT INTO channels (channel, guild_id) VALUES ()
|
||||||
|
"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user