@JSer/

Node.js Discord Bot Starter

Nodejs

No description

fork
loading
Files
  • index.js
  • package-lock.json

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8273102814215094","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"LyogU2V0dXAKCiAgIDEuIENyZWF0ZSBhIC5lbnYgZmlsZSAoY2xpY2sgYWRkIGZpbGUgdGhlbiByZW1hbmUgaXQgdG8gLmVudikKCiAgIDIuIFB1dCAidG9rZW49IiAod2l0aG91dCBxdW90ZXMpIGludG8gdGhlIC5lbnYgZmlsZSBmb2xsb3dlZCBieSB5b3VyIERpc2NvcmQgQm90IHRva2VuIChObyBzcGFjZXMhKQoKKi8KCmNvbnN0IGRvdGVudiA9IHJlcXVpcmUoImRvdGVudiIpOwoKLyogSWYgeW91IHVzZSB1cHRpbWVyb2JvdCB0byBwaW5nLCBkZWxldGUgdGhpcyBsaW5lIGFuZCBsaW5lIDIyCgpjb25zdCBleHByZXNzID0gcmVxdWlyZSgiZXhwcmVzcyIpOwpjb25zdCBhcHAgPSBleHByZXNzKCk7CgphcHAubGlzdGVuKCgpID0+IGNvbnNvbGUubG9nKCJTZXJ2ZXIgc3RhcnRlZCIpKTsKCmFwcC51c2UoJy9waW5nJywgKHJlcSwgcmVzKSA9PiB7CiAgcmVzLnNlbmQobmV3IERhdGUoKSk7Cn0pOwoKKi8KCmNvbnN0IERpc2NvcmQgPSByZXF1aXJlKCdkaXNjb3JkLmpzJyk7CmNvbnN0IGNsaWVudCA9IG5ldyBEaXNjb3JkLkNsaWVudCgpOwoKY2xpZW50Lm9uKCdyZWFkeScsICgpID0+IHsKICBjb25zb2xlLmxvZyhgTG9nZ2VkIGluIGFzICR7Y2xpZW50LnVzZXIudGFnfSFgKTsKfSk7CgpjbGllbnQub24oJ21lc3NhZ2UnLCBtZXNzYWdlID0+IHsKICAvLyBIZXJlIGlzIHdoZXJlIHlvdSBuZWVkIHRvIGNvZGUKICBpZihtZXNzYWdlLmNvbnRlbnQgPT0gIk5vZGUuanMgaXMgY29vbCIpIHsKICAgIG1lc3NhZ2UuY2hhbm5lbC5zZW5kKCJZZWEhIik7CiAgfQp9KTsKCmNsaWVudC5sb2dpbihwcm9jZXNzLmVudi50b2tlbik7"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Setup

   1. Create a .env file (click add file then remane it to .env)

   2. Put "token=" (without quotes) into the .env file followed by your Discord Bot token (No spaces!)

*/

const dotenv = require("dotenv");

/* If you use uptimerobot to ping, delete this line and line 22

const express = require("express");
const app = express();

app.listen(() => console.log("Server started"));

app.use('/ping', (req, res) => {
  res.send(new Date());
});

*/

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

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', message => {
  // Here is where you need to code
  if(message.content == "Node.js is cool") {
    message.channel.send("Yea!");
  }
});

client.login(process.env.token);
node v10.16.0