MonotterM
Denoβ€’3y agoβ€’
3 replies
Monotter

DiscordJS "Error: Not implemented: ClientRequest.options.createConnection"

import { GatewayDispatchEvents, GatewayIntentBits, InteractionType, MessageFlags, Client } from "npm:@discordjs/core@0.6.0"
import { REST } from "npm:@discordjs/rest@1.7.1"
import { WebSocketManager } from "npm:@discordjs/ws@0.8.3"

const rest = new  REST({ version: '10' }).setToken(Deno.env.get("DISCORD_TOKEN")!);

const gateway = new WebSocketManager({
    token: Deno.env.get("DISCORD_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 !== 'ping') {
        return;
    }

    await api.interactions.reply(interaction.id, interaction.token, { content: 'Pong!', flags: MessageFlags.Ephemeral });
});

// Listen for the ready event
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
// Start the WebSocket connection.
gateway.connect();
Ekran_Resmi_2023-06-12_15.19.14.png
Was this page helpful?