AlKiw38
Femtopat
- Katılım
- 24 Mayıs 2023
- Mesajlar
- 7
Daha fazla
- Cinsiyet
- Erkek
Merhaba. Discord'da sa/as botu yapmaya çalışıyorum ama npm test yazarken hata veriyor. Yardımcı olursanız sevinirim.
NOT: Visual Studio Code üzerinden yapıyorum.
Kod:
NOT: Visual Studio Code üzerinden yapıyorum.
Kod:
JavaScript:
import { REST } from '@discordjs/rest';
import { WebSocketManager } from '@discordjs/ws';
import { GatewayDispatchEvents, GatewayIntentBits, InteractionType, MessageFlags, Client } from '@discordjs/core';
// Create REST and WebSocket managers directly
const rest = new REST({ version: '10' }).setToken(token);
const gateway = new WebSocketManager({
token,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
});
// Create a client to emit relevant events.
const client = new Client({ rest, gateway });
// Listen for interactions
// Each event contains an `api` prop along with the event data that allows you to interface with the Discord REST API
client.on(GatewayDispatchEvents.InteractionCreate, async ({ data: interaction, api }) => {
if (interaction.type !== InteractionType.ApplicationCommand || interaction.data.name !== 'sa') {
return;
}
await api.interactions.reply(interaction.id, interaction.token, { content: 'Aleyküm Selam! Hoş Geldin!', flags: MessageFlags.Ephemeral });
});
// Listen for the ready event
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
// Start the WebSocket connection.
gateway.connect();
Son düzenleyen: Moderatör: