-
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.
- Loading branch information
1 parent
81557e3
commit bd613bc
Showing
2 changed files
with
79 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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', | ||
|
||
async execute(client, interaction) { | ||
const subreddits = ['memes', 'dankmemes', 'comedynecrophilia', 'theletterh', 'okbuddyretard', '196', 'comedyheaven']; | ||
const randomSubreddit = subreddits[Math.floor(Math.random() * subreddits.length)]; | ||
|
||
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)]; | ||
|
||
interaction.reply({ | ||
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 | ||
}], | ||
components: [{ | ||
type: 'ACTION_ROW', | ||
components: [{ | ||
type: 'BUTTON', | ||
style: 'SECONDARY', | ||
label: 'Refresh', | ||
customId: `meme::${interaction.user.id}` | ||
}] | ||
}] | ||
}); | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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', | ||
|
||
async execute(client, interaction) { | ||
const subreddits = ['memes', 'dankmemes', 'comedynecrophilia', 'theletterh', 'okbuddyretard', '196', 'comedyheaven']; | ||
const randomSubreddit = subreddits[Math.floor(Math.random() * subreddits.length)]; | ||
|
||
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)]; | ||
|
||
interaction.update({ | ||
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 | ||
}] | ||
}); | ||
} | ||
}; |