Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
ASCII Table does not format as I want it to be

I'm making a discord bot using MySQL, the database stores some usernames and passwords. I fetch the data from the table in MySQL to format it in an ASCII table. The expected output was to be like the image below. (edited it to look better)

.------------------------------------------------.
|       Username       |        Password         |
|----------------------|-------------------------|
|      amonggers       |          no             |
|  no username for u   |          no             |
|  not even this one   |          no             |
|         no           |          no             |
'------------------------------------------------'

But the bot forms the table like this.

.------------------------------------------------.
|       Username       |        Password         |
|----------------------|-------------------------|
| amonggers            |          no 
 |
| no username for u    |          no
 |
| not even this one    |          no
 |
| no                   |          no             |
'------------------------------------------------'

Edit: I also console logged it and the output is a bit better than the discord bot one.

.------------------------------------------------.
|       Username       |        Password         |
|----------------------|-------------------------|
 |amonggers            |          no             
 |no username for u    |          no             
 |not even this one    |          no             
|         no           |          no             |
'------------------------------------------------'

[![Console Log created][3]][3] Heres the command code

client.on("messageCreate", async (message) => {
    if (message.content.toLowerCase().startsWith("=list")) {
        connection.query("SELECT * FROM rbinfo", (err, results) => {
            if (err) {
                console.log(err)
            }
            const ascii = require('ascii-table');
            var table = new ascii()
            table.setHeading('Username', 'Password')
            results.forEach(ok => table.addRow(ok.Username, ok.Password))
        });
    }
});

Any help at all is appreciated, thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!