The Fabulous Geek
The Fabulous Geek
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by The Fabulous Geek on 10/13/2024 in #djs-questions
Is fetching all threads safe?
I am using private threads as a ticketing system. We have roughly 300 open threads. I currently fetch all the threads on the ready event so they are cached. I am doing this becuase when someone clicks the button to create a ticket, I am searching the titles of the existing tickets to see if they already have one open. I want to make sure that there is nothing I should be concerned about in doing this, especially in reguards to memory usage. (I have a memory leak somewhere, so I am investigating anything I am not fully sure about).
5 replies
DTDrizzle Team
Created by The Fabulous Geek on 10/9/2024 in #help
db client typing
Good morning. I am using the new connect method, and working on typing. I am new to TS so still working out how to make it work.
interface Client {
config: Config;
interactions: Collection<string, InteractionSpark | CommandSpark>;
gates: Collection<string, Gate>;
logger: Logger;
scheduledEvents: Collection<string, CronJob>;
db: any;
}

client.db = await drizzle('node-postgres', dbURL);
interface Client {
config: Config;
interactions: Collection<string, InteractionSpark | CommandSpark>;
gates: Collection<string, Gate>;
logger: Logger;
scheduledEvents: Collection<string, CronJob>;
db: any;
}

client.db = await drizzle('node-postgres', dbURL);
Clearly, I do not want any here; I just put it there for the moment as I figure out the correct type. I am just not sure what to do. Normally, I use the function returns for clues, but in this case, DetermineClient is not exported, and I doubt it is correct anyway.
1 replies
DIAdiscord.js - Imagine a boo! 👻
Created by The Fabulous Geek on 10/6/2024 in #djs-questions
Posting img with REST
I may be approaching this in an inefficient manner, so while I am asking specifically how to post an image using REST, I am open to other ideas. My use case involves occasionally posting as the bot, typically components like buttons that are permanent. I prefer not to use / commands for these, as I only need to update if I change the code. These utility functions are currently written as mini-apps, creating a client, logging in, and then posting on the ready event. But I don't think this is the best way to do so, as I am now logging in as a second client. So, I have been trying to use a simple REST post. I got it working; not really hard, I can do text, buttons, menus, etc., but I can't get files (i.e., images) to post. Here is the relevant code I am using.
await rest.post(
Routes.channelMessages(config.devMaps.channels['selfService'] ?? ''),
{
body: {
files: [
{
attachment: `${join(import.meta.dirname, '../assets/images/self-service.png')}`,
},
],
content: 'Test',
},
},
);
await rest.post(
Routes.channelMessages(config.devMaps.channels['selfService'] ?? ''),
{
body: {
files: [
{
attachment: `${join(import.meta.dirname, '../assets/images/self-service.png')}`,
},
],
content: 'Test',
},
},
);
5 replies
DIAdiscord.js - Imagine a boo! 👻
Created by The Fabulous Geek on 8/2/2024 in #djs-questions
Troubleshoot Memory Issues
I have one app that is regularly getting killed by the system for memory consumption. Any tips on how to begin troubleshooting what is causing this would be appreciated.
7 replies
DTDrizzle Team
Created by The Fabulous Geek on 6/15/2024 in #help
Automating migration
I am considering adding code to run a migration within my server startup. Basically, any time the server starts, the migration will run. The idea is that when the code is updated and the server restarts, the database stays up to date. My questions: a) is there a way programmatically to determine if there is a need to do a migration? b) is there are a harm in running the migration every time you start up your server (migrate(database, { migrationsFolder: './db/drizzle' });)
2 replies
DIAdiscord.js - Imagine a boo! 👻
Created by The Fabulous Geek on 4/13/2024 in #djs-questions
Comparing commands
Rather than setting all commands when I change one command, I am looking at designing a system that fetches the commands already registered and compare the commands in the files then only update any new, changed or deleted commands. I have found the ApplicationCommand.equals() method, but this can not take a SlashCommandBuilder as the argument. Is there a way to convert the SlashCommandBuilder into an appropriate object or is there some other way to achieve this comparison? (I then hope to extend this to a hotload scenario that utilizes a file system watcher)
16 replies
DIAdiscord.js - Imagine a boo! 👻
Created by The Fabulous Geek on 3/27/2024 in #djs-questions
Hot loading
Is it possible to hot load commands and event handlers?
6 replies