Mickhat / FloBot

7 stars 1 forks source link

Heeecker improving file structure #35

Closed filip326 closed 1 year ago

filip326 commented 1 year ago

Why?

In the previous version, different parts of the bot were in different folders, e.g. the ticket system was in the listeners/interactionCreate file, some commands were in the actions file, other commands were just somewhere

What happened?

There are different types of events:

Events

Each event has got a folder. All data about this event are in a single file in the folder it belongs to.

Handler

When the bot starts, it reads each of the directory and imports the files, check them for validity and adds them to the handler. When an event occurs, it will run the execute method inside the belonging file. Commands are being registred to the discord api based on the data from the filed inside the directories.

How to work with it?

When you want to do something on an event, add a file into the correct folder. The main file will find the file and use it when needed. To make the file valid, you need to export the correct type (see commandTypes.ts), else the bot will ignore it. Look at the files I've already created and just replicate the same, then it will work ;)

Questions?

Just ask :)

filip326 commented 1 year ago

For reference: Changes inspired by https://discordjs.guide/creating-your-bot/command-handling.html#loading-command-files