forked from DiscordBots/Rustendo
WIP: started to impl. songbird
This commit is contained in:
parent
d6a2cb5c8b
commit
d48de636f9
8 changed files with 1064 additions and 268 deletions
|
@ -1,9 +1,8 @@
|
|||
use chrono::Local;
|
||||
use serenity::all::{CommandInteraction, Context};
|
||||
use serenity::builder::{CreateCommand, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter};
|
||||
use serenity::model::application::ResolvedOption;
|
||||
|
||||
pub fn run(ctx: &Context, command: &CommandInteraction, _options: &[ResolvedOption]) -> CreateEmbed {
|
||||
pub async fn run(_ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
|
||||
let username = command.user.name.as_str();
|
||||
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
|
||||
CreateEmbed::new()
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
|
||||
use chrono::Local;
|
||||
use serenity::all::{CommandInteraction, Context, ResolvedOption, ResolvedValue};
|
||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, Context, ResolvedOption, ResolvedValue};
|
||||
use serenity::builder::{CreateCommand, CreateCommandOption, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter};
|
||||
use serenity::model::application::CommandOptionType;
|
||||
|
||||
pub fn run(ctx: &Context, command: &CommandInteraction, options: &[ResolvedOption]) -> CreateEmbed {
|
||||
pub async fn run(ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
|
||||
let username = command.user.name.as_str();
|
||||
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
|
||||
let options = &command.data.options;
|
||||
|
||||
let query = if let Some(ResolvedOption {
|
||||
value: ResolvedValue::String(query), ..
|
||||
}) = options.first()
|
||||
let query = if let Some(CommandDataOption {
|
||||
value: CommandDataOptionValue::String(query), ..
|
||||
}) = &options.first()
|
||||
{
|
||||
query
|
||||
} else {
|
||||
|
@ -21,6 +21,45 @@ pub fn run(ctx: &Context, command: &CommandInteraction, options: &[ResolvedOptio
|
|||
.footer(CreateEmbedFooter::new(format!(">{} | {}", current_time, username)))
|
||||
};
|
||||
|
||||
let guild_id = match &command.guild_id {
|
||||
Some(guild_id) => guild_id,
|
||||
None => {
|
||||
return CreateEmbed::new()
|
||||
.author(CreateEmbedAuthor::new("Rustendo"))
|
||||
.title("guildid not found")
|
||||
.description("Could not find guild id.")
|
||||
.footer(CreateEmbedFooter::new(format!("> {} | {}", current_time, username)));
|
||||
}
|
||||
};
|
||||
|
||||
let (guild_id, channel_id) = {
|
||||
let guild = &ctx.cache.guild(guild_id).unwrap();
|
||||
// This may be unsafe, idk not sure yet
|
||||
let channel_id = guild
|
||||
.voice_states
|
||||
.get(&command.user.id)
|
||||
.and_then(|voice_state| voice_state.channel_id);
|
||||
(guild.id, channel_id)
|
||||
};
|
||||
|
||||
let connect_to = match channel_id {
|
||||
Some(channel) => channel,
|
||||
None => {
|
||||
return CreateEmbed::new()
|
||||
.author(CreateEmbedAuthor::new("Rustendo"))
|
||||
.title("You are not in a VC.")
|
||||
.description("Join one to start playing music.")
|
||||
.footer(CreateEmbedFooter::new(format!("> {} | {}", current_time, username)));
|
||||
},
|
||||
};
|
||||
|
||||
let manager = &songbird::get(ctx)
|
||||
.await
|
||||
.expect("")
|
||||
.clone();
|
||||
|
||||
manager.join(guild_id, connect_to).await.expect("Cannot connect>...");
|
||||
|
||||
CreateEmbed::new()
|
||||
.author(CreateEmbedAuthor::new("Rustendo"))
|
||||
.title(format!("Searching for {}", query))
|
||||
|
@ -35,4 +74,4 @@ pub fn register() -> CreateCommand {
|
|||
CreateCommandOption::new(CommandOptionType::String, "query", "Link or search term")
|
||||
.required(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use chrono::Local;
|
||||
use serenity::all::{CommandInteraction, Context};
|
||||
use serenity::builder::{CreateCommand, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter};
|
||||
use serenity::model::application::ResolvedOption;
|
||||
|
||||
pub fn run(ctx: &Context, command: &CommandInteraction, _options: &[ResolvedOption]) -> CreateEmbed {
|
||||
pub async fn run(_ctx: &Context, command: &CommandInteraction) -> CreateEmbed {
|
||||
let username = command.user.name.as_str();
|
||||
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
|
||||
CreateEmbed::new()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue