Skip to content

Instantly share code, notes, and snippets.

@fuyarde
Last active March 10, 2023 02:59
Show Gist options
  • Save fuyarde/fe708778efd7d1bbe0920c7e0897b271 to your computer and use it in GitHub Desktop.
Save fuyarde/fe708778efd7d1bbe0920c7e0897b271 to your computer and use it in GitHub Desktop.
Discord.JS - Send random cat pics
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
@Ne-k
Copy link

Ne-k commented Oct 20, 2020

Is it possible to put the image inside a Richembed?

@JediMadeThis
Copy link

Ya

@JediMadeThis
Copy link

Is it possible to put the image inside a Richembed?

Yes

@uboabot
Copy link

uboabot commented Jan 13, 2021

it sends the image as a .dream file :/

@KKGAMER
Copy link

KKGAMER commented Jan 22, 2021

it sends the image as a .dream file :/

yes same pls help

@fuyarde
Copy link
Author

fuyarde commented Jan 22, 2021

it sends the image as a .dream file :/

yes same pls help

The API has changed, I'll fix that.
Thanks for the report :)

@fuyarde
Copy link
Author

fuyarde commented Jan 22, 2021

it sends the image as a .dream file :/

yes same pls help

Fixed! :-)

@ballersuperinanauditorium

Is it possible to change the link to another link?

@fuyarde
Copy link
Author

fuyarde commented Mar 4, 2021

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.

@Creeperz653
Copy link

i want to make it so it sends disney pictures but idk how

@Deveroonie
Copy link

help me this is my err
TypeError: Class constructor Snekfetch cannot be invoked without 'new'

@jaspermayone
Copy link

Snekfetch is depreciated

@Deveroonie
Copy link

what can i use instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment