ralphkb/sentinel-tickets

Little bug with the new commits

Closed this issue ยท 15 comments

Closing a ticket that has been claimed the ticket author still has perms to talk. Not a huge issue down the line but making sure everything is covered (also realised you might be getting email spammed i do apologise ๐Ÿ™)

Also maybe down the line what would the chances be of this bot being sharded? (ability to operate in more than 1 server) Honestly, I would pay or at least donate, you deserve the recognition

Hey @Mirrage0, no worries regarding the emails haha.
I think the issue you're facing might be related to specific configuration options being enabled together, could you send your configuration file so I can try to replicate and fix the issue? (Please remove channel IDs, role IDs and such information before sending it)

Regarding your question about sharding the bot, I'm still not sure since I'm still learning and improving my skills but I think the bot currently does not work well on multiple guilds due to how it stores data. I can definitely change that in the future to make it store data based on each guild which would make it work on multiple servers but I would also have to do some more research about any other requirements for sharding.

Thank you for your kind words and for reporting issues, I truly appreciate that! ๐Ÿ˜„

config.txt

That should be everything with the IDs removed (if you meant the other stuff as well i do apologise) . I did add the image and thumbnail option to the panel embed builder too along with in the config file because why not. (thumbnail isn't put into the code yet hence why its been commented)

Other bots I see on github use SQLite for the database (or mongo but mongo can be an ass sometimes) if that is any help/interest to you.

Did the issue happen again after you first encountered it? It may be due to discord API interaction errors sometimes which can happen when the API has latency spikes. I tried the new options I added in the last few commits and I could not replicate the issue with a claimed ticket not properly removing the permission of the ticket author yet.

Can you try to replicate the issue and see if it happens again? I'm also not sure if you're on the latest commit but I noticed the "closeRemoveUser" option is missing in your config.

Regarding having thumbnail on embeds, that sounds good and I can of course add it as an extra option, I think most embeds can have more options and customizable features in the future as I keep evolving the bot.

The bot uses SQLite as well, but I was wondering if what you meant by using the bot on multiple servers is having it on a few discord servers? After some research it seems that sharding is for bots who are on a lot of servers, probably 1000+ which means it might not be necessary to add complexity to this bot for this to work. I think improving the way it stores data and registers slash commands could make it usable on multiple servers probably without issues.

I also tried testing with the config option "closeRemoveUser" being absent in the config however I cannot seem to be able to replicate the issue, when tickets are claimed or just closed without being claimed the ticket author permissions to send messages is being denied properly it seems, so I'm not sure.

I added thumbnail and image options for the panel embed. (aa5696c)

Odd, never noticed that option was missingas I just refilled in the info from my old config to the new (just IDs). What part does the missing close suer option I was missing in the config go under?

I also noticed that when having the working hours set to true and claiming a ticket set to true is all fine but when claiming a ticket the working hours gets overwritten, is that intentional?

Regarding the sharding, I meant as in multiguild, could add a guildId column to the SQLite file(s) might be a way to go, change the config file to a json or another sqlite and the configs just go under a guild id.

Also started fiddling around with a boolean option in the config to have a randomColor, so the embed colours will just be randomised instead of the set colours, if no panel title is set it would revert to interaction.guild.name Ticket Panel or something i dunno. My aim is to add defaults (minus stuff that need IDs ofc) to everything in case people miss filling stuff in the config like I have done a million times, and put something in the config to mark stuff as required might be quite handy for everyone.

P.S. With the above paragraph if I ever get something solid and not buggy ill make a pull request and share it

Found a bug where the bot would stop responding if the bot cannot DM the user at ticket deletion so I added a try catch block around it all and it will send a message to a channel in the config I added (just a channel: "" under the errors: category) and has been working smoothly every since. Nevermind it just introduced more. The bot not being able to DM the user causes a lot of errors. I am working on it though

Here is the copy of the new delete.js file. Look at the very bottom of the file, I added comments to assist.
ill reupload the file when i add a few more fixes i noticed

FIXES:

In the config.yml file add this to the errors: under locale

errors:
  not_in_a_ticket: "You are not in a ticket channel!" # Error displayed when a user tries to use a command in a non-ticket channel
  not_allowed: "You are not allowed to use this command!" # Error displayed when a user tries to use a staff-only command
  blacklisted: "You are blacklisted from creating tickets at this time." # Error displayed when a user tries to create a ticket but is blacklisted
  channel: "1125196332521504848" # The channel ID to send a message if the bot cannot DM the ticket author upon deletion !! User must be able to see this channel !!
  color: '#FF0000' # colour of the embed
  description: "Please enable `Allow Direct Messages` in this server to receive your closed ticket info next time!\n\nIf you don't know how to change it, read [this article](https://support.discord.com/hc/en-us/articles/217916488-Blocking-Privacy-Settings)."

Below is the updated delete.js file. Look right down the very bottom for the modifications. Take a look if you wish.

This fix now adds behaviour when a user has DMs from server members disabled, preventing the Unable to send messages API error!

Hello @Mirrage0, thank you for finding this issue I'm working on a fix and will push the commits as soon as I'm done.

I'll assume the issue you originally reported was some discord API latency spike or possible rate limit since I cannot replicate it under even the same config settings.
The missing config option you had was from this commit: 3d9373c

I will also push a fix for the claim field overriding the working hours/possibly other fields.
For now I think I will indeed focus on improving the bot, making the config less error prone and easier to understand before considering working on adding multiple guild support to the bot. For now I think the simplicity of the bot is better and focusing on stability and features is a higher priority.

Adding a randomColor option in the future as well as more embed options/default options to prevent errors will be a more long term goal I will focus on.

delete.txt
Updated file, again

After if (config.DMUserSettings.enabled) { (around line 124) put await interaction.deferReply(); right after it before the embeds

Regarding the " ... making the config less error prone ... " you could do this for example

      const ratingEmbed = new EmbedBuilder()
        .setColor(config.DMUserSettings.ratingSystem.embed.color || '#FF00FF')
        .setTitle(config.DMUserSettings.ratingSystem.embed.title || 'Feedback title')
        .setDescription(config.DMUserSettings.ratingSystem.embed.description || 'You got feedback!')
        .setFooter({
          text: `Ticket: #${interaction.channel.name} | Category: ${await ticketsDB.get(`${interaction.channel.id}.ticketType`)}`,
        });

Yes I intend to add such default values in future updates.
The claim field issue and DM errors should both be fixed in the last 2 commits now.

In the interactionCreate.js at like 887:41 embed is undefined, for the time being I just manually replaced it with the normal .setColor() and feedbacks arent dm'd any more (that could be because I messed up somewhere but anyway). Ill see what I can do about this and get back to you

If line 887 is undefined, you might be missing new config options that were added in the commit which fixed the DM errors. Please add them and try again, as it works for me when I tried it.

I suggest using notepad++ and it's comparison plugin to easily add new config options each time I update the config.

I also tried the rating system and it was DMed properly, you may try to follow the updating process written in the README after taking a backup of your files and see if that fixes your issues. If you modified the code itself it might have indeed caused some issues, in that case I would suggest reverting the changes and if you need them to be added, you may suggest them in a feature request issue here.

Apologies for the delayed reply,
So i started completely refreshed with all the new files (redownloaded as .zip) and im getting unknown interaction errors for delete and close (havent tried the others). Could be fixed by deferring the interaction then using interaction.editReply() but just thinking on the fly. You have to run them commands twice for it to work. Both button and slash if it helps you. Ither than that is completely bug free from what I can see!

Off topic, is there any way that I'm able to donate to you or anything? You deserve it and a few of my friends are using your code too and they love it

Hey, no worries about the delay and thank you for catching this issue!
It should be fixed now in the latest commit, I changed the commands/buttons that were not using deferReply to make use of it which should fix such issues.

I'm really glad you're enjoying using my bot and I appreciate your feedback a lot, I haven't set up a way to donate yet but I'll make sure to add a link for that once I figure out which platform would work for me to receive potential donations since not all payment methods/platforms work globally unfortunately.

I intend to keep evolving this project and adding more configuration options alongside improving the wiki in the future. ๐Ÿ˜„