0reddit 中文文档教程
0reddit
snoowrap 的一个小扩展,带有一些简化的 reddit API 函数。
Install
npm i 0reddit
Use
const snoowrap = require("snoowrap");
const $reddit = require("0reddit");
const requester = new snoowrap({
/* OAuth credentials here */
});
const $subreddit = $reddit(requester, "SomeSubreddit");
// Submit a link
const submission = await $subreddit.submitLink({
title: "Wracurd",
url: "https://example.com/wracurd.jpg",
oc: true,
flairs: ["artwork", "comic", "color"],
});
// Get own newest submission
const myLatestSubmission = await $subreddit.getNewByMe({ one: true });
API
reddit(requester, subredditName)
:创建一个包含函数的对象。请求者:snoowrap
:Snoowrap 请求者对象。subredditName: String
: Subreddit 名称(不带 r/ 前缀)。await submitLink(post)
:提交链接帖子。post: Object
:描述链接帖子的对象。title: String
: post title.url: String
: post link.oc?: Boolean
: If true, mark post as OC.flairs?: String[]
: Texts of flairs to assign to post.
await getNewByMe(options)
:获取自己的新提交。options?: 对象
:选项对象。one?: Boolean
: If true, return the first submission object (Instead of Array).limit?: Number
: Maximum number of submissions to retrieve.
await markAsOC(submission)
:将提交标记为 OC。提交:提交
:Snowrap 提交。await applyFlairs(submission, flairsTexts)
:将 flairs 分配给提交。提交:提交
:Snowrap 提交。flairsTexts: String[]
:天赋文本数组。
License
???? 0reddit
A small extension of snoowrap with some simplified reddit API functions.
???? Install
npm i 0reddit
???? Use
const snoowrap = require("snoowrap");
const $reddit = require("0reddit");
const requester = new snoowrap({
/* OAuth credentials here */
});
const $subreddit = $reddit(requester, "SomeSubreddit");
// Submit a link
const submission = await $subreddit.submitLink({
title: "Wracurd",
url: "https://example.com/wracurd.jpg",
oc: true,
flairs: ["artwork", "comic", "color"],
});
// Get own newest submission
const myLatestSubmission = await $subreddit.getNewByMe({ one: true });
???? API
reddit(requester, subredditName)
: Create an object containing the functions.requester: snoowrap
: Snoowrap requester object.subredditName: String
: Subreddit name (without r/ prefix).await submitLink(post)
: Submit a link post.post: Object
: Object describing a link post.title: String
: post title.url: String
: post link.oc?: Boolean
: If true, mark post as OC.flairs?: String[]
: Texts of flairs to assign to post.
await getNewByMe(options)
: Get own new submissions.options?: Object
: Options object.one?: Boolean
: If true, return the first submission object (Instead of Array).limit?: Number
: Maximum number of submissions to retrieve.
await markAsOC(submission)
: Mark a submission as OC.submission: Submission
: Snowrap submission.await applyFlairs(submission, flairsTexts)
: assign flairs to a submissions.submission: Submission
: Snowrap submission.flairsTexts: String[]
: Array of flairs texts.