var { Client, Attachment } = require('discord.js'); const UserStorage = require('./user-storage') const session = require('./session') var bot = new Client() /* bot.on('ready', function() { // console.log('ready', arguments) console.log('Logged in as %s - %s\n', bot.username, bot.id); }); */ bot.on('message', async function(message) { try { if (message.author.id === bot.user.id) return; if (message.channel.type === 'dm') { const state = await UserStorage.get(message.author) const nextState = await session(message, state) if (nextState) { await UserStorage.set(message.author, Object.assign({}, state, nextState)) } else { console.warn(`Session did not return state for <${message.author}>: ${message.content}.`) } } } catch (e) { console.error(e) } }); const experiment = (message) => { console.log(message.channel.type, message.toString()) if (message.channel.type === 'dm') { message.channel.send(`Hello, ${message.author.username}`) } } /* bot.on("any", function(event) { console.log(event) }); */ /* bot.on('channelCreate', function() { console.log('channelCreate', Array.from(arguments)) }) bot.on('channelDelete', function() { console.log('channelDelete', Array.from(arguments)) }) bot.on('channelPinsUpdate', function() { console.log('channelPinsUpdate', Array.from(arguments)) }) bot.on('channelUpdate', function() { console.log('channelUpdate', Array.from(arguments)) }) bot.on('clientUserGuildSettingsUpdate', function() { console.log('clientUserGuildSettingsUpdate', Array.from(arguments)) }) bot.on('clientUserSettingsUpdate', function() { console.log('clientUserSettingsUpdate', Array.from(arguments)) }) bot.on('debug', function() { console.log('debug', Array.from(arguments)) }) bot.on('disconnect', function() { console.log('disconnect', Array.from(arguments)) }) bot.on('emojiCreate', function() { console.log('emojiCreate', Array.from(arguments)) }) bot.on('emojiDelete', function() { console.log('emojiDelete', Array.from(arguments)) }) bot.on('emojiUpdate', function() { console.log('emojiUpdate', Array.from(arguments)) }) bot.on('error', function() { console.log('error', Array.from(arguments)) }) bot.on('guildBanAdd', function() { console.log('guildBanAdd', Array.from(arguments)) }) bot.on('guildBanRemove', function() { console.log('guildBanRemove', Array.from(arguments)) }) bot.on('guildCreate', function() { console.log('guildCreate', Array.from(arguments)) }) bot.on('guildDelete', function() { console.log('guildDelete', Array.from(arguments)) }) bot.on('guildMemberAdd', function() { console.log('guildMemberAdd', Array.from(arguments)) }) bot.on('guildMemberAvailable', function() { console.log('guildMemberAvailable', Array.from(arguments)) }) bot.on('guildMemberRemove', function() { console.log('guildMemberRemove', Array.from(arguments)) }) bot.on('guildMembersChunk', function() { console.log('guildMembersChunk', Array.from(arguments)) }) bot.on('guildMemberSpeaking', function() { console.log('guildMemberSpeaking', Array.from(arguments)) }) bot.on('guildMemberUpdate', function() { console.log('guildMemberUpdate', Array.from(arguments)) }) bot.on('guildUnavailable', function() { console.log('guildUnavailable', Array.from(arguments)) }) bot.on('guildUpdate', function() { console.log('guildUpdate', Array.from(arguments)) }) bot.on('message', function() { console.log('message', Array.from(arguments)) }) bot.on('messageDelete', function() { console.log('messageDelete', Array.from(arguments)) }) bot.on('messageDeleteBulk', function() { console.log('messageDeleteBulk', Array.from(arguments)) }) bot.on('messageReactionAdd', function() { console.log('messageReactionAdd', Array.from(arguments)) }) bot.on('messageReactionRemove', function() { console.log('messageReactionRemove', Array.from(arguments)) }) bot.on('messageReactionRemoveAll', function() { console.log('messageReactionRemoveAll', Array.from(arguments)) }) bot.on('messageUpdate', function() { console.log('messageUpdate', Array.from(arguments)) }) bot.on('presenceUpdate', function() { console.log('presenceUpdate', Array.from(arguments)) }) bot.on('rateLimit', function() { console.log('rateLimit', Array.from(arguments)) }) bot.on('ready', function() { console.log('ready', Array.from(arguments)) }) bot.on('reconnecting', function() { console.log('reconnecting', Array.from(arguments)) }) bot.on('resume', function() { console.log('resume', Array.from(arguments)) }) bot.on('roleCreate', function() { console.log('roleCreate', Array.from(arguments)) }) bot.on('roleDelete', function() { console.log('roleDelete', Array.from(arguments)) }) bot.on('roleUpdate', function() { console.log('roleUpdate', Array.from(arguments)) }) bot.on('typingStart', function() { console.log('typingStart', Array.from(arguments)) }) bot.on('typingStop', function() { console.log('typingStop', Array.from(arguments)) }) bot.on('userNoteUpdate', function() { console.log('userNoteUpdate', Array.from(arguments)) }) bot.on('userUpdate', function() { console.log('userUpdate', Array.from(arguments)) }) bot.on('voiceStateUpdate', function() { console.log('voiceStateUpdate', Array.from(arguments)) }) bot.on('warn', function() { console.log('warn', Array.from(arguments)) }) */ bot.login('NTEwNTcwNjkzNDM2NjM3MjA5.DsjCpg.f8dNtS13pOlinF6WmMjJD3Xg3Zc') module.exports = bot