Monotter
Monotter14mo ago

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();
3 Replies
Monotter
Monotter14mo ago
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
mmastrac
mmastrac14mo ago
It looks like this is a hole in our node.js emulation. Would you mind filing an issue for this? https://github.com/denoland/deno/blob/e1be2bb80d2c9e7f56221d53349cdcea6d76ddde/ext/node/polyfills/http.ts#L503
GitHub
deno/http.ts at e1be2bb80d2c9e7f56221d53349cdcea6d76ddde · denoland...
A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.
Monotter
Monotter14mo ago
GitHub
Error: Not implemented: ClientRequest.options.createConnection · Is...
import tls from 'node:tls' import https from 'node:https' import net from 'node:net' function tlsConnect(options) { options.path = undefined; if (!options.servername &&a...