import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js";

//check if the bot is pinged by someone

const answers = [
  'Oui ? (stiti)',
  "On m'a appelé ?",
  'https://tenor.com/view/bonjour-hello-oss117-jean-dujardin-hubert-bonisseur-de-la-bath-gif-13920747',
  'https://tenor.com/fr/view/hello-there-gif-5677380953331354485',
  'https://tenor.com/view/casse-fracasse-chabal-destroy-mur-gif-21656168'
];

export default class PingDetector extends detector {
  triggerName = 'mention';

//prevent trigger if user is doing a troll on its own
  async detect(message) {
    if (/(^|\b)(feur|quoicoubeh)(\b|$)/i.test(cleanMessageContent(message))) {
      return false;
    }

    return message.mentions.parsedUsers.has(message.client.user.id);
  }

  async createSpecificReply(message) {
    if (await this.detect(message)) {
      return Promise.resolve(answers[Math.floor(Math.random() * answers.length)]);
    }
    return Promise.resolve(null);
  }
}