feat: initialise Discord bridge crate
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/*"]
|
members = ["crates/*", "crates/bridges/*"]
|
||||||
|
exclude = ["crates/bridges"]
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
# mobc-redis = { git = "https://github.com/insertish/mobc", rev = "8b880bb59f2ba80b4c7bc40c649c113d8857a186" }
|
# mobc-redis = { git = "https://github.com/insertish/mobc", rev = "8b880bb59f2ba80b4c7bc40c649c113d8857a186" }
|
||||||
|
|||||||
1294
crates/bridges/discord/Cargo.lock
generated
Normal file
1294
crates/bridges/discord/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
crates/bridges/discord/Cargo.toml
Normal file
10
crates/bridges/discord/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "revolt-discord-bridge"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
|
||||||
|
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
|
||||||
45
crates/bridges/discord/src/main.rs
Normal file
45
crates/bridges/discord/src/main.rs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
use std::env;
|
||||||
|
|
||||||
|
use serenity::async_trait;
|
||||||
|
use serenity::model::channel::Message;
|
||||||
|
use serenity::model::channel::Channel;
|
||||||
|
use serenity::model::gateway::{GatewayIntents, Ready};
|
||||||
|
use serenity::prelude::*;
|
||||||
|
|
||||||
|
struct Handler;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl EventHandler for Handler {
|
||||||
|
async fn message(&self, ctx: Context, msg: Message) {
|
||||||
|
println!("Received message: {}", msg.content);
|
||||||
|
|
||||||
|
if msg.content == "deez" {
|
||||||
|
if let Ok(Channel::Guild(channel)) = msg.channel(&ctx).await {
|
||||||
|
channel.send_message(&ctx, |m| {
|
||||||
|
m.content("this is where a message would usually go")
|
||||||
|
}).await.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn ready(&self, _: Context, ready: Ready) {
|
||||||
|
println!("{} is connected!", ready.user.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let token = env::var("DISCORD_TOKEN").expect("Expected a token in the environment");
|
||||||
|
|
||||||
|
let intents =
|
||||||
|
GatewayIntents::GUILDS | GatewayIntents::GUILD_MESSAGES | GatewayIntents::MESSAGE_CONTENT;
|
||||||
|
|
||||||
|
let mut client = Client::builder(token, intents)
|
||||||
|
.event_handler(Handler)
|
||||||
|
.await
|
||||||
|
.expect("Error creating client");
|
||||||
|
|
||||||
|
if let Err(why) = client.start().await {
|
||||||
|
println!("Client error: {:?}", why);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user