forked from ZekeAzrail/Andoi
-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
234 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,201 @@ | ||
const { Collection, MessageEmbed } = require("discord.js"); | ||
const { Database } = require("quickmongo"); | ||
module.exports = (client) => { | ||
const db = new Database(client.config.Mongo); | ||
|
||
const Invites = new Collection(); | ||
client.on("ready", () => { | ||
client.guilds.cache.forEach((guild) => { | ||
if (!guild.me.hasPermission("MANAGE_GUILD")) return; | ||
guild | ||
.fetchInvites() | ||
.then((_invites) => { | ||
Invites.set(guild.id, _invites); | ||
}) | ||
.catch((err) => {}); | ||
}); | ||
}); | ||
client.on("inviteCreate", (invite) => { | ||
var gi = Invites.get(invite.guild.id) || new Collection(); | ||
gi.set(invite.code, invite); | ||
Invites.set(invite.guild.id, gi); | ||
}); | ||
client.on("inviteDelete", (invite) => { | ||
var gi = Invites.get(invite.guild.id) || new Collection(); | ||
gi.delete(invite.code); | ||
Invites.set(invite.guild.id, gi); | ||
}); | ||
//#endregion | ||
|
||
client.on("guildMemberAdd", async (member) => { | ||
const guild = member.guild, | ||
fake = | ||
(Date.now() - member.createdAt) / (1000 * 60 * 60 * 24) <= 3 | ||
? true | ||
: false; | ||
const conf = await member.guild.getConfig(); | ||
let channel = conf?.welcomeChannel; | ||
|
||
guild | ||
.fetchInvites() | ||
.then((invites) => { | ||
const invite = | ||
invites.find( | ||
(_i) => gi.has(_i.code) && gi.get(_i.code).uses < _i.uses | ||
) || | ||
gi.find((_i) => !invites.has(_i.code)) || | ||
guild.vanityURLCode; | ||
Invites.set(member.guild.id, invites); | ||
var content = `${member} has joined the server.`, | ||
total = 0, | ||
regular = 0, | ||
_fake = 0, | ||
bonus = 0; | ||
if (invite == guild.vanityURLCode) | ||
content = `-member- has joined the server! But don't know that invitation he came up with. :tada:`; | ||
else | ||
content = `The -member-, joined the server using the invitation of the -target-. He now has -total- invites`; | ||
|
||
if (invite.inviter) { | ||
db.set(`invites.${member.id}.inviter`, invite.inviter.id); | ||
if (fake) { | ||
total = db.add(`invites.${invite.inviter.id}.total`, 1); | ||
_fake = db.add(`invites.${invite.inviter.id}.fake`, 1); | ||
} else { | ||
total = db.add(`invites.${invite.inviter.id}.total`, 1); | ||
regular = db.add(`invites.${invite.inviter.id}.regular`, 1); | ||
} | ||
var im = guild.member(invite.inviter.id); | ||
bonus = db.get(`invites.${invite.inviter.id}.bonus`) || 0; | ||
if (im) | ||
global.onUpdateInvite(im, guild.id, Number(total + Number(bonus))); | ||
} | ||
|
||
db.set(`invites.${member.id}.isfake`, fake); | ||
|
||
if (channel) { | ||
content = content | ||
.replace("-member-", `${member}`) | ||
.replace("-target-", `${invite.inviter}`) | ||
.replace("-total-", `${total + bonus}`) | ||
.replace("-regular-", `${regular}`) | ||
.replace("-fakecount-", `${_fake}`) | ||
.replace( | ||
"-invite-", | ||
`${ | ||
invite && invite.code != undefined | ||
? invite.code | ||
: "what is that?" | ||
}` | ||
) | ||
.replace("-fake-", `${fake}`); | ||
channel.send(content); | ||
} | ||
}) | ||
.catch(); | ||
}); | ||
client.on("guildMemberRemove", async (member) => { | ||
var settings = await member.guild.getConfig(); | ||
var channel = settings?.leaveChannel; | ||
var total = 0, | ||
bonus = 0, | ||
regular = 0, | ||
fakecount = 0; | ||
var data = db.get(`invites.${member.id}`); | ||
if (!data) { | ||
if (channel) { | ||
content = content.replace("-member-", `${member}`); | ||
channel.send(content); | ||
} | ||
return; | ||
} | ||
|
||
if (data.isfake && data.inviter) { | ||
fakecount = db.substract(`invites.${data.inviter}.fake`, 1); | ||
total = db.substract(`invites.${data.inviter}.total`, 1); | ||
} else if (data.inviter) { | ||
regular = db.substract(`invites.${data.inviter}.regular`, 1); | ||
total = db.substract(`invites.${data.inviter}.total`, 1); | ||
} | ||
if (data.inviter) bonus = db.get(`invites.${data.inviter}.bonus`) || 0; | ||
|
||
var im = member.guild.member(data.inviter); | ||
|
||
db.add(`invites.${data.inviter}.leave`, 1); | ||
if (channel) { | ||
content = content | ||
.replace("-member-", `${member}`) | ||
.replace("-target-", `${im ? im : data.inviter}`) | ||
.replace("-total-", `${Number(total) + Number(bonus)}`) | ||
.replace("-regular-", `${regular}`) | ||
.replace("-fakecount-", `${fakecount}`) | ||
.replace("-fake-", `${data.isfake}`); | ||
channel.send(content); | ||
} | ||
}); | ||
client.on("message", async (message) => { | ||
var config = await message.guild.getConfig(); | ||
if (!message.content.startsWith(config.prefix)) return; | ||
const args = message.content.slice(config.prefix.length).trim().split(/ +/); | ||
if (args[0] === "invites") { | ||
const command = { | ||
name: "invites", | ||
category: "invites", | ||
}; | ||
client.commands.set(command.name, command); | ||
var victim = | ||
message.mentions.users.first() || | ||
client.users.cache.get(args[0]) || | ||
message.author; | ||
var data = db.get(`invites.${victim.id}`) || { | ||
total: 0, | ||
fake: 0, | ||
inviter: null, | ||
regular: 0, | ||
bonus: 0, | ||
leave: 0, | ||
}; | ||
var embed = new MessageEmbed() | ||
.setDescription( | ||
`You have **${(data.total || 0) + (data.bonus || 0)}** invites! (**${ | ||
data.regular || 0 | ||
}** regular, **${data.bonus || 0}** bonus, **${ | ||
data.leave || 0 | ||
}** leaves, **${data.fake || 0}** fake)` | ||
) | ||
.setColor("RANDOM"); | ||
message.channel.send(embed); | ||
} else if (args[0] === "invites-leaderboard") { | ||
const command = { | ||
name: "invites-leaderboard", | ||
category: "invites", | ||
}; | ||
client.commands.set(command.name, command); | ||
var data = db.get(`invites`) || {}; | ||
|
||
var list = Object.keys(data) | ||
.map((_data) => { | ||
return { | ||
Id: _data, | ||
Value: (data[_data].total || 0) + (data[_data].bonus || 0), | ||
}; | ||
}) | ||
.sort((x, y) => y.Value - x.Value); | ||
|
||
var embed = new MessageEmbed().addField( | ||
"Invites", | ||
` | ||
** **${list | ||
.splice(0, 10) | ||
.map( | ||
(item, index) => | ||
`\`${index + 1}.\` <@${item.Id}>: \`${item.Value} invite\`` | ||
) | ||
.join("\n")} | ||
` | ||
); | ||
|
||
message.channel.send(embed); | ||
} | ||
}); | ||
}; |
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 +1 @@ | ||
[{"messageID":"747089418652745728","channelID":"450832239626813470","guildID":"450594207787384832","startAt":1598190397586,"endAt":1598190439681,"ended":true,"winnerCount":"1","prize":"test","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"🎉🎉 **GIVEAWAY ENDED** 🎉🎉","timeRemaining":"Time remaining: **{duration}**!","inviteToParticipate":"React with 🎉 to participate!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","hostedBy":"Hosted by: {user}","winners":"winner(s)","endedAt":"Ended at","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@717822288375971900>"},{"messageID":"748270736539516999","channelID":"745714155616469114","guildID":"745714155063083010","startAt":1598472045736,"endAt":1598472105736,"ended":true,"winnerCount":"1","prize":"role","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"🎉🎉 **GIVEAWAY ENDED** 🎉🎉","timeRemaining":"Time remaining: **{duration}**!","inviteToParticipate":"React with 🎉 to participate!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","hostedBy":"Hosted by: {user}","winners":"winner(s)","endedAt":"Ended at","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>"},{"messageID":"749373412203298816","channelID":"745714155616469114","guildID":"745714155063083010","startAt":1598734944073,"endAt":1598734964073,"ended":true,"winnerCount":"1","prize":"test","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"🎉🎉 **GIVEAWAY ENDED** 🎉🎉","timeRemaining":"Time remaining: **{duration}**!","inviteToParticipate":"React with 🎉 to participate!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","hostedBy":"Hosted by: {user}","winners":"winner(s)","endedAt":"Ended at","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@595920870057312257>"},{"messageID":"794935409909825536","channelID":"740683040610582528","guildID":"740295580886106233","startAt":1609597770748,"endAt":1609684170748,"ended":true,"winnerCount":"1","winners":["556218750337286145"],"prize":"test","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"🎉🎉 **GIVEAWAY ENDED** 🎉🎉","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","winnerIDs":["556218750337286145"]},{"messageID":"794974192336240672","channelID":"740683040610582528","guildID":"740295580886106233","startAt":1609607017627,"endAt":1609607067627,"ended":true,"winnerCount":"1","winners":[],"prize":"gayness","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"🎉🎉 **GIVEAWAY ENDED** 🎉🎉","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","winnerIDs":[]},{"messageID":"795291869893623808","channelID":"740482348277039127","guildID":"740295580886106233","startAt":1609682757471,"endAt":1609682817471,"ended":true,"winnerCount":"1","winners":["556218750337286145"],"prize":"yeet power","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"**GIVEAWAY ENDED**","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","winnerIDs":["556218750337286145"]},{"messageID":"795294296907186196","channelID":"740295581481697342","guildID":"740295580886106233","startAt":1609683336132,"endAt":1609683396132,"ended":true,"winnerCount":"1","winners":[],"prize":"yeet","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"**GIVEAWAY ENDED**","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","winnerIDs":[]},{"messageID":"795295361148256297","channelID":"740482348277039127","guildID":"740295580886106233","startAt":1609683589841,"endAt":1609683649841,"ended":true,"winnerCount":"1","winners":[],"prize":"yete","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"**GIVEAWAY ENDED**","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","winnerIDs":[]},{"messageID":"795298892765724694","channelID":"740295581481697342","guildID":"740295580886106233","startAt":1609684431846,"endAt":1609684491846,"ended":true,"winnerCount":"1","winners":[],"prize":"yeet","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"**GIVEAWAY ENDED**","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","winnerIDs":[]},{"messageID":"795303138025537586","channelID":"740482348277039127","guildID":"740295580886106233","startAt":1609685443939,"endAt":1609685503940,"ended":true,"winnerCount":"1","winners":[],"prize":"yeet","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"**GIVEAWAY ENDED**","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","exemptPermissions":["MANAGE_MESSAGES"],"winnerIDs":[]},{"messageID":"795303606730752000","channelID":"740295581481697342","guildID":"740295580886106233","startAt":1609685555683,"endAt":1609685615683,"ended":true,"winnerCount":"1","winners":[],"prize":"test","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"**GIVEAWAY ENDED**","inviteToParticipate":"React with 🎉 to participate!","timeRemaining":"Time remaining: **{duration}**!","winMessage":"Congratulations, {winners}! You won **{prize}**!","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {user}","units":{"seconds":"seconds","minutes":"minutes","hours":"hours","days":"days","pluralS":false}},"hostedBy":"<@556218750337286145>","exemptPermissions":["MANAGE_MESSAGES"],"winnerIDs":[]}] | ||
[] |
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,9 @@ | ||
const { model, Schema } = require("mongoose"); | ||
module.exports = model( | ||
"requirements", | ||
new Schema({ | ||
message: String, | ||
role: String, | ||
permissions: String, | ||
}) | ||
); |
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