Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/romozz/reddit-discord-image

Random subreddit image in discord
https://github.com/romozz/reddit-discord-image

discord discord-js node nodejs npm-package reddit reddit-api

Last synced: about 1 month ago
JSON representation

Random subreddit image in discord

Awesome Lists containing this project

README

        


Npm package versionNpm package total downloads

# Installation
**Node.js 16.6.0 or newer is required**

```bash
$ npm install reddit-discord-image
```

## MessageCreate v13

```js
const { RedditImage } = require('../dist') // write reddit-discord-image instead ../dist
const { Client, Intents } = require('discord.js')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] })
const reddit = new RedditImage()

client.on('messageCreate', async message => {
if (message.content.startsWith('!reddit')) {
const args = message.content.split(' ').splice(1)
await reddit.fetch({
reddit: args[0], // (required) subreddit name to find pictures
limit: 1000, // (optional) the number of pictures among which you will get 1 random one
sort: 'new', // (optional) a rather useless option, because the pictures are given out randomly
time: 'week' // (optional) how old are the pictures you want to get
})
message.channel.send({ embeds: [reddit] })
}
})

client.login(token)
```

# Interaction v13

You can view interaction example at this link

### More examples in examples