Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete a giveaway from a json database make random char to be on it #460

Open
Telepathique opened this issue Apr 27, 2022 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Telepathique
Copy link

Telepathique commented Apr 27, 2022

Describe the bug
while i delete a giveaway from the command provided in the docs :

client.on('interactionCreate', (interaction) => {

    if (interaction.isCommand() && interaction.commandName === 'delete') {
        const messageId = interaction.options.getString('message_id');
        client.giveawaysManager.delete(messageId).then(() => {
            interaction.channel.send('Success! Giveaway deleted!');
        }).catch((err) => {
            interaction.channel.send(`An error has occurred, please check and try again.\n\`${err}\``);
        });
    }
});

the deletion leave some random chars on the json
Error before the delete
image
after the delete :
image
0377088>"} is the random
To Reproduce
create a giveaway, then delete it check the json file you will see the error
Expected behavior
complete removal of the giveaway without the random chars.
Additional context

  • discord-giveaways version: 5.1.1
  • discord.js version: 13.6.0
  • Custom Database (if you use one):
@Telepathique Telepathique added the bug Something isn't working label Apr 27, 2022
@Nico105
Copy link
Collaborator

Nico105 commented May 4, 2022

json unfortunately is a little prone to such "glitches", at least since because of giveaways a lot of stuff has to be saved.
For now it is just recommended to try to fix the "glitch" by yourself/switch to a more reliable db (examples folder).

More for open discussion than an actual proposing:
I read some articles, which lightly suggest imo, that it can occur when the writing of the file does not happen in an orderly fashion, and so conflicts/"glitches" happen cause "two writeFile executions don't wait for one another"/the amount of write requests is to "high"/isn't processed in copletely correct order.
Tho correct me on that if i'm interpreting stuff wrong.
(and ik we are using promises for writeFile already, but idk if it still can happen even with that)

I thought of maybe implementing some kind of "writeTask" array, or maybe using timestamps for the requests or smth in order to reduce the load/make it more orderly.
but i'm really to expert at smth like thinking that stuff out logically, so if anyone is knowing a solution which has provenness, then please feel free to suggest.

btw if needed, feel free to ask me to make this a github discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants