mirror of
https://github.com/MrUnknownDE/UnknownAI.git
synced 2026-04-18 05:53:45 +02:00
push 2
This commit is contained in:
45
functions.js
Normal file
45
functions.js
Normal file
@@ -0,0 +1,45 @@
|
||||
module.exports = {
|
||||
getMember: function(message, toFind = "") {
|
||||
toFind = toFind.toLowerCase();
|
||||
|
||||
let target = message.guild.members.get(toFind);
|
||||
|
||||
if (!target && message.mentions.members)
|
||||
target = message.mentions.members.first();
|
||||
|
||||
if (!target && toFind) {
|
||||
target = message.guild.members.find(member => {
|
||||
return (
|
||||
member.displayName.toLowerCase().includes(toFind) ||
|
||||
member.user.tag.toLowerCase().includes(toFind)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (!target) target = message.member;
|
||||
|
||||
return target;
|
||||
},
|
||||
|
||||
formatDate: function(date) {
|
||||
return new Intl.DateTimeFormat("en-US").format(date);
|
||||
},
|
||||
|
||||
promptMessage: async function(message, author, time, validReactions) {
|
||||
// We put in the time as seconds, with this it's being transfered to MS
|
||||
time *= 1000;
|
||||
|
||||
// For every emoji in the function parameters, react in the good order.
|
||||
for (const reaction of validReactions) await message.react(reaction);
|
||||
|
||||
// Only allow reactions from the author,
|
||||
// and the emoji must be in the array we provided.
|
||||
const filter = (reaction, user) =>
|
||||
validReactions.includes(reaction.emoji.name) && user.id === author.id;
|
||||
|
||||
// And ofcourse, await the reactions
|
||||
return message
|
||||
.awaitReactions(filter, { max: 1, time: time })
|
||||
.then(collected => collected.first() && collected.first().emoji.name);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user