mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-18 21:11:39 +01:00
added silverbullets, added gettimeout command
This commit is contained in:
@@ -78,6 +78,7 @@ COMMAND|FUNCTION|USER|ALIASES|DISABLEABLE
|
||||
COMMAND|FUNCTION|USER|ALIASES|DISABLEABLE
|
||||
-|-|-|-|-
|
||||
`getcommands [enabled/disabled]`|Get a list of all, enabled or disabled commands|anyone|`getcommands` `getc`|:x:
|
||||
`gettimeout {target}`|Get the remaining timeout duration of targeted user|anyone|`gettimeout` `gett`|:white_check_mark:
|
||||
`vulnchatters`|Get amount of chatters vulnerable to explosives|anyone|`vulnchatters` `vulnc`|:white_check_mark:
|
||||
`disablecommand {command/item}`|Disable a specific command/item|admins|`disablecommand`|:x:
|
||||
`enablecommand {command/item}`|Re-enable a specific command/item|admins|`enablecommand`|:x:
|
||||
@@ -91,4 +92,6 @@ COMMAND|FUNCTION|USER|ALIASES|DISABLEABLE
|
||||
NAME|COMMAND|FUNCTION|ALIASES
|
||||
-|-|-|-
|
||||
Blaster|`blaster {target}`|Times targeted user out for 60 seconds|`blaster` `blast`
|
||||
Silver Bullet|`silverbullet {target}`|Times targeted user out for 24 hours|`silverbullet` `execute`
|
||||
Grenade|`grenade`|Times a random vulnerable chatter out for 60 seconds|`grenade`
|
||||
TNT|`tnt`|Give 5-10 random chatters 60 second timeouts|`tnt`
|
||||
|
||||
16
bot/commands/gettimeout.ts
Normal file
16
bot/commands/gettimeout.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Command, sendMessage } from ".";
|
||||
import { streamerApi, streamerId } from "..";
|
||||
import { buildTimeString } from "../lib/dateManager";
|
||||
import parseCommandArgs from "../lib/parseCommandArgs";
|
||||
import { User } from "../user";
|
||||
|
||||
export default new Command('gettimeout', ['gett', 'gettimeout'], 'chatter', async msg => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
|
||||
const target = await User.initUsername(args[0].toLowerCase());
|
||||
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
|
||||
const data = await streamerApi.moderation.getBannedUsers(streamerId, { userId: target.id }).then(a => a.data);
|
||||
if (!data[0]) { await sendMessage(`Chatter ${target.displayName} isn't timed out`, msg.messageId); return; };
|
||||
if (data[0].expiryDate) { await sendMessage(`${target.displayName} is still timed out for ${buildTimeString(data[0].expiryDate.getTime(), Date.now())}`, msg.messageId); return; };
|
||||
await sendMessage(`${target.displayName} is permanently banned`, msg.messageId);
|
||||
});
|
||||
@@ -7,14 +7,14 @@ import parseCommandArgs from "../lib/parseCommandArgs";
|
||||
import { timeout } from "../lib/timeout";
|
||||
import { User } from "../user";
|
||||
|
||||
const ITEMNAME = 'blaster';
|
||||
const ITEMNAME = 'silverbullet';
|
||||
|
||||
export default new Item(ITEMNAME, 'Blaster', 's',
|
||||
'Times a specific person out for 60 seconds',
|
||||
['blaster', 'blast'],
|
||||
export default new Item(ITEMNAME, 'Silver bullet', 's',
|
||||
'Times a specific person out for 24 hours',
|
||||
['execute', 'silverbullet'],
|
||||
async (msg, user) => {
|
||||
const userObj = await getUserRecord(user);
|
||||
if (userObj.inventory[ITEMNAME]! < 1) { await sendMessage(`You don't have any blasters!`, msg.messageId); return; };
|
||||
if (userObj.inventory[ITEMNAME]! < 1) { await sendMessage(`You don't have any silver bullets!`, msg.messageId); return; };
|
||||
const messagequery = parseCommandArgs(msg.messageText);
|
||||
if (!messagequery[0]) { await sendMessage('Please specify a target'); return; };
|
||||
const target = await User.initUsername(messagequery[0].toLowerCase());
|
||||
@@ -23,9 +23,9 @@ export default new Item(ITEMNAME, 'Blaster', 's',
|
||||
|
||||
if (await user.itemLock()) { await sendMessage('Cannot use an item right now', msg.messageId); return; };
|
||||
await user.setLock();
|
||||
const result = await timeout(target, `You got blasted by ${user.displayName}!`, 60);
|
||||
const result = await timeout(target, `You got blasted by ${user.displayName}!`, 60 * 60 * 24);
|
||||
if (result.status) await Promise.all([
|
||||
sendMessage(`GOTTEM ${target.displayName} got BLASTED by ${user.displayName} GOTTEM`),
|
||||
sendMessage(`${target.displayName} RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO`),
|
||||
changeItemCount(user, userObj, ITEMNAME),
|
||||
createTimeoutRecord(user, target, ITEMNAME),
|
||||
createUsedItemRecord(user, ITEMNAME)
|
||||
17
bot/lib/dateManager.ts
Normal file
17
bot/lib/dateManager.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export function buildTimeString(time1: number, time2: number) {
|
||||
const diff = Math.abs(time1 - time2);
|
||||
const timeobj = {
|
||||
day: Math.floor(diff / (1000 * 60 * 60 * 24)),
|
||||
hour: Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
|
||||
minute: Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)),
|
||||
second: Math.floor((diff % (1000 * 60)) / 1000)
|
||||
};
|
||||
const stringarray: string[] = [];
|
||||
for (const [unit, value] of Object.entries(timeobj)) {
|
||||
if (value === 0) continue;
|
||||
if (unit === 'second' && timeobj.day > 0) continue;
|
||||
stringarray.push(`${value} ${unit}${value === 1 ? '' : 's'}`);
|
||||
};
|
||||
const last = stringarray.pop();
|
||||
return stringarray.length === 0 ? last : stringarray.join(', ') + " and " + last;
|
||||
};
|
||||
Reference in New Issue
Block a user