-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save messages and import them from database
- Loading branch information
Barış Demirci
authored and
repl.it user
committed
Jul 8, 2020
1 parent
87b48d2
commit 611cf34
Showing
8 changed files
with
480 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
module.exports = (master, ...arguments) => { | ||
const SuperError = require("../classes/SuperError"); | ||
|
||
module.exports = async(self, ...arguments) => { | ||
let reactions = []; | ||
for (let i = 4; i < arguments.length; i++) reactions.push(arguments[i]); | ||
master.config.push({ | ||
let message = { | ||
"messageID": arguments[0], | ||
"channelID": arguments[1], | ||
"limit": arguments[2], | ||
"restrictions": arguments[3], | ||
"reactions": reactions | ||
}); | ||
} | ||
if (self.client.user) { | ||
let msg = await self.client.channels.cache.get(message.channelID).messages.fetch(message.messageID).catch(err => { | ||
throw new SuperError("CanNotFetchMesssage", err.toString()); | ||
}); | ||
if (!msg) throw new SuperError("CanNotFetchMesssage", err.toString()); | ||
|
||
for (let { emoji } of reactions) { | ||
emoji = require("./cleanEmoji")(emoji); | ||
let messageReaction = msg.reactions.cache.get(emoji); | ||
if (!messageReaction) await msg.react(emoji).catch((err) => { | ||
throw new SuperError("CanNotReactMesssage", err.toString()); | ||
}); | ||
else { | ||
if (!messageReaction.me) { | ||
messageReaction.users.fetch(); | ||
await msg.react(emoji).catch((err) => { | ||
throw new SuperError("CanNotReactMesssage", err.toString()); | ||
}); | ||
}; | ||
}; | ||
}; | ||
if (self.mongoURL) self.database.createMessage(message); | ||
} | ||
self.config.push(message); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = async(self, messageID, channelID) => { | ||
self.config = self.config.filter(rr => { | ||
return rr.messageID != messageID; | ||
}); | ||
if (self.client.user) { | ||
let message = self.client.channels.cache.get(channelID).messages.cache.get(messageID).reactions.cache.forEach(async reaction => { | ||
await reaction.users.remove(self.client.user.id).catch((err) => { | ||
throw new SuperError("CanNotRemoveReaction", err.toString()); | ||
}); | ||
}); | ||
if (self.mongoURL) self.database.deleteMessage(messageID); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const Mongoose = require("mongoose"); | ||
|
||
const rrSchema = new Mongoose.Schema({ | ||
messageID: { | ||
type: String, | ||
required: true | ||
}, | ||
channelID: { | ||
type: String, | ||
required: true | ||
}, | ||
limit: { | ||
type: Number, | ||
required: true | ||
}, | ||
restrictions: Object, | ||
reactions: { | ||
type: Object, | ||
required: true | ||
} | ||
}); | ||
|
||
module.exports = Mongoose.model("rrModel", rrSchema, "REACTION_ROLE_MODELS"); |
Oops, something went wrong.