DenoDDeno
Powered by
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();
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
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Warning: Not implemented: ClientRequest.options.createConnection
MOtherMetroidMMOtherMetroid / help
2y ago
Error: Not implemented: http2.createSecureServer
domtomsDdomtoms / help
2y ago
libp2p crypto error - Not implemented
denyncrawfordDdenyncrawford / help
2y ago
Error: Not implemented: crypto.Sign
Mr VoidMMr Void / help
3y ago