My first experience using stackoverflow was to seek help regarding a bot created to post results whenever a new episode of a show in the search list is added on nyaa.si. The issue I'm facing is that the bot posts the same episode multiple times within different time frames, even though I want it to only post the result once for every episode. This problem seems to be temporarily fixed when I restart the bot.
async addShow(msg) {
const regex = /"(.+?)" "(.+?)"(?: "(.+?)")?/g;
const found = regex.exec(msg.content);
if (found === null) {
await msg.channel.send(`Invalid new syntax:\n${COMMAND_CHARACTER} new \"show search phrase\" \"MALURL\" \"attribute regex\" (optional last)`);
return;
}
// code continues...
The code provided for searching
async searchShow(id, query, channel = null, OG = null) {
const results = await this.nyaa.getResults(query);
if (!results.length) {
return;
}
// code continues...
The snippet for posting the result once a new episode is available
async postShow(embedFunc, item, channel = null, og = null, channelType = NYAA_UPDATES) {
if (channel === null) {
channel = await this.getGuildChannel(channelType);
// code continues...
I would like to point out that most of the original code was written by someone else, and I have only made minor additions here and there. Since the original developer had to leave Discord, I am now responsible for hosting the bot on repl.it. I am seeking assistance to determine whether the issue lies within the code or not.