mirror of
https://github.com/FoxxMD/context-mod.git
synced 2026-05-11 03:00:42 -04:00
Implement basic actions #1
This commit is contained in:
@@ -5,6 +5,10 @@ import Snoowrap, {Comment, Submission} from "snoowrap";
|
||||
export class LockAction extends Action {
|
||||
name?: string = 'Lock';
|
||||
async handle(item: Comment|Submission, client: Snoowrap): Promise<void> {
|
||||
if (item instanceof Submission) {
|
||||
// @ts-ignore
|
||||
await item.lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import Snoowrap, {Comment, Submission} from "snoowrap";
|
||||
export class RemoveAction extends Action {
|
||||
name?: string = 'Remove';
|
||||
async handle(item: Comment|Submission, client: Snoowrap): Promise<void> {
|
||||
// @ts-ignore
|
||||
await item.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ export class ReportAction extends Action {
|
||||
this.content = options.content;
|
||||
}
|
||||
|
||||
async handle(item: Comment|Submission, client: Snoowrap): Promise<void> {
|
||||
async handle(item: Comment | Submission, client: Snoowrap): Promise<void> {
|
||||
// @ts-ignore
|
||||
await item.report({reason: content});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import Action, {ActionJSONConfig} from "../index";
|
||||
import Snoowrap, {Comment, Submission} from "snoowrap";
|
||||
|
||||
export class FlairAction extends Action {
|
||||
text?: string;
|
||||
css?: string;
|
||||
text: string;
|
||||
css: string;
|
||||
name?: string = 'Flair';
|
||||
|
||||
constructor(options: FlairActionOptions) {
|
||||
@@ -12,11 +12,15 @@ export class FlairAction extends Action {
|
||||
if (options.text === undefined && options.css === undefined) {
|
||||
throw new Error('Must define either text or css on FlairAction');
|
||||
}
|
||||
this.text = options.text;
|
||||
this.css = options.css;
|
||||
this.text = options.text || '';
|
||||
this.css = options.css || '';
|
||||
}
|
||||
|
||||
async handle(item: Comment | Submission, client: Snoowrap): Promise<void> {
|
||||
if (item instanceof Submission) {
|
||||
// @ts-ignore
|
||||
await item.assignFlair({text: this.text, cssClass: this.css})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user