mirror of
https://github.com/Noratrieb/killjoy-turret.git
synced 2026-01-14 14:45:01 +01:00
init
This commit is contained in:
commit
03087702af
7 changed files with 1437 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
/target
|
||||
.idea
|
||||
*.iml
|
||||
1294
Cargo.lock
generated
Normal file
1294
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
18
Cargo.toml
Normal file
18
Cargo.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[package]
|
||||
name = "killjoy_turret"
|
||||
version = "0.1.0"
|
||||
authors = ["Nilstrieb <nilstrieb@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
|
||||
[dependencies.serenity]
|
||||
version = "0.10.7"
|
||||
default-features = false
|
||||
features = ["client", "gateway", "rustls_backend", "model", "framework", "standard_framework", "cache", "http", "utils"]
|
||||
10
src/autorole.rs
Normal file
10
src/autorole.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use serenity::framework::standard::Args;
|
||||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
|
||||
#[group]
|
||||
struct AutoRole;
|
||||
|
||||
#[command]
|
||||
#[desciption = "Add auto assign roles"]
|
||||
async fn auto_role(ctx: &Context, msg: &Message, args: &Args) {}
|
||||
31
src/commands.rs
Normal file
31
src/commands.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use rand::Rng;
|
||||
use serenity::client::Context;
|
||||
use serenity::framework::standard::{
|
||||
help_commands,
|
||||
macros::{command, group, help},
|
||||
Args, CommandGroup, CommandResult, HelpOptions,
|
||||
};
|
||||
use serenity::model::channel::Message;
|
||||
use serenity::model::id::UserId;
|
||||
use serenity::utils::{content_safe, ContentSafeOptions};
|
||||
|
||||
#[help]
|
||||
#[individual_command_tip = "Killjoy Turret Command Info"]
|
||||
#[command_not_found_text = "Could not find command: `{}`."]
|
||||
#[max_levenshtein_distance(3)]
|
||||
#[strikethrough_commands_tip_in_dm = ""]
|
||||
#[strikethrough_commands_tip_in_guild = ""]
|
||||
pub async fn my_help(
|
||||
context: &Context,
|
||||
msg: &Message,
|
||||
args: Args,
|
||||
help_options: &'static HelpOptions,
|
||||
groups: &[&'static CommandGroup],
|
||||
owners: HashSet<UserId>,
|
||||
) -> CommandResult {
|
||||
let _ = help_commands::with_embeds(context, msg, args, help_options, groups, owners).await;
|
||||
Ok(())
|
||||
}
|
||||
0
src/general.rs
Normal file
0
src/general.rs
Normal file
81
src/main.rs
Normal file
81
src/main.rs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
mod autorole;
|
||||
mod commands;
|
||||
mod general;
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fs;
|
||||
|
||||
use serenity::client::Context;
|
||||
use serenity::framework::StandardFramework;
|
||||
use serenity::http::Http;
|
||||
use serenity::model::id::{ChannelId, UserId};
|
||||
use serenity::{async_trait, model::gateway::Ready, prelude::*};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct AutoRoleData {
|
||||
|
||||
}
|
||||
|
||||
pub struct AutoRoleDataKey;
|
||||
|
||||
impl TypeMapKey for AutoRoleDataKey {
|
||||
type Value = AutoRoleData;
|
||||
}
|
||||
|
||||
struct Handler;
|
||||
|
||||
#[async_trait]
|
||||
impl EventHandler for Handler {
|
||||
async fn ready(&self, _: Context, ready: Ready) {
|
||||
println!("{} is connected!", ready.user.name);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let token = fs::read_to_string("bot_token").expect("Expected bot token in file 'bot_token'");
|
||||
|
||||
let http = Http::new_with_token(&token);
|
||||
|
||||
let (owners, bot_id) = match http.get_current_application_info().await {
|
||||
Ok(_) => {
|
||||
let mut owners = HashSet::new();
|
||||
owners.insert(UserId(414755070161453076)); //nils
|
||||
match http.get_current_user().await {
|
||||
Ok(bot_id) => (owners, bot_id.id),
|
||||
Err(why) => panic!("Could not access the bot id: {:?}", why),
|
||||
}
|
||||
}
|
||||
Err(why) => panic!("Could not access application info: {:?}", why),
|
||||
};
|
||||
|
||||
let framework = StandardFramework::new()
|
||||
.configure(|c| {
|
||||
c.with_whitespace(false)
|
||||
.on_mention(Some(bot_id))
|
||||
.prefix("turret ")
|
||||
.delimiter(" ")
|
||||
.owners(owners)
|
||||
})
|
||||
.normal_message(normal_message)
|
||||
.help(&MY_HELP)
|
||||
.group(&GENERAL_GROUP)
|
||||
.group(&MEME_GROUP)
|
||||
.group(&ADMIN_GROUP);
|
||||
|
||||
let mut client = Client::builder(&token)
|
||||
.event_handler(Handler)
|
||||
.framework(framework)
|
||||
.await
|
||||
.expect("Err creating client");
|
||||
|
||||
{
|
||||
let mut data = client.data.write().await;
|
||||
data.insert::<LastMessageInChannel>(HashMap::default());
|
||||
}
|
||||
|
||||
if let Err(why) = client.start().await {
|
||||
println!("Client error: {:?}", why);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue