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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. console.log("best girl?".replace(/best g(ir|ri|ur)l+\??/g, "Big Band."));
  22. // Call the web page with express
  23. app.use(express.static('public'));
  24. app.use(bodyParser.json());
  25. app.use(bodyParser.urlencoded({
  26. extended: true
  27. }));
  28. // Listen for the users local script to post the current track and log it to console
  29. app.listen(process.env.PORT, () => console.log(`App listening on port ${process.env.PORT}!`))
  30. app.post('/endpoint', (req, res) => {
  31. let trackName = req.body.trackName;
  32. res.send('Track received!');
  33. console.log(`Received ${trackName}`);
  34. // Post the current track in discord
  35. if (musicChannel) {
  36. musicChannel.send(trackName);
  37. }
  38. });
  39. // Make sure the bot is in the correct channel and show that the bot has launched successfully in console
  40. client.on('ready', () => {
  41. let musicChannelId = '318919013101076481'; //This number will need too be set you your desired channel id
  42. musicChannel = client.channels.find(channel => channel.id === musicChannelId);
  43. if (!musicChannel) console.error('Could not find music channel!');
  44. console.log('I am ready!');
  45. });
  46. // Reply to keywords in the array
  47. client.on("message", (message) => {
  48. if (responseObject[message.content]) {
  49. message.channel.send(responseObject[message.content]);
  50. }
  51. });
  52. // Reply to regex regarding best girl
  53. client.on("message", (message) => {
  54. if (responseObject[message.content]) {
  55. message.channel.send(message.content.replace(/best g(ir|ri|ur)l+\??/g, "Big Band."));
  56. }
  57. });
  58. // Ping server every 15 minutes to prevent web dyno from sleeping
  59. var http = require("http");
  60. setInterval(function() {
  61. http.get('http://bansheebot.herokuapp.com');
  62. }, 1500000);
  63. // Do not change
  64. client.login(process.env.BOT_TOKEN);