-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: sadie brooklyn <senkodev@gmail.com>
- Loading branch information
1 parent
2c3b268
commit 2b3b15d
Showing
1 changed file
with
29 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,36 @@ | ||
const snoo = require('snoowrap'); | ||
|
||
const r = new snoo({ | ||
userAgent: 'G.A.S-Bot<Next>', | ||
clientId: '49z0Xcek_8DeB8LyDjsjyA', | ||
clientSecret: process.env.REDDIT_TOKEN, | ||
refreshToken: process.env.REDDIT_REFRESH | ||
const Snoowrap = require('snoowrap'); | ||
const reddit = new Snoowrap({ | ||
userAgent: 'gasbot', | ||
clientId: process.env.REDDIT_CLIENT_ID, | ||
clientSecret: process.env.REDDIT_TOKEN, | ||
refreshToken: process.env.REDDIT_REFRESH | ||
}); | ||
|
||
module.exports = { | ||
name: 'meme', | ||
description: 'Shows you a meme!', | ||
name: 'meme', | ||
description: 'Displays a meme from Reddit', | ||
|
||
async execute(client, message) { | ||
const memeReddits = ['memes', 'dankmemes', 'comedynecrophilia', 'theletterh', 'okbuddyretard', '196', 'comedyheaven']; | ||
const sourceReddit = memeReddits[Math.floor(Math.random() * memeReddits.length)]; | ||
async execute(client, message) { | ||
const subreddits = ['memes', 'dankmemes', 'comedynecrophilia', 'theletterh', 'okbuddyretard', '196', 'comedyheaven']; | ||
const randomSubreddit = subreddits[Math.floor(Math.random() * subreddits.length)]; | ||
|
||
const post = r.getHot(sourceReddit); | ||
console.log(post); | ||
const listing = (await reddit.getHot(randomSubreddit)).filter(p => !p.over_18 && p.is_reddit_media_domain && !p.is_video); | ||
const post = listing[Math.floor(Math.random() * listing.length)]; | ||
|
||
message.channel.send({ | ||
embeds: [{ | ||
title: 'this is supposed to be real', | ||
description: sourceReddit, | ||
color: client.config.color | ||
}] | ||
}); | ||
} | ||
message.channel.send({ | ||
embeds: [{ | ||
title: post.title.replaceAll(/g/giu, 'q'), | ||
url: `https://reddit.com${post.permalink}`, | ||
image: post.preview.images[0].variants.gif?.source ?? post.preview.images[0].source, | ||
author: { | ||
name: post.subreddit_name_prefixed | ||
}, | ||
footer: { | ||
text: `u/${post.author.name}` | ||
}, | ||
timestamp: post.created * 1000, | ||
color: client.config.color | ||
}] | ||
}); | ||
} | ||
}; |