Last active
March 10, 2023 02:59
-
-
Save tt024/fe708778efd7d1bbe0920c7e0897b271 to your computer and use it in GitHub Desktop.
Discord.JS - Send random cat pics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Discord = require("discord.js"); | |
const client = new Discord.Client(); | |
const {get} = require("snekfetch"); | |
const TOKEN = 'YOUR_BOT_TOKEN_HERE' | |
const PREFIX = ";;"; | |
client.on('message', message => { | |
if (message.content.startsWith(PREFIX + 'cat')) { | |
try { | |
get('https://aws.random.cat/meow').then(response => { | |
message.channel.send({files: [{attachment: response.body.file, name: `cat.${response.body.file.split('.')[4]}`}]}); | |
console.log('random cat picture'); | |
}) | |
} catch (e) { | |
console.log('error!'); | |
} | |
}; | |
}); | |
client.login(TOKEN); | |
// from https://github.com/trrb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what can i use instead