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 |
Is it possible to change the link to another link?
Yep, it's quite possible with another API.
You'll just have to tweak line 12 to adapt the other API to the link it will give.
i want to make it so it sends disney pictures but idk how
help me this is my err
TypeError: Class constructor Snekfetch cannot be invoked without 'new'
Snekfetch is depreciated
what can i use instead
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to change the link to another link?