Bot Code
Added by astuffedtiger on 2018-11-08 16:13:42
bot.on('message', function(user, userID, channelID, message, event) {
    if (!bot.directMessages[channelID]) return; {
        if (bot.users[userID].bot) return;
            if (event.d.attachments[0]) {
                var fileExtension = event.d.attachments[0].url.split('.').pop();
                if ((/(gif|jpg|jpeg|png)$/i).test(fileExtension)) {
                    bot.sendMessage({
                        to: config.channel,
                        message: `<@${userID}> shared a picture of their build!  ${event.d.attachments[0].url}`
                    });
                    bot.sendMessage({
                        to: `${userID}`,
                        message: `Thank you for your submission, it has been sent to the builds channel!`
                    })
                    console.log(`I sent a build from ${user} to the builds channel.`);
                }
                else {
                    bot.sendMessage({
                        to: `${userID}`,
                        message: `Sorry, I only accept image files - .gif, .jpg, .jpeg, .png.`
                    })
                }
            }
    }
});

bot.on('message', function(user, userID, channelID, message, event) {
    if (!bot.directMessages[channelID]) return; {
        if (bot.users[userID].bot) return;
            if (message.substring(0, 1) == '!') {
                var args = message.substring(1).split(' ');
                var cmd = args[0].toLowerCase();

                args = args.splice(1);

                if (cmd == 'wallpaper'){
                    if (event.d.attachments[0]) {
                        bot.sendMessage({
                            to: userID,
                            message: 'Sorry, I don\'t accept attachments for wallpapers. Please provide me with the URL to your wallpaper image.\nUsage: `!wallpaper URL`'
                        })
                        return;
                    }
                    if (args[0] == null) {
                        bot.sendMessage({
                            to: userID,
                            message: 'You need to give me the URL to your wallpaper so I can share it!\nUsage: `!wallpaper URL`'
                        })
                        return;
                    }

                    if (args[0].split('.').length == 1) {
                        bot.sendMessage({
                            to: userID,
                            message: 'The URL you provided me is not valid.' })
                        return;
                    }

                    let extension = args[0].split('.').pop()

                    if ((/(gif|jpg|jpeg|png)$/i).test(extension)) {
                        bot.sendMessage({
                            to: config.wallpapers,
                            message: `Enjoy the latest creation from <@${userID}> - ${args[0]}`
                        })
                        bot.sendMessage({
                            to: userID,
                            message: 'Thanks for your wallpaper, I\'ve posed it to the wallpapers channel!'
                        })
                    } else {
                        bot.sendMessage({
                            to: userID,
                            message: 'Sorry, I only accept image files - .gif, .jpg, .jpeg, .png.'
                        })
                    }
                }
            }
    }
});