mirror of
https://gitlab.com/ceda_ei/Quadnite-Bot
synced 2026-05-06 05:40:04 +02:00
Add roleplay commands
This commit is contained in:
40
commands/roleplay.js
Normal file
40
commands/roleplay.js
Normal file
@@ -0,0 +1,40 @@
|
||||
function joinUsers(users) {
|
||||
|
||||
if (users.length == 1)
|
||||
return users[0];
|
||||
return users.slice(0, users.length - 1).join(", ")
|
||||
+ ` and ${users[users.length - 1]}`;
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = (forms, gifs) => (ctx) => {
|
||||
|
||||
const gif = gifs[Math.floor(Math.random() * gifs.length)];
|
||||
const message = ctx.message.text.replace(/^[^ ]+\s*/, "")
|
||||
.match(/^((@\w+(\s+|$))*)(.*)/);
|
||||
const users = message[1].trim().split(" ").filter(i => i.length);
|
||||
const reason = message[4];
|
||||
let reply = "";
|
||||
const from = ctx.message.from;
|
||||
const user = from.username ? "@" + from.username : from.first_name;
|
||||
if (users.length > 0 && reason.length > 0)
|
||||
reply = forms.both
|
||||
.replace("{}", user)
|
||||
.replace("{}", joinUsers(users))
|
||||
.replace("{}", reason);
|
||||
else if (users.length > 0)
|
||||
reply = forms.others
|
||||
.replace("{}", user)
|
||||
.replace("{}", joinUsers(users));
|
||||
else if (reason.length > 0)
|
||||
reply = forms.reason
|
||||
.replace("{}", user)
|
||||
.replace("{}", reason);
|
||||
else
|
||||
reply = forms.none
|
||||
.replace("{}", user);
|
||||
|
||||
ctx.replyWithAnimation(gif, {caption: reply});
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user