Skip to content

Commit

Permalink
Made progress adding songbird to the stack
Browse files Browse the repository at this point in the history
  • Loading branch information
xToxette committed Oct 30, 2023
1 parent 0b789a1 commit 2c092d8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 37 deletions.
53 changes: 27 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ edition = "2021"
[dependencies]
dotenv = "0.15"
env_logger = "0.10.0"
log = "0.4.20"
poise = "0.5.6"
songbird = { git = "https://github.com/serenity-rs/songbird.git", branch = "next" }
songbird = { git = "https://github.com/serenity-rs/songbird.git", branch = "next"}
sqlx = { version = "0.7.2", features = ["runtime-tokio", "time", "sqlite"] }
sysinfo = "0.29.10"
tokio = { version = "1.33.0", features = ["rt-multi-thread"] }
12 changes: 6 additions & 6 deletions src/dal/events/voice_state_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use crate::{dal, dal::models};
/// Inserts a voice state update event into the table
/// Automatically handles inserting a new row into the general_info table
pub async fn insert(executor: &SqlitePool, voice_state: &VoiceState) -> Result<sqlite::SqliteQueryResult, Error> {
let general_info_result =
dal::events::general_info::insert(&executor,
std::time::UNIX_EPOCH.elapsed().unwrap().as_secs() as i64,
voice_state.user_id.0 as i64,
voice_state.guild_id.map(|i| i.0 as i64)).await?;
let general_info_result = dal::events::general_info::insert(&executor,
std::time::UNIX_EPOCH.elapsed().unwrap().as_secs() as i64,
voice_state.user_id.0 as i64,
voice_state.guild_id.map(|i| i.0 as i64)
).await?;

let general_info_id = general_info_result.last_insert_rowid();

Expand Down Expand Up @@ -63,4 +63,4 @@ pub async fn get_voice_state_updates(executor: &SqlitePool, user_id: i64, guild_
let voice_state_updates = db_voice_state_updates.iter().map(|row| models::DBVoiceStateUpdate::from_joined(row)).collect();

Ok(voice_state_updates)
}
}
13 changes: 9 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#![warn(clippy::str_to_string)]

#[macro_use]
extern crate log;

mod dal;
mod event_handler;
mod commands;
mod handlers;

use poise::{serenity_prelude as serenity};
use std::{env::var};
use sqlx::{SqlitePool};
// use songbird::serenity::SerenityInit;
use poise::serenity_prelude as serenity;
use songbird::SerenityInit;
use std::env::var;
use sqlx::SqlitePool;

type Error = Box<dyn std::error::Error + Send + Sync>;
type Context<'a> = poise::Context<'a, Data, Error>;


// Custom user data passes to all command functions
pub struct Data {
conn_pool: SqlitePool,
Expand Down Expand Up @@ -51,6 +55,7 @@ async fn main() {
poise::Framework::builder()
.token(var("DISCORD_TOKEN").expect("Missing `DISCORD_TOKEN` env var") )
.setup(handlers::setup::handler)
.client_settings(|c| c.register_songbird())
.options(options)
.intents(
serenity::GatewayIntents::GUILD_MESSAGES
Expand Down

0 comments on commit 2c092d8

Please sign in to comment.