mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
add better aniv timeouts, add aniv dodges, fix blank user target bug
This commit is contained in:
19
src/commands/anivtimeouts.ts
Normal file
19
src/commands/anivtimeouts.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Command, sendMessage } from "commands";
|
||||
import { getAnivTimeouts } from "db/dbAnivTimeouts";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'anivtimeouts',
|
||||
aliases: ['anivtimeouts', 'anivtimeout'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
const target = args[0] ? await User.initUsername(args[0].toLowerCase()) : user;
|
||||
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist!`, msg.messageId); return; };
|
||||
const { dodge, dead } = await getAnivTimeouts(target);
|
||||
const percentage = ((dodge / (dead + dodge)) * 100);
|
||||
const message = `Aniv timeouts of ${target.displayName}: Dodge: ${dodge}, Timeout: ${dead}. Dodge percentage: ${isNaN(percentage) ? "0" : percentage.toFixed(1)}%`;
|
||||
await sendMessage(message, msg.messageId);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user