Skip to content

Commit

Permalink
add command: ruby-name
Browse files Browse the repository at this point in the history
  • Loading branch information
salix5 committed Nov 4, 2024
1 parent b59a3c6 commit 5360b6b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions commands/ruby-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SlashCommandBuilder } from 'discord.js';
import { get_name } from '../ygo-query.mjs';
import { choice_table } from '../common_all.js';
import { reply_text } from '../common_query.js';

export const module_url = import.meta.url;
export const data = new SlashCommandBuilder()
.setName('ruby-name')
.setDescription('カードを検索します。')
.addStringOption(option => option.setName('input')
.setDescription('カード名')
.setRequired(true)
.setMaxLength(50)
.setAutocomplete(true)
);
data.integration_types = [0, 1];
data.contexts = [0, 1, 2];
export { autocomplete_jp as autocomplete } from '../common_all.js';
export async function execute(interaction) {
const input = interaction.options.getString('input');
const cid = choice_table['ja'].get(input);
const jp_name = cid ? get_name(cid, 'ja') : '';
if (jp_name) {
await interaction.reply(jp_name);
}
else {
await interaction.reply(reply_text['ja'].none);
}
}

0 comments on commit 5360b6b

Please sign in to comment.