update rust deps and nixpkgs
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
use anyhow::Result;
|
||||
use serenity::{
|
||||
client::Client as DiscordClient, framework::standard::StandardFramework, prelude::TypeMapKey,
|
||||
client::Client as DiscordClient,
|
||||
framework::standard::StandardFramework,
|
||||
prelude::{GatewayIntents, TypeMapKey},
|
||||
};
|
||||
use songbird::SerenityInit;
|
||||
use sunk::Client as SubsonicClient;
|
||||
|
||||
use std::{env, fs, io};
|
||||
|
||||
use crate::discord::{Handler, GENERAL_GROUP, after_hook};
|
||||
use crate::discord::{after_hook, Handler, GENERAL_GROUP};
|
||||
|
||||
pub struct Client {
|
||||
ss_url: String,
|
||||
@@ -45,17 +47,19 @@ impl Client {
|
||||
}
|
||||
|
||||
pub async fn discord(&self, ss: SubsonicClient) -> Result<DiscordClient> {
|
||||
Ok(DiscordClient::builder(&self.discord_token)
|
||||
.event_handler(Handler)
|
||||
.framework(
|
||||
StandardFramework::new()
|
||||
.configure(|c| c.prefix("~"))
|
||||
.group(&GENERAL_GROUP)
|
||||
.after(after_hook)
|
||||
)
|
||||
.type_map_insert::<MusicClient>(ss)
|
||||
.register_songbird()
|
||||
.await?)
|
||||
Ok(
|
||||
DiscordClient::builder(&self.discord_token, GatewayIntents::default())
|
||||
.event_handler(Handler)
|
||||
.framework(
|
||||
StandardFramework::new()
|
||||
.configure(|c| c.prefix("~"))
|
||||
.group(&GENERAL_GROUP)
|
||||
.after(after_hook),
|
||||
)
|
||||
.type_map_insert::<MusicClient>(ss)
|
||||
.register_songbird()
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn subsonic(&self) -> Result<SubsonicClient> {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use log::warn;
|
||||
use serenity::{
|
||||
async_trait,
|
||||
client::{Context, EventHandler},
|
||||
@@ -6,7 +7,7 @@ use serenity::{
|
||||
macros::{command, group, hook},
|
||||
Args, CommandResult,
|
||||
},
|
||||
model::channel::Message,
|
||||
model::{channel::Message, gateway::Ready},
|
||||
prelude::Mutex,
|
||||
utils::MessageBuilder,
|
||||
};
|
||||
@@ -33,7 +34,11 @@ pub struct General;
|
||||
pub struct Handler;
|
||||
|
||||
#[async_trait]
|
||||
impl EventHandler for Handler {}
|
||||
impl EventHandler for Handler {
|
||||
async fn ready(&self, _: Context, ready: Ready) {
|
||||
println!("{} is connected!", ready.user.name);
|
||||
}
|
||||
}
|
||||
|
||||
#[hook]
|
||||
pub async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: CommandResult) {
|
||||
@@ -45,7 +50,7 @@ pub async fn after_hook(ctx: &Context, msg: &Message, cmd_name: &str, error: Com
|
||||
|
||||
#[command]
|
||||
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
|
||||
let guild = msg.guild(&ctx.cache).await.unwrap();
|
||||
let guild = msg.guild(&ctx.cache).unwrap();
|
||||
let guild_id = guild.id;
|
||||
|
||||
let manager = songbird::get(ctx)
|
||||
@@ -58,7 +63,7 @@ async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
|
||||
|
||||
#[command]
|
||||
async fn join(ctx: &Context, msg: &Message) -> CommandResult {
|
||||
let guild = msg.guild(&ctx.cache).await.unwrap();
|
||||
let guild = msg.guild(&ctx.cache).unwrap();
|
||||
let guild_id = guild.id;
|
||||
|
||||
let channel = guild
|
||||
@@ -306,7 +311,6 @@ async fn queue_song(
|
||||
) -> Result<()> {
|
||||
let guild = msg
|
||||
.guild(&ctx.cache)
|
||||
.await
|
||||
.ok_or_else(|| anyhow!("Couldn't get guild id"))?;
|
||||
let manager = songbird::get(ctx)
|
||||
.await
|
||||
@@ -343,7 +347,6 @@ async fn queue_song(
|
||||
async fn get_handler(ctx: &Context, msg: &Message) -> Result<Arc<Mutex<Call>>> {
|
||||
let guild = msg
|
||||
.guild(&ctx.cache)
|
||||
.await
|
||||
.ok_or_else(|| anyhow!("Couldn't get guild id"))?;
|
||||
let manager = songbird::get(ctx)
|
||||
.await
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
use anyhow::Result;
|
||||
use log::warn;
|
||||
|
||||
use disconic::Client;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
dotenv::dotenv().ok();
|
||||
env_logger::init();
|
||||
|
||||
let client = Client::from_env().await?;
|
||||
warn!("Initialized disconic client.");
|
||||
let subsonic = client.subsonic().await?;
|
||||
warn!("Initialized subsonic client.");
|
||||
let mut discord = client.discord(subsonic).await?;
|
||||
warn!("Initialized discord client.");
|
||||
|
||||
discord.start().await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user