0

I'm trying to use the readline for Node.js when working with my Discord bot to make handling inputs easier, however no matter what I do to the code it always runs the bot events only rather than the reader events as well. I'm not sure why this is and I really would like to be able to use both to output messages easier.

My bot:

    'use strict';

const Discord = require('discord.js');
const Chalk = require('chalk');
const Readline = require('readline');
const Token;
const Script = require('./data.js');


const rl = Readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question(Chalk.yellow("Enter guild representative's ID: ", (answer) => {
            rep = answer;
            console.log(Chalk.green("ID Recorded: " + rep));
        }));

        rl.question(Chalk.magenta("Enter embed color: ", (answer) => {
            color = answer;
            console.log(Chalk.green("Color recorded: " + color));
        }));

        rl.question(Chalk.blueBright("Enter guild description: ", (answer) => {
            color = answer;
            console.log(Chalk.green("Color recorded: " + color));
        }));

const bot = new Discord.Client();

bot.on("ready", () => {
    console.log("Bot is ready!");
});


bot.on("message", (message) => {

    if (message.content == ":addPartner") {
        message.guild.channels.find("name", "affiliates").send({ embed });
        message.channel.send(":white_check_mark: Affiliate message sent in #affiliates!");
        */
    }
});
Neuheit
  • 75
  • 3
  • It is unclear what you are trying to accomplish. What inputs are you handling? From whom? How would it be easier? – MxLDevs May 18 '18 at 17:43
  • 1
    i think hes trying to initialize the bot with some node/cmdline stuff beforehand and i think the issue is asyncronous flow here. – Matt Pengelly May 27 '18 at 03:41
  • It wouldn't be because you are using `discord.js`, [I have helped someone else with a line reader while he was using discord.js](https://stackoverflow.com/questions/50560129/javascript-scan-a-google-document-line-by-line-node-js/50575997#50575997) – Aidan el Goste Jun 22 '18 at 01:03

0 Answers0