You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bot.js~ 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. // Express site serving
  4. const express = require('express');
  5. const app = express();
  6. const bodyParser = require('body-parser');
  7. // Message Array
  8. const responseObject = {
  9. "test": "It worked!",
  10. /* "best girl?": "Big Band.",
  11. "best girl": "Big Band.",
  12. "best grill": "Big Band.",
  13. "best grill?": "Big Band.",
  14. "best gurl": "Big Band.",
  15. "best gurl?": "Big Band.",*/
  16. "best booty": "Squigly, Duh.",
  17. "best booty?": "Squigly, Duh.",
  18. "hi": "Hello there, I'm a dumb bot written by [@calexil#9270](https://github.com/calexil) and [@Timberius#8180](https://github.com/TimboKZ) , you can see my commands here: https://github.com/calexil/BansheeBot/blob/master/Commands.md",
  19. "commands": "You can see my commands here: https://github.com/calexil/BansheeBot/blob/master/Commands.md"
  20. };
  21. // Call the web page with express
  22. app.use(express.static('public'));
  23. app.use(bodyParser.json());
  24. app.use(bodyParser.urlencoded({
  25. extended: true
  26. }));
  27. // Listen for the users local script to post the current track and log it to console
  28. app.listen(process.env.PORT, () => console.log(`App listening on port ${process.env.PORT}!`))
  29. app.post('/endpoint', (req, res) => {
  30. let trackName = req.body.trackName;
  31. res.send('Track received!');
  32. console.log(`Received ${trackName}`);
  33. // Post the current track in discord
  34. if (musicChannel) {
  35. musicChannel.send(trackName);
  36. }
  37. });
  38. // Make sure the bot is in the correct channel and show that the bot has launched successfully in console
  39. client.on('ready', () => {
  40. let musicChannelId = '318919013101076481'; //This number will need too be set you your desired channel id
  41. musicChannel = client.channels.find(channel => channel.id === musicChannelId);
  42. if (!musicChannel) console.error('Could not find music channel!');
  43. console.log('I am ready!');
  44. });
  45. // Reply to keywords in the array
  46. client.on("message", (message) => {
  47. if (responseObject[message.content]) {
  48. message.channel.send(responseObject[message.content]);
  49. }
  50. });
  51. /*// Reply to regex regarding best girl
  52. client.on("message", (message) => {
  53. message.channel.send(message.content.replace(/best g(ir|ri|ur)l+\??/g, "Big Band."));
  54. });*/
  55. let rg = /best g(ir|ri|ur)l+\??/igy;
  56. client.on( "message", (message) => {
  57. let m = message.content.replace( rg, "Big Band" );
  58. if( rg.lastIndex > 0 ) {
  59. message.channel.send(m);
  60. }
  61. } );
  62. // Ping server every 15 minutes to prevent web dyno from sleeping
  63. var http = require("http");
  64. setInterval(function() {
  65. http.get('http://bansheebot.herokuapp.com');
  66. }, 1500000);
  67. // Do not change
  68. client.login(process.env.BOT_TOKEN);