Compare commits
No commits in common. "main" and "v3.4.1" have entirely different histories.
20 changed files with 137 additions and 315 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "moover_rust"
|
name = "moover_rust"
|
||||||
version = "3.4.2"
|
version = "3.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use poise;
|
use poise;
|
||||||
use serenity::all::{Embed, User};
|
use serenity::all::{Embed, User};
|
||||||
|
|
||||||
use crate::types::{Context, ContextExt, Error};
|
use crate::types::{Error, Context};
|
||||||
|
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
|
@ -15,6 +15,6 @@ pub async fn gif(ctx: Context<'_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// let embed;
|
// let embed;
|
||||||
// send_with_embed(ctx, "hug", &title, &desc).await?;
|
// send_with_embed(ctx, "hug", &title, &desc).await?;
|
||||||
ctx.reply_ephemeral("Done!").await?;
|
ctx.reply("Done!").await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
|
@ -51,7 +51,7 @@ pub async fn moove(http: Arc<Http>, msg: Message, m_channel_id: u64) -> anyhow::
|
||||||
.map(| embed | CreateEmbed::from(embed))
|
.map(| embed | CreateEmbed::from(embed))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
||||||
let mut new_content = format!("Sent by {}\n mooved {}\n", msg_to_moove.author, msg.author);
|
let mut new_content = format!("Sent by {}\n mooved {}\n", msg_to_moove.author, msg.author);
|
||||||
let mut new_msg = CreateMessage::new();
|
let mut new_msg = CreateMessage::new();
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ pub async fn moove(http: Arc<Http>, msg: Message, m_channel_id: u64) -> anyhow::
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.field("MOO", new_content, false)
|
.field("MOO", new_content, false)
|
||||||
.field("Message:\n", msg_to_moove.content.clone(), false);
|
.field("Message:\n", msg_to_moove.content.clone(), false);
|
||||||
|
|
||||||
new_msg = new_msg.add_embed(embed);
|
new_msg = new_msg.add_embed(embed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use poise;
|
||||||
use serenity::all::User;
|
use serenity::all::User;
|
||||||
|
|
||||||
use super::interaction::send_with_embed;
|
use super::interaction::send_with_embed;
|
||||||
use crate::types::{Context, Error};
|
use crate::types::{Context, ContextExt, Error};
|
||||||
|
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
|
@ -15,5 +16,6 @@ pub async fn headpat(ctx: Context<'_>,
|
||||||
let title = "HEADPATS!";
|
let title = "HEADPATS!";
|
||||||
let desc = format!("{} headpats {}", ctx.author(), user);
|
let desc = format!("{} headpats {}", ctx.author(), user);
|
||||||
send_with_embed(ctx, "headpat", &title, &desc).await?;
|
send_with_embed(ctx, "headpat", &title, &desc).await?;
|
||||||
|
ctx.reply_ephemeral("Done!").await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ use poise;
|
||||||
use serenity::all::User;
|
use serenity::all::User;
|
||||||
|
|
||||||
use super::interaction::send_with_embed;
|
use super::interaction::send_with_embed;
|
||||||
use crate::types::{Context, Error};
|
use crate::types::{Context, ContextExt, Error};
|
||||||
|
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
|
@ -16,5 +16,6 @@ pub async fn hug(ctx: Context<'_>,
|
||||||
let title = "HUGS!";
|
let title = "HUGS!";
|
||||||
let desc = format!("{} hugs {}", ctx.author(), user);
|
let desc = format!("{} hugs {}", ctx.author(), user);
|
||||||
send_with_embed(ctx, "hug", &title, &desc).await?;
|
send_with_embed(ctx, "hug", &title, &desc).await?;
|
||||||
|
ctx.reply_ephemeral("Done!").await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
use poise::CreateReply;
|
use anyhow::anyhow;
|
||||||
use serenity::all::{Colour, CreateEmbed};
|
use serenity::all::{Colour, CreateEmbed, CreateMessage};
|
||||||
use tenorv2::tenor_builder::Tenor;
|
use tenorv2::tenor_builder::Tenor;
|
||||||
|
|
||||||
use crate::{types::Context, utils::gifs::get_random_tenor_gif};
|
use crate::{types::Context, utils::gifs::get_random_tenor_gif};
|
||||||
|
@ -20,7 +20,15 @@ pub(super) async fn send_with_embed(ctx: Context<'_>, query: &str, title: &str,
|
||||||
.description(desc)
|
.description(desc)
|
||||||
.image(url.as_str());
|
.image(url.as_str());
|
||||||
|
|
||||||
ctx.send(CreateReply::default().embed(embed)).await?;
|
if ctx.guild_id().is_none() {
|
||||||
|
return Err(anyhow!("Guild id not available in context"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.channel_id()
|
||||||
|
.send_message(
|
||||||
|
ctx.http(),
|
||||||
|
CreateMessage::new().add_embed(embed)
|
||||||
|
).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
use songbird::input::YoutubeDl;
|
use songbird::input::YoutubeDl;
|
||||||
use songbird::TrackEvent;
|
|
||||||
|
|
||||||
use crate::types::{Context, ContextExt, Error};
|
use crate::types::{Context, ContextExt, Error};
|
||||||
use crate::commands::voice::voice_utils::autocomplete_channel;
|
use crate::commands::voice::voice_utils::autocomplete_channel;
|
||||||
|
@ -12,8 +11,7 @@ use super::connect;
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
description_localized("en-US", "Plays music from supported URL"),
|
description_localized("en-US", "Plays music from supported URL"),
|
||||||
category = "Voice",
|
category = "Voice"
|
||||||
guild_only
|
|
||||||
)]
|
)]
|
||||||
pub async fn play(ctx: Context<'_>,
|
pub async fn play(ctx: Context<'_>,
|
||||||
#[autocomplete = "autocomplete_channel"]
|
#[autocomplete = "autocomplete_channel"]
|
||||||
|
@ -22,20 +20,34 @@ pub async fn play(ctx: Context<'_>,
|
||||||
#[description = "Source URL: "]
|
#[description = "Source URL: "]
|
||||||
url: String,
|
url: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let events = vec![TrackEvent::End];
|
|
||||||
let (manager, guild_id) = match connect(&ctx, channel, events).await {
|
if ctx.guild().is_none() {
|
||||||
Ok(result) => result,
|
ctx.reply_ephemeral("Can't use this outside of guild").await?;
|
||||||
Err(e) => {
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird Voice client placed in at initialisation.")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
let Some(guild_id) = ctx.guild_id() else {
|
||||||
|
ctx.reply_ephemeral("Guild id not found").await?;
|
||||||
|
return Ok(())
|
||||||
|
};
|
||||||
|
|
||||||
|
let http_client = &ctx.data().http_client;
|
||||||
|
|
||||||
|
if manager.get(guild_id).is_none() {
|
||||||
|
if let Err(e) = connect(&ctx, guild_id, channel).await {
|
||||||
ctx.reply_ephemeral(&e.to_string()).await?;
|
ctx.reply_ephemeral(&e.to_string()).await?;
|
||||||
println!("SONGBIRD MANAGER ERROR: {}", e.to_string());
|
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(guild_id) {
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
||||||
let http_client = &ctx.data().http_client;
|
|
||||||
let src = YoutubeDl::new(http_client.clone(), url);
|
let src = YoutubeDl::new(http_client.clone(), url);
|
||||||
handler.enqueue_input(src.into()).await;
|
handler.enqueue_input(src.into()).await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ use std::vec;
|
||||||
|
|
||||||
use poise::CreateReply;
|
use poise::CreateReply;
|
||||||
use songbird::input::{File, Input};
|
use songbird::input::{File, Input};
|
||||||
use songbird::TrackEvent;
|
|
||||||
|
|
||||||
use crate::utils::debug::send_error;
|
use crate::utils::debug::send_error;
|
||||||
use crate::types::{Context, ContextExt, Error};
|
use crate::types::{Context, ContextExt, Error};
|
||||||
|
@ -19,8 +18,7 @@ use super::voice_utils::{connect, autocomplete_channel};
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
description_localized("en-US", "Disconnect from voice channel"),
|
description_localized("en-US", "Disconnect from voice channel"),
|
||||||
category = "Voice",
|
category = "Voice"
|
||||||
guild_only
|
|
||||||
)]
|
)]
|
||||||
pub async fn disconnect(
|
pub async fn disconnect(
|
||||||
ctx: Context<'_>
|
ctx: Context<'_>
|
||||||
|
@ -70,8 +68,7 @@ async fn autocomplete_song(
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
description_localized("en-US", "Play song from server storage"),
|
description_localized("en-US", "Play song from server storage"),
|
||||||
category = "Voice",
|
category = "Voice"
|
||||||
guild_only
|
|
||||||
)]
|
)]
|
||||||
pub async fn play_local(ctx: Context<'_>,
|
pub async fn play_local(ctx: Context<'_>,
|
||||||
#[autocomplete = "autocomplete_channel"]
|
#[autocomplete = "autocomplete_channel"]
|
||||||
|
@ -81,16 +78,32 @@ pub async fn play_local(ctx: Context<'_>,
|
||||||
#[description = "Filename of local song: "]
|
#[description = "Filename of local song: "]
|
||||||
file_name: String
|
file_name: String
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let events = vec![TrackEvent::End];
|
|
||||||
let (manager, guild_id) = match connect(&ctx, channel, events).await {
|
if ctx.guild().is_none() {
|
||||||
Ok(result) => result,
|
ctx.reply_ephemeral("Can't use this outside of guild").await?;
|
||||||
Err(e) => {
|
return Ok(());
|
||||||
ctx.reply_ephemeral(&e.to_string()).await?;
|
}
|
||||||
println!("SONGBIRD MANAGER ERROR: {}", e.to_string());
|
|
||||||
return Ok(())
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
}
|
.await
|
||||||
|
.expect("Songbird Voice client placed in at initialisation.")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
let Some(guild_id) = ctx.guild_id() else {
|
||||||
|
ctx.reply_ephemeral("Guild id not found").await?;
|
||||||
|
return Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if manager.get(guild_id).is_none() {
|
||||||
|
match connect(&ctx, guild_id, channel).await {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(e) => {
|
||||||
|
ctx.reply_ephemeral(&e.to_string()).await?;
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(guild_id) {
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
||||||
|
@ -111,8 +124,7 @@ pub async fn play_local(ctx: Context<'_>,
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
description_localized("en-US", "Display currently playing info"),
|
description_localized("en-US", "Display currently playing info"),
|
||||||
category = "Voice",
|
category = "Voice"
|
||||||
guild_only
|
|
||||||
)]
|
)]
|
||||||
pub async fn playing(ctx: Context<'_>) -> Result<(), Error> {
|
pub async fn playing(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ use reqwest::Client;
|
||||||
|
|
||||||
use songbird::input::Input;
|
use songbird::input::Input;
|
||||||
use songbird::input::HttpRequest;
|
use songbird::input::HttpRequest;
|
||||||
use songbird::TrackEvent;
|
|
||||||
|
|
||||||
use super::super::connect;
|
use super::super::connect;
|
||||||
use super::link_or_string;
|
use super::link_or_string;
|
||||||
|
@ -22,8 +21,7 @@ use crate::commands::voice::voice_utils::autocomplete_channel;
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
slash_command,
|
slash_command,
|
||||||
description_localized("en-US", "Plays music from URL source"),
|
description_localized("en-US", "Plays music from URL source"),
|
||||||
subcommands("search", "play"),
|
subcommands("search", "play")
|
||||||
guild_only
|
|
||||||
)]
|
)]
|
||||||
pub async fn radio(_ctx: Context<'_>) -> Result<(), Error> {
|
pub async fn radio(_ctx: Context<'_>) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -43,6 +41,12 @@ pub async fn play(ctx: Context<'_>,
|
||||||
#[description = "Radio station: "]
|
#[description = "Radio station: "]
|
||||||
name: String,
|
name: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
|
if ctx.guild().is_none() {
|
||||||
|
ctx.reply_ephemeral("Can't use this outside of guild").await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let api = &ctx.data().radio_browser;
|
let api = &ctx.data().radio_browser;
|
||||||
|
|
||||||
let stations_result = match link_or_string(&name) {
|
let stations_result = match link_or_string(&name) {
|
||||||
|
@ -84,15 +88,23 @@ pub async fn play(ctx: Context<'_>,
|
||||||
return Ok(())
|
return Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
let events = vec![TrackEvent::End];
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
let (manager, guild_id) = match connect(&ctx, channel, events).await {
|
.await
|
||||||
Ok(result) => result,
|
.expect("Songbird Voice client placed in at initialisation.")
|
||||||
Err(e) => {
|
.clone();
|
||||||
|
|
||||||
|
let Some(guild_id) = ctx.guild_id() else {
|
||||||
|
ctx.reply_ephemeral("Guild id not found").await?;
|
||||||
|
return Ok(())
|
||||||
|
};
|
||||||
|
|
||||||
|
if manager.get(guild_id).is_none() {
|
||||||
|
if let Err(e) = connect(&ctx, guild_id, channel).await {
|
||||||
ctx.reply_ephemeral(&e.to_string()).await?;
|
ctx.reply_ephemeral(&e.to_string()).await?;
|
||||||
println!("SONGBIRD MANAGER ERROR: {}", e.to_string());
|
println!("SONGBIRD MANAGER ERROR: {}", e.to_string());
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(guild_id) {
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
|
@ -16,32 +16,32 @@ pub async fn paginate_search_stations(
|
||||||
let ctx_id = ctx.id();
|
let ctx_id = ctx.id();
|
||||||
let prev_button_id = format!("{}prev", ctx_id);
|
let prev_button_id = format!("{}prev", ctx_id);
|
||||||
let next_button_id = format!("{}next", ctx_id);
|
let next_button_id = format!("{}next", ctx_id);
|
||||||
|
|
||||||
let search_builder = search_builder;
|
let search_builder = search_builder;
|
||||||
|
|
||||||
let Ok(stations) = search_builder.clone().send().await else {
|
let Ok(stations) = search_builder.clone().send().await else {
|
||||||
ctx.reply_ephemeral("Something went wrong, try searching again").await?;
|
ctx.reply_ephemeral("Something went wrong, try searching again").await?;
|
||||||
return Ok(())
|
return Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut page = 0;
|
let mut page = 0;
|
||||||
|
|
||||||
let embed = create_station_list_embed(&stations, page);
|
let embed = create_station_list_embed(&stations, page);
|
||||||
|
|
||||||
// Send the embed with the first page as content
|
// Send the embed with the first page as content
|
||||||
let reply = {
|
let reply = {
|
||||||
let components = CreateActionRow::Buttons(vec![
|
let components = CreateActionRow::Buttons(vec![
|
||||||
CreateButton::new(&prev_button_id).emoji('◀'),
|
CreateButton::new(&prev_button_id).emoji('◀'),
|
||||||
CreateButton::new(&next_button_id).emoji('▶'),
|
CreateButton::new(&next_button_id).emoji('▶'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
CreateReply::default()
|
CreateReply::default()
|
||||||
.embed(embed)
|
.embed(embed)
|
||||||
.components(vec![components])
|
.components(vec![components])
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.send(reply).await?;
|
ctx.send(reply).await?;
|
||||||
|
|
||||||
// Loop through incoming interactions with the navigation buttons
|
// Loop through incoming interactions with the navigation buttons
|
||||||
let mut offset = 0;
|
let mut offset = 0;
|
||||||
let limit_int = limit as u32;
|
let limit_int = limit as u32;
|
||||||
|
@ -73,16 +73,16 @@ pub async fn paginate_search_stations(
|
||||||
if stations.is_empty() {
|
if stations.is_empty() {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
page = 0;
|
page = 0;
|
||||||
|
|
||||||
let Ok(new_stations) = search_builder.clone().offset(offset.to_string()).send().await else {
|
let Ok(new_stations) = search_builder.clone().offset(offset.to_string()).send().await else {
|
||||||
ctx.reply_ephemeral("Something went wrong, try searching again").await?;
|
ctx.reply_ephemeral("Something went wrong, try searching again").await?;
|
||||||
return Ok(())
|
return Ok(())
|
||||||
};
|
};
|
||||||
stations = new_stations;
|
stations = new_stations;
|
||||||
}
|
}
|
||||||
|
|
||||||
let embed = create_station_list_embed(&stations, page);
|
let embed = create_station_list_embed(&stations, page);
|
||||||
|
|
||||||
// Update the message with the new page contents
|
// Update the message with the new page contents
|
||||||
press
|
press
|
||||||
.create_response(
|
.create_response(
|
||||||
|
|
|
@ -35,6 +35,7 @@ pub struct GeneralInfo {
|
||||||
pub duration: Option<String>
|
pub duration: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl GenerateEmbed for GeneralInfo {
|
impl GenerateEmbed for GeneralInfo {
|
||||||
async fn generate_embed(&self) -> CreateEmbed {
|
async fn generate_embed(&self) -> CreateEmbed {
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
use std::sync::Arc;
|
use serenity::all::{ChannelId, GuildId};
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use serenity::all::{CacheHttp, ChannelId, CreateMessage, GuildId};
|
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
|
|
||||||
use songbird::events::{Event, EventContext, EventHandler as VoiceEventHandler};
|
use songbird::events::{Event, EventContext, EventHandler as VoiceEventHandler};
|
||||||
use songbird::{Songbird, TrackEvent};
|
use songbird::TrackEvent;
|
||||||
use tokio::time::sleep;
|
|
||||||
|
|
||||||
use crate::{types::Context, utils::utilities::get_channel_by_name};
|
use crate::{types::{Context, Error}, utils::utilities::get_channel_by_name};
|
||||||
|
|
||||||
pub const MAX_ENTRIES: &str = "15";
|
pub const MAX_ENTRIES: &str = "15";
|
||||||
|
|
||||||
|
@ -34,87 +30,18 @@ async fn get_voice_channel(ctx: &Context<'_>, name: Option<String>) -> Result<Ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TrackEventNotifier {
|
struct TrackErrorNotifier;
|
||||||
ctx: serenity::all::Context,
|
|
||||||
guild_id: GuildId,
|
|
||||||
channel_id: ChannelId
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TrackEventNotifier {
|
|
||||||
fn new(ctx: serenity::all::Context,
|
|
||||||
guild_id: GuildId,
|
|
||||||
channel_id: ChannelId) -> TrackEventNotifier {
|
|
||||||
TrackEventNotifier {
|
|
||||||
ctx,
|
|
||||||
guild_id,
|
|
||||||
channel_id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl VoiceEventHandler for TrackEventNotifier {
|
|
||||||
async fn act(&self, ctx: &EventContext<'_>) -> Option<Event> {
|
|
||||||
if let EventContext::Track(track_list) = ctx {
|
|
||||||
for (_, _) in *track_list {
|
|
||||||
sleep(Duration::from_secs(60)).await;
|
|
||||||
let manager = songbird::get(&self.ctx)
|
|
||||||
.await
|
|
||||||
.expect("Songbird Voice client placed in at initialisation.")
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(self.guild_id) {
|
|
||||||
let handler = handler_lock.lock().await;
|
|
||||||
if !handler.queue().is_empty() {
|
|
||||||
return None
|
|
||||||
}
|
|
||||||
|
|
||||||
drop(handler);
|
|
||||||
drop(handler_lock);
|
|
||||||
match manager.remove(self.guild_id).await {
|
|
||||||
Ok(_) => (),
|
|
||||||
Err(e) => {
|
|
||||||
dbg!(e);
|
|
||||||
()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = self.channel_id.say(self.ctx.http(), "Disconnected to save bandwidth!").await;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct TrackErrorNotifier {
|
|
||||||
ctx: serenity::all::Context,
|
|
||||||
channel_id: ChannelId
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TrackErrorNotifier {
|
|
||||||
fn new(ctx: serenity::all::Context, channel_id: ChannelId) -> TrackErrorNotifier {
|
|
||||||
TrackErrorNotifier {
|
|
||||||
ctx,
|
|
||||||
channel_id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl VoiceEventHandler for TrackErrorNotifier {
|
impl VoiceEventHandler for TrackErrorNotifier {
|
||||||
async fn act(&self, ctx: &EventContext<'_>) -> Option<Event> {
|
async fn act(&self, ctx: &EventContext<'_>) -> Option<Event> {
|
||||||
if let EventContext::Track(track_list) = ctx {
|
if let EventContext::Track(track_list) = ctx {
|
||||||
for (_, _) in *track_list {
|
for (state, handle) in *track_list {
|
||||||
match self.channel_id.send_message(
|
println!(
|
||||||
self.ctx.http(),
|
"Track {:?} encountered an error: {:?}",
|
||||||
CreateMessage::new().content("There was an error when playing a track!")
|
handle.uuid(),
|
||||||
).await {
|
state.playing
|
||||||
Ok(_) => (),
|
);
|
||||||
Err(e) => println!("{}", e)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,16 +49,7 @@ impl VoiceEventHandler for TrackErrorNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn connect(ctx: &Context<'_>, guild_id: GuildId, channel: Option<String>) -> Result<(), Error> {
|
||||||
pub async fn connect(ctx: &Context<'_>, channel: Option<String>, events: Vec<TrackEvent>) -> Result<(Arc<Songbird>, GuildId), String> {
|
|
||||||
if ctx.guild().is_none() {
|
|
||||||
return Err("This command can be used only in guild".to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
let Some(guild_id) = ctx.guild_id() else {
|
|
||||||
return Err("Guild id not found".to_string())
|
|
||||||
};
|
|
||||||
|
|
||||||
let voice_channel = get_voice_channel(&ctx, channel).await?;
|
let voice_channel = get_voice_channel(&ctx, channel).await?;
|
||||||
|
|
||||||
let manager = songbird::get(ctx.serenity_context())
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
@ -141,20 +59,10 @@ pub async fn connect(ctx: &Context<'_>, channel: Option<String>, events: Vec<Tra
|
||||||
|
|
||||||
if let Ok(handler_lock) = manager.join(guild_id, voice_channel).await {
|
if let Ok(handler_lock) = manager.join(guild_id, voice_channel).await {
|
||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier::new(ctx.serenity_context().clone(), voice_channel));
|
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||||
for event in events {
|
|
||||||
handler.add_global_event(
|
|
||||||
event.into(),
|
|
||||||
TrackEventNotifier::new(
|
|
||||||
ctx.serenity_context().clone(),
|
|
||||||
guild_id,
|
|
||||||
voice_channel
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((manager, guild_id))
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn autocomplete_channel(
|
pub async fn autocomplete_channel(
|
||||||
|
|
|
@ -6,6 +6,7 @@ use songbird::input::YoutubeDl;
|
||||||
use crate::commands::util::connect;
|
use crate::commands::util::connect;
|
||||||
use crate::util::poise_context_extension::ContextExt;
|
use crate::util::poise_context_extension::ContextExt;
|
||||||
use crate::types::{Context, Error};
|
use crate::types::{Context, Error};
|
||||||
|
use crate::commands::voice::util::autocomplete_channel;
|
||||||
|
|
||||||
// TODO: search, queue
|
// TODO: search, queue
|
||||||
#[poise::command(
|
#[poise::command(
|
||||||
|
@ -13,9 +14,9 @@ use crate::types::{Context, Error};
|
||||||
description_localized("en-US", "Plays music from YouTube URL")
|
description_localized("en-US", "Plays music from YouTube URL")
|
||||||
)]
|
)]
|
||||||
pub async fn play_yt(ctx: Context<'_>,
|
pub async fn play_yt(ctx: Context<'_>,
|
||||||
|
#[autocomplete = "autocomplete_channel"]
|
||||||
#[description = "Voice channel name: "]
|
#[description = "Voice channel name: "]
|
||||||
#[channel_types("Voice")]
|
channel: Option<String>,
|
||||||
channel: Option<GuildChannel>,
|
|
||||||
#[description = "Source URL: "]
|
#[description = "Source URL: "]
|
||||||
url: String,
|
url: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
pub mod message_handler;
|
|
||||||
pub mod voice_state_handler;
|
|
|
@ -1,110 +0,0 @@
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use serenity::all::{Context, CreateMessage, GuildChannel, VoiceState};
|
|
||||||
use tokio::time::sleep;
|
|
||||||
|
|
||||||
use crate::utils::{debug::send_error, voice_state_to_guild_channel};
|
|
||||||
|
|
||||||
async fn get_channel_info(ctx: &Context, voice_state: &VoiceState) -> Option<GuildChannel> {
|
|
||||||
let voice_channel = voice_state_to_guild_channel(&ctx, &voice_state).await?;
|
|
||||||
|
|
||||||
let Ok(members) = voice_channel.members(&ctx.cache) else {
|
|
||||||
return None
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut is_connected = false;
|
|
||||||
let mut users_connected: usize = 0;
|
|
||||||
for member in &members {
|
|
||||||
if member.user.id == ctx.cache.current_user().id {
|
|
||||||
is_connected = true
|
|
||||||
}
|
|
||||||
if ! member.user.bot {
|
|
||||||
users_connected += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there is no real user in the voice channel
|
|
||||||
if ! is_connected || users_connected > 0 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(voice_channel)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn handle_autodisconnect(ctx: Context, voice_state_old: VoiceState, voice_state: VoiceState) -> Option<()> {
|
|
||||||
// Logic is as follows:
|
|
||||||
// User connected -> voice_state_old is None (we handle this before this function)
|
|
||||||
// Bot was moved to different vc -> we check if the new voice_state has the bot's user id
|
|
||||||
// User moved to different VC or disconnected -> we check old channel instead (the bot could be still there)
|
|
||||||
let mut voice_channel: GuildChannel;
|
|
||||||
if voice_state.user_id == ctx.cache.current_user().id {
|
|
||||||
voice_channel = get_channel_info(&ctx, &voice_state).await?;
|
|
||||||
}
|
|
||||||
// Someone disconnected or moved channels
|
|
||||||
else {
|
|
||||||
voice_channel = get_channel_info(&ctx, &voice_state_old).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let manager = songbird::get(&ctx)
|
|
||||||
.await
|
|
||||||
.expect("Songbird Voice client placed in at initialisation.")
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
// bot is not connected to any channel via songbird, don't need to do anything
|
|
||||||
if manager.get(voice_channel.guild_id).is_none() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is a problem with this implementation
|
|
||||||
// if bot is left alone and users joins and disconnects while this counts down
|
|
||||||
// this is not a big problem since we want to disconnect anyway
|
|
||||||
sleep(Duration::from_secs(120)).await;
|
|
||||||
|
|
||||||
if voice_state.user_id == ctx.cache.current_user().id {
|
|
||||||
voice_channel = get_channel_info(&ctx, &voice_state).await?;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
voice_channel = get_channel_info(&ctx, &voice_state_old).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// bot is not connected to any channel via songbird, don't need to do anything
|
|
||||||
// ? could have been removed while sleeping if the song stopped playing
|
|
||||||
if manager.get(voice_channel.guild_id).is_none() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
match manager.remove(voice_channel.guild_id).await {
|
|
||||||
Ok(()) => {
|
|
||||||
let _ = voice_channel.send_message(ctx.http,
|
|
||||||
CreateMessage::new()
|
|
||||||
.content("Disconnected to save bandwidth")
|
|
||||||
).await;
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
let _ = send_error(ctx.http, e.to_string()).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn handle_voice_update(ctx: Context, voice_state_old: VoiceState, voice_state: VoiceState) -> Option<()> {
|
|
||||||
// if the user was disconnected remove Songbird manager so it won't get stuck
|
|
||||||
// Actually this is not really a bug since we can handle disconnect and therefore saving the song queue for example
|
|
||||||
if voice_state.channel_id.is_none() && voice_state.user_id == ctx.cache.current_user().id {
|
|
||||||
let manager = songbird::get(&ctx)
|
|
||||||
.await
|
|
||||||
.expect("Songbird Voice client placed in at initialisation.")
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
let guild_id = voice_state_old.guild_id?;
|
|
||||||
// bot is not connected to any channel via songbird, don't need to do anything
|
|
||||||
if manager.get(guild_id).is_some() {
|
|
||||||
let _ = manager.remove(guild_id).await;
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_autodisconnect(ctx, voice_state_old, voice_state).await?;
|
|
||||||
None
|
|
||||||
}
|
|
25
src/main.rs
25
src/main.rs
|
@ -6,7 +6,6 @@ use std::time::Duration;
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use serenity::all::VoiceState;
|
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
use serenity::futures::lock::Mutex;
|
use serenity::futures::lock::Mutex;
|
||||||
use serenity::prelude::GatewayIntents;
|
use serenity::prelude::GatewayIntents;
|
||||||
|
@ -20,14 +19,12 @@ use reqwest::Client as HttpClient;
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
|
|
||||||
use songbird::SerenityInit;
|
use songbird::SerenityInit;
|
||||||
|
|
||||||
use tokio_cron_scheduler::{JobScheduler, Job};
|
use tokio_cron_scheduler::{JobScheduler, Job};
|
||||||
|
|
||||||
use radiobrowser::RadioBrowserAPI;
|
use radiobrowser::RadioBrowserAPI;
|
||||||
|
|
||||||
mod handlers;
|
mod message_handler;
|
||||||
use handlers::message_handler::handle;
|
use message_handler::handle;
|
||||||
use handlers::voice_state_handler::handle_voice_update;
|
|
||||||
|
|
||||||
mod commands;
|
mod commands;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
@ -38,7 +35,6 @@ use other::notice;
|
||||||
mod types;
|
mod types;
|
||||||
use types::{Data, Error};
|
use types::{Data, Error};
|
||||||
|
|
||||||
|
|
||||||
struct Handler;
|
struct Handler;
|
||||||
|
|
||||||
async fn on_error(error: poise::FrameworkError<'_, Data, Error>) {
|
async fn on_error(error: poise::FrameworkError<'_, Data, Error>) {
|
||||||
|
@ -57,15 +53,6 @@ async fn on_error(error: poise::FrameworkError<'_, Data, Error>) {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for Handler {
|
impl EventHandler for Handler {
|
||||||
async fn voice_state_update(&self, ctx: Context, old: Option<VoiceState>, new: VoiceState) {
|
|
||||||
// User was not connected to any channel and connected to VC
|
|
||||||
let Some(old_channel) = old else {
|
|
||||||
return
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_voice_update(ctx, old_channel, new).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn message(&self, ctx: Context, msg: Message) {
|
async fn message(&self, ctx: Context, msg: Message) {
|
||||||
handle(ctx, msg).await;
|
handle(ctx, msg).await;
|
||||||
}
|
}
|
||||||
|
@ -126,11 +113,11 @@ async fn main() -> anyhow::Result<()> {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let framework = poise::Framework::builder()
|
let framework = poise::Framework::builder()
|
||||||
.setup(move |ctx, _ready, framework| {
|
.setup(move |ctx, _ready, framework| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
|
|
||||||
#[cfg(feature="GUILD_COMMAND")] {
|
#[cfg(feature="GUILD_COMMAND")] {
|
||||||
use poise::samples::register_in_guild;
|
use poise::samples::register_in_guild;
|
||||||
use serenity::all::GuildId;
|
use serenity::all::GuildId;
|
||||||
|
@ -138,7 +125,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let debug_guild_id = env::var("DEBUG_GUILD_ID")
|
let debug_guild_id = env::var("DEBUG_GUILD_ID")
|
||||||
.context("DEBUG_GUILD_ID not found in env")?
|
.context("DEBUG_GUILD_ID not found in env")?
|
||||||
.parse::<u64>().unwrap();
|
.parse::<u64>().unwrap();
|
||||||
|
|
||||||
register_in_guild(ctx, &framework.options().commands, GuildId::new(debug_guild_id)).await?;
|
register_in_guild(ctx, &framework.options().commands, GuildId::new(debug_guild_id)).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +134,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
register_globally(ctx, &framework.options().commands).await?;
|
register_globally(ctx, &framework.options().commands).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Ok(Data {
|
Ok(Data {
|
||||||
http_client: HttpClient::new(),
|
http_client: HttpClient::new(),
|
||||||
radio_browser: RadioBrowserAPI::new().await?,
|
radio_browser: RadioBrowserAPI::new().await?,
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub async fn handle(ctx: Context, msg: Message) {
|
||||||
if msg.author.bot {
|
if msg.author.bot {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let lower_case_content = msg.content.to_lowercase();
|
let lower_case_content = msg.content.to_lowercase();
|
||||||
|
|
||||||
let bot_id = ctx.cache.current_user().id;
|
let bot_id = ctx.cache.current_user().id;
|
||||||
|
@ -31,7 +31,7 @@ pub async fn handle(ctx: Context, msg: Message) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// X and IG not embedding correctly (IG fix does not work for now need to find different one)
|
// X and IG not embedding correctly (IG fix does not work for now need to find different one)
|
||||||
let link_fixes = HashMap::from([
|
let link_fixes = HashMap::from([
|
||||||
("//x.com", "//fixvx.com")
|
("//x.com", "//fixvx.com")
|
||||||
|
@ -96,7 +96,7 @@ async fn henlo(http: Arc<Http>, msg: Message) -> bool {
|
||||||
|
|
||||||
let emoji = EMOJIS.choose(&mut rand::rng()).unwrap_or(&"🐮");
|
let emoji = EMOJIS.choose(&mut rand::rng()).unwrap_or(&"🐮");
|
||||||
let response = format!("Henlooo {} {}", msg.author.name, emoji);
|
let response = format!("Henlooo {} {}", msg.author.name, emoji);
|
||||||
|
|
||||||
match msg.reply(http.clone(), response).await {
|
match msg.reply(http.clone(), response).await {
|
||||||
Ok(_) => { return true }
|
Ok(_) => { return true }
|
||||||
Err(e) => {
|
Err(e) => {
|
|
@ -26,13 +26,13 @@ pub async fn notice_wrapper(ctx: Context) {
|
||||||
|
|
||||||
/// Send embed with event name and optional special message to guild's general channel
|
/// Send embed with event name and optional special message to guild's general channel
|
||||||
async fn announce_event(guild_id: GuildId, name: &str, special_message: &str, http: Arc<Http>) -> anyhow::Result<()> {
|
async fn announce_event(guild_id: GuildId, name: &str, special_message: &str, http: Arc<Http>) -> anyhow::Result<()> {
|
||||||
|
|
||||||
let mut event_embed = CreateEmbed::new()
|
let mut event_embed = CreateEmbed::new()
|
||||||
.color(Colour::new(rand::random::<u32>() % 0xFFFFFF))
|
.color(Colour::new(rand::random::<u32>() % 0xFFFFFF))
|
||||||
.title("Today's event is:");
|
.title("Today's event is:");
|
||||||
|
|
||||||
let system_channel = utilities::get_system_channel(guild_id, &http).await?;
|
let system_channel = utilities::get_system_channel(guild_id, &http).await?;
|
||||||
|
|
||||||
if special_message.contains("http") {
|
if special_message.contains("http") {
|
||||||
event_embed = event_embed.description(name);
|
event_embed = event_embed.description(name);
|
||||||
system_channel.send_message(http.clone(),
|
system_channel.send_message(http.clone(),
|
||||||
|
|
|
@ -4,13 +4,13 @@ use serenity::http::Http;
|
||||||
|
|
||||||
pub async fn send_error(_http: Arc<Http>, msg: String) -> anyhow::Result<()> {
|
pub async fn send_error(_http: Arc<Http>, msg: String) -> anyhow::Result<()> {
|
||||||
println!("ERROR: {msg}");
|
println!("ERROR: {msg}");
|
||||||
|
|
||||||
#[cfg(feature="RELEASE")] {
|
#[cfg(feature="RELEASE")] {
|
||||||
use serenity::all::ChannelId;
|
use serenity::all::ChannelId;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::env;
|
use std::env;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
|
||||||
let channel_id: String = env::var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
let channel_id: String = env::var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
||||||
match ChannelId::new(channel_id.parse::<u64>().unwrap())
|
match ChannelId::new(channel_id.parse::<u64>().unwrap())
|
||||||
.say(_http, msg).await {
|
.say(_http, msg).await {
|
||||||
|
@ -20,7 +20,7 @@ pub async fn send_error(_http: Arc<Http>, msg: String) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature="RELEASE")]
|
#[cfg(feature="RELEASE")]
|
||||||
pub async fn hello(http: Arc<Http>) -> anyhow::Result<()> {
|
pub async fn hello(http: Arc<Http>) -> anyhow::Result<()> {
|
||||||
use serenity::all::ChannelId;
|
use serenity::all::ChannelId;
|
||||||
|
@ -40,7 +40,7 @@ pub async fn hello(http: Arc<Http>) -> anyhow::Result<()> {
|
||||||
];
|
];
|
||||||
|
|
||||||
let message = messages.choose(&mut rand::rng()).unwrap_or(&"Chello").to_string();
|
let message = messages.choose(&mut rand::rng()).unwrap_or(&"Chello").to_string();
|
||||||
|
|
||||||
let channel_id: String = env::var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
let channel_id: String = env::var("DEBUG_CHANNEL_ID").context("DEBUG_CHANNEL_ID not found in env file")?;
|
||||||
let channel = ChannelId::new(channel_id.parse::<u64>().unwrap());
|
let channel = ChannelId::new(channel_id.parse::<u64>().unwrap());
|
||||||
if let Err(why) = channel.say(http, message).await {
|
if let Err(why) = channel.say(http, message).await {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{fs, hash::{DefaultHasher, Hash, Hasher}, io, path::Path, sync::Arc, vec};
|
use std::{fs, hash::{DefaultHasher, Hash, Hasher}, io, path::Path, sync::Arc, vec};
|
||||||
|
|
||||||
use serenity::{all::{ChannelId, ChannelType, Context, CreateMessage, GuildChannel, GuildId, GuildRef, Message, VoiceState}, http::Http};
|
use serenity::{all::{ChannelId, ChannelType, CreateMessage, GuildId, GuildRef, Message}, http::Http};
|
||||||
|
|
||||||
|
|
||||||
pub async fn get_system_channel(guild_id: GuildId, http: &Http) -> anyhow::Result<ChannelId> {
|
pub async fn get_system_channel(guild_id: GuildId, http: &Http) -> anyhow::Result<ChannelId> {
|
||||||
|
@ -15,16 +15,6 @@ pub async fn replace_msg(http: Arc<Http>, msg: Message, content: String) -> Resu
|
||||||
return ChannelId::new(msg.channel_id.get()).send_message(http.clone(), CreateMessage::new().content(content)).await;
|
return ChannelId::new(msg.channel_id.get()).send_message(http.clone(), CreateMessage::new().content(content)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn voice_state_to_guild_channel(ctx: &Context, voice_state: &VoiceState) -> Option<GuildChannel> {
|
|
||||||
let Ok(channel) = voice_state.channel_id?
|
|
||||||
.to_channel(&ctx.http)
|
|
||||||
.await else {
|
|
||||||
return None
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(channel.guild()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_vc_names(guild: GuildRef) -> Vec<String> {
|
pub fn get_vc_names(guild: GuildRef) -> Vec<String> {
|
||||||
|
|
||||||
let mut result: Vec<String> = [].to_vec();
|
let mut result: Vec<String> = [].to_vec();
|
||||||
|
|
Loading…
Reference in a new issue