OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Discord.js bot's reaction roles embeds do not work after bot restart

  • Thread starter Thread starter Jake Livsey
  • Start date Start date
J

Jake Livsey

Guest
My trouble begins from trying to get my bot to store and fetch reaction data from the embed properly between up/downtime. When my bot goes down and then comes back up again, all of my logging seems to imply the correct information as far as I'm able to read--the embed, its reactions, and the users responsible for them are being stored in database.sqlite. They're also being fetched properly according to the logs. But this is sort of proven wrong by virtue that the initial removal of a reaction is not logged and so, subsequently, a role is not removed when doing that. Adding the same reaction back is logged, but the role is not added because it was never removed to begin with. A subsequent second attempt to remove the reaction does log and does remove the role because, I guess, by that time, the bot is truly aware that there was a reaction to remove in the first place... but so then why does it pretend to be aware that a reaction exists upon restart? Why is it logged from the embed that there is an existing reaction, but it's incapable of recognizing the removal of that reaction the first time?

Below is everything that is logged from initial startup (lots of logged info from up to 3 existing embeds for you to ignore), creation of a new embed via a new /roll command, reacting to that embed, turning the bot off, turning the bot back on, removing the reaction I originally gave to the embed (not logged, as explained above), then re-adding that same reaction (logged but ineffective because the role was never removed from the reaction's removal, as explained above), then--for good measure--removing and re-adding the reaction again to show that it all logs properly (and I can vouch that it functions correctly in those actions, too).

Please forgive some irrelevant log information from other commands and any spaghetti code. I've been round and round on this, so it's not pretty.



// my command, which functions well up until the problem detailed above...


// my interaction events handler...


// my ready event, which plays a role in this mess, I'm sure...


// my role handler, which also probably plays a role in the mess, I'm sure...


// my sqlite3 database file is at the root near my index...

  • ./database.sqlite

// schema info...


// my index and database sync files...


<p>My trouble begins from trying to get my bot to store and fetch reaction data from the embed properly between up/downtime. When my bot goes down and then comes back up again, all of my logging seems to imply the correct information as far as I'm able to read--the embed, its reactions, and the users responsible for them are being stored in <code>database.sqlite</code>. They're also being fetched properly according to the logs. But this is sort of proven wrong by virtue that the initial removal of a reaction is not logged and so, subsequently, a role is not removed when doing that. Adding the same reaction back is logged, but the role is not added because it was never removed to begin with. A subsequent second attempt to remove the reaction <em>does</em> log and <em>does</em> remove the role because, I guess, by that time, the bot is truly aware that there was a reaction to remove in the first place... but so then why does it pretend to be aware that a reaction exists upon restart? Why is it logged from the embed that there is an existing reaction, but it's incapable of recognizing the removal of that reaction the first time?</p>
<p>Below is everything that is logged from initial startup (lots of logged info from up to 3 existing embeds for you to ignore), creation of a new embed via a new <code>/roll</code> command, reacting to that embed, turning the bot off, turning the bot back on, removing the reaction I originally gave to the embed (not logged, as explained above), then re-adding that same reaction (logged but ineffective because the role was never removed from the reaction's removal, as explained above), then--for good measure--removing and re-adding the reaction again to show that it all logs properly (and I can vouch that it functions correctly in those actions, too).</p>
<p>Please forgive some irrelevant log information from other commands and any spaghetti code. I've been round and round on this, so it's not pretty.</p>
<ul>
<li>log: <a href="https://sourceb.in/Po6RUlhutU" rel="nofollow noreferrer">https://sourceb.in/Po6RUlhutU</a></li>
</ul>
<hr />
<p><code>// my command, which functions well up until the problem detailed above...</code></p>
<ul>
<li>./commands/roles.js: <a href="https://sourceb.in/myjlXQXoGV" rel="nofollow noreferrer">https://sourceb.in/myjlXQXoGV</a></li>
</ul>
<p><code>// my interaction events handler...</code></p>
<ul>
<li>./events/interactionCreate.js: <a href="https://sourceb.in/9pM254j4Av" rel="nofollow noreferrer">https://sourceb.in/9pM254j4Av</a></li>
</ul>
<p><code>// my ready event, which plays a role in this mess, I'm sure...</code></p>
<ul>
<li>./events/ready.js: <a href="https://sourceb.in/rsf99Q8Cuy" rel="nofollow noreferrer">https://sourceb.in/rsf99Q8Cuy</a></li>
</ul>
<p><code>// my role handler, which also probably plays a role in the mess, I'm sure...</code></p>
<ul>
<li>./utils/roleManager.js: <a href="https://sourceb.in/GXFYjn9wcJ" rel="nofollow noreferrer">https://sourceb.in/GXFYjn9wcJ</a></li>
</ul>
<p><code>// my sqlite3 database file is at the root near my index...</code></p>
<ul>
<li>./database.sqlite</li>
</ul>
<p><code>// schema info...</code></p>
<ul>
<li>./models/database.js: <a href="https://sourceb.in/fyI0fVCKN7" rel="nofollow noreferrer">https://sourceb.in/fyI0fVCKN7</a></li>
<li>./models/embed.js: <a href="https://sourceb.in/PtEEwIVWo7" rel="nofollow noreferrer">https://sourceb.in/PtEEwIVWo7</a></li>
<li>./models/reaction.js: <a href="https://sourceb.in/rsBipMjYQN" rel="nofollow noreferrer">https://sourceb.in/rsBipMjYQN</a></li>
<li>./models/user.js: <a href="https://sourceb.in/URDcRVfyHl" rel="nofollow noreferrer">https://sourceb.in/URDcRVfyHl</a></li>
</ul>
<p><code>// my index and database sync files...</code></p>
<ul>
<li>./index.js: <a href="https://sourceb.in/lfs0btrMTd" rel="nofollow noreferrer">https://sourceb.in/lfs0btrMTd</a></li>
<li>./syncdb.js: <a href="https://sourceb.in/O1azamh9TS" rel="nofollow noreferrer">https://sourceb.in/O1azamh9TS</a></li>
</ul>
 

Latest posts

Online statistics

Members online
0
Guests online
5
Total visitors
5
Top