Batimius
Explore posts from serversDIAdiscord.js - Imagine an app
•Created by Batimius on 9/19/2023 in #djs-questions
Slash Command Guild Permission Overwrite
Hello there. I'll make this quick. In sort, I am making a command that applies slash command permission overwrites to servers based on a file it reads. Now, I did manage to write everything that sets up the properties object to be applied to the
guild.commands.permissions.set()
function, but for some reason, it just does not accept it. Here is an overview of the important chunks of code:
The error I get is the following:
I am unsure whether I am doing something wrong or this is a TS issue. If anyone knows how I could solve this, then it would be very helpful. Thank you for your time and help, I truly appreciate it.5 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 8/5/2023 in #djs-voice
Is it possible to fetch a subscribed AudioPlayer from a VoiceConnection?
Hello there. So I'm making a song bot that plays local files. The current play command simply joins a voice channel (or moves to the current channel) and plays the song that was requested (from a selection of MP3 files on my local system). I am planning on making a queue system so you can queue whatever song you want. My problem comes with fetching the AudioPlayer. The
discord.js/voice
guide advised against keeping track of connections as you can accidentally create memory leaks. That said, I decided that I won't be keeping track of anything (apart from what is in the queue). From my understanding, an AudioPlayer is something like Media Player on Windows, an instance which a bunch of AudioResources can be passed in and it plays the latest one. If that is correct, then that means that it would be odd and wasteful to create an AudioPlayer for every single AudioResource, it would be the equivalent of opening a new Media Player window for every song. That being said, I plan on utilizing a single AudioPlayer per server. Now, since it was advised against to keep track of connections and such, is there a way for me to fetch that AudioPlayer using a VoiceConnection, or would I need to manually keep track of it? Also, would it maybe be better to create a new AudioPlayer for each song and just find a way to unsubscribe from the previous one? What do you recommend I do?5 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 8/1/2023 in #djs-questions
TypeScript .getSubcommand() issue
5 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 1/5/2023 in #djs-questions
What is the difference between guildMemberAdd and guildMemberAvailable?
Just like the title says, what is the difference between
guildMemberAdd
and guildMemberAvailable
? I know guildMemberAdd
is when a user is added to the guild, but I have no idea what guildMemberAvailable
is. I assume that it is when the user has agreed to the rules and maybe finished the cooldown (so when Discord holding them back is over), but I can't find it documented anywhere.
If it is like I assumed it is, then can I use it reliably as a replacement for guildMemberAdd
? What happens if you use it in a server that has no requirements? Would it be better to use it instead of guildMemberAdd
? If someone could answer these questions, that would be amazing. Thank you for your time and help, it is truly appreciated.4 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 1/3/2023 in #djs-questions
How would I convert a URL into an attachment?
Hello there. So, I'll keep this short. I have a
messageDelete
event handler, and I have a problem. When a user sends a sticker and deletes it, obviously, I cannot reuse that sticker in my log message. That said, I thought that I could probably retrieve the sticker URL and use it as a file attachment instead. The main problem is that I have no idea how to do that. If someone could enlighten me on how I could achieve this, that would be amazing. Thank you for your help, it is truly appreciated.6 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 1/3/2023 in #djs-questions
Attaching already existing attachments to message
Hello there. So, as the title suggests, I want to attach already-existing message attachments on a new message. I am making a
messageDelete
event handler and I want to attach any files that have been deleted to the log message. Here is the code that I have so far:
Now, when I delete a message with an image attached, I get the following error:
I really don't understand why this is a problem. I did think that it might be because I am not using an AttachmentBuilder
, but the wiki clearly states that Array <Attachment>
is also a viable option for the files
argument. If someone could help me, that would be awesome. Thank you for your time and help, it is truly appreciated.10 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 1/2/2023 in #djs-questions
Best way to find and delete user messages
Hello there. So, as the title implies, I want to know what the best way to fetch ALL user messages and then delete them. My idea on how to go about this is to utilize the
MessageManager.fetch({})
command to get all messages, filter them using messages.filter(m => m.author.id === USER_ID)
, and then using the TextChannel.bulkDelete()
function and passing all the messages as an array.
Before putting this into practice though, I do have some questions. First and foremost is if this method is the most efficient. I don't want to waste resources and API calls when I don't need to, so is there a better way of going about this, or is this ultimately the best way? Also, will this method guarantee that I'll fetch ALL user messages, regardless of time passed, or will the filter only get the most recent ones? The command is responsible for deleting ALL user messages (well, I'll modify it to delete a specific number of messages in the future), so getting every message the user has sent (even if the first message was 2 years ago) is essential.
That is all. If someone could help me with my issue, that would be amazing. Thank you for your time and help, it is truly appreciated.16 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 11/12/2022 in #djs-questions
Problem with intents
Hello there. So, I just downloaded the new version of Discord.js, and I am surprised at how quickly I came across some errors. The first problem I came across was
Intents.FLAGS
being replaced. No problem there though, I quickly fixed that by replacing Intents.FLAGS
with GatewayIntentBits
. What is my problem? After doing that, it ended up giving me a RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
error. Here are my intents:
If someone could help me, that would be awesome. Thank you for your time and help, it is truly appreciated.
Full error stack:
Discord.js Version: 14.6.0
Node Version: 8.1.46 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 6/23/2022 in #djs-questions
How would I listen to DM messages?
Hello there. The title explains the question. How would I listen to any DM messages.
client.on("messageCreate")
does not seem to listen to any DM messages at all, so how would I be able to listen to DM messages in order to run commands there too? Thanks.4 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 6/21/2022 in #djs-questions
'TypeError this.options.components?.map is not a function' when using spliceComponents() function
Hello there. I am fairly certain this is a bug rather than a question. I tried using the
spliceComponents()
function and got this error in return:
Here is the code that generated this error:
Not really sure if there's a solution except from waiting for a bug fix. If there is, please let me know. Thank you.22 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 6/21/2022 in #djs-questions
Help with Slash Commands
2 replies
DIAdiscord.js - Imagine an app
•Created by Batimius on 6/20/2022 in #djs-questions
'DiscordAPIError Invalid Form Body' when creating channel
Hello there. Basically, I am trying to create a text channel using the following code:
But whenever the code runs, I get the following error:
Not really sure why. If someone could help me, that would be awesome. Thank you for your time and help, I greatly appreciate it.
3 replies