Skip to content
This repository was archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #74 from KuronekoServer/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
TanakaTakeshikun authored Mar 30, 2023
2 parents 58b6d81 + 5698fbc commit af767fb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 23 deletions.
3 changes: 1 addition & 2 deletions commands/misc/adminspeak.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ module.exports = {
.addSubcommand(subcommand =>
subcommand
.setName('server_exvoice-word')
.addStringOption(option => option.setName("select").setDescription("単語の操作").addChoices({ name: "追加", value: "add" }, { name: "削除", value: "remove" }, { name: "除外リスト", value: "removelist" }, { name: "一覧", value: "list" }).setRequired(true))
.addStringOption(option => option.setName("select").setDescription("単語の操作").addChoices({ name: "追加", value: "add" }, { name: "削除", value: "remove" }).setRequired(true))
.addStringOption(option => option.setName("話者").setDescription("話者の選択").setAutocomplete(true).setRequired(true))
.setDescription('読み上げないexvoiceの追加。')

)
.addSubcommand(subcommand =>
subcommand
Expand Down
12 changes: 12 additions & 0 deletions commands/misc/speak.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const live_read = require("./speak/live_read");
const skip = require("./speak/skip");
const setting_show = require("./speak/setting-show");
const live_read_stop = require("./speak/live_read_stop");
const all_voice_list = require("../../helpers/voicelist/allvoicelist.json");
let response;
module.exports = {
data: new SlashCommandBuilder()
Expand Down Expand Up @@ -104,7 +105,18 @@ module.exports = {
.setName('live_read-stop')
.addStringOption(option => option.setName("select").setDescription("選択してください").addChoices({ name: "youtube", value: "youtube" }, { name: "twitch", value: "twitch" }).setRequired(true))
.setDescription('ライブの読み上げを停止します。')
)
.addSubcommand(subcommand =>
subcommand
.setName('exvoice-word')
.addStringOption(option => option.setName("select").setDescription("単語の操作").addChoices({ name: "除外リスト", value: "removelist" }, { name: "一覧", value: "list" }).setRequired(true))
.addStringOption(option => option.setName("話者").setDescription("話者の選択").setAutocomplete(true).setRequired(true))
.setDescription('読み上げないexvoiceの追加。')
),
async autocomplete(interaction) {
const focusedValue = interaction.options.getFocused();
await interaction.respond(all_voice_list.filter(data => data.name.startsWith(focusedValue))).catch(() => { });
},
async execute(interaction) {
const sub = interaction.options.getSubcommand();
//user_voice
Expand Down
40 changes: 40 additions & 0 deletions commands/misc/speak/exvoice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { EmbedBuilder, Colors } = require("discord.js");
const { sql } = require("../../../helpers/utils");
const { escape } = require("mysql2")
const { PagesManager } = require('discord.js-pages');
const pagesManager = new PagesManager();
const url = new EmbedBuilder()
.setTitle(`✅完了`)
.setDescription(`https://kuroneko6423.com/exvoice`)
.setFooter({ iconURL: "https://media.discordapp.net/attachments/1081437402389811301/1082168221320364062/kuroneko.png", text: "©️ 2023 KURONEKOSERVER | speak" })
.setColor(Colors.Green);
const undefined_error = new EmbedBuilder()
.setTitle("⚠️エラー")
.setDescription("データが見つかりません。")
.setColor(Colors.Red)
.setFooter({ iconURL: "https://media.discordapp.net/attachments/1081437402389811301/1082168221320364062/kuroneko.png", text: "©️ 2023 KURONEKOSERVER | speak" });
module.exports = async (interaction) => {
const name = interaction.options.getString("話者");
const select = interaction.options.getString("select");
if (select === "removelist") {
const getdata = await sql(`select * from exvoiceword where guildid=${escape(interaction.guild.id)} and speakname=${escape(name)};`);
if (getdata[0][0]?.guildid) {
const list = getdata[0].map(data => "```" + `${data.word}(${data.speakname})` + "```");
const maxcontent = 10;
const pages = Math.ceil(list.length / maxcontent);
const content = [...Array(pages)].map((_, index) => new EmbedBuilder().setDescription(list.slice(maxcontent * ((index + 1) - 1), maxcontent * (index + 1)).join("\n")));
pagesManager.middleware(interaction);
await interaction.pagesBuilder()
.setTitle('読み上げないテキスト一覧')
.setPages(content)
.setColor('Green')
.setFooter({ iconURL: "https://media.discordapp.net/attachments/1081437402389811301/1082168221320364062/kuroneko.png", text: "©️ 2023 KURONEKOSERVER | speak" })
.setPaginationFormat()
.build();
return "exception";
} else return ({ embeds: [undefined_error] });
};
if (select === "list") {
return ({ embeds: [url] });
};
};
21 changes: 0 additions & 21 deletions commands/misc/speak/server_exvoice-word.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,4 @@ module.exports = async (interaction) => {
}
return ({ embeds: [success] });
};
if (select === "removelist") {
const getdata = await sql(`select * from exvoiceword where guildid=${escape(interaction.guild.id)} and speakname=${escape(name)};`);
if (getdata[0][0]?.guildid) {
const list = getdata[0].map(data => "```" + `${data.word}(${data.speakname})` + "```");
const maxcontent = 10;
const pages = Math.ceil(list.length / maxcontent);
const content = [...Array(pages)].map((_, index) => new EmbedBuilder().setDescription(list.slice(maxcontent * ((index + 1) - 1), maxcontent * (index + 1)).join("\n")));
pagesManager.middleware(interaction);
await interaction.pagesBuilder()
.setTitle('読み上げないテキスト一覧')
.setPages(content)
.setColor('Green')
.setFooter({ iconURL: "https://media.discordapp.net/attachments/1081437402389811301/1082168221320364062/kuroneko.png", text: "©️ 2023 KURONEKOSERVER | speak" })
.setPaginationFormat()
.build();
return "exception";
} else return ({ embeds: [undefined_error] });
};
if (select === "list") {
return ({ embeds: [url] });
};
};

0 comments on commit af767fb

Please sign in to comment.