BradyDaLlama .*˖
BradyDaLlama .*˖
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 1/7/2024 in #djs-questions
use setEmoji to set no emoji/ remove an emoji from a button
I wasn't using null, I was using {name: undefined} which worked previously. I wasn't really asking for opinions on my style just if there was a change to that which I guess there was. I'll have to use another method
12 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 1/7/2024 in #djs-questions
use setEmoji to set no emoji/ remove an emoji from a button
it would be for things like setEmoji(condition ? emoji : null), it was how I dynamically created menus.
12 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 1/7/2024 in #djs-questions
use setEmoji to set no emoji/ remove an emoji from a button
like I said, it's mostly for dynamic stuff. Also, yes I can see that it says it didn't expect a null value. The latter three were suggestions I saw and wanted to confirm I tested. All I needed to know was if it did indeed change and if there was an alternative available
12 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
wow yeah I'm pretty sure that was it. I'll look into why it's caching it each time, and also make it reuse images if it's the same. thanks!
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
I tried not using the attachment but I think it still made it and just never sent it. let me go test it not creating it at all
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
it does use canvas to resize it
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
it returns an object of content, and a calculated update interval. I don't use the interval anymore because I just hardcoded it at 30 seconds, it's just an option for the future. so reply content is reduced to replyContent.content, which is like { embeds: [responseEmbed], components: [buttonRow], files: [attachment]}
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
oh yeah that was in the case that it wasn't defined, which obviously I just said it was. I was considering making this a public bot so I wanted to make it robust. but yeah the optional chaining is never regarded because it's always defined. I think I'll remove it there and check if the msg id exists before trying to fetch. no sense trying to check if it exists in the fetch statement (I did just go now and remove that optional chain)
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
but anyways you're saying that fetch will not just limit to the one message? dashData.dashboard.dashmsg in this case is defined and a valid message ID
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
I think the issue I was running into was it returning an empty collection if the channel was empty, so I just added that iirc
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
oldDashboard = await oldDashboardChannel.messages.fetch(dashData.dashboard?.dashmsg).catch(() => {
oldDashboard = undefined;
})
oldDashboard = await oldDashboardChannel.messages.fetch(dashData.dashboard?.dashmsg).catch(() => {
oldDashboard = undefined;
})
you mean on this part? (just to make sure I'm on the same page)
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
in the ready event it sets it back to not updating, so it starts again. it's just a private bot, but is there a better way to do that? I couldn't really figure out things like cronjob so that i could reference it and cancel it later oldDashboard is declared on line 10ish, ill add a comment
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
the last part is commented out, so that it doesn't try to update the dashboard. Basically if it's not updating, it starts an interval and then saves it to the database that it's updating. I've tested this and it does only start one interval and clear it when you have it stop updating. ik it's kinda an odd way to do this but it's what I was able to do with the database thing (to stop updating when the db updates to tell it to stop)
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
let dashboard;
if(oldDashboard){
dashboard = await oldDashboard.edit(replyContent);
} else {
dashboard = await oldDashboardChannel.send(replyContent);
}
let dashboard;
if(oldDashboard){
dashboard = await oldDashboard.edit(replyContent);
} else {
dashboard = await oldDashboardChannel.send(replyContent);
}
I defined it just above it, but I found that that specific line is what causes the memory to go up by a few mb each time it happens here's the full function:
const Music = require('../../discord/models/Music.js');
const musicDashboard = require('./dashboard.js');

async function updateDashboard(song) {
const dashData = await Music.findOne({guildID: song.member.guild.id, clientID: client.user.id });
let replyContent = await musicDashboard(song.member.voice.channel);

let durationInfo = replyContent.durationInfo;
replyContent = replyContent.content;

let oldDashboardChannel; let oldDashboard;
// --------------- old dashboard declared here --------------------------

if(dashData.dashboard.dashchannel){
oldDashboardChannel = await client.channels.fetch(dashData.dashboard.dashchannel);
}

if(oldDashboardChannel){
oldDashboard = await oldDashboardChannel.messages.fetch(dashData.dashboard?.dashmsg).catch(() => {
oldDashboard = undefined;
})
}

let dashboard;
if(oldDashboard){
dashboard = await oldDashboard.edit(replyContent);
} else {
dashboard = await oldDashboardChannel.send(replyContent);
}

dashData.dashboard.dashchannel = dashboard.channel.id;
dashData.dashboard.dashmsg = dashboard.id;

dashData.markModified('dashboard');
await dashData.save();

let updateDelay = 30

/*if(!dashData.dashboard.updating){
let timer = setInterval(async () => {
let updatedDashData = await Music.findOne({guildID: song.member.guild.id, clientID: client.user.id });
if(!updatedDashData.dashboard.updating){
clearInterval(timer);
return;
}
await updateDashboard(song);
}, updateDelay * 1000);

dashData.dashboard.updating = true;
dashData.markModified('dashboard');
await dashData.save();
}*/
}

module.exports = updateDashboard;
const Music = require('../../discord/models/Music.js');
const musicDashboard = require('./dashboard.js');

async function updateDashboard(song) {
const dashData = await Music.findOne({guildID: song.member.guild.id, clientID: client.user.id });
let replyContent = await musicDashboard(song.member.voice.channel);

let durationInfo = replyContent.durationInfo;
replyContent = replyContent.content;

let oldDashboardChannel; let oldDashboard;
// --------------- old dashboard declared here --------------------------

if(dashData.dashboard.dashchannel){
oldDashboardChannel = await client.channels.fetch(dashData.dashboard.dashchannel);
}

if(oldDashboardChannel){
oldDashboard = await oldDashboardChannel.messages.fetch(dashData.dashboard?.dashmsg).catch(() => {
oldDashboard = undefined;
})
}

let dashboard;
if(oldDashboard){
dashboard = await oldDashboard.edit(replyContent);
} else {
dashboard = await oldDashboardChannel.send(replyContent);
}

dashData.dashboard.dashchannel = dashboard.channel.id;
dashData.dashboard.dashmsg = dashboard.id;

dashData.markModified('dashboard');
await dashData.save();

let updateDelay = 30

/*if(!dashData.dashboard.updating){
let timer = setInterval(async () => {
let updatedDashData = await Music.findOne({guildID: song.member.guild.id, clientID: client.user.id });
if(!updatedDashData.dashboard.updating){
clearInterval(timer);
return;
}
await updateDashboard(song);
}, updateDelay * 1000);

dashData.dashboard.updating = true;
dashData.markModified('dashboard');
await dashData.save();
}*/
}

module.exports = updateDashboard;
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
yes, and as for the keys I couldn't find a list of options (the new website is not working great for me) but I saw someone had a similar issue with cache and they fixed it and had these keys. I adjusted the guildMember one but yeah I really dont need stuff cached. its not like it deals with invites or stickers or anything tho, so I can probably remove them
18 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 11/21/2023 in #djs-questions
Cache on edit message (?)
client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
],
partials: [Partials.Channel],
makeCache: Options.cacheWithLimits({
...Options.DefaultMakeCacheSettings,
GuildMessageManager: 0,
GuildInviteManager: 0,
GuildEmojiManager: 0,
GuildStickerManager: 0,
GuildMemberManager: {
maxSize: 10,
keepOverLimit: member => member.id === client.user.id
}
}),
});
client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
],
partials: [Partials.Channel],
makeCache: Options.cacheWithLimits({
...Options.DefaultMakeCacheSettings,
GuildMessageManager: 0,
GuildInviteManager: 0,
GuildEmojiManager: 0,
GuildStickerManager: 0,
GuildMemberManager: {
maxSize: 10,
keepOverLimit: member => member.id === client.user.id
}
}),
});
here's my intents and makeCache stuff also
18 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
i just had a similar ish issue and it seems sweepers/ cache settings helped
19 replies
DIAdiscord.js - Imagine an app
Created by Sayrix on 9/14/2023 in #djs-questions
Cache Sweeper
the top command shows super low memory usage, but the free -g/-m shows a higher amount is being used, closer to what my VPS monitoring reports.
52 replies
DIAdiscord.js - Imagine an app
Created by Sayrix on 9/14/2023 in #djs-questions
Cache Sweeper
No description
52 replies
DIAdiscord.js - Imagine an app
Created by BradyDaLlama .*˖ on 10/21/2023 in #djs-questions
Missing Access when deleting a VC but it does have the Manage Channel permissions?
yup that does it! I think they should update the manage channel description, it doesn't mention needing the connect permission ^^'
5 replies