5 Commits

Author SHA1 Message Date
mii
6aec4e4ea7 fix dockerfile 2022-08-12 00:50:12 +09:00
mii
2bf2fe05f1 dockerfile 2022-08-12 00:40:14 +09:00
mii
f99d37ea56 fix slash commands register 2022-08-12 00:25:52 +09:00
mii
3652079bab fix audio path 2022-08-12 00:00:03 +09:00
mii
8a4de65a8a fix audio path 2022-08-11 23:59:52 +09:00
4 changed files with 21 additions and 21 deletions

View File

@ -1,16 +1,18 @@
FROM ubuntu:22.04 FROM ubuntu:22.04
RUN apt-get update \
&& apt-get install -y ffmpeg libssl-dev pkg-config libopus-dev wget curl gcc \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/*
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
ENV PATH $PATH:/root/.cargo/bin/
RUN rustup install stable
WORKDIR /usr/src/ncb-tts-r2 WORKDIR /usr/src/ncb-tts-r2
COPY Cargo.toml . COPY Cargo.toml .
COPY src src COPY src src
RUN cargo build --release \ ENV PATH $PATH:/root/.cargo/bin/
RUN apt-get update \
&& apt-get install -y ffmpeg libssl-dev pkg-config libopus-dev wget curl gcc \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/* \
&& curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable \
&& rustup install stable \
&& cargo build --release \
&& cp /usr/src/ncb-tts-r2/target/release/ncb-tts-r2 /usr/bin/ncb-tts-r2 \ && cp /usr/src/ncb-tts-r2/target/release/ncb-tts-r2 /usr/bin/ncb-tts-r2 \
&& mkdir -p /ncb-tts-r2/audio && mkdir -p /ncb-tts-r2/audio \
&& apt-get purge -y pkg-config wget curl gcc \
&& rustup self uninstall -y
WORKDIR /ncb-tts-r2 WORKDIR /ncb-tts-r2
CMD ["ncb-tts-r2"] CMD ["ncb-tts-r2"]

View File

@ -1,4 +1,4 @@
use serenity::{client::{EventHandler, Context}, async_trait, model::{gateway::Ready, interactions::{Interaction, application_command::ApplicationCommandInteraction, InteractionApplicationCommandCallbackDataFlags}, id::{GuildId, UserId}, channel::Message, prelude::Member, voice::VoiceState}, framework::standard::macros::group}; use serenity::{client::{EventHandler, Context}, async_trait, model::{gateway::Ready, interactions::{Interaction, application_command::ApplicationCommandInteraction, InteractionApplicationCommandCallbackDataFlags}, id::{GuildId, UserId}, channel::Message, prelude::{Member, application_command::{ApplicationCommandOptionType, ApplicationCommandOption, ApplicationCommand}}, voice::VoiceState}, framework::standard::macros::group};
use crate::{data::TTSData, tts::{instance::TTSInstance, message::AnnounceMessage}, implement::member_name::ReadName}; use crate::{data::TTSData, tts::{instance::TTSInstance, message::AnnounceMessage}, implement::member_name::ReadName};
#[group] #[group]
@ -281,10 +281,7 @@ impl EventHandler for Handler {
async fn ready(&self, ctx: Context, ready: Ready) { async fn ready(&self, ctx: Context, ready: Ready) {
println!("{} is connected!", ready.user.name); println!("{} is connected!", ready.user.name);
let _ = ApplicationCommand::set_global_application_commands(&ctx.http, |commands| {
let guild_id = GuildId(660046656934248460);
let commands = GuildId::set_application_commands(&guild_id, &ctx.http, |commands| {
commands.create_application_command(|command| { commands.create_application_command(|command| {
command.name("stop") command.name("stop")
.description("Stop tts") .description("Stop tts")
@ -292,8 +289,11 @@ impl EventHandler for Handler {
commands.create_application_command(|command| { commands.create_application_command(|command| {
command.name("setup") command.name("setup")
.description("Setup tts") .description("Setup tts")
});
commands.create_application_command(|command| {
command.name("config")
.description("Config")
}) })
}).await; }).await;
println!("{:?}", commands);
} }
} }

View File

@ -1,4 +1,4 @@
use std::{path::Path, fs::File, io::Write}; use std::{path::Path, fs::File, io::Write, env};
use async_trait::async_trait; use async_trait::async_trait;
use serenity::{prelude::Context, model::prelude::Message}; use serenity::{prelude::Context, model::prelude::Message};
@ -80,8 +80,7 @@ impl TTSMessage for Message {
let uuid = uuid::Uuid::new_v4().to_string(); let uuid = uuid::Uuid::new_v4().to_string();
let root = option_env!("CARGO_MANIFEST_DIR").unwrap(); let path = env::current_dir().unwrap();
let path = Path::new(root);
let file_path = path.join("audio").join(format!("{}.mp3", uuid)); let file_path = path.join("audio").join(format!("{}.mp3", uuid));
let mut file = File::create(file_path.clone()).unwrap(); let mut file = File::create(file_path.clone()).unwrap();

View File

@ -1,4 +1,4 @@
use std::{path::Path, fs::File, io::Write}; use std::{path::Path, fs::File, io::Write, env};
use async_trait::async_trait; use async_trait::async_trait;
use serenity::prelude::Context; use serenity::prelude::Context;
@ -64,8 +64,7 @@ impl TTSMessage for AnnounceMessage {
let uuid = uuid::Uuid::new_v4().to_string(); let uuid = uuid::Uuid::new_v4().to_string();
let root = option_env!("CARGO_MANIFEST_DIR").unwrap(); let path = env::current_dir().unwrap();
let path = Path::new(root);
let file_path = path.join("audio").join(format!("{}.mp3", uuid)); let file_path = path.join("audio").join(format!("{}.mp3", uuid));
let mut file = File::create(file_path.clone()).unwrap(); let mut file = File::create(file_path.clone()).unwrap();