mirror of
https://github.com/mii443/ncb-tts-r2.git
synced 2025-08-22 16:15:29 +00:00
update serenity and songbird
This commit is contained in:
@ -21,11 +21,11 @@ version = "0.8"
|
||||
features = ["serde", "v4"]
|
||||
|
||||
[dependencies.songbird]
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
features = ["builtin-queue"]
|
||||
|
||||
[dependencies.serenity]
|
||||
version = "0.10.9"
|
||||
version = "0.11.5"
|
||||
features = ["builder", "cache", "client", "gateway", "model", "utils", "unstable_discord_api", "collector", "rustls_backend", "framework", "voice"]
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
use serenity::{
|
||||
model::prelude::{
|
||||
application_command::ApplicationCommandInteraction,
|
||||
InteractionApplicationCommandCallbackDataFlags,
|
||||
model::prelude::interaction::{
|
||||
application_command::ApplicationCommandInteraction, MessageFlags,
|
||||
},
|
||||
prelude::Context,
|
||||
};
|
||||
@ -81,7 +80,7 @@ pub async fn config_command(
|
||||
})
|
||||
})
|
||||
})
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use serenity::{
|
||||
model::prelude::{
|
||||
application_command::ApplicationCommandInteraction,
|
||||
InteractionApplicationCommandCallbackDataFlags, UserId,
|
||||
interaction::{application_command::ApplicationCommandInteraction, MessageFlags},
|
||||
UserId,
|
||||
},
|
||||
prelude::Context,
|
||||
};
|
||||
@ -17,20 +17,20 @@ pub async fn setup_command(
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("このコマンドはサーバーでのみ使用可能です.")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let guild = command.guild_id.unwrap().to_guild_cached(&ctx.cache).await;
|
||||
let guild = command.guild_id.unwrap().to_guild_cached(&ctx.cache);
|
||||
if let None = guild {
|
||||
command
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("ギルドキャッシュを取得できませんでした.")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
@ -48,7 +48,7 @@ pub async fn setup_command(
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("ボイスチャンネルに参加してから実行してください.")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
@ -77,7 +77,7 @@ pub async fn setup_command(
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("すでにセットアップしています.")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
@ -99,7 +99,7 @@ pub async fn setup_command(
|
||||
|
||||
command.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.create_embed(|e| {
|
||||
d.embed(|e| {
|
||||
e.title("読み上げ (Serenity)")
|
||||
.field("クレジット", "```\n四国めたん ずんだもん\n春日部つむぎ 雨晴はう\n波音リツ 玄野武宏\n白上虎太郎 青山龍星\n冥鳴ひまり 九州そら\nモチノ・キョウコ```", false)
|
||||
.field("設定コマンド", "`/config`", false)
|
||||
|
@ -1,7 +1,7 @@
|
||||
use serenity::{
|
||||
model::prelude::{
|
||||
application_command::ApplicationCommandInteraction,
|
||||
InteractionApplicationCommandCallbackDataFlags, UserId,
|
||||
interaction::{application_command::ApplicationCommandInteraction, MessageFlags},
|
||||
UserId,
|
||||
},
|
||||
prelude::Context,
|
||||
};
|
||||
@ -17,20 +17,20 @@ pub async fn stop_command(
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("このコマンドはサーバーでのみ使用可能です.")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let guild = command.guild_id.unwrap().to_guild_cached(&ctx.cache).await;
|
||||
let guild = command.guild_id.unwrap().to_guild_cached(&ctx.cache);
|
||||
if let None = guild {
|
||||
command
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("ギルドキャッシュを取得できませんでした.")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
@ -48,7 +48,7 @@ pub async fn stop_command(
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("ボイスチャンネルに参加してから実行してください.")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
@ -75,7 +75,7 @@ pub async fn stop_command(
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("すでに停止しています")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
|
@ -8,8 +8,10 @@ use serenity::{
|
||||
async_trait,
|
||||
client::{Context, EventHandler},
|
||||
model::{
|
||||
channel::Message, gateway::Ready, id::GuildId, interactions::Interaction,
|
||||
prelude::InteractionApplicationCommandCallbackDataFlags, voice::VoiceState,
|
||||
channel::Message,
|
||||
gateway::Ready,
|
||||
prelude::interaction::{Interaction, MessageFlags},
|
||||
voice::VoiceState,
|
||||
},
|
||||
};
|
||||
|
||||
@ -94,16 +96,14 @@ impl EventHandler for Handler {
|
||||
message_component.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("設定しました\nこの音声を使うにはAPIをGoogleからVOICEVOXに変更する必要があります。")
|
||||
.flags(InteractionApplicationCommandCallbackDataFlags::EPHEMERAL)
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
}).await.unwrap();
|
||||
} else {
|
||||
message_component
|
||||
.create_interaction_response(&ctx.http, |f| {
|
||||
f.interaction_response_data(|d| {
|
||||
d.content("設定しました").flags(
|
||||
InteractionApplicationCommandCallbackDataFlags::EPHEMERAL,
|
||||
)
|
||||
d.content("設定しました").flags(MessageFlags::EPHEMERAL)
|
||||
})
|
||||
})
|
||||
.await
|
||||
@ -114,13 +114,7 @@ impl EventHandler for Handler {
|
||||
}
|
||||
}
|
||||
|
||||
async fn voice_state_update(
|
||||
&self,
|
||||
ctx: Context,
|
||||
guild_id: Option<GuildId>,
|
||||
old: Option<VoiceState>,
|
||||
new: VoiceState,
|
||||
) {
|
||||
events::voice_state_update::voice_state_update(ctx, guild_id, old, new).await
|
||||
async fn voice_state_update(&self, ctx: Context, old: Option<VoiceState>, new: VoiceState) {
|
||||
events::voice_state_update::voice_state_update(ctx, old, new).await
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ pub async fn message(ctx: Context, message: Message) {
|
||||
return;
|
||||
}
|
||||
|
||||
let guild_id = message.guild(&ctx.cache).await;
|
||||
let guild_id = message.guild(&ctx.cache);
|
||||
|
||||
if let None = guild_id {
|
||||
return;
|
||||
|
@ -1,12 +1,12 @@
|
||||
use serenity::{
|
||||
model::prelude::{application_command::ApplicationCommand, Ready},
|
||||
model::prelude::{command::Command, Ready},
|
||||
prelude::Context,
|
||||
};
|
||||
|
||||
pub async fn ready(ctx: Context, ready: Ready) {
|
||||
println!("{} is connected!", ready.user.name);
|
||||
|
||||
let _ = ApplicationCommand::set_global_application_commands(&ctx.http, |commands| {
|
||||
let _ = Command::set_global_application_commands(&ctx.http, |commands| {
|
||||
commands.create_application_command(|command| command.name("stop").description("Stop tts"));
|
||||
commands
|
||||
.create_application_command(|command| command.name("setup").description("Setup tts"));
|
||||
|
@ -1,8 +1,3 @@
|
||||
use serenity::{
|
||||
model::{prelude::GuildId, voice::VoiceState},
|
||||
prelude::Context,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
data::TTSData,
|
||||
implement::{
|
||||
@ -11,17 +6,15 @@ use crate::{
|
||||
},
|
||||
tts::message::AnnounceMessage,
|
||||
};
|
||||
use serenity::{model::voice::VoiceState, prelude::Context};
|
||||
|
||||
pub async fn voice_state_update(
|
||||
ctx: Context,
|
||||
guild_id: Option<GuildId>,
|
||||
old: Option<VoiceState>,
|
||||
new: VoiceState,
|
||||
) {
|
||||
pub async fn voice_state_update(ctx: Context, old: Option<VoiceState>, new: VoiceState) {
|
||||
if new.member.clone().unwrap().user.bot {
|
||||
return;
|
||||
}
|
||||
let guild_id = guild_id.unwrap();
|
||||
let guild_id = new
|
||||
.guild_id
|
||||
.unwrap_or(old.clone().unwrap().guild_id.unwrap());
|
||||
|
||||
let storage_lock = {
|
||||
let data_read = ctx.data.read().await;
|
||||
|
@ -14,10 +14,10 @@ use data::{DatabaseClientData, TTSClientData, TTSData};
|
||||
use database::database::Database;
|
||||
use event_handler::Handler;
|
||||
use serenity::{
|
||||
client::{bridge::gateway::GatewayIntents, Client},
|
||||
client::Client,
|
||||
framework::StandardFramework,
|
||||
futures::lock::Mutex,
|
||||
prelude::RwLock,
|
||||
prelude::{GatewayIntents, RwLock},
|
||||
};
|
||||
use tts::{gcp_tts::gcp_tts::TTS, voicevox::voicevox::VOICEVOX};
|
||||
|
||||
@ -34,11 +34,10 @@ use songbird::SerenityInit;
|
||||
async fn create_client(prefix: &str, token: &str, id: u64) -> Result<Client, serenity::Error> {
|
||||
let framework = StandardFramework::new().configure(|c| c.with_whitespace(true).prefix(prefix));
|
||||
|
||||
Client::builder(token)
|
||||
Client::builder(token, GatewayIntents::all())
|
||||
.event_handler(Handler)
|
||||
.application_id(id)
|
||||
.framework(framework)
|
||||
.intents(GatewayIntents::all())
|
||||
.register_songbird()
|
||||
.await
|
||||
}
|
||||
@ -75,7 +74,7 @@ async fn main() {
|
||||
// Create GCP TTS client
|
||||
let tts = match TTS::new("./credentials.json".to_string()).await {
|
||||
Ok(tts) => tts,
|
||||
Err(err) => panic!("{}", err),
|
||||
Err(err) => panic!("GCP init error: {}", err),
|
||||
};
|
||||
|
||||
let voicevox = VOICEVOX::new(config.voicevox_key);
|
||||
|
Reference in New Issue
Block a user