sean
sean
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by sean on 12/2/2023 in #djs-questions
Sending Images with djs/rest
My issue is that the promise dont get resolved of the rest#post() neither the followup works in Discord and I dont see what the issue is. My rest function:
static async sendFollowUp(interaction, data, files) {
const rest = GatewayManager.getRest();

return rest
.post(Routes.webhook(interaction.application_id ?? "927598798019108894", interaction.token), {
body: data,
files: files ?? [],
});
}
static async sendFollowUp(interaction, data, files) {
const rest = GatewayManager.getRest();

return rest
.post(Routes.webhook(interaction.application_id ?? "927598798019108894", interaction.token), {
body: data,
files: files ?? [],
});
}
getRest is a valid rest instance My code that dont work
return GatewayManager.sendFollowUp(interaction, {
embeds: [
{
image: {
url: "attachment://image.png"
},
color: 0x146533,
}
],
}, [{
data: image,
name: 'image.png'
}]);
return GatewayManager.sendFollowUp(interaction, {
embeds: [
{
image: {
url: "attachment://image.png"
},
color: 0x146533,
}
],
}, [{
data: image,
name: 'image.png'
}]);
Image is a valid buffer generated with @napi-rs/canvas Any ideas?
46 replies
DIAdiscord.js - Imagine an app
Created by sean on 11/30/2023 in #djs-questions
issue with /core
Its my first time trying core since I want to have a lightbuild gateway helper and I think I do something wrong? This is my current test script
const gateway = new WebSocketManager({
token: '',
intents: GatewayIntentBits.Guilds,
rest: GatewayManager.getRest(),
});

const client = new Client({rest: GatewayManager.getRest(), gateway});

client.once(GatewayDispatchEvents.Ready, this.onReady);
client.on(GatewayDispatchEvents.GuildCreate, this.onGuildCreate);
client.once(GatewayDispatchEvents.GuildDelete, this.onGuildDelete);

await gateway.connect();

const shards = await gateway.getShardIds();
for (const shardId of shards) {
await gateway.send(shardId, {
"op": 3,
"d": {
"activities": [{
"name": "We love casting spells | Memer.gg",
"type": 4
}],
"status": "online",
}
});
}
const gateway = new WebSocketManager({
token: '',
intents: GatewayIntentBits.Guilds,
rest: GatewayManager.getRest(),
});

const client = new Client({rest: GatewayManager.getRest(), gateway});

client.once(GatewayDispatchEvents.Ready, this.onReady);
client.on(GatewayDispatchEvents.GuildCreate, this.onGuildCreate);
client.once(GatewayDispatchEvents.GuildDelete, this.onGuildDelete);

await gateway.connect();

const shards = await gateway.getShardIds();
for (const shardId of shards) {
await gateway.send(shardId, {
"op": 3,
"d": {
"activities": [{
"name": "We love casting spells | Memer.gg",
"type": 4
}],
"status": "online",
}
});
}
The issue I see is that it dont set the status but I thought thats the way to do it? xD
13 replies
DIAdiscord.js - Imagine an app
Created by sean on 9/12/2023 in #djs-questions
Bot is stuck in request
async function editMessage(data, channelId, messageId) {
if (typeof messageId !== 'string' && typeof messageId !== 'number') throw new Error('Message ID must be a string or number! Not ' + messageId);
if (typeof channelId !== 'string' && typeof channelId !== 'number') throw new Error('Channel ID must be a string or number! Not ' + channelId);

return new Promise(async (resolve, reject) => {
console.log('Sending Request');

rest
.patch(`/channels/${channelId}/messages/${messageId}`, {
body: data,
})
.then((msg) => {
console.log('Request Done');
resolve(msg);
})
.catch(error => {
console.log('Request Errored');
reject(error);
});
});
}
async function editMessage(data, channelId, messageId) {
if (typeof messageId !== 'string' && typeof messageId !== 'number') throw new Error('Message ID must be a string or number! Not ' + messageId);
if (typeof channelId !== 'string' && typeof channelId !== 'number') throw new Error('Channel ID must be a string or number! Not ' + channelId);

return new Promise(async (resolve, reject) => {
console.log('Sending Request');

rest
.patch(`/channels/${channelId}/messages/${messageId}`, {
body: data,
})
.then((msg) => {
console.log('Request Done');
resolve(msg);
})
.catch(error => {
console.log('Request Errored');
reject(error);
});
});
}
it never logs the then() part or catch()
12 replies
DIAdiscord.js - Imagine an app
Created by sean on 7/17/2023 in #djs-questions
Does djs/rest just wait until the cf ban is over?
What I exactly mean with this is that I checked the source of djs/rest and notice that I only find a wait until its unblocked again? Is this true and if yes is there a way that rest dont wait and just stop all requests until its unblocked again?
9 replies
DIAdiscord.js - Imagine an app
Created by sean on 3/31/2023 in #djs-questions
High usage leak after updating to v13@latest (13.14.0)
Does DJs have any known usage leak? Because after updating djs v13 to latest after 5h the usage go over 26gb ram and 60% CPU usage the code didnt changed at all only the djs version got updated? And if not any ideas what could create such high usage in seconds?
34 replies
DIAdiscord.js - Imagine an app
Created by sean on 3/12/2023 in #djs-questions
TypeError: this.dispatch is not a function
Hi Guys I use @discordjs/rest but when I try to do a request I always get:
TypeError: this.dispatch is not a function
at String.request (/root/testApp/node_modules/undici/lib/api/api-request.js:193:10)
at /root/testApp/node_modules/undici/lib/api/api-request.js:186:15
at new Promise (<anonymous>)
at String.request (/root/testApp/node_modules/undici/lib/api/api-request.js:185:12)
at /root/testApp/node_modules/undici/index.js:83:15
at SequentialHandler.runRequest (/root/testApp/node_modules/@discordjs/rest/dist/index.js:531:46)
at SequentialHandler.queueRequest (/root/testApp/node_modules/@discordjs/rest/dist/index.js:464:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: this.dispatch is not a function
at String.request (/root/testApp/node_modules/undici/lib/api/api-request.js:193:10)
at /root/testApp/node_modules/undici/lib/api/api-request.js:186:15
at new Promise (<anonymous>)
at String.request (/root/testApp/node_modules/undici/lib/api/api-request.js:185:12)
at /root/testApp/node_modules/undici/index.js:83:15
at SequentialHandler.runRequest (/root/testApp/node_modules/@discordjs/rest/dist/index.js:531:46)
at SequentialHandler.queueRequest (/root/testApp/node_modules/@discordjs/rest/dist/index.js:464:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
My Code:
rest
.get(Routes.user(this.applicationId))
.then(data => {
this.emit('debug', "[DEBUG] Got the client data from the API");
this.user = new User(data);
}).catch(e => {
this.emit('debug', "[DEBUG] Got a error by fetching the client data from the API!" + e);
console.log(e)
});
rest
.get(Routes.user(this.applicationId))
.then(data => {
this.emit('debug', "[DEBUG] Got the client data from the API");
this.user = new User(data);
}).catch(e => {
this.emit('debug', "[DEBUG] Got a error by fetching the client data from the API!" + e);
console.log(e)
});
NPM Version: @discordjs/[email protected] NodeJS: v18.12.0
50 replies
DIAdiscord.js - Imagine an app
Created by sean on 9/3/2022 in #djs-questions
Custom Bots
Hey guys my Question is I currently build a custom bot module for my main bot I have all done I only think about what I should do when the token of a custom bot gets invalid. Means I want to directly stop the process when this gonna happen to prevent a not needed memory leak
26 replies
DIAdiscord.js - Imagine an app
Created by sean on 8/6/2022 in #djs-questions
Get null from a reaction?
9 replies