Quadnite-Bot/commands/absurdify.js

28 lines
603 B
JavaScript
Raw Normal View History

2019-02-12 00:15:02 +01:00
function absurdify(text) {
const text_array = text.split("");
return text_array.map((character) =>
Math.random() > 0.5 ? character.toLowerCase(): character.toUpperCase())
.join("");
}
module.exports = () => (ctx) => {
const message = ctx.message.text.replace(/^[^ ]+/, "");
if (message) {
return absurdify(message);
} else {
2024-01-24 20:08:35 +01:00
if (ctx.message.reply_to_message && !ctx.message.reply_to_message.is_topic_message)
2019-02-12 00:15:02 +01:00
return absurdify(ctx.message.reply_to_message.text);
else
return "Need text to absurdify. Send /absurdify text or reply to a"
+ "message with /absurdify";
}
};