repl.it
@octavelr/

bip-bot

Nodejs

No description

fork
loading
Files
  • index.js
  • public
  • Packager files
  • package-lock.json
  • package.json
index.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function(req, res){
  res.sendFile(path.join(process.cwd(), "public/index.html"));
}); 

io.on('connection', (socket) => {
  var userid = Math.floor(Math.random() * Math.floor(10));
  console.log('User n° ' + userid + ' connected!');
  socket.on('disconnect', () => {
    console.log('User n° ' + userid + ' disconnected.');
  });
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
});

http.listen(8080, () => {
  console.log('listening on *:8080');
});

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

bot.on("ready", () => {
  bot.user.setActivity("this server", {type:"WATCHING"})
  console.log("Prêt !");
})

bot.on("messageReactionAdd", (reaction, user) => {
  if (user.bot) return;
  if(reaction.emoji.name === "▶") {
    function clean(text) {
      if (typeof(text) === "string") 
        return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
      else
        return text;
    }
    try {
      const code = reaction.message.content;
      let evaled = eval(code);
      if (typeof evaled !== "string") 
        evaled = require("util").inspect(evaled);   		  reaction.message.channel.send(clean(evaled), {code:"xl"});
      } catch (err) {
        reaction.message.channel.send(`\`\`\`xl\n${clean(err)}\n\`\`\``);
      }
    }
});

bot.on("message", message => {
  if (message.author.bot) return;
  const prefix = "$";
  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();
  const allargs = args.join(" ");

  if (!message.author.id === "432508632370774026") return;
  if(message.channel.id === "568451062219145231") {
    message.react("▶");
  }
  if(message.content.includes("?bbo") || message.channel.id === "610612857742032928") {
    io.emit('link', message.content);
    message.react('✅').then((reaction) => {
      setTimeout(() => {
        reaction.remove();
      }, 3000);
    })
  }
  if (command === 'eval') {
    function clean(text) {
      if (typeof(text) === "string") 
        return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
      else
        return text;
    }
    try {
      const code = allargs;
      let evaled = eval(code);
      if (typeof evaled !== "string") 
        evaled = require("util").inspect(evaled);   		  message.channel.send(clean(evaled), {code:"xl"});
      } catch (err) {
        message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
      }
    }
});

bot.login("NDgyOTkxODYxNjM2NzkyMzMx.XLiL9g.zoaPS17TGgSr3uMeQBzsSyJIsc4");
Fetching token
?