#how does one extend a guild with typescript

53 messages · Page 1 of 1 (latest)

high narwhal
#

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

GitHub

A Discord bot for all your needs. With memes, utilities, moderation & more, Fire is the only bot you'll need. - bot/guild.ts at eea931c5ef76afbc0a56a6d66b90c81c48498917 · FireDiscordBot/bot

mint muralBOT
#

• 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.

high narwhal
#

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

broken skiff
#

Structures is not in v14

patent urchin
#

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.

high narwhal
#

so ur saying they forked and made theyr own version of djs?

broken skiff
#

That seems to be the case

high narwhal
#

well thats a bit sad

#

is there a probable way of doing it on mine?

broken skiff
#

No, the problem has to be fixed in their fork

#

Unless you can ts-ignore it, not sure if that’s allowed

high narwhal
#

how do u ts-ignore a private class

broken skiff
#

Js doesn’t care, only ts does

patent urchin
#

Kinect they're trying to do structures in v14

#

not off geeks fork

broken skiff
#

Structures was imported from their fork

high narwhal
#

okay so
by just doing //@ts-ignore it seems to work

patent urchin
#

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

high narwhal
#

sorry what?

#

wait

broken skiff
#

I can’t guarantee it'll work bc it’s not our official build

#

Structures was removed in v13

patent urchin
#

Kinect they're trying to do this on bare 14.0.3

broken skiff
#

Wouldn’t importing Structures be an error then?

patent urchin
#

that's fire's code

broken skiff
#

Oh

patent urchin
# high narwhal sorry what?

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)

high narwhal
#

so i would extend theyr interaction to and make the guild in there

patent urchin
#

and how does djs know about your extended interaction class then?

high narwhal
#

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?

patent urchin
#

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

high narwhal
#

therefor i want to try extending the guild

broken skiff
#

BaseInteraction has subclasses

high narwhal
#

bcs for some reason it looks cleaner

high narwhal
broken skiff
#

and those sub classes extends BaseInteraction, not ur extended class

patent urchin
#

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)

broken skiff
high narwhal
#

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

broken skiff
#

It’s actually a bad idea, esp bc you don’t control nor create these structures

lunar forum
#

The idea is fucked mate

patent urchin
#

we had it in the past. It was removed because it became infeasible to maintain and support