mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
renamed unbannableUsers to something better
This commit is contained in:
@@ -3,7 +3,7 @@ import { addAdmin } from "../lib/admins";
|
|||||||
import parseCommandArgs from "../lib/parseCommandArgs";
|
import parseCommandArgs from "../lib/parseCommandArgs";
|
||||||
import { User } from "../user";
|
import { User } from "../user";
|
||||||
|
|
||||||
export default new Command('addadmin', ['addadmin'], 'unbannable', async msg => {
|
export default new Command('addadmin', ['addadmin'], 'streamer', async msg => {
|
||||||
const args = parseCommandArgs(msg.messageText);
|
const args = parseCommandArgs(msg.messageText);
|
||||||
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
|
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
|
||||||
const target = await User.initUsername(args[0].toLowerCase());
|
const target = await User.initUsername(args[0].toLowerCase());
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base";
|
import { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base";
|
||||||
import { User } from "../user";
|
import { User } from "../user";
|
||||||
|
|
||||||
export type userType = 'chatter' | 'admin' | 'unbannable';
|
export type userType = 'chatter' | 'admin' | 'streamer';
|
||||||
|
|
||||||
/** The Command class represents a command */
|
/** The Command class represents a command */
|
||||||
export class Command {
|
export class Command {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { Command, sendMessage } from ".";
|
import { Command, sendMessage } from ".";
|
||||||
import { unbannableUsers } from "..";
|
import { streamerUsers } from "..";
|
||||||
import { removeAdmin } from "../lib/admins";
|
import { removeAdmin } from "../lib/admins";
|
||||||
import parseCommandArgs from "../lib/parseCommandArgs";
|
import parseCommandArgs from "../lib/parseCommandArgs";
|
||||||
import { User } from "../user";
|
import { User } from "../user";
|
||||||
|
|
||||||
export default new Command('removeadmin', ['removeadmin'], 'unbannable', async msg => {
|
export default new Command('removeadmin', ['removeadmin'], 'streamer', async msg => {
|
||||||
const args = parseCommandArgs(msg.messageText);
|
const args = parseCommandArgs(msg.messageText);
|
||||||
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
|
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
|
||||||
const target = await User.initUsername(args[0].toLowerCase());
|
const target = await User.initUsername(args[0].toLowerCase());
|
||||||
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
|
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
|
||||||
if (unbannableUsers.includes(target.id)) { await sendMessage(`Can't remove admin ${target.displayName} as they are managed by the bot program`, msg.messageId); return; };
|
if (streamerUsers.includes(target.id)) { await sendMessage(`Can't remove admin ${target.displayName} as they are managed by the bot program`, msg.messageId); return; };
|
||||||
const data = await removeAdmin(target.id);
|
const data = await removeAdmin(target.id);
|
||||||
if (data === 1) await sendMessage(`${target.displayName} is no longer an admin`, msg.messageId);
|
if (data === 1) await sendMessage(`${target.displayName} is no longer an admin`, msg.messageId);
|
||||||
else await sendMessage(`${target.displayName} isn't an admin`, msg.messageId);
|
else await sendMessage(`${target.displayName} isn't an admin`, msg.messageId);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { chatterId, streamerId, eventSub, commandPrefix, singleUserMode, unbannableUsers } from "..";
|
import { chatterId, streamerId, eventSub, commandPrefix, singleUserMode, streamerUsers } from "..";
|
||||||
import { User } from "../user";
|
import { User } from "../user";
|
||||||
import commands from "../commands";
|
import commands from "../commands";
|
||||||
import { redis } from "bun";
|
import { redis } from "bun";
|
||||||
@@ -23,7 +23,7 @@ eventSub.onChannelChatMessage(streamerId, streamerId, async msg => {
|
|||||||
redis.smembers('disabledcommands')
|
redis.smembers('disabledcommands')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!unbannableUsers.includes(msg.chatterId)) user?.makeVulnerable(); // Make the user vulnerable to explosions
|
if (!streamerUsers.includes(msg.chatterId)) user?.makeVulnerable(); // Make the user vulnerable to explosions if not streamerbot or chatterbot
|
||||||
|
|
||||||
// Parse commands:
|
// Parse commands:
|
||||||
if (msg.messageText.startsWith(commandPrefix)) {
|
if (msg.messageText.startsWith(commandPrefix)) {
|
||||||
@@ -36,8 +36,8 @@ eventSub.onChannelChatMessage(streamerId, streamerId, async msg => {
|
|||||||
case "admin":
|
case "admin":
|
||||||
if (!await isAdmin(user!.id)) return;
|
if (!await isAdmin(user!.id)) return;
|
||||||
break;
|
break;
|
||||||
case "unbannable":
|
case "streamer":
|
||||||
if (!unbannableUsers.includes(msg.chatterId)) return;
|
if (!streamerUsers.includes(msg.chatterId)) return;
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export const eventSub = new EventSubHttpListener({
|
|||||||
|
|
||||||
export const commandPrefix = process.env.COMMAND_PREFIX ?? "!";
|
export const commandPrefix = process.env.COMMAND_PREFIX ?? "!";
|
||||||
|
|
||||||
export const unbannableUsers = [chatterId, streamerId];
|
export const streamerUsers = [chatterId, streamerId];
|
||||||
unbannableUsers.forEach(async id => await addAdmin(id));
|
streamerUsers.forEach(async id => await addAdmin(id));
|
||||||
|
|
||||||
await import("./events");
|
await import("./events");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { streamerApi, streamerId, unbannableUsers } from "..";
|
import { streamerApi, streamerId, streamerUsers } from "..";
|
||||||
import { User } from "../user";
|
import { User } from "../user";
|
||||||
|
|
||||||
type SuccessfulTimeout = { status: true };
|
type SuccessfulTimeout = { status: true };
|
||||||
@@ -10,7 +10,7 @@ type TimeoutResult = SuccessfulTimeout | UnSuccessfulTimeout;
|
|||||||
* @param reason - reason for timeout/ban
|
* @param reason - reason for timeout/ban
|
||||||
* @param duration - duration of timeout. don't specifiy for ban */
|
* @param duration - duration of timeout. don't specifiy for ban */
|
||||||
export const timeout = async (user: User, reason: string, duration?: number): Promise<TimeoutResult> => {
|
export const timeout = async (user: User, reason: string, duration?: number): Promise<TimeoutResult> => {
|
||||||
if (unbannableUsers.includes(user.id)) return { status: false, reason: 'illegal' };
|
if (streamerUsers.includes(user.id)) return { status: false, reason: 'illegal' };
|
||||||
|
|
||||||
// Check if user already has a timeout
|
// Check if user already has a timeout
|
||||||
const banStatus = await streamerApi.moderation.getBannedUsers(streamerId, { userId: user.id }).then(a => a.data);
|
const banStatus = await streamerApi.moderation.getBannedUsers(streamerId, { userId: user.id }).then(a => a.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user