refactor(reddit-bot): don't use global variables

This commit is contained in:
GramingFoxTeam
2022-11-18 15:44:41 +03:00
parent 551891e4c3
commit e84edd3cd9
3 changed files with 26 additions and 29 deletions

View File

@@ -1,8 +1,8 @@
export default {
name: 'aiResponse',
once: false,
async execute(aiRes) {
const response = global.config.responses.find(
async execute(client, config, aiRes) {
const response = config.responses.find(
(res) => res.label === aiRes.predictions[0].label
);
if (!response) return;
@@ -14,12 +14,12 @@ export default {
switch (ids[0]) {
case 'comment': {
global.client.getComment(ids[1]).reply(response.text);
client.getComment(ids[1]).reply(response.text);
break;
}
case 'post': {
global.client.getSubmission(ids[1]).reply(response.text);
client.getSubmission(ids[1]).reply(response.text);
break;
}
}