+
Skip to content

Bot Not Intercepting Command Input #181

@GalGreenfield

Description

@GalGreenfield

I modified my local installation with a fork of the library that adds ESM exports
And added a single ping command from the official guide

Note: My prefix is $.
When I send $ping in a channel the bot has the right messages (read messages history, send messages, read history, view channel), it doesn't reply to me with pong. Evren when I changed the exec function to log something, it doesn't do it.

This is my project's file system:

config
   ┕━ config.mjs
commands
    ┕━━ ping.mjs  
package.json
Bot.mjs
index.mjs

This is Bot.mjs:

import {
  AkairoClient,
  InhibitorHandler,
  CommandHandler,
  ListenerHandler
} 
from 'discord-akairo';

class Bot extends AkairoClient {
  constructor(CONFIG) {

    super( { }, { } );

    /* #region Handling Commands */
    this.commandHandler = new CommandHandler(
      this,
      {
        directory: './commands/',
        prefix: CONFIG.prefix
      }
    );
    this.commandHandler.loadAll();
    /* #endregion */

    // Log in the Bot
    this._login(CONFIG.auth_token)

    // onReady, log the bot is ready
    this._onReady();
  }

  _login(auth_token) {
    this.login(auth_token)
      .then(console.log(`[✔️ ] 🔓 Logged bot in`))
      .catch(error => console.error(error));
  }

  _onReady() {
    this.once(
      "ready",
      () => {
        console.log(` 🟢  🤖  + ${this.user.username} — ready `);
      }
    );
  }

}

export default Bot;

Ping.mjs - copy-pasted from the official guide:

import {
  Command
} from 'discord-akairo';

class PingCommand extends Command {
  constructor() {
    super(
      'ping', {
        aliases: ['ping']
      }
    );
  }

  exec(message) {
    console.log("pong!");
    return message.reply('Pong!');
  }
}

export default PingCommand;

And index.mjs where I create an instance of the client Bot:

import CONFIG from './config.mjs'; // { prefix: "$", auth_token: <my-token> }
import Bot from './Bot.mjs';
const BOT = new Bot(CONFIG);

Am I doing something wrong? AFAIK I'm following the official guide but with some extra steps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载