← back to browse
goat command

setting

Bot settings

0
views
0
likes
0
installs
raw source
const fs = require("fs");
const path = require("path");

module.exports = {
  config: {
    name: "setting",
    version: "1.0.0",
    author: "๐Œ๐š๐‘๐ฎ๐…",
    countDown: 5,
    role: 2,
    shortDescription: "Bot settings",
    longDescription: "Control bot settings",
    category: "admin",
    guide: "{prefix}setting"
  },

  onStart: async function ({ api, event, args, message }) {
    const mainMenu = [
      "โ•ญโ”€ใ€” โš™๏ธ ๐๐จ๐ญ ๐’๐ž๐ญ๐ญ๐ข๐ง๐ ๐ฌ ใ€•",
      "โ”‚",
      "โ”‚  โžŠ ๐๐จ๐ญ ๐‚๐จ๐ง๐Ÿ๐ข๐ ",
      "โ”‚  โž‹ ๐€๐๐ฆ๐ข๐ง ๐Œ๐š๐ง๐š๐ ๐ž",
      "โ”‚  โžŒ ๐–๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ ๐Œ๐š๐ง๐š๐ ๐ž",
      "โ”‚  โž ๐๐จ ๐๐ซ๐ž๐Ÿ๐ข๐ฑ",
      "โ”‚  โžŽ ๐‘๐ž๐š๐œ๐ญ ๐”๐ง๐ฌ๐ž๐ง๐",
      "โ”‚  โž ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž",
      "โ”‚  โž ๐…๐‚๐€ ๐Ž๐ฉ๐ญ๐ข๐จ๐ง๐ฌ",
      "โ”‚",
      "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐Ÿโ€“๐Ÿ• ใ€•"
    ].join("\n");

    const sent = await message.reply(mainMenu);

    global.GoatBot.onReply.set(sent.messageID, {
      commandName: "setting",
      messageID: sent.messageID,
      author: event.senderID,
      state: "main"
    });
  },

  onReply: async function ({ api, event, Reply, message }) {
    const { author, state } = Reply;

    if (event.senderID !== author) return;

    const configPath = path.join(process.cwd(), "config.json");
    const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
    const input = event.body.trim();
    const num = parseInt(input);

    function saveConfig() {
      fs.writeFileSync(
        configPath,
        JSON.stringify(config, null, 2),
        "utf8"
      );
    }

    function status(val) {
      return val ? "โ— ๐Ž๐" : "โ—‹ ๐Ž๐…๐…";
    }

    async function sendAndListen(text, newState, extra = {}) {
      const sent = await message.reply(text);

      global.GoatBot.onReply.set(sent.messageID, {
        commandName: "setting",
        messageID: sent.messageID,
        author,
        state: newState,
        ...extra
      });
    }

    if (state === "main") {
      if (num === 1) {
        const menu = [
          "โ•ญโ”€ใ€” โš™๏ธ ๐๐จ๐ญ ๐‚๐จ๐ง๐Ÿ๐ข๐  ใ€•",
          "โ”‚",
          `โ”‚  โžŠ ๐€๐๐ฆ๐ข๐ง ๐Ž๐ง๐ฅ๐ฒ  ${status(config.adminOnly?.enable)}`,
          `โ”‚  โž‹ ๐€๐ฎ๐ญ๐จ ๐‘๐ž๐ฌ๐ญ๐š๐ซ๐ญ  ${status(config.autoRestart?.enable)}`,
          `โ”‚  โžŒ ๐€๐ง๐ญ๐ข ๐ˆ๐ง๐›๐จ๐ฑ  ${status(config.antiInbox?.enable)}`,
          `โ”‚  โž ๐Ž๐ง๐ฅ๐ฒ ๐€๐๐ฆ๐ข๐ง ๐๐จ๐ฑ  ${status(config.onlyAdminBox)}`,
          "โ”‚",
          "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐Ÿโ€“๐Ÿ’ ๐ญ๐จ ๐ญ๐จ๐ ๐ ๐ฅ๐ž ใ€•"
        ].join("\n");

        return await sendAndListen(menu, "botConfig");
      }

      if (num === 2) {
        const menu = [
          "โ•ญโ”€ใ€” ๐Ÿ‘‘ ๐€๐๐ฆ๐ข๐ง ๐Œ๐š๐ง๐š๐ ๐ž ใ€•",
          "โ”‚",
          "โ”‚  โžŠ ๐€๐๐ ๐€๐๐ฆ๐ข๐ง",
          "โ”‚  โž‹ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐€๐๐ฆ๐ข๐ง",
          "โ”‚  โžŒ ๐‹๐ข๐ฌ๐ญ ๐€๐๐ฆ๐ข๐ง๐ฌ",
          "โ”‚",
          "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐Ÿโ€“๐Ÿ‘ ใ€•"
        ].join("\n");

        return await sendAndListen(menu, "adminManage");
      }

      if (num === 3) {
        const menu = [
          "โ•ญโ”€ใ€” ๐Ÿ›ก๏ธ ๐–๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ ใ€•",
          "โ”‚",
          `โ”‚  โžŠ ๐“๐ก๐ซ๐ž๐š๐ ๐–๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ  ${status(config.whiteListModeThread?.enable)}`,
          "โ”‚  โž‹ ๐€๐๐ ๐“๐ก๐ซ๐ž๐š๐",
          "โ”‚  โžŒ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐“๐ก๐ซ๐ž๐š๐",
          `โ”‚  โž ๐”๐ฌ๐ž๐ซ ๐–๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ  ${status(config.whiteListMode?.enable)}`,
          "โ”‚  โžŽ ๐€๐๐ ๐”๐ฌ๐ž๐ซ",
          "โ”‚  โž ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐”๐ฌ๐ž๐ซ",
          "โ”‚",
          "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐Ÿโ€“๐Ÿ” ใ€•"
        ].join("\n");

        return await sendAndListen(menu, "whitelist");
      }

      if (num === 4) {
        config.noPrefix = config.noPrefix || {};
        config.noPrefix.enable = !config.noPrefix.enable;
        saveConfig();

        return message.reply(
          `โ•ญโ”€ใ€” โœฆ ๐๐จ ๐๐ซ๐ž๐Ÿ๐ข๐ฑ ใ€•\nโ”‚\nโ”‚  ${status(config.noPrefix.enable)}\nโ•ฐโ”€`
        );
      }

      if (num === 5) {
        const menu = [
          "โ•ญโ”€ใ€” ๐Ÿ’ซ ๐‘๐ž๐š๐œ๐ญ ๐”๐ง๐ฌ๐ž๐ง๐ ใ€•",
          "โ”‚",
          `โ”‚  โžŠ ๐“๐จ๐ ๐ ๐ฅ๐ž  ${status(config.reactUnsend?.enable)}`,
          `โ”‚  โž‹ ๐Ž๐ง๐ฅ๐ฒ ๐€๐๐ฆ๐ข๐ง  ${status(config.reactUnsend?.onlyAdmin)}`,
          "โ”‚  โžŒ ๐€๐๐ ๐„๐ฆ๐จ๐ฃ๐ข",
          "โ”‚  โž ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐„๐ฆ๐จ๐ฃ๐ข",
          "โ”‚  โžŽ ๐‹๐ข๐ฌ๐ญ ๐„๐ฆ๐จ๐ฃ๐ข๐ฌ",
          "โ”‚",
          "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐Ÿโ€“๐Ÿ“ ใ€•"
        ].join("\n");

        return await sendAndListen(menu, "reactUnsend");
      }

      if (num === 6) {
        const current = config.nickNameBot || "Not set";

        const menu = [
          "โ•ญโ”€ใ€” โœ๏ธ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ใ€•",
          "โ”‚",
          `โ”‚  โœฆ ๐‚๐ฎ๐ซ๐ซ๐ž๐ง๐ญ: ${current}`,
          "โ”‚",
          "โ”‚  โžŠ ๐’๐ž๐ญ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ใ€”๐“๐ก๐ข๐ฌ ๐†๐ซ๐จ๐ฎ๐ฉใ€•",
          "โ”‚  โž‹ ๐’๐ž๐ญ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ใ€”๐€๐ฅ๐ฅ ๐†๐ซ๐จ๐ฎ๐ฉ๐ฌใ€•",
          "โ”‚  โžŒ ๐‘๐ž๐ฌ๐ž๐ญ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž",
          "โ”‚",
          "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐Ÿโ€“๐Ÿ‘ ใ€•"
        ].join("\n");

        return await sendAndListen(menu, "nickname");
      }

      if (num === 7) {
        const o = config.optionsFca || {};

        const menu = [
          "โ•ญโ”€ใ€” ๐Ÿ”ง ๐…๐‚๐€ ๐Ž๐ฉ๐ญ๐ข๐จ๐ง๐ฌ ใ€•",
          "โ”‚",
          `โ”‚  โžŠ ๐€๐ฎ๐ญ๐จ ๐”๐ฉ๐๐š๐ญ๐ž      ${status(o.autoUpdate)}`,
          `โ”‚  โž‹ ๐‹๐ข๐ฌ๐ญ๐ž๐ง ๐„๐ฏ๐ž๐ง๐ญ๐ฌ     ${status(o.listenEvents)}`,
          `โ”‚  โžŒ ๐’๐ž๐ฅ๐Ÿ ๐‹๐ข๐ฌ๐ญ๐ž๐ง        ${status(o.selfListen)}`,
          `โ”‚  โž ๐‹๐ข๐ฌ๐ญ๐ž๐ง ๐“๐ฒ๐ฉ๐ข๐ง๐       ${status(o.listenTyping)}`,
          `โ”‚  โžŽ ๐”๐ฉ๐๐š๐ญ๐ž ๐๐ซ๐ž๐ฌ๐ž๐ง๐œ๐ž   ${status(o.updatePresence)}`,
          `โ”‚  โž ๐…๐จ๐ซ๐œ๐ž ๐‹๐จ๐ ๐ข๐ง          ${status(o.forceLogin)}`,
          `โ”‚  โž ๐€๐ฎ๐ญ๐จ ๐Œ๐š๐ซ๐ค ๐‘๐ž๐š๐   ${status(o.autoMarkRead)}`,
          `โ”‚  โž‘ ๐€๐ฎ๐ญ๐จ ๐‘๐ž๐œ๐จ๐ง๐ง๐ž๐œ๐ญ  ${status(o.autoReconnect)}`,
          `โ”‚  โž’ ๐„๐Ÿ๐„๐„ ๐„๐ง๐š๐›๐ฅ๐ž๐     ${status(config.e2ee?.enable)}`,
          "โ”‚",
          "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐Ÿโ€“๐Ÿ— ๐ญ๐จ ๐ญ๐จ๐ ๐ ๐ฅ๐ž ใ€•"
        ].join("\n");

        return await sendAndListen(menu, "fcaOptions");
      }
    }

    if (state === "botConfig") {
      if (num === 1) {
        config.adminOnly = config.adminOnly || {};
        config.adminOnly.enable = !config.adminOnly.enable;
        saveConfig();
        return message.reply(`โœฆ ๐€๐๐ฆ๐ข๐ง ๐Ž๐ง๐ฅ๐ฒ โ€” ${status(config.adminOnly.enable)}`);
      }

      if (num === 2) {
        config.autoRestart = config.autoRestart || {};
        config.autoRestart.enable = !config.autoRestart.enable;
        saveConfig();
        return message.reply(`โœฆ ๐€๐ฎ๐ญ๐จ ๐‘๐ž๐ฌ๐ญ๐š๐ซ๐ญ โ€” ${status(config.autoRestart.enable)}`);
      }

      if (num === 3) {
        config.antiInbox = config.antiInbox || {};
        config.antiInbox.enable = !config.antiInbox.enable;
        saveConfig();
        return message.reply(`โœฆ ๐€๐ง๐ญ๐ข ๐ˆ๐ง๐›๐จ๐ฑ โ€” ${status(config.antiInbox.enable)}`);
      }

      if (num === 4) {
        config.onlyAdminBox = !config.onlyAdminBox;
        saveConfig();
        return message.reply(`โœฆ ๐Ž๐ง๐ฅ๐ฒ ๐€๐๐ฆ๐ข๐ง ๐๐จ๐ฑ โ€” ${status(config.onlyAdminBox)}`);
      }
    }

    if (state === "adminManage") {
      if (num === 1) {
        return await sendAndListen(
          "โ•ญโ”€ใ€” ๐Ÿ‘‘ ๐€๐๐ ๐€๐๐ฆ๐ข๐ง ใ€•\nโ”‚\nโ”‚  โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก ๐”๐ˆ๐ƒ ๐จ๐ซ ๐ญ๐š๐  ๐ฎ๐ฌ๐ž๐ซ\nโ•ฐโ”€",
          "adminAdd"
        );
      }

      if (num === 2) {
        const admins = config.adminBot || [];

        if (!admins.length)
          return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐๐จ ๐š๐๐ฆ๐ข๐ง๐ฌ ๐Ÿ๐จ๐ฎ๐ง๐ ใ€•");

        const list = admins
          .map((id, i) => `โ”‚  ${i + 1}. ${id}`)
          .join("\n");

        const menu = [
          "โ•ญโ”€ใ€” ๐Ÿ‘‘ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐€๐๐ฆ๐ข๐ง ใ€•",
          "โ”‚",
          list,
          "โ”‚",
          "โ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ง๐ฎ๐ฆ๐›๐ž๐ซ ใ€•"
        ].join("\n");

        return await sendAndListen(menu, "adminRemoveSelect");
      }

      if (num === 3) {
        const admins = config.adminBot || [];

        if (!admins.length)
          return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐๐จ ๐š๐๐ฆ๐ข๐ง๐ฌ ๐Ÿ๐จ๐ฎ๐ง๐ ใ€•");

        return message.reply(
          `โ•ญโ”€ใ€” ๐Ÿ‘‘ ๐€๐๐ฆ๐ข๐ง๐ฌ ใ€•\nโ”‚\nโ”‚  ${admins.join("\nโ”‚  ")}\nโ•ฐโ”€`
        );
      }
    }

    if (state === "adminAdd") {
      let uid = input;

      if (event.mentions && Object.keys(event.mentions).length > 0)
        uid = Object.keys(event.mentions)[0];

      if (!uid || isNaN(uid))
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐”๐ˆ๐ƒ ใ€•");

      config.adminBot = config.adminBot || [];

      if (config.adminBot.includes(uid))
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐€๐ฅ๐ซ๐ž๐š๐๐ฒ ๐š๐ง ๐š๐๐ฆ๐ข๐ง ใ€•");

      config.adminBot.push(uid);
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐€๐๐๐ž๐ ๐š๐๐ฆ๐ข๐ง: ${uid} ใ€•`);
    }

    if (state === "adminRemoveSelect") {
      const admins = config.adminBot || [];
      const idx = num - 1;

      if (isNaN(num) || !admins[idx])
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ฌ๐ž๐ฅ๐ž๐œ๐ญ๐ข๐จ๐ง ใ€•");

      const removed = admins.splice(idx, 1)[0];

      config.adminBot = admins;
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž๐: ${removed} ใ€•`);
    }

    if (state === "whitelist") {
      if (num === 1) {
        config.whiteListModeThread = config.whiteListModeThread || {};
        config.whiteListModeThread.enable =
          !config.whiteListModeThread.enable;

        saveConfig();

        return message.reply(
          `โœฆ ๐“๐ก๐ซ๐ž๐š๐ ๐–๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ โ€” ${status(config.whiteListModeThread.enable)}`
        );
      }

      if (num === 2) {
        return await sendAndListen(
          "โ•ญโ”€ใ€” ๐Ÿ›ก๏ธ ๐€๐๐ ๐“๐ก๐ซ๐ž๐š๐ ใ€•\nโ”‚\nโ”‚  โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก ๐“๐ก๐ซ๐ž๐š๐ ๐ˆ๐ƒ\nโ•ฐโ”€",
          "threadAdd"
        );
      }

      if (num === 3) {
        const threads =
          config.whiteListModeThread?.whiteListThreadIds || [];

        if (!threads.length)
          return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐๐จ ๐ญ๐ก๐ซ๐ž๐š๐๐ฌ ๐Ÿ๐จ๐ฎ๐ง๐ ใ€•");

        const list = threads
          .map((id, i) => `โ”‚  ${i + 1}. ${id}`)
          .join("\n");

        return await sendAndListen(
          `โ•ญโ”€ใ€” ๐Ÿ›ก๏ธ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐“๐ก๐ซ๐ž๐š๐ ใ€•\nโ”‚\n${list}\nโ”‚\nโ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ง๐ฎ๐ฆ๐›๐ž๐ซ ใ€•`,
          "threadRemoveSelect"
        );
      }

      if (num === 4) {
        config.whiteListMode = config.whiteListMode || {};
        config.whiteListMode.enable = !config.whiteListMode.enable;

        saveConfig();

        return message.reply(
          `โœฆ ๐”๐ฌ๐ž๐ซ ๐–๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ โ€” ${status(config.whiteListMode.enable)}`
        );
      }

      if (num === 5) {
        return await sendAndListen(
          "โ•ญโ”€ใ€” ๐Ÿ›ก๏ธ ๐€๐๐ ๐”๐ฌ๐ž๐ซ ใ€•\nโ”‚\nโ”‚  โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก ๐”๐ˆ๐ƒ ๐จ๐ซ ๐ญ๐š๐  ๐ฎ๐ฌ๐ž๐ซ\nโ•ฐโ”€",
          "userAdd"
        );
      }

      if (num === 6) {
        const users = config.whiteListMode?.whiteListIds || [];

        if (!users.length)
          return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐๐จ ๐ฎ๐ฌ๐ž๐ซ๐ฌ ๐Ÿ๐จ๐ฎ๐ง๐ ใ€•");

        const list = users
          .map((id, i) => `โ”‚  ${i + 1}. ${id}`)
          .join("\n");

        return await sendAndListen(
          `โ•ญโ”€ใ€” ๐Ÿ›ก๏ธ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐”๐ฌ๐ž๐ซ ใ€•\nโ”‚\n${list}\nโ”‚\nโ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ง๐ฎ๐ฆ๐›๐ž๐ซ ใ€•`,
          "userRemoveSelect"
        );
      }
    }

    if (state === "threadAdd") {
      const tid = input;

      if (!tid || isNaN(tid))
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐“๐ก๐ซ๐ž๐š๐ ๐ˆ๐ƒ ใ€•");

      config.whiteListModeThread =
        config.whiteListModeThread || {};

      config.whiteListModeThread.whiteListThreadIds =
        config.whiteListModeThread.whiteListThreadIds || [];

      if (
        config.whiteListModeThread.whiteListThreadIds.includes(tid)
      )
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐€๐ฅ๐ซ๐ž๐š๐๐ฒ ๐ข๐ง ๐ฐ๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ ใ€•");

      config.whiteListModeThread.whiteListThreadIds.push(tid);
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐“๐ก๐ซ๐ž๐š๐ ๐š๐๐๐ž๐: ${tid} ใ€•`);
    }

    if (state === "threadRemoveSelect") {
      const threads =
        config.whiteListModeThread?.whiteListThreadIds || [];

      const idx = num - 1;

      if (isNaN(num) || !threads[idx])
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ฌ๐ž๐ฅ๐ž๐œ๐ญ๐ข๐จ๐ง ใ€•");

      const removed = threads.splice(idx, 1)[0];

      config.whiteListModeThread.whiteListThreadIds = threads;
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž๐: ${removed} ใ€•`);
    }

    if (state === "userAdd") {
      let uid = input;

      if (event.mentions && Object.keys(event.mentions).length > 0)
        uid = Object.keys(event.mentions)[0];

      if (!uid || isNaN(uid))
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐”๐ˆ๐ƒ ใ€•");

      config.whiteListMode = config.whiteListMode || {};
      config.whiteListMode.whiteListIds =
        config.whiteListMode.whiteListIds || [];

      if (config.whiteListMode.whiteListIds.includes(uid))
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐€๐ฅ๐ซ๐ž๐š๐๐ฒ ๐ข๐ง ๐ฐ๐ก๐ข๐ญ๐ž๐ฅ๐ข๐ฌ๐ญ ใ€•");

      config.whiteListMode.whiteListIds.push(uid);
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐”๐ฌ๐ž๐ซ ๐š๐๐๐ž๐: ${uid} ใ€•`);
    }

    if (state === "userRemoveSelect") {
      const users = config.whiteListMode?.whiteListIds || [];
      const idx = num - 1;

      if (isNaN(num) || !users[idx])
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ฌ๐ž๐ฅ๐ž๐œ๐ญ๐ข๐จ๐ง ใ€•");

      const removed = users.splice(idx, 1)[0];

      config.whiteListMode.whiteListIds = users;
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž๐: ${removed} ใ€•`);
    }

    if (state === "reactUnsend") {
      if (num === 1) {
        config.reactUnsend = config.reactUnsend || {};
        config.reactUnsend.enable = !config.reactUnsend.enable;
        saveConfig();

        return message.reply(
          `โœฆ ๐‘๐ž๐š๐œ๐ญ ๐”๐ง๐ฌ๐ž๐ง๐ โ€” ${status(config.reactUnsend.enable)}`
        );
      }

      if (num === 2) {
        config.reactUnsend = config.reactUnsend || {};
        config.reactUnsend.onlyAdmin =
          !config.reactUnsend.onlyAdmin;

        saveConfig();

        return message.reply(
          `โœฆ ๐Ž๐ง๐ฅ๐ฒ ๐€๐๐ฆ๐ข๐ง โ€” ${status(config.reactUnsend.onlyAdmin)}`
        );
      }

      if (num === 3) {
        return await sendAndListen(
          "โ•ญโ”€ใ€” ๐Ÿ’ซ ๐€๐๐ ๐„๐ฆ๐จ๐ฃ๐ข ใ€•\nโ”‚\nโ”‚  โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก ๐ž๐ฆ๐จ๐ฃ๐ข\nโ•ฐโ”€",
          "emojiAdd"
        );
      }

      if (num === 4) {
        const emojis = config.reactUnsend?.emojis || [];

        if (!emojis.length)
          return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐๐จ ๐ž๐ฆ๐จ๐ฃ๐ข๐ฌ ๐Ÿ๐จ๐ฎ๐ง๐ ใ€•");

        const list = emojis
          .map((e, i) => `โ”‚  ${i + 1}. ${e}`)
          .join("\n");

        return await sendAndListen(
          `โ•ญโ”€ใ€” ๐Ÿ’ซ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž ๐„๐ฆ๐จ๐ฃ๐ข ใ€•\nโ”‚\n${list}\nโ”‚\nโ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ง๐ฎ๐ฆ๐›๐ž๐ซ ใ€•`,
          "emojiRemoveSelect"
        );
      }

      if (num === 5) {
        const emojis = config.reactUnsend?.emojis || [];

        if (!emojis.length)
          return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐๐จ ๐ž๐ฆ๐จ๐ฃ๐ข๐ฌ ใ€•");

        return message.reply(
          `โ•ญโ”€ใ€” ๐Ÿ’ซ ๐„๐ฆ๐จ๐ฃ๐ข๐ฌ ใ€•\nโ”‚\nโ”‚  ${emojis.join("  ")}\nโ•ฐโ”€`
        );
      }
    }

    if (state === "emojiAdd") {
      const emoji = input.trim();

      if (!emoji)
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ž๐ฆ๐จ๐ฃ๐ข ใ€•");

      config.reactUnsend = config.reactUnsend || {};
      config.reactUnsend.emojis =
        config.reactUnsend.emojis || [];

      if (config.reactUnsend.emojis.includes(emoji))
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐€๐ฅ๐ซ๐ž๐š๐๐ฒ ๐š๐๐๐ž๐ ใ€•");

      config.reactUnsend.emojis.push(emoji);
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐€๐๐๐ž๐: ${emoji} ใ€•`);
    }

    if (state === "emojiRemoveSelect") {
      const emojis = config.reactUnsend?.emojis || [];
      const idx = num - 1;

      if (isNaN(num) || !emojis[idx])
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ฌ๐ž๐ฅ๐ž๐œ๐ญ๐ข๐จ๐ง ใ€•");

      const removed = emojis.splice(idx, 1)[0];

      config.reactUnsend.emojis = emojis;
      saveConfig();

      return message.reply(`โ•ฐโ”€ใ€” โœฆ ๐‘๐ž๐ฆ๐จ๐ฏ๐ž๐: ${removed} ใ€•`);
    }

    if (state === "nickname") {
      if (num === 1) {
        return await sendAndListen(
          "โ•ญโ”€ใ€” โœ๏ธ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ใ€•\nโ”‚\nโ”‚  โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก ๐ง๐ž๐ฐ ๐ง๐ข๐œ๐ค๐ง๐š๐ฆ๐ž\nโ•ฐโ”€",
          "nicknameSet"
        );
      }

      if (num === 2) {
        return await sendAndListen(
          "โ•ญโ”€ใ€” โœ๏ธ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ใ€”๐€๐ฅ๐ฅใ€•ใ€•\nโ”‚\nโ”‚  โ€บ ๐‘๐ž๐ฉ๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก ๐ง๐ž๐ฐ ๐ง๐ข๐œ๐ค๐ง๐š๐ฆ๐ž\nโ•ฐโ”€",
          "nicknameSetAll"
        );
      }

      if (num === 3) {
        config.nickNameBot = "";
        saveConfig();

        try {
          await api.changeNickname(
            "",
            event.threadID,
            api.getCurrentUserID()
          );
        } catch (e) {}

        return message.reply("โ•ฐโ”€ใ€” โœฆ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ๐ซ๐ž๐ฌ๐ž๐ญ ใ€•");
      }
    }

    if (state === "nicknameSet") {
      const nickname = input;

      if (!nickname)
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ง๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ใ€•");

      config.nickNameBot = nickname;
      saveConfig();

      try {
        await api.changeNickname(
          nickname,
          event.threadID,
          api.getCurrentUserID()
        );
      } catch (e) {}

      return message.reply(
        `โ•ฐโ”€ใ€” โœฆ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž: ${nickname} ใ€•`
      );
    }

    if (state === "nicknameSetAll") {
      const nickname = input;

      if (!nickname)
        return message.reply("โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ง๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ใ€•");

      config.nickNameBot = nickname;
      saveConfig();

      const threads = await api.getThreadList(
        100,
        null,
        ["INBOX"]
      );

      let success = 0;

      for (const thread of threads) {
        if (!thread.isGroup) continue;

        try {
          await api.changeNickname(
            nickname,
            thread.threadID,
            api.getCurrentUserID()
          );

          success++;
        } catch (e) {}
      }

      return message.reply(
        `โ•ญโ”€ใ€” โœฆ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ๐”๐ฉ๐๐š๐ญ๐ž๐ ใ€•\nโ”‚\nโ”‚  โ€บ ${nickname}\nโ”‚  โ€บ ๐†๐ซ๐จ๐ฎ๐ฉ๐ฌ: ${success}\nโ•ฐโ”€`
      );
    }

    if (state === "fcaOptions") {
      const keys = [
        "autoUpdate",
        "listenEvents",
        "selfListen",
        "listenTyping",
        "updatePresence",
        "forceLogin",
        "autoMarkRead",
        "autoReconnect"
      ];

      if (num === 9) {
        config.e2ee = config.e2ee || {};
        config.e2ee.enable = !config.e2ee.enable;

        saveConfig();

        return message.reply(
          `โ•ญโ”€ใ€” ๐Ÿ” ๐„๐Ÿ๐„๐„ ใ€•\nโ”‚\nโ”‚  ${status(config.e2ee.enable)}\nโ”‚\nโ•ฐโ”€ใ€” โ€บ ๐‘๐ž๐ฌ๐ญ๐š๐ซ๐ญ ๐›๐จ๐ญ ๐Ÿ๐จ๐ซ ๐œ๐ก๐š๐ง๐ ๐ž ใ€•`
        );
      }

      const key = keys[num - 1];

      if (!key)
        return message.reply(
          "โ•ฐโ”€ใ€” ๐—ซ ๐ˆ๐ง๐ฏ๐š๐ฅ๐ข๐ ๐ฌ๐ž๐ฅ๐ž๐œ๐ญ๐ข๐จ๐ง ใ€•"
        );

      config.optionsFca = config.optionsFca || {};
      config.optionsFca[key] = !config.optionsFca[key];

      saveConfig();

      if (key !== "autoUpdate" && key !== "forceLogin") {
        api.setOptions({
          [key]: config.optionsFca[key]
        });
      }

      return message.reply(
        `โ•ฐโ”€ใ€” โœฆ ๐…๐‚๐€ ${key} โ€” ${status(config.optionsFca[key])} ใ€•`
      );
    }
  }
};

View raw file