Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working run handler #32

Open
rafia9005 opened this issue Jan 4, 2025 · 0 comments
Open

not working run handler #32

rafia9005 opened this issue Jan 4, 2025 · 0 comments

Comments

@rafia9005
Copy link

import {
  Client,
  CommandHandler,
  Ctx,
  Events,
  MessageType,
} from "@mengkodingan/ckptw";
import path from "path";
import { handleChat } from "./bot";

export const bot = new Client({
  prefix: "!",
  printQRInTerminal: true,
  readIncommingMsg: false
});

const bioTexts = [
  "🚀 Bot is active right now",
  "🚀 Bot created by Tuxedo Labs",
  "🌟 Stay tuned for updates!",
  "🔥 Powered by Node.js",
  "💻 Coding is fun!",
  "🌐 Always online!",
];

let currentBioIndex = 0;
const cmd = new CommandHandler(bot, path.resolve(__dirname, "handler"));

bot.ev.once(Events.ClientReady, (m) => {
  console.log(`ready at ${m.user.id}`);
  updateBio();
  cmd.load();
});

bot.hears(MessageType.conversation, async (ctx: Ctx) => {
  const messageText = ctx.msg?.content || "";
  // pingin nya di sini jika startwith "!" yang jalan commandhandler
  if (messageText.startsWith("!")) {
    return;
  }

  handleChat(ctx);
});

function updateBio() {
  const bio = bioTexts[currentBioIndex];

  bot.bio(bio);
  currentBioIndex = (currentBioIndex + 1) % bioTexts.length;
  setTimeout(updateBio, 10000);
}

bot.launch();

cara fix nya gimana? agar di MessageType.conversation jika startwith ! nanti yang jalan Commandhandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant