import { Command, sendMessage } from "lib/commandUtils";
import { redis } from "lib/redis";
import User from "user";

export default new Command({
	name: "backshot",
	aliases: ["backshot"],
	usertype: "chatter",
	execution: async (msg, user) => {
		const targets = await redis.keys(`user:*:haschatted`);
		const selection = targets[Math.floor(Math.random() * targets.length)]!;
		const target = await User.initUserId(selection.slice(5, -11));
		await sendMessage(
			`${user.displayName} backshotted ${target?.displayName}`,
			msg.messageId,
		);
	},
});
