Skip to content

I decided to create a discord bot from scratch, by teaching myself JavaScript, there's a lot I still have to learn about programming as a whole, currently AsneeBot is being created in JavaScript, using my favourite editor, Atom.

xzephhy/Project-Asnee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Synopsis

I decided to create a discord bot from scratch, by teaching myself JavaScript, there's a lot I still have to learn about programming as a whole. However, ever since I've started taking programming as a hobby, this is a project solely based on my own personal development as a programmer. If you stumble across this page, there are some things you should know.

Currently AsneeBot is being created in Python, using VSCode, a source editor i'm getting used too.

This is just some old code, you can ignore this.

Code Example

const Discord = require("discord.js");
const client = new Discord.Client();
const fs = require("fs");

const config = require("./config.json");

// This loop reads the /events/ folder and attaches each event file to the appropriate event.
fs.readdir("./events/", (err, files) => {
  if (err) return console.error(err);
  files.forEach(file => {
    let eventFunction = require(`./events/${events.json}`);
    let eventName = file.split(".")[0];
    // super-secret recipe to call events with all their proper arguments *after* the `client` var.
    client.on(eventName, (...args) => eventFunction.run(client, ...args));
  });
});

client.on("message", message => {
  if (message.author.bot) return;
  if(message.content.indexOf(config.prefix) !== 0) return;

  // This is the best way to define args. Trust me.
  const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();

  // The list of if/else is replaced with those simple 2 lines:
  try {
    let commandFile = require(`./commands/${command}.js`);
    commandFile.run(client, message, args);
  } catch (err) {
    console.error(err);
  }
});

client.login(config.token);

About

I decided to create a discord bot from scratch, by teaching myself JavaScript, there's a lot I still have to learn about programming as a whole, currently AsneeBot is being created in JavaScript, using my favourite editor, Atom.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages