CYPH ERZZ
CYPH ERZZ
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 6/21/2024 in #djs-questions
Sending attachment with message edit
Thanks a lot ! ❤️
17 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 6/21/2024 in #djs-questions
Sending attachment with message edit
MAN.
17 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 6/21/2024 in #djs-questions
Sending attachment with message edit
trying ahah
17 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 6/21/2024 in #djs-questions
Sending attachment with message edit
i'm updating. You're so damn right ! i wasn't on the same pc neither and checking the production server it's already in 21.6.2
17 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 6/21/2024 in #djs-questions
Sending attachment with message edit
17 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 6/21/2024 in #djs-questions
Sending attachment with message edit
I guess it's coming from the attachment being resent, never had this problem months ago, and the attachment is sent correctly the first time...
17 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 6/21/2024 in #djs-questions
Sending attachment with message edit
Here's the stack trace :
arg1: TypeError: terminated
at Fetch.onAborted (C:\Dev\CryptoGamersMinigames
ode_modules\undici\lib\web\fetch\index.js:2034:49)
at Fetch.emit (node:events:527:28)
at Fetch.terminate (C:\Dev\CryptoGamersMinigames
ode_modules\undici\lib\web\fetch\index.js:93:10)
at C:\Dev\CryptoGamersMinigames
ode_modules\undici\lib\web\fetch\index.js:506:30
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {stack: 'TypeError: terminated
at Fetch.onAborted …ions (node:internal/process/task_queues:95:5)', message: 'terminated', cause: TypeError [ERR_INVALID_ARG_TYPE]: The "stream"…t must be an instance of Stream. Received an …}
code: 'ERR_INVALID_ARG_TYPE'
message: 'The "stream" argument must be an instance of Stream. Received an instance of ReadableStream'
stack: 'TypeError [ERR_INVALID_ARG_TYPE]: The "stream" argument must be an instance of Stream. Received an instance of ReadableStream
at new NodeError (node:internal/errors:377:5)
at eos (node:internal/streams/end-of-stream:62:11)
at fetchFinale (C:\\Dev\\CryptoGamersMinigames\
ode_modules\\undici\\lib\\web\\fetch\\index.js:1093:5)
at mainFetch (C:\\Dev\\CryptoGamersMinigames\
ode_modules\\undici\\lib\\web\\fetch\\index.js:760:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)'
arg1: TypeError: terminated
at Fetch.onAborted (C:\Dev\CryptoGamersMinigames
ode_modules\undici\lib\web\fetch\index.js:2034:49)
at Fetch.emit (node:events:527:28)
at Fetch.terminate (C:\Dev\CryptoGamersMinigames
ode_modules\undici\lib\web\fetch\index.js:93:10)
at C:\Dev\CryptoGamersMinigames
ode_modules\undici\lib\web\fetch\index.js:506:30
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {stack: 'TypeError: terminated
at Fetch.onAborted …ions (node:internal/process/task_queues:95:5)', message: 'terminated', cause: TypeError [ERR_INVALID_ARG_TYPE]: The "stream"…t must be an instance of Stream. Received an …}
code: 'ERR_INVALID_ARG_TYPE'
message: 'The "stream" argument must be an instance of Stream. Received an instance of ReadableStream'
stack: 'TypeError [ERR_INVALID_ARG_TYPE]: The "stream" argument must be an instance of Stream. Received an instance of ReadableStream
at new NodeError (node:internal/errors:377:5)
at eos (node:internal/streams/end-of-stream:62:11)
at fetchFinale (C:\\Dev\\CryptoGamersMinigames\
ode_modules\\undici\\lib\\web\\fetch\\index.js:1093:5)
at mainFetch (C:\\Dev\\CryptoGamersMinigames\
ode_modules\\undici\\lib\\web\\fetch\\index.js:760:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)'
17 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
I made a circular reference yesterday night, perhaps that's it
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
Thanks man, i'll monitor this
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
That's terrifying lol, hope it's not or it's because i fucked up at one point and made too many requests but it's temporary
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
Nah i'm hosting it myself, own server, own internet connection.
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
Bot's back online but i changed nothing so i guess it's temporary... until next reboot
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
If you come here thank you for taking the time ❤️ :blobreachReverse:
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
I think i fucked up something because even when it starts, sometime my commands are not registered, even if it shows a successfull registration in the logs.
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
Note that this module is imported in a command sub-module too, but not calling anything, it's just used to get the native this.client to retrieve a user object from a userID
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
registerEventHandlers() {
this.client.once(Events.ClientReady, async () => {
console.log('Discord bot is online!');
const commands = this.commands.map(command => command.data.toJSON());
try {
for (const guildId of discordConfig.guildIds) {
await this.client.application.commands.set(commands, guildId);
console.log(`Successfully registered slash commands for guild ID: ${guildId}`);
}
} catch (error) {
console.error('Error registering commands:', error);
}
});

this.client.on(Events.InteractionCreate, async interaction => {
if (interaction.guildId && !discordConfig.guildIds.includes(interaction.guildId)) {
return;
}

if (interaction.isCommand()) {
const command = this.commands.get(interaction.commandName);
if (!command) return;

try {
await command.execute(interaction);
} catch (error) {
console.error('Command execution error:', error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});

this.client.on('rateLimit', (info) => {
console.log(`Rate limit hit ${info.timeDifference ? info.timeDifference : info.timeout ? info.timeout : 'Unknown timeout '}`);
});

this.client.on(Events.Error, (error) => {
console.error('Error from the Discord API:', error);
});

this.client.on('debug', console.debug);

}

login() {
this.client.login(discordConfig.botToken);
}
}

const discordBot = new DiscordClient();
export default discordBot
registerEventHandlers() {
this.client.once(Events.ClientReady, async () => {
console.log('Discord bot is online!');
const commands = this.commands.map(command => command.data.toJSON());
try {
for (const guildId of discordConfig.guildIds) {
await this.client.application.commands.set(commands, guildId);
console.log(`Successfully registered slash commands for guild ID: ${guildId}`);
}
} catch (error) {
console.error('Error registering commands:', error);
}
});

this.client.on(Events.InteractionCreate, async interaction => {
if (interaction.guildId && !discordConfig.guildIds.includes(interaction.guildId)) {
return;
}

if (interaction.isCommand()) {
const command = this.commands.get(interaction.commandName);
if (!command) return;

try {
await command.execute(interaction);
} catch (error) {
console.error('Command execution error:', error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});

this.client.on('rateLimit', (info) => {
console.log(`Rate limit hit ${info.timeDifference ? info.timeDifference : info.timeout ? info.timeout : 'Unknown timeout '}`);
});

this.client.on(Events.Error, (error) => {
console.error('Error from the Discord API:', error);
});

this.client.on('debug', console.debug);

}

login() {
this.client.login(discordConfig.botToken);
}
}

const discordBot = new DiscordClient();
export default discordBot
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
And my DiscordClient class :
import { Client, GatewayIntentBits, Partials, Collection, Events } from 'discord.js';
import fs from 'fs';
import appRootPath from 'app-root-path';
import { discord as discordConfig } from '../../config.mjs';

class DiscordClient {
constructor() {
this.client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Channel,
Partials.Message
]
});
this.commands = new Collection();
}

async initializeCommands() {
const modulesPath = appRootPath.path + '/modules/discord/commands/';
const commandFiles = fs.readdirSync(modulesPath).filter(file => file.endsWith('.command.mjs'));

for (const file of commandFiles) {
const module = await import(`./commands/${file}`)
const command = module.default;
this.commands.set(command.data.name, command);
}
}
import { Client, GatewayIntentBits, Partials, Collection, Events } from 'discord.js';
import fs from 'fs';
import appRootPath from 'app-root-path';
import { discord as discordConfig } from '../../config.mjs';

class DiscordClient {
constructor() {
this.client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Channel,
Partials.Message
]
});
this.commands = new Collection();
}

async initializeCommands() {
const modulesPath = appRootPath.path + '/modules/discord/commands/';
const commandFiles = fs.readdirSync(modulesPath).filter(file => file.endsWith('.command.mjs'));

for (const file of commandFiles) {
const module = await import(`./commands/${file}`)
const command = module.default;
this.commands.set(command.data.name, command);
}
}
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
Here's my entrypoint :
import DiscordClient from "./modules/discord/DiscordClient.mjs";

DiscordClient.initializeCommands();
DiscordClient.registerEventHandlers();
DiscordClient.login();
import DiscordClient from "./modules/discord/DiscordClient.mjs";

DiscordClient.initializeCommands();
DiscordClient.registerEventHandlers();
DiscordClient.login();
16 replies
DIAdiscord.js - Imagine an app
Created by CYPH ERZZ on 4/26/2024 in #djs-questions
Opening handshake timeout
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 994
WebSocketManager.js:125
[WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
WebSocketManager.js:125
[WS => Shard 0] Waiting for event hello for 60000ms
WebSocketManager.js:125
[WS => Shard 0] The gateway closed with an unexpected code 1006, attempting to resume.
WebSocketManager.js:125
[WS => Shard 0] Destroying shard
Reason: none
Code: 1006
Recover: Resume
WebSocketManager.js:125
[WS => Shard 0] Connection status during destroy
Needs closing: false
Ready state: 3
WebSocketManager.js:125
[WS => Shard 0] Tried to destroy a shard that was idle
WebSocketManager.js:125
[WS => Manager] Manager was destroyed:
at WebSocketManager.destroy (Z:\DiscordDeFi\node_modules\discord.js\src\client\websocket\WebSocketManager.js:327:30)
at Client.destroy (Z:\DiscordDeFi\node_modules\discord.js\src\client\Client.js:253:19)
at Client.login (Z:\DiscordDeFi\node_modules\discord.js\src\client\Client.js:231:18)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
WebSocketManager.js:125
[WS => Shard 0] Tried to destroy a shard that was idle
Uncaught Error Error: Opening handshake has timed out
at <anonymous> (z:\DiscordDeFi\node_modules\@discordjs\ws\node_modules\ws\lib\websocket.js:872:7)
at emit (events:514:28)
at emitRequestTimeout (_http_client:840:9)
at onceWrapper (events:628:28)
at emit (events:514:28)
at Socket._onTimeout (net:589:8)
at listOnTimeout (internal/timers:573:17)
at processTimers (internal/timers:514:7)
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 994
WebSocketManager.js:125
[WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
WebSocketManager.js:125
[WS => Shard 0] Waiting for event hello for 60000ms
WebSocketManager.js:125
[WS => Shard 0] The gateway closed with an unexpected code 1006, attempting to resume.
WebSocketManager.js:125
[WS => Shard 0] Destroying shard
Reason: none
Code: 1006
Recover: Resume
WebSocketManager.js:125
[WS => Shard 0] Connection status during destroy
Needs closing: false
Ready state: 3
WebSocketManager.js:125
[WS => Shard 0] Tried to destroy a shard that was idle
WebSocketManager.js:125
[WS => Manager] Manager was destroyed:
at WebSocketManager.destroy (Z:\DiscordDeFi\node_modules\discord.js\src\client\websocket\WebSocketManager.js:327:30)
at Client.destroy (Z:\DiscordDeFi\node_modules\discord.js\src\client\Client.js:253:19)
at Client.login (Z:\DiscordDeFi\node_modules\discord.js\src\client\Client.js:231:18)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
WebSocketManager.js:125
[WS => Shard 0] Tried to destroy a shard that was idle
Uncaught Error Error: Opening handshake has timed out
at <anonymous> (z:\DiscordDeFi\node_modules\@discordjs\ws\node_modules\ws\lib\websocket.js:872:7)
at emit (events:514:28)
at emitRequestTimeout (_http_client:840:9)
at onceWrapper (events:628:28)
at emit (events:514:28)
at Socket._onTimeout (net:589:8)
at listOnTimeout (internal/timers:573:17)
at processTimers (internal/timers:514:7)
16 replies