hi im trying to make a ticket bot
i took inspiration from firebot at getfire.bot
i see they extend the guild and passing down the guilddata
when i try this on my own it does not work
i need help
https://github.com/FireDiscordBot/bot/blob/eea931c5ef76afbc0a56a6d66b90c81c48498917/lib/extensions/guild.ts
^^ is the said code from firebot
#how does one extend a guild with typescript
53 messages · Page 1 of 1 (latest)
• 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.
Discord version: [email protected]
node: v16.16.0
error: Cannot extend a class '"C:/Users/Louie/OneDrive/Desktop/Ticketly/node_modules/discord.js/typings/index".Guild'. Class constructor is marked as private.
notes:
i dont tolerate people who say im not experienced with typescript im here to get answers not to get insults
Structures is not in v14
Well put simply, you can't. Fire is using an old and terrible system called structures to do that. Geek is currently "maintaining" (not really) a fork of v13 to do that. I'm quite literally in the process of making PR to completely remove that because its not sustainable.
so ur saying they forked and made theyr own version of djs?
That seems to be the case
No, the problem has to be fixed in their fork
Unless you can ts-ignore it, not sure if that’s allowed
how do u ts-ignore a private class
Js doesn’t care, only ts does
Structures was imported from their fork
okay so
by just doing //@ts-ignore it seems to work
that won't work, you're extending the class but none of djs will use that extended class
so it doesn't actually do you any good
I can’t guarantee it'll work bc it’s not our official build
Structures was removed in v13
Kinect they're trying to do this on bare 14.0.3
Wouldn’t importing Structures be an error then?
that's fire's code
Oh
When djs constructs a new Guild() its constructing just that, it doesn't know that you've extend and doesn't care, so the class you actually see everywhere where you can get a guild from djs is still the original
(this is why structures were dropped, maintenance on things like that is extremely hard)
so i would extend theyr interaction to and make the guild in there
and how does djs know about your extended interaction class then?
and then i can use the functions like in interactionCreate to put like below
client.on('interactionCreate', (interaction) => {interactionHandler(interaction)})
function interactionHandler (interaction: myInteraction) {
}
would this work?
the much easier (and easier to maintain) way to do this is a getGuild() function or something similar. Anywhere where you would've wanted to do <guild>.tickets you can instead to getTickets(guild)
oh..yeah
that
i tried this but my inner self simply hates it for some reason
therefor i want to try extending the guild
BaseInteraction has subclasses
bcs for some reason it looks cleaner
so i would need to extend the Subclasses too?
and those sub classes extends BaseInteraction, not ur extended class
then you can do guild = makeGuild(djsguild) everywhere you need to access your custom properties, to make a custom guild class (wouldn't need to extend)
That’s
of work just to get that working, also considering the potential maintenance
okay so im now not going to do this
but i wonder would they add something that would enable us (the users / devs) in doing this type of stuff
bcs it is a sick idea
It’s actually a bad idea, esp bc you don’t control nor create these structures
The idea is fucked mate
we had it in the past. It was removed because it became infeasible to maintain and support