anipalur / anipalur/gce-a-levels-bot
Log command and button usage before they are executed
- Lingua principale
- JavaScript
- Stelle
- 1
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Discord Username
Not specified.
### Bug Description
When a command or button is used, a log message is only posted to the console *after* its [`execute()` function](https://github.com/anipalur/gce-a-levels-bot/blob/0dcbee9af737350b7f70bcff5dc07de1969a571c/src/events/interaction-create.js#L145 "View an example of an execute() function.") is called. This is a problem if, for example, a user uses a button that prompts for confirmation. A [log message](https://github.com/anipalur/gce-a-levels-bot/blob/0dcbee9af737350b7f70bcff5dc07de1969a571c/src/events/interaction-create.js#L148 "View an example of a log message.") is only posted after the collector on the confirmation message ends, which can be up to 15 minutes later.
For reference:
https://github.com/anipalur/gce-a-levels-bot/blob/0dcbee9af737350b7f70bcff5dc07de1969a571c/src/events/interaction-create.js#L145-L148
### Steps to Reproduce
1. Use a command or button, e.g. a button that prompts for confirmation.
2. Terminate the command or button early, e.g. by cancelling the confirmation.
3. Take note of when the log message is posted.
### Expected Behaviour
The log message to be posted immediately after a command or button is used.
### Relevant Log Output
```shell
Log Message Posted After: 8.717s
anipalur used the close-suggestion button in #Test.
```
### Relevant Screenshots
None.
### Additional Information
Add this to [`interaction-create.js`](https://github.com/anipalur/gce-a-levels-bot/blob/0dcbee9af737350b7f70bcff5dc07de1969a571c/src/events/interaction-create.js#L148 "View when a button's execute() function is called."):
```js
console.time('Log Message Posted After');
await button.execute(interaction, client, user);
console.timeEnd('Log Message Posted After');
```
### Code of Conduct
- [X] I agree to abide by the Code of Conduct.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.