import PointRedeem from "pointRedeems";
import { sendMessage } from "lib/commandUtils";
import { redis } from "lib/redis";

export default new PointRedeem({
	name: "setwelcomemsg",
	cost: 15000,
	title: "Set welcome message",
	input: true,
	color: "#0099FF",
	prompt:
		"Set your welcome message (echoed once per stream). Character limit is 200",
	async execution(msg) {
		if (msg.input.length > 200) {
			await sendMessage(`Your desired welcome message is too long`);
			if (process.env.NODE_ENV === "production")
				await msg.updateStatus("CANCELED");
		}
		await Promise.all([
			sendMessage(
				`${msg.userDisplayName} successfully set their new welcome message`,
			),
			redis.set(`user:${msg.userId}:welcomemessagetext`, "1"),
		]);
	},
});
