Kenny P

@kpostal10 (27)
__dirname not defined on nodejs server
posted to Ask by NIghel123

two ways to fix this use process.cwd()
or you can fix it via path
const path = require('path'); var __dirname = path.resolve();

How do I install mySQL on my Project
posted to Ask by OblivionTDW

Relooking at the repl link provided if you are wanting to do login and have a website and stuff it might be better for you to look into node.js and use express. I dont think you could really do a login with a simple html thing uless you call an external server.
You can do login information however there will be no "main" server for it so logging in will do nothing for them.
(If you switch to node.js there are more powerful ways to render html pages with custom user information, React.js, pug (different format doestn use <> but still lets you do html), handlebars, or e.js)

You can use MySQL with just plain js. However the database itself would have to be hosted externally from repl.it (you can not install mysql on repl.it)
The following is how you would do it using express
And for what I think you are wanting to do you would want the session store for MySQL
var MySQLStore = require('express-mysql-session')(session);
const mysql = require("mysql");

Quick example of some code.

    const sessionoptions = {
        //checkExpirationInterval: 1000 * 60 * 15,// 15 min // How frequently expired sessions will be cleared; milliseconds.
        expiration: 1000 * 60 * 60 * 24 * 7,// 1 week // The maximum age of a valid session; milliseconds.
        createDatabaseTable: true,// Whether or not to create the sessions database table, if one does not already exist.
        schema: {
            tableName: 'sessions',
            columnNames: {
                session_id: 'session_id',
                expires: 'expires',
                data: 'data'
   const dbConnectionInfosession = { 
        multipleStatements: true,    
        connectionLimit : 10,
        host: "localhost",
        user: "root",
        password: config.passwordDB,
        database: "session"
    const poolsession = mysql.createPool(dbConnectionInfosession);

    const sessionStore = new MySQLStore(sessionoptions,poolsession);
    /*cookie: {
        secure: true,
         maxAge: 36000000 },*/
    secret: secretRandom,
    saveUninitialized: false,
    resave: false,
    store: sessionStore,

Also side note from personal experince call the session store option first in your app chai. (app.use(sessionStore) -> app.use("someViewthing") -> app.get('/index'))
If you follow that

All code provided does work in a production enviorment.

Making a discord bot using the discord.js Commando framework
posted to Tutorials by TheDrone7

Looks good, warning to anyone that follows this tutorial on repl.it, using sqlite as the settings provider might break or become corrupt.

Variables showing blank after being defined
posted to Ask by RossJames

Right now from the code that is there the only 2 places where authlevel is lines 107 and 108.

Can you create a database with Repl?
posted to Ask by CarrollN

@TheDrone7 I want to correct the statement "they reset the files everytime your repl run". That is not true (Unless things have changed) What happenes when you click run is it sends all the files / code of to a virtual server. Thats how you can make files with a repl but will not see them. The repl itself will not look at the code after it is done running to modify the base repl.

They (repl.it team) are working on making some type of data storage coming soon (tm). What you can do is connect to an external database from the repl and that is fine.

Database-Like File
posted to Ask by KiKUP

As stated by TheDrone7 It is highly recommended to use some sort of external database. If you try to use a file on repl while sometimes it will work and save the data it will get corrupt at some point. As for making it unchangeable by any users, handling it server side and protecting it and using some sort of authentification system with tokens might be something you could look into.

How do I install mySQL on my Project
posted to Ask by OblivionTDW

@OblivionTDW node.js is seprated from the HTML / css / js repl. You would click new repl and select Nodejs (javascript) and that will be the repl you run.
You will have to transfer all the files over. The main website libary for js is called "express" https://www.npmjs.com/package/express

Why does this not work?
posted to Ask by ebest

You only need to post it once. Stop posting the same question over and over.
Someone else was able to see the second one they responded to it. That post has since been taken down.

Can Repl.it have a Stack overflow community?
posted to Ask by PYer

@RobertoBean Also, on a question about discord bots, someone posted that there was a error in someones code and that it was their falt the code wasnt sending messages to the channel, rather than them acknowledging there was a rate limit, I wanted to respond and correct that but nope I couldn't didn't have any reputation.

Can I create a free auto-graded class?
posted to Ask by tlc35us

As far as making a class with out being a teacher all you need to do is go to Account, then roles and click teacher. Then a teacher tab will appear next to "my repls" where you can create class rooms. Also some good information under https://repl.it/site/pricing

Variables showing blank after being defined
posted to Ask by RossJames

@RossJames No I was not, do not recalll seeing where it was specified my mistake. From what I see you set it authlevel on line 8 then you set auth to (authlevel) 122 but if you are trying to pull that from outside the file you might get conflicting varible names.

How do I install mySQL on my Project
posted to Ask by OblivionTDW

@ArchieMaclean Re looking at it he is using a html / css / js repl so what you put might be more valible, mine is a node.js implementation (I have since updated my main post above) where the "server" handles the login and displaying of webpages and allows the rendering of custom webpages where user information (varibles) can be passed through. However I dont think doing the type of repl he has currently can do a login system because of how it functions.

How do I install mySQL on my Project
posted to Ask by OblivionTDW

@ArchieMaclean All good, all you did was Cunningham's law "the best way to get the right answer on the internet is not to ask a question; it's to post the wrong answer."

How do I install mySQL on my Project
posted to Ask by OblivionTDW

@ArchieMaclean You can do mysql with javascript you dont need some type of external file thing. I have before and its really powerful when it comes to data storage for a javascript application.

Making a discord bot using the discord.js Commando framework
posted to Tutorials by TheDrone7

@pizzafox Nothing wrong with being critical about a post, there is just a right and wrong way to appraoch it. Dont want to come off sounding like a "know-it-all" but you also want to make it to where what you are saying makes sense and is contributing (not taking away from) the post.
Thanks for providing another perspective to the bot.
Also @TheDrone7 might want to check the docs:
It is clientPermissions

This is a really nice list of all the things you can put when you make a command in the constructor: https://discord.js.org/#/docs/commando/master/typedef/CommandInfo

Making a discord bot using the discord.js Commando framework
posted to Tutorials by TheDrone7

@pizzafox As for the class name being captiol, it does not matter all you are doing is exporting the class object. Weather or not it is captiol will not affect the function of the bot. For how long I've been doing JS bots this is one of the better tutorials I've seen; Espically for commando. Also just because it is not regex does not mean it will not work the same. I like the fact that he showed that it can be more than one line in the validate function because a novice might do more custom validation in that check.

As for the other "bugs" you fixed I would like to know which ones they are? Because I pasted his code in a bot and it ran just fine as it is.

And for editing the node_modules that complitly fine. I've done it for my bot to add a header to the built in help method saying that this bot was coded in commando and who made it.

💲Make Money 💲Building a Bot 🤖
posted to Ask by amasad

Is mat going to be making any money off for writing the code to interact with repl talk?

Make a discord-bot using the discord.js Commando framework
posted to Tutorials

Sqlite does not work with repl.it and you do not go any further than saying that sqlite is required, what do you do with sqlite?
For the custom commands can you add how to use the validate option?
And for custom commands you should use async run() to work better with how the framework works. (To work with the async function of javascript)
Also might want to link some documentation: https://discord.js.org/#/docs/commando/master/general/welcome

posted to Ask by 2020_JustinJust

Saw that going to be a issue with your System.out.println(fillCheckerboard(array)). Right now you are current not returning anything so there is nothing to print. Which why you get the void error on the system.out.println line, there are 2 ways to fix it, make your fillCheckerboard() return something, or call it above the System.out.println()
For fixing it myself I chose to remove it from the system.out.println() and call it above it like this:
fillCheckerboard(array); System.out.println();
Now for the method not working, you are calling a non static method from a static one. Java really doesnt like that. I fixed it by changing it to public static void fillCheckerboard(char [] [] board) and there seems to be no errors when running it and you get this result: https://i.imgur.com/FHqSZ4Y.png

posted to Ask by 2020_JustinJust

What it is doing is treating fillCheckerboard[5][5] as a 2d array. Since that does not exist it errors. You are wanting to call the fillCheckerboard method which takes a paramter of 2d array.
I imagine that you want to be able to do things with the 2d array.
You first need to create the 2d (assuming char) array.
char[][] array = new char[5][5];
Next with the system.out.print() you will want to pass it like this:

If you run into any bugs with that let me know

Get json file
posted to Ask by Coder100

This is how I've done it in the past, and for your unexpected end of JSON input your file might not be setup correctly.
const guildProp = require("../../guildProperties.json");
var channelId=guildProp[message.guild.id].guildLogChannelId;
That is how you access stuff from it, its just like a normal json object, just stored in a file rather than a var (let) in the program
And to rite to it I make a simple json object
warn[message.guild.id] = {
warnamount: x+1,
rule : args2[0]
and then I do a fs.write to the file
fs.writeFile("./warn.json", JSON.stringify(warn, null, 4), err => {
if(err) throw err;

Maybe this can help you.

Repl Talk Discord Bot
posted to Share by mat1

link kpostal10#9568