-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
134 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const { PermissionFlagsBits, Events } = require("discord.js"); | ||
const reactions = require("../Schemas/reactionrole.js"); | ||
const requests = require("../Schemas/request-status.js"); | ||
|
||
module.exports = { | ||
name: Events.MessageReactionAdd, | ||
async execute(reaction, user, client) { | ||
if (!reaction || !user || !client) { | ||
return; | ||
} | ||
|
||
if (user.partial) await user.fetch(); | ||
if (reaction.message.partial) await reaction.message.fetch(); | ||
if (reaction.partial) await reaction.fetch(); | ||
|
||
let cID = `<:${reaction.emoji.name}:${reaction.emoji.id}>`; | ||
if (!reaction.emoji.id) { | ||
cID = reaction.emoji.name; | ||
} | ||
const reactData = await reactions.findOne({ | ||
Guild: reaction.message.guildId, | ||
Message: reaction.message.id, | ||
Emoji: cID, | ||
}); | ||
if (reactData) { | ||
const guild = await client.guilds.cache.get(reaction.message.guildId); | ||
if (!guild) { | ||
return; | ||
} | ||
|
||
const member = await guild.members.cache.get(user.id); | ||
if (!member) { | ||
return; | ||
} | ||
|
||
try { | ||
await member.roles.add(reactData.Role); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
|
||
const requestData = await requests.findOne({ | ||
User: user.id, | ||
Type: "Whitelist", | ||
}); | ||
if (requestData) { | ||
const guild = reaction.message.guild; | ||
const newRole = guild.roles.cache.find((role) => role.name === "Femmy"); | ||
const oldRole = member.roles.cache.find( | ||
(role) => role.name === "Wannabe Fem" | ||
); | ||
|
||
const member = reaction.message.guild.members.cache.get(user.id); | ||
if ( | ||
!member || | ||
!member.permissions.has(PermissionFlagsBits.Administrator) | ||
) { | ||
return; | ||
} | ||
if (reaction.emoji.name === "👍") { | ||
await schema.findOneAndUpdate( | ||
{ User: user.id, Type: "Whitelist" }, | ||
{ Status: true } | ||
); | ||
if (member.roles.cache.has(newRole.id)) await member.roles.add(newRole); | ||
if (member.roles.cache.has(oldRole.id)) | ||
await member.roles.remove(oldRole); | ||
} else if (reaction.emoji.name === "👎") { | ||
await schema.findOneAndUpdate( | ||
{ User: user.id, Type: "Whitelist" }, | ||
{ Status: false } | ||
); | ||
} else { | ||
return; | ||
} | ||
} | ||
}, | ||
}; |
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,55 @@ | ||
const { Events } = require("discord.js"); | ||
const reactions = require("../Schemas/reactionrole.js"); | ||
//const requests = require("../Schemas/request-status.js"); | ||
|
||
module.exports = { | ||
name: Events.MessageReactionRemove, | ||
async execute(reaction, user, client) { | ||
if (!reaction || !user || !client) { | ||
return; | ||
} | ||
|
||
if (user.partial) await user.fetch(); | ||
if (reaction.message.partial) await reaction.message.fetch(); | ||
if (reaction.partial) await reaction.fetch(); | ||
|
||
let cID = `<:${reaction.emoji.name}:${reaction.emoji.id}>`; | ||
if (!reaction.emoji.id) { | ||
cID = reaction.emoji.name; | ||
} | ||
const reactData = await reactions.findOne({ | ||
Guild: reaction.message.guildId, | ||
Message: reaction.message.id, | ||
Emoji: cID, | ||
}); | ||
if (reactData) { | ||
const guild = await client.guilds.cache.get(reaction.message.guildId); | ||
if (!guild) { | ||
return; | ||
} | ||
|
||
const member = await guild.members.cache.get(user.id); | ||
if (!member) { | ||
return; | ||
} | ||
|
||
try { | ||
await member.roles.remove(reactData.Role); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
}, | ||
}; | ||
|
||
/* | ||
module.exports = { | ||
name: Events.MessageReactionRemoveAll, | ||
async execute(reaction, user, client) {}, | ||
}; | ||
module.exports = { | ||
name: Events.MessageReactionRemoveEmoji, | ||
async execute(reaction, user, client) {}, | ||
}; | ||
*/ |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.