Skip to content

toolbox-team/toolbox-devvit

Repository files navigation

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

About

Helpers forworking with /r/toolbox data from Devvit community apps

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published