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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. if (responseObject[message.content]) {
  54. message.channel.send(message.content.replace(/best g(ir|ri|ur)l+\??/g, "Big Band."));
  55. }
  56. });
  57. // Ping server every 15 minutes to prevent web dyno from sleeping
  58. var http = require("http");
  59. setInterval(function() {
  60. http.get('http://bansheebot.herokuapp.com');
  61. }, 1500000);
  62. // Do not change
  63. client.login(process.env.BOT_TOKEN);