UNPKG

@twitchfy/chatbot

Version:

A powerful node module to make your own Twitch ChatBot

118 lines (117 loc) 5.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AutoMod = void 0; const Base_1 = require("./Base"); const managers_1 = require("./managers"); /** * Represents the automod of a chatroom. */ class AutoMod extends Base_1.Base { /** * The chatroom where the automod is. */ chatroom; /** * The settings manager of the automod. */ settings; /** * Creates a new instance of the automod. * @param chatbot The current instance of the chatbot. * @param chatroom The chatroom where the automod is. */ constructor(chatbot, chatroom) { super(chatbot); this.chatroom = chatroom; this.settings = new managers_1.AutoModSettingsManager(chatbot, this); } /** * Sets the overall level of the automod. This setting will overwrite all the others. * @param level The overall level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setOverall(level) { return await this.settings.edit({ overall_level: level ?? 0 }); } /** * Sets the disability level of the automod. This settings will disable the overall level. * @param level The disability level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setDisability(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, disability: level ?? 0 }); } /** * Sets the aggression level of the automod. This settings will disable the overall level. * @param level The aggression level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setAggression(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, aggression: level ?? 0 }); } /** * Sets the sexuality level of the automod. This settings will disable the overall level. * @param level The sexuality level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setSexuality(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, sexuality_sex_or_gender: level ?? 0 }); } /** * Sets the misogyny level of the automod. This settings will disable the overall level. * @param level The misogyny level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setMisogyny(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, misogyny: level ?? 0 }); } /** * Sets the bullying level of the automod. This settings will disable the overall level. * @param level The bullying level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setBullying(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, bullying: level ?? 0 }); } /** * Sets the harassment level of the automod. This settings will disable the overall level. * @param level The harassment level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setSwearing(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, swearing: level ?? 0 }); } /** * Sets the racism level of the automod. This settings will disable the overall level. * @param level The racism level of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setRacism(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, race_ethnicity_or_religion: level ?? 0 }); } /** * Sets the level of sex based terms of the automod. This settings will disable the overall level. * @param level The level of sex based terms of the automod. If null, it will be set to 0. * @returns The new settings of the automod. */ async setSexBasedTerms(level) { const settingsData = await this.settings.fetch(); const { overall_level, ...rest } = settingsData.data; return await this.settings.edit({ ...rest, sex_based_terms: level ?? 0 }); } } exports.AutoMod = AutoMod;