Skip to content

Ihsan-N/Discord-Bot-Starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Discord-Bot-Starter

A basic discord bot

Basic Discord.js Bot

Installation

Use npm init and it will create a package.json file

npm init

Now Make a File called index.js and type npm i discord.js in the terminal.

npm i discord.js

Get your bot token from Discord Developer Portal

const Discord = require("discord.js");
const client = new Discord.Client({
  intents: [
    "GUILDS",
    "GUILD_MESSAGES",
  ],
});



client.on('ready', () => {
  console.log("I'm in");
  console.log(client.user.username);
});

let prefix = "!";// or use the prefix that you want 

client.on("messageCreate", (message) => {

  if (!message.content.startsWith(prefix) || message.author.bot) return;
 
  if (message.content.startsWith(prefix + "ping")) { // ping command
    message.channel.send("pong."); // responds by sending pong 
 
  }
});

client.login(token)//your discord bot token from Developer Portal

To Start the Bot Use node index.js in the terminal.

node index.js

About

A basic discord bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published