toolbox-devvit
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

toolbox-devvit npm version

Helpers for working with /r/toolbox data from Devvit community apps. Read the documentation.

Installation

npm install --production toolbox-devvit

Usage Example

import {Devvit} from '@devvit/public-api';
import {ToolboxClient} from 'toolbox-devvit';

Devvit.configure({
	redditAPI: true,
	// ...
});

// A simple action that creates a usernote on a post's author
Devvit.addMenuItem({
	location: 'post',
	label: 'Create Test Usernote',
	description: 'Creates a Toolbox usernote for testing',
	onPress: async (event, {reddit, ui, postId}) => {
		const subredditName = (await reddit.getCurrentSubreddit()).name;
		const username = (await reddit.getPostById(postId!)).authorName;
		const text = 'Hihi i am a note';
		const wikiRevisionReason = 'Create note via my custom app';

		const toolbox = new ToolboxClient(reddit);
		await toolbox.addUsernote(subredditName, {
			username,
			text,
		}, wikiRevisionReason);

		ui.showToast({
			appearance: 'success',
			text: 'Note added!',
		});
	},
});

export default Devvit;

License

MIT © the toolbox team

Readme

Keywords

none

Package Sidebar

Install

npm i toolbox-devvit

Weekly Downloads

1

Version

0.3.1

License

MIT

Unpacked Size

50.8 kB

Total Files

21

Last publish

Collaborators

  • eritbh