prepare template

This commit is contained in:
Baipyrus 2024-01-13 17:31:03 +01:00
parent d3cd5f6945
commit 79144799f0
2 changed files with 1 additions and 29 deletions

View File

@ -1,3 +1 @@
# L Pa So Discord-Bot
Discord invite link [here](https://discord.com/api/oauth2/authorize?client_id=1184493544698810450&permissions=8&scope=bot%20applications.commands).
# A DiscordJS Template

View File

@ -1,26 +0,0 @@
import { SlashCommandBuilder } from 'discord.js';
export const data = new SlashCommandBuilder()
.setName('get')
.setDescription('Google GET Request.')
.addStringOption((option) =>
option
.setName('api')
.setRequired(true)
.setAutocomplete(true)
.setDescription('Specify API to call GET.')
);
export async function autocomplete(interaction) {
const APIs = ['serverlist', 'read-tournament', 'announcements'];
const focused = interaction.options.getString('api');
const filtered = APIs.filter((choice) => choice.startsWith(focused));
await interaction.respond(filtered.map((choice) => ({ name: choice, value: choice })));
}
export async function execute(interaction) {
const endpoint = interaction.options.getString('api');
const response = await fetch(`http://localhost:5173/api/${endpoint}`);
const text = await response.text();
await interaction.reply({ content: text, ephemeral: true });
}