From 8179f0f6072ea13677eefef00060443f80ce21ed Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Wed, 21 Feb 2024 01:44:46 +0900 Subject: [PATCH 1/8] =?UTF-8?q?=F0=9F=90=9B=20Corrected=20member=20log=20c?= =?UTF-8?q?onditions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Events/onGuildMemberUpdate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Events/onGuildMemberUpdate.ts b/src/Events/onGuildMemberUpdate.ts index 44ddf6b..277afe4 100644 --- a/src/Events/onGuildMemberUpdate.ts +++ b/src/Events/onGuildMemberUpdate.ts @@ -11,7 +11,7 @@ export async function onGuildMemberUpdate(oldMember: GuildMember | PartialGuildM const MemberLog = new Database('MemberLog'); list['member'] = await MemberLog.keys(); const serverId = oldMember.guild.id; - if (list['join'].includes(serverId)) { + if (list['member'].includes(serverId)) { try { const MemberLogData = (await MemberLog.get(serverId)) as string; const channel = oldMember.guild.channels.cache.get(MemberLogData); From 4f5aca975d26d79ae67ddd7da366f97684762c81 Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Sat, 2 Mar 2024 00:42:00 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Show=20original=20text?= =?UTF-8?q?=20together?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interactions/context_en_translate.ts | 3 ++- src/interactions/context_ja_translate.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/interactions/context_en_translate.ts b/src/interactions/context_en_translate.ts index 11db9c2..4848475 100644 --- a/src/interactions/context_en_translate.ts +++ b/src/interactions/context_en_translate.ts @@ -25,7 +25,8 @@ export async function en_translateCommand(interaction: MessageContextMenuCommand .then((res) => { const embed = new EmbedBuilder() .setTitle('Translation Result') - .setDescription(res.data.translations[0].text) + .addFields({ name: 'Original', value: interaction.targetMessage.content }) + .addFields({ name: 'Translation (EN)', value: res.data.translations[0].text }) .setColor('#0099ff') .setFooter({ text: 'Powered by DeepL' }); interaction.reply({ embeds: [embed] }); diff --git a/src/interactions/context_ja_translate.ts b/src/interactions/context_ja_translate.ts index c8b958c..5078ddf 100644 --- a/src/interactions/context_ja_translate.ts +++ b/src/interactions/context_ja_translate.ts @@ -26,7 +26,8 @@ export async function ja_translateCommand(interaction: MessageContextMenuCommand .then((res) => { const embed = new EmbedBuilder() .setTitle('翻訳結果') - .setDescription(res.data.translations[0].text) + .addFields({ name: '原文', value: interaction.targetMessage.content }) + .addFields({ name: '翻訳(日本語)', value: res.data.translations[0].text }) .setColor('#0099ff') .setFooter({ text: 'Powered by DeepL' }); interaction.reply({ embeds: [embed] }); From 0d910242fae8f6bc13d6caf0066b51eb9ee72a6f Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Sat, 2 Mar 2024 00:43:01 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=E2=9C=A8=20Added=20a=20command=20to=20retr?= =?UTF-8?q?ieve=20the=20Bedrock=20Edition=20skin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Events/onInteractionCreate.ts | 3 +++ src/Events/onMessageCreate.ts | 3 +++ src/commands/index.ts | 2 ++ src/commands/mcbeskin.ts | 21 +++++++++++++++++++++ src/deploy-commands.ts | 6 +++++- src/interactions/index.ts | 2 ++ src/interactions/mcbeskin.ts | 21 +++++++++++++++++++++ 7 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/commands/mcbeskin.ts create mode 100644 src/interactions/mcbeskin.ts diff --git a/src/Events/onInteractionCreate.ts b/src/Events/onInteractionCreate.ts index 59f4186..f95581a 100644 --- a/src/Events/onInteractionCreate.ts +++ b/src/Events/onInteractionCreate.ts @@ -89,6 +89,9 @@ export async function onInteractionCreate(interaction: BaseInteraction): Promise case 'log': interactions.log(interaction); break; + case 'mcbeskin': + interactions.mcbeskin(interaction); + break; case 'mcskin': interactions.mcskin(interaction); break; diff --git a/src/Events/onMessageCreate.ts b/src/Events/onMessageCreate.ts index c465bdf..b392d7e 100644 --- a/src/Events/onMessageCreate.ts +++ b/src/Events/onMessageCreate.ts @@ -101,6 +101,9 @@ export async function onMessageCreate(message: Message): Promise case 'log': commands.log(message); break; + case 'mcbeskin': + commands.mcbeskin(message); + break; case 'mcskin': commands.mcskin(message); break; diff --git a/src/commands/index.ts b/src/commands/index.ts index 534b747..472c56b 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -12,6 +12,7 @@ import { joinCommand } from './join'; import { kickCommand } from './kick'; import { leaveCommand } from './leave'; import { logCommand } from './log'; +import { mcbeskinCommand } from './mcbeskin'; import { mcskinCommand } from './mcskin'; import { mcstatusCommand } from './mcstatus'; import { pingCommand } from './ping'; @@ -43,6 +44,7 @@ export const commands = { kick: kickCommand, leave: leaveCommand, log: logCommand, + mcbeskin: mcbeskinCommand, mcskin: mcskinCommand, mcstatus: mcstatusCommand, ping: pingCommand, diff --git a/src/commands/mcbeskin.ts b/src/commands/mcbeskin.ts new file mode 100644 index 0000000..0840dbb --- /dev/null +++ b/src/commands/mcbeskin.ts @@ -0,0 +1,21 @@ +import { embeds } from '../embeds'; +import axios from 'axios'; +import { Message, EmbedBuilder } from 'discord.js'; + +export async function mcbeskinCommand(message: Message) { + const name = message.content.split(' ')[1]; + if (!name) return message.reply(embeds.mcskinHelp); + try { + const response = await axios.get(`https://api.geysermc.org/v2/xbox/xuid/${name}`); + const xuid = response.data.xuid.toString(16).toUpperCase(); + const uuid = '00000000-0000-0000-000' + xuid.slice(0, 1) + '-' + xuid.slice(1); + const embed = new EmbedBuilder() + .setTitle(`${name}のスキン`) + .setColor('#0099ff') + .setImage(`https://api.tydiumcraft.net/v1/players/skin?uuid=${uuid}&type=player`) + .setThumbnail(`https://api.tydiumcraft.net/v1/players/skin?uuid=${uuid}&type=skin`); + message.reply({ embeds: [embed] }); + } catch (error) { + message.reply(embeds.defaultError); + } +} diff --git a/src/deploy-commands.ts b/src/deploy-commands.ts index dcb9876..6e675de 100644 --- a/src/deploy-commands.ts +++ b/src/deploy-commands.ts @@ -77,6 +77,10 @@ const commands = [ .setDescription('ユーザーをキックします') .addUserOption((option) => option.setName('member').setDescription('キックするユーザー').setRequired(true)) .setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers), + new SlashCommandBuilder() + .setName('mcbeskin') + .setDescription('Minecraft BEのスキンを表示します') + .addStringOption((option) => option.setName('user').setDescription('スキンを表示するユーザー').setRequired(true)), new SlashCommandBuilder() .setName('mcskin') .setDescription('Minecraftのスキンを表示します') @@ -149,7 +153,7 @@ const commands = [ new ContextMenuCommandBuilder().setName('英語に翻訳').setType(ApplicationCommandType.Message) ]; -const rest = new REST().setToken(process.env.DISCORD_TOKEN!); +const rest = new REST().setToken(process.env.TOKEN!); (async () => { try { diff --git a/src/interactions/index.ts b/src/interactions/index.ts index 90c5ec1..fa8e82c 100644 --- a/src/interactions/index.ts +++ b/src/interactions/index.ts @@ -17,6 +17,7 @@ import { joinCommand } from './join'; import { kickCommand } from './kick'; import { leaveCommand } from './leave'; import { logCommand } from './log'; +import { mcbeskinCommand } from './mcbeskin'; import { mcskinCommand } from './mcskin'; import { mcstatusCommand } from './mcstatus'; import { pingCommand } from './ping'; @@ -43,6 +44,7 @@ export const interactions = { join: joinCommand, kick: kickCommand, leave: leaveCommand, + mcbeskin: mcbeskinCommand, mcskin: mcskinCommand, mcstatus: mcstatusCommand, ping: pingCommand, diff --git a/src/interactions/mcbeskin.ts b/src/interactions/mcbeskin.ts new file mode 100644 index 0000000..1bbb0fe --- /dev/null +++ b/src/interactions/mcbeskin.ts @@ -0,0 +1,21 @@ +import { embeds } from '../embeds'; +import axios from 'axios'; +import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js'; + +export async function mcbeskinCommand(interaction: ChatInputCommandInteraction) { + await interaction.deferReply(); + const name = interaction.options.getString('name'); + try { + const response = await axios.get(`https://api.geysermc.org/v2/xbox/xuid/${name}`); + const xuid = response.data.xuid.toString(16).toUpperCase(); + const uuid = '00000000-0000-0000-000' + xuid.slice(0, 1) + '-' + xuid.slice(1); + const embed = new EmbedBuilder() + .setTitle(`${name}のスキン`) + .setColor('#0099ff') + .setImage(`https://api.tydiumcraft.net/v1/players/skin?uuid=${uuid}&type=player`) + .setThumbnail(`https://api.tydiumcraft.net/v1/players/skin?uuid=${uuid}&type=skin`); + interaction.followUp({ embeds: [embed] }); + } catch (error) { + interaction.followUp(embeds.defaultError); + } +} From 36cfb523367c3f6b80f420c18c559ade5354c579 Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Sat, 2 Mar 2024 00:43:36 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=90=9B=20Fix=20mcstatus=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interactions/mcstatus.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interactions/mcstatus.ts b/src/interactions/mcstatus.ts index 04a54df..81fb3c3 100644 --- a/src/interactions/mcstatus.ts +++ b/src/interactions/mcstatus.ts @@ -4,7 +4,7 @@ import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js'; export async function mcstatusCommand(interaction: ChatInputCommandInteraction) { const mcServerIp = interaction.options.getString('address'); - const mcServerPort = interaction.options.getString('port') ?? '25565'; + const mcServerPort = interaction.options.getInteger('port') ?? 25565; const url = `https://mcapi.us/server/status?ip=${mcServerIp}&port=${mcServerPort}`; if (!mcServerIp) return interaction.reply(embeds.mcstatusHelp); axios From bdbcd7fc75e81e8a58be06b86fd3be01141ad6f8 Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Sat, 2 Mar 2024 17:39:00 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=E2=9C=A8=20add=20ticket=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Events/onInteractionCreate.ts | 3 +++ src/deploy-commands.ts | 6 +++++- src/interactions/index.ts | 2 ++ src/interactions/ticket.ts | 13 +++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/interactions/ticket.ts diff --git a/src/Events/onInteractionCreate.ts b/src/Events/onInteractionCreate.ts index f95581a..53c67ce 100644 --- a/src/Events/onInteractionCreate.ts +++ b/src/Events/onInteractionCreate.ts @@ -116,6 +116,9 @@ export async function onInteractionCreate(interaction: BaseInteraction): Promise case 'status': interactions.status(interaction); break; + case 'ticket': + interactions.ticket(interaction); + break; case 'timeout': interactions.timeout(interaction); break; diff --git a/src/deploy-commands.ts b/src/deploy-commands.ts index 6e675de..c35c3cc 100644 --- a/src/deploy-commands.ts +++ b/src/deploy-commands.ts @@ -91,7 +91,6 @@ const commands = [ .addStringOption((option) => option.setName('address').setDescription('サーバーアドレス').setRequired(true)) .addIntegerOption((option) => option.setName('port').setDescription('ポート番号').setRequired(false)), new SlashCommandBuilder().setName('ping').setDescription('BotのPingを表示します'), - new SlashCommandBuilder().setName('resnow').setDescription('レスポンスを表示します'), new SlashCommandBuilder() .setName('response') .setDescription('レスポンスを設定します') @@ -134,6 +133,11 @@ const commands = [ .addStringOption((option) => option.setName('query').setDescription('検索する内容').setRequired(true)), new SlashCommandBuilder().setName('server').setDescription('サーバーの情報を表示します'), new SlashCommandBuilder().setName('status').setDescription('Botのステータスを表示します'), + new SlashCommandBuilder() + .setName('ticket') + .setDescription('チケットを作成します') + .addStringOption((option) => option.setName('title').setDescription('チケットのタイトル').setRequired(false)) + .addStringOption((option) => option.setName('description').setDescription('チケットの説明').setRequired(false)), new SlashCommandBuilder() .setName('timeout') .setDescription('タイムアウトします') diff --git a/src/interactions/index.ts b/src/interactions/index.ts index fa8e82c..44d9b15 100644 --- a/src/interactions/index.ts +++ b/src/interactions/index.ts @@ -27,6 +27,7 @@ import { roleCommand } from './role'; import { searchCommand } from './search'; import { serverCommand } from './server'; import { statusCommand } from './status'; +import { ticketCommand } from './ticket'; import { timeoutCommand } from './timeout'; import { untimeoutCommand } from './untimeout'; import { userCommand } from './user'; @@ -54,6 +55,7 @@ export const interactions = { search: searchCommand, server: serverCommand, status: statusCommand, + ticket: ticketCommand, timeout: timeoutCommand, untimeout: untimeoutCommand, user: userCommand, diff --git a/src/interactions/ticket.ts b/src/interactions/ticket.ts new file mode 100644 index 0000000..6d7ecdd --- /dev/null +++ b/src/interactions/ticket.ts @@ -0,0 +1,13 @@ +import { EmbedBuilder, ChatInputCommandInteraction, ButtonBuilder, ButtonStyle, ActionRowBuilder } from 'discord.js'; + +export async function ticketCommand(interaction: ChatInputCommandInteraction) { + const title = interaction.options.getString('title') ?? 'お問い合わせ'; + const description = interaction.options.getString('description') ?? 'ボタンを押してチケットを作成してください。'; + const embed = new EmbedBuilder().setTitle(title).setDescription(description).setColor('#0099ff').setFooter({ text: 'Motcher v2.0' }); + + const button = new ButtonBuilder().setCustomId('createticket').setLabel('Create Ticket🎫').setStyle(ButtonStyle.Primary); + + const row = new ActionRowBuilder().addComponents(button); + await interaction.channel?.send({ embeds: [embed], components: [row] }); + await interaction.reply({ content: 'チケットを作成しました。', ephemeral: true }); +} From 08f1efd19751552639d1cd29212a07091a691cfe Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Sat, 2 Mar 2024 17:40:06 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=90=9B=20fix=20mcbeskin=20interacion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interactions/mcbeskin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interactions/mcbeskin.ts b/src/interactions/mcbeskin.ts index 1bbb0fe..1f35a4e 100644 --- a/src/interactions/mcbeskin.ts +++ b/src/interactions/mcbeskin.ts @@ -4,7 +4,7 @@ import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js'; export async function mcbeskinCommand(interaction: ChatInputCommandInteraction) { await interaction.deferReply(); - const name = interaction.options.getString('name'); + const name = interaction.options.getString('user'); try { const response = await axios.get(`https://api.geysermc.org/v2/xbox/xuid/${name}`); const xuid = response.data.xuid.toString(16).toUpperCase(); From b287c64b63cd6e6b5dbf3e0d795bd91670b44ca0 Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Sat, 2 Mar 2024 17:40:19 +0900 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=A7=B9=20format=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/embeds/index.ts | 16 +++++++++++++--- src/interactions/ban.ts | 1 - src/interactions/mcskin.ts | 2 -- src/interactions/mcstatus.ts | 1 - src/interactions/role.ts | 1 - 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/embeds/index.ts b/src/embeds/index.ts index b5ad5b2..1e65aaf 100644 --- a/src/embeds/index.ts +++ b/src/embeds/index.ts @@ -17,9 +17,9 @@ export const embeds = { { name: 'Commands', value: '`server`, `user`, `list`, `invite`, `search`' }, { name: 'Server', - value: '`join`, `leave`, `response`, `log`' + value: '`join`, `leave`, `response`, `log`, `ticket`' }, - { name: 'Minecraft', value: '`mcskin`, `mcstatus`' }, + { name: 'Minecraft', value: '`mcskin`, `mcbeskin`, `mcstatus`' }, { name: 'Moderation', value: '`ban`, `unban`, `kick`, `role`, `clear`, `timeout`, `untimeout`' } ) .setTimestamp() @@ -40,7 +40,7 @@ export const embeds = { }, { name: ':arrow_up:botの歴史', - value: '```diff\n+ 2023/05/21 認証\n+ 2023/02/21 v1.0 Release\n- 2023/02/10 暴走\n+ 2022/05/15 Botアカウントの作成\n```' + value: '```diff\n+ 2023/06/27 100サーバー達成\n+ 2023/05/21 認証\n+ 2023/02/21 v1.0 Release\n- 2023/02/10 暴走\n+ 2022/05/15 Botアカウントの作成\n```' }, { name: ':link:関連リンク', @@ -150,6 +150,16 @@ export const embeds = { .setColor('#ff0000') .build(), kickSuccess: new Builder().addFields({ name: 'Success', value: '指定したユーザーをkickしました。' }).setColor('#0099ff').build(), + mcbeskinHelp: new Builder() + .setTitle('mcbeskinコマンド') + .setDescription('指定したユーザーのマイクラBEスキンを取得するコマンド') + .setColor('#0099ff') + .addFields({ + name: '使い方', + value: 'mc!mcbeskin ユーザー名' + }) + .setFooter({ text: 'Motcher v2.0' }) + .build(), mcskinHelp: new Builder() .setTitle('mcskinコマンド') .setDescription('指定したユーザーのマイクラスキンを取得するコマンド') diff --git a/src/interactions/ban.ts b/src/interactions/ban.ts index db2b2a0..a60f541 100644 --- a/src/interactions/ban.ts +++ b/src/interactions/ban.ts @@ -5,7 +5,6 @@ export async function banCommand(interaction: ChatInputCommandInteraction) { if (!(interaction.member instanceof GuildMember)) return; if (!interaction.guild?.members.me?.permissions.has(PermissionsBitField.Flags.BanMembers)) return interaction.reply(embeds.banPermissionError); const member = interaction.options.getMember('member') as GuildMember; - if (!member) return interaction.reply(embeds.banHelp); member .ban() .then(() => { diff --git a/src/interactions/mcskin.ts b/src/interactions/mcskin.ts index 06e45a5..f5d6858 100644 --- a/src/interactions/mcskin.ts +++ b/src/interactions/mcskin.ts @@ -1,9 +1,7 @@ -import { embeds } from '../embeds'; import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js'; export async function mcskinCommand(interaction: ChatInputCommandInteraction) { const name = interaction.options.getString('user'); - if (!name) return interaction.reply(embeds.mcskinHelp); const embed = new EmbedBuilder() .setTitle(`${name}のスキン`) .setColor('#0099ff') diff --git a/src/interactions/mcstatus.ts b/src/interactions/mcstatus.ts index 81fb3c3..98ab14e 100644 --- a/src/interactions/mcstatus.ts +++ b/src/interactions/mcstatus.ts @@ -6,7 +6,6 @@ export async function mcstatusCommand(interaction: ChatInputCommandInteraction) const mcServerIp = interaction.options.getString('address'); const mcServerPort = interaction.options.getInteger('port') ?? 25565; const url = `https://mcapi.us/server/status?ip=${mcServerIp}&port=${mcServerPort}`; - if (!mcServerIp) return interaction.reply(embeds.mcstatusHelp); axios .get(url) .then((response) => { diff --git a/src/interactions/role.ts b/src/interactions/role.ts index 5f9422e..cacd45e 100644 --- a/src/interactions/role.ts +++ b/src/interactions/role.ts @@ -9,7 +9,6 @@ export async function roleCommand(interaction: ChatInputCommandInteraction) { return interaction.reply(embeds.roleAddPermissionError); const role = interaction.options.getRole('role') as Role; const member = interaction.options.getMember('member') as GuildMember; - if (!role || !member) return interaction.reply(embeds.roleAddHelp); member.roles .add(role) .then(() => { From fc8ad93ae0fcb7ed4be3e8957f33a93b2d589178 Mon Sep 17 00:00:00 2001 From: MotiCAT Date: Sat, 2 Mar 2024 17:52:28 +0900 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=90=9B=20Change=20Embed=20to=20approp?= =?UTF-8?q?riate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/mcbeskin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/mcbeskin.ts b/src/commands/mcbeskin.ts index 0840dbb..a72ac49 100644 --- a/src/commands/mcbeskin.ts +++ b/src/commands/mcbeskin.ts @@ -4,7 +4,7 @@ import { Message, EmbedBuilder } from 'discord.js'; export async function mcbeskinCommand(message: Message) { const name = message.content.split(' ')[1]; - if (!name) return message.reply(embeds.mcskinHelp); + if (!name) return message.reply(embeds.mcbeskinHelp); try { const response = await axios.get(`https://api.geysermc.org/v2/xbox/xuid/${name}`); const xuid = response.data.xuid.toString(16).toUpperCase();