Bot crashes after running a servercreate command
Hey, I have some problems with one of my commands,. So it should simply create a discord server from a server template , but it's crashing with an error code, i'll provide you. It would be really nice if someone can help.
Code:
Error:
Node.js: v18.15.0
Discord.js: See Tag
34 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.Not what I need
It should create a Server from a Template
not a Template of a Server
then you'd need to fetch the template
<Guild>.fetchTemplates()
fetches all templates for the given guild, the resulting collection mapped by code
<Client>.fetchGuildTemplate()
can be used to fetch a single template by code/url Guild#fetchTemplates()
Fetches a collection of templates from this guild. Resolves with a collection mapping templates by their Client#fetchGuildTemplate()
Obtains a template from Discord.
Wait now I'm confused.
<Guild>.templates
doesn't exist
you'd need to fetch the template you want to use, then call <GuildTemplate>.createGuild()
Ok, I'll try.
so I have to replace this with
GuildTemplate.createGuild()
?not directly
you still need to fetch the template first
I'm to dumb for that... Still don't get it
which part of this are you having trouble with?
I don't really know where to implent that 🥶
anywhere before you want to create the guild from the template
so like here?
sure, but you should probably await it and store the result, since you need to get the template from the resulting collection
fetching the templates doesn't make
<Guild>.template
or <Guild>.guildTemplate
existwhat?
I don't know how to explain it more simply
<Guild>.template
doesn't exist
<Guild>.guildTemplate
doesn't exist
interaction.guildTempalte.templates
doesn't exist
they will never exist
fetchTemplate
resolves in a collection of templatesOk
you have yet to define
guildTemplate
but you're getting closer
again, fetchTemplates
resolves in the collection of fetched templateshmm ok
I don't know how i should define it ...
I know...
if you know, would you like to store it in a variable? 🙂
you should probably await it and store the result, since you need to get the template from the resulting collection
you should probably await it
why are you calling it a second time?
just call it once, await it, and store that
then probably fix your syntax error when calling
createGuild
?
alright I'm gonna suggest you brush up on the basics of javascript before continuing
#resources
I know the error was becuase i havent declared the const variable.
yes but
1. defining and declaring values for variables, constant or not, is incredibly basic in js and programming in general
2. looking at your code, this isn't something you should be having trouble with unless you don't understand anything you've written so far (potentially because it was copypasted)
which is why I would suggest you brush up on the basics before continuing
so that you can understand what you've written and should write
Ok.
I forgot about that... const cannot be edited, let can
ok, so i removed the constant and replaced it with "let".
that wasn't the issue, more so this is sidestepping the issue
I'm still going to suggest you brush up on the basics before continuing
doing a udemy course, yep