0.1.0 • Published 11 months ago

@eritbh/toolbox-devvit v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

toolbox-devvit

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

Installation

npm install --production @eritbh/toolbox-devvit

Usage Example

Install the library

import {Devvit, RedditAPIClient, Context} from '@devvit/public-api';
import {ToolboxClient} from '@eritbh/toolbox-devvit';

const reddit = new RedditAPIClient();
const toolbox = new ToolboxClient(reddit);

// A simple action that creates a usernote on a post's author
Devvit.addAction({
	context: Context.POST,
	name: 'Create Test Usernote',
	description: 'Creates a Toolbox usernote for testing',
	handler: async (event, metadata) => {
		const subreddit = await reddit.getCurrentSubreddit(metadata);
		const user = event.post.author!;
		const note = 'Hihi i am a note';
		await toolbox.createUsernote({subreddit, user, note}, metadata);
		return {success: true, message: 'Note added!'};
	}
});

export default Devvit;

License

MIT © eritbh

0.1.0

11 months ago