|
@@ -92,10 +92,33 @@ const commands = {
|
|
|
.remove({ name: guideName })
|
|
|
.write();
|
|
|
msg.channel.send(
|
|
|
- `${msg.author.toString()} Removed guide "${guideName}!"`
|
|
|
+ `${msg.author.toString()} Removed guide "${guideName}"!`
|
|
|
);
|
|
|
},
|
|
|
- help: msg => {
|
|
|
+ "react to": (msg, s) => {
|
|
|
+ const pattern = /^react to\s+(\<[^\>]+\>)\s+with\s+\<:[^:]+:([^\>]+)\>$/i;
|
|
|
+ let contents = pattern.exec(s);
|
|
|
+ if(contents != null) {
|
|
|
+ let reactable = contents[1];
|
|
|
+ let reactionEmoji = contents[2];
|
|
|
+ if(!client.emojis.has(reactionEmoji)){
|
|
|
+ msg.channel.send(`${msg.author.toString()} I cannot react with this emoji :(`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ db.get("messageReactions").set(reactable, reactionEmoji).write();
|
|
|
+ msg.channel.send(`${msg.author.toString()} Added reaction!`);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "remove reaction to": (msg, s) => {
|
|
|
+ let content = s.substring("remove reaction to ".length).trim();
|
|
|
+ if(!db.get("messageReactions").has(content).value()) {
|
|
|
+ msg.channel.send(`${msg.author.toString()} No such reaction available!`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ db.get("messageReactions").unset(content).write();
|
|
|
+ msg.channel.send(`${msg.author.toString()} Removed reaction!`);
|
|
|
+ },
|
|
|
+ "help": msg => {
|
|
|
let guides = db
|
|
|
.get("guides")
|
|
|
.map(g => g.name)
|
|
@@ -114,7 +137,16 @@ client.on("ready", () => {
|
|
|
});
|
|
|
|
|
|
client.on("message", m => {
|
|
|
- if (m.author.id == client.user.id || m.mentions.users.size == 0) return;
|
|
|
+ if (m.author.id == client.user.id) return;
|
|
|
+
|
|
|
+ let content = m.cleanContent.trim();
|
|
|
+ if(db.get("messageReactions").has(content).value()) {
|
|
|
+ m.react(client.emojis.get(db.get("messageReactions").get(content).value()));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(m.mentions.users.size == 0)
|
|
|
+ return;
|
|
|
|
|
|
if (!db.get("reactableMentionedUsers").intersectionWith(m.mentions.users.map(u => u.id)).isEmpty().value()) {
|
|
|
const emoteId = db
|
|
@@ -127,7 +159,6 @@ client.on("message", m => {
|
|
|
}
|
|
|
|
|
|
if (m.mentions.users.first().id == client.user.id) {
|
|
|
- let content = m.cleanContent.trim();
|
|
|
if(content.startsWith(`@${client.user.username}`)) {
|
|
|
content = content
|
|
|
.substring(`@${client.user.username} `.length);
|