TypeScript ModMail
In TypeScript: How do I have a bot send a message for a user to react, remove the reaction once reacted, and then D.M. the user? I'm trying to make a modmail bot in TypeScript but have no idea how.
21 Replies
Partially to save myself code dumping and partially to check where your progress is - do you know how to do this in another language? Say JavaScript or Python or whatever.
Honestly, no.
I haven't vetted it but maybe check out this
https://youtu.be/0ckwqupNEFk
Once you do know how to do in other languages and develop some programming skills you can then work on climbing the typescript learning curve. Jumping straight into typescript is quite steep.
MrJAwesome
YouTube
[NEW] - How to make MODMAIL SYSTEM for your discord bot || Discord....
This is how you can make a MODMAIL system for your discord.js v14 bot! If you need help, join the server below. The mongoose guide & tutorial is linked below as well.
Invite my bots!:
🡺 https://top.gg/bot/977594345756688384 (ESKI)
🡺 https://discord.com/api/oauth2/authorize?client_id=986762502455033916&permissions=8&scope=bot%20applications.co...
However, there is this one very small YouTuber who showed his TypeScript code for a ModMail bot, but I got 18 errors in 8 files!
And I have no idea how to fix the errors.
Show the errors I suppose
Thanks!
One moment, please.
@Favna
Uh as file. I'm on mobile. No problem. I'll check after breakfast and all that on laptop. Probably easier anyway.
?????
Sorry, I'm confused.
Can't view it on mobile lol
Right.
I'm confused by "Uh as file" and also am confused by what time you will be eating breakfast.
I'll come back to this in like 1,5 hours probably
All right.
@Favna You'll need the code to properly debug, though.
It can be found here: https://github.com/TFAGaming/DiscordTS-Template
Thanks.
@Favna wait no that's not it
https://github.com/TFAGaming/DiscordTS-ModMail-Bot/tree/main @Favna this is it
all of the errors are simply cases you need to cover @sourcelight. All the null and undefined checks means you need to check for them being null or undefined using if checks, this also means rather than using something like
user?.id
wrapping it in an if (user)
then just using user.id
inside that if.
The process.env.X
errors are also correct, env vars can be undefined. You need to check that too.
at the bottom where it says Cannot find name 'pmessage'. Did you mean 'message'?
is because there is a typo
and lastly the error Property 'parentId' does not exist on type 'TextBasedChannel'.
is because you need to use interaction?.channel.isThread()
in an if statement to validate that the interaction runs in a thread. https://old.discordjs.dev/#/docs/discord.js/main/class/TextChannel?scrollTo=isThreadHard to explain because you just said yourself what you're supposed to do
send -> react
collect reactions -> if filters returns true remove reaction -> send message
did they just copy/paste JavaScript code into a TypeScript file?
I had gotten thirty errors before; when I put the ? before the dots, almost half of the errors went away.
@Favna So, how exactly do I fix the errors?
"and lastly the error Property 'parentId' does not exist on type 'TextBasedChannel'. is because you need to use interaction?.channel.isThread()"
this only gave me a new error"The process.env.X errors are also correct, env vars can be undefined. You need to check that too."
i again want to clarify that i do not know how to fix the errors"at the bottom where it says Cannot find name 'pmessage'. Did you mean 'message'? is because there is a typo"
changing that worked
If statements to verify that things exist.
..... i dont know how
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- Read and understand docs
- Debug code
- Syntax
- NodeJS module system
If you aren't sure that your understanding of JavaScript is truly good enough to make a bot, you should really try to continue learning first. Here are good resources to learn both Javascript and NodeJS:
Codecademy: https://www.codecademy.com/learn/javascript
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
JavaScript Garden: https://bonsaiden.github.io/JavaScript-Garden/
JavaScript reference/docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
Nodeschool: https://nodeschool.io/
Pluralsight: https://www.codeschool.com/courses/real-time-web-with-node-js
Before you ask a question, you should ask these yourself:
1) Is this question related to JavaScript, or the library I am using? - If it is the library you are using, go to the proper server. You would get better answers there.
2) Have I tried to google and / or check StackOverflow? - Double check that you can't find anywhere that can lead you to a solution online.
3) Have I tried to look on MDN or the library documentation? - You should always check documentations to make sure you aren't missing how any details.
4) Does my question make enough sense so that people can understand it, and do they understand what I am trying to accomplish? - If no, revise your question. Give as much detail as possible. Include any error or code output that can help us help you.
5) Am I aware of what I am doing, and not just mindlessly copy and pasting? - If you are just copy and pasting code from a guide, you are not going to be able to solve anything. Make sure you understand the code you are writing.
@Favna all right so i have this typescript code that compiles perfectly... but it won't run! one of my typescript files seems to be issuing an error in its corresponding javascript file
@drainpixie
@Favna @drainpixie Never mind. Sorry.
I fixed it.