bot.js 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const { Dice } = require('./dice')
  2. var { Client, Attachment } = require('discord.js');
  3. var bot = new Client()
  4. /*
  5. bot.on('ready', function() {
  6. // console.log('ready', arguments)
  7. console.log('Logged in as %s - %s\n', bot.username, bot.id);
  8. });
  9. */
  10. bot.on('message', function(message) {
  11. if (message.author.id === bot.user.id) return;
  12. const response = Dice.chat(message.content)
  13. console.log(`message from ${message.author.username}: ${message.content}`)
  14. if (response) {
  15. console.log(response)
  16. const chatLine = response.split('[').join('`').split(']').join('`')
  17. .replace(/= (\d+)\./g, (a, b) => `= **${b}**.`)
  18. console.log(chatLine)
  19. message.reply(chatLine)
  20. }
  21. });
  22. /*
  23. bot.on('channelCreate', function() { console.log('channelCreate', Array.from(arguments)) })
  24. bot.on('channelDelete', function() { console.log('channelDelete', Array.from(arguments)) })
  25. bot.on('channelPinsUpdate', function() { console.log('channelPinsUpdate', Array.from(arguments)) })
  26. bot.on('channelUpdate', function() { console.log('channelUpdate', Array.from(arguments)) })
  27. bot.on('clientUserGuildSettingsUpdate', function() { console.log('clientUserGuildSettingsUpdate', Array.from(arguments)) })
  28. bot.on('clientUserSettingsUpdate', function() { console.log('clientUserSettingsUpdate', Array.from(arguments)) })
  29. bot.on('debug', function() { console.log('debug', Array.from(arguments)) })
  30. bot.on('disconnect', function() { console.log('disconnect', Array.from(arguments)) })
  31. bot.on('emojiCreate', function() { console.log('emojiCreate', Array.from(arguments)) })
  32. bot.on('emojiDelete', function() { console.log('emojiDelete', Array.from(arguments)) })
  33. bot.on('emojiUpdate', function() { console.log('emojiUpdate', Array.from(arguments)) })
  34. bot.on('error', function() { console.log('error', Array.from(arguments)) })
  35. bot.on('guildBanAdd', function() { console.log('guildBanAdd', Array.from(arguments)) })
  36. bot.on('guildBanRemove', function() { console.log('guildBanRemove', Array.from(arguments)) })
  37. bot.on('guildCreate', function() { console.log('guildCreate', Array.from(arguments)) })
  38. bot.on('guildDelete', function() { console.log('guildDelete', Array.from(arguments)) })
  39. bot.on('guildMemberAdd', function() { console.log('guildMemberAdd', Array.from(arguments)) })
  40. bot.on('guildMemberAvailable', function() { console.log('guildMemberAvailable', Array.from(arguments)) })
  41. bot.on('guildMemberRemove', function() { console.log('guildMemberRemove', Array.from(arguments)) })
  42. bot.on('guildMembersChunk', function() { console.log('guildMembersChunk', Array.from(arguments)) })
  43. bot.on('guildMemberSpeaking', function() { console.log('guildMemberSpeaking', Array.from(arguments)) })
  44. bot.on('guildMemberUpdate', function() { console.log('guildMemberUpdate', Array.from(arguments)) })
  45. bot.on('guildUnavailable', function() { console.log('guildUnavailable', Array.from(arguments)) })
  46. bot.on('guildUpdate', function() { console.log('guildUpdate', Array.from(arguments)) })
  47. bot.on('message', function() { console.log('message', Array.from(arguments)) })
  48. bot.on('messageDelete', function() { console.log('messageDelete', Array.from(arguments)) })
  49. bot.on('messageDeleteBulk', function() { console.log('messageDeleteBulk', Array.from(arguments)) })
  50. bot.on('messageReactionAdd', function() { console.log('messageReactionAdd', Array.from(arguments)) })
  51. bot.on('messageReactionRemove', function() { console.log('messageReactionRemove', Array.from(arguments)) })
  52. bot.on('messageReactionRemoveAll', function() { console.log('messageReactionRemoveAll', Array.from(arguments)) })
  53. bot.on('messageUpdate', function() { console.log('messageUpdate', Array.from(arguments)) })
  54. bot.on('presenceUpdate', function() { console.log('presenceUpdate', Array.from(arguments)) })
  55. bot.on('rateLimit', function() { console.log('rateLimit', Array.from(arguments)) })
  56. bot.on('ready', function() { console.log('ready', Array.from(arguments)) })
  57. bot.on('reconnecting', function() { console.log('reconnecting', Array.from(arguments)) })
  58. bot.on('resume', function() { console.log('resume', Array.from(arguments)) })
  59. bot.on('roleCreate', function() { console.log('roleCreate', Array.from(arguments)) })
  60. bot.on('roleDelete', function() { console.log('roleDelete', Array.from(arguments)) })
  61. bot.on('roleUpdate', function() { console.log('roleUpdate', Array.from(arguments)) })
  62. bot.on('typingStart', function() { console.log('typingStart', Array.from(arguments)) })
  63. bot.on('typingStop', function() { console.log('typingStop', Array.from(arguments)) })
  64. bot.on('userNoteUpdate', function() { console.log('userNoteUpdate', Array.from(arguments)) })
  65. bot.on('userUpdate', function() { console.log('userUpdate', Array.from(arguments)) })
  66. bot.on('voiceStateUpdate', function() { console.log('voiceStateUpdate', Array.from(arguments)) })
  67. bot.on('warn', function() { console.log('warn', Array.from(arguments)) })
  68. */
  69. bot.login('NTA5NzMzOTczNjQ0Mjc5ODE4.DsSLOw.AeKUx4C-ceWxHYjf1tbephaRDxw')
  70. module.exports = bot