Skip to content

Commit

Permalink
Send statistics if the bot actually works.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maseshi committed Apr 30, 2022
1 parent e98d3a1 commit 8147c3a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 17 additions & 0 deletions source/events/interaction/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ module.exports = async (interaction) => {

try {
await command.interaction.execute(interaction);

// Stores information when the bot is working properly.
if (client.mode === "start") {
get(ref(getDatabase(), 'Shioru/data/survey/working'), (snapshot) => {
if (snapshot.exists()) {
let working = snapshot.val();

update(ref(getDatabase(), 'Shioru/data/survey'), {
"working": (working + 1)
});
} else {
update(ref(getDatabase(), 'Shioru/data/survey'), {
"working": 1
});
}
});
}
} catch (error) {
catchError(interaction.client, interaction, interaction.commandName, error);
}
Expand Down
8 changes: 4 additions & 4 deletions source/events/message/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ module.exports = async (message) => {
}
}

// Stores information when the bot is working properly.
try {
command.run(client, message, args);

// Stores information when the bot is working properly.
if (client.mode === "start") {
get(ref(getDatabase(), 'Shioru/data/survey/working'), (snapshot) => {
if (snapshot.exists()) {
Expand All @@ -93,9 +96,6 @@ module.exports = async (message) => {
}
});
}

try {
command.run(client, message, args);
} catch(error) {
catchError(client, message, command.help.name, error);
}
Expand Down

0 comments on commit 8147c3a

Please sign in to comment.