mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-14 08:02:17 +00:00
Initial push of le bot
This commit is contained in:
parent
48a5a49ac6
commit
0b926d310e
5 changed files with 1626 additions and 0 deletions
0
README.md → .github/README.md
vendored
0
README.md → .github/README.md
vendored
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Ignore Editor files
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Ignore build and environment files
|
||||||
|
/target/
|
||||||
|
**.env
|
1539
Cargo.lock
generated
Normal file
1539
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
17
Cargo.toml
Normal file
17
Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "lynxie"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Fluffy Bean <@Fluffy Bean>"]
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# Discord API wrapper, yoinked from robbb bot as I have no clue what I'm doing
|
||||||
|
serenity = { version = "0.11.5", default-features = false, features = ["collector", "builder", "cache", "chrono", "client", "gateway", "model", "http", "utils", "rustls_backend"]}
|
||||||
|
|
||||||
|
# Required for async applications
|
||||||
|
tokio = { version = "1.21", features = ["macros", "fs", "rt-multi-thread"]}
|
||||||
|
|
||||||
|
# Dot env for variables
|
||||||
|
dotenv = "0.15.0"
|
63
src/main.rs
Normal file
63
src/main.rs
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
use dotenv::dotenv;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
use serenity::{
|
||||||
|
async_trait,
|
||||||
|
model::{channel::Message, gateway::Ready},
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Will handle Pisscord events
|
||||||
|
struct Handler;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl EventHandler for Handler {
|
||||||
|
// Create a handler for a new message event
|
||||||
|
async fn message(&self, ctx: Context, msg: Message) {
|
||||||
|
if msg.content == "ping" {
|
||||||
|
// Set Reply to "pong"
|
||||||
|
let reply: &str = "pong";
|
||||||
|
|
||||||
|
if let Err(why) = msg.channel_id.say(&ctx.http, reply).await {
|
||||||
|
// If an error occurs, display it
|
||||||
|
println!("Error sending message: {:?}", why);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if msg.content == "pale" {
|
||||||
|
// Set Reply to "We should ban this guy"
|
||||||
|
let reply: &str = "We should ban this guy";
|
||||||
|
|
||||||
|
if let Err(why) = msg.channel_id.say(&ctx.http, reply).await {
|
||||||
|
// If an error occurs, display it
|
||||||
|
println!("Error sending message: {:?}", why);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a handler for when the bot is ready
|
||||||
|
async fn ready(&self, _: Context, ready: Ready) {
|
||||||
|
// Display that the bot is ready along with the username
|
||||||
|
println!("{} is ready Bitch!", ready.user.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// Load dotenv file and yoink the token
|
||||||
|
dotenv().ok();
|
||||||
|
let token = env::var("DISCORD_TOKEN").expect("No Env enviroment variable found!");
|
||||||
|
|
||||||
|
// Set the bots intents
|
||||||
|
let intents = GatewayIntents::GUILD_MESSAGES
|
||||||
|
| GatewayIntents::DIRECT_MESSAGES
|
||||||
|
| GatewayIntents::MESSAGE_CONTENT;
|
||||||
|
|
||||||
|
// Login to the Pisscord client as a bot
|
||||||
|
let mut client = Client::builder(token, intents).event_handler(Handler).await.expect("Error connecting to client, are you online???");
|
||||||
|
|
||||||
|
// We start a single shart
|
||||||
|
if let Err(why) = client.start().await {
|
||||||
|
println!("Clinet buggin out, heres why: {:?}", why);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue