-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from Blumlaut/djs-v14-dev
chore(deps): update to v14, currently broken
- Loading branch information
Showing
12 changed files
with
224 additions
and
49 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
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
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,104 @@ | ||
|
||
var reports = [] | ||
|
||
function generateReportEmbed(report, disabled, closed) { | ||
var reportId = report.id | ||
|
||
var embed = new Embed() | ||
.setTimestamp() | ||
|
||
if (closed) { | ||
embed.setColor((808080)) | ||
} else { | ||
embed.setColor((65280)) | ||
} | ||
|
||
if (report.type == 1) { | ||
embed.addFields({name:"Player Report", value: `**${report.reporterName}** reported **${report.reportedName}**!`}) | ||
} else { | ||
embed.addFields({name:"Admin Call", value: `**${report.reporterName}** called for an Admin!`}) | ||
} | ||
|
||
embed.addFields( | ||
{name:"Reason", value: `\`\`\`\n${report.reason}\`\`\``}, | ||
{name:"Report ID", value: `#${report.id}`, inline: true}, | ||
{name:"Claimed by", value:`${(report.claimedName || "Noone")}`, inline: true}) | ||
|
||
|
||
|
||
/* | ||
const row = new ActionRow() | ||
var button = new ButtonComponent() | ||
button.setCustomId(`report_close${reportId}`) | ||
button.setLabel('Close Report') | ||
if (disabled) { | ||
button.setDisabled(true) | ||
} | ||
row.addComponents(button) | ||
*/ | ||
|
||
return {embeds: [embed], /* components: [row] */} | ||
|
||
} | ||
|
||
async function logNewReport(report) { | ||
var reportId = report.id | ||
reports[reportId] = report | ||
|
||
|
||
|
||
var reportMessage = generateReportEmbed(report) | ||
|
||
|
||
var msg = await client.channels.cache.get(GetConvar("ea_botLogChannel", "")).send(reportMessage) | ||
reports[reportId].msg = msg | ||
|
||
|
||
/* | ||
const filter = i => (i.customId === `report_close${reportId}`); | ||
const collector = interaction.channel.createMessageComponentCollector({ | ||
filter, | ||
time: 240000 | ||
}); | ||
collector.on('collect', async i => { | ||
if (i.customId === `report_close${reportId}` && await DoesGuildMemberHavePermission(i.member, "player.reports.process")) { | ||
var reportMessage = generateReportEmbed(report, true, true) | ||
msg.edit(reportMessage) | ||
} | ||
await i.deferUpdate() | ||
}); | ||
*/ | ||
|
||
} | ||
exports('logNewReport', logNewReport) | ||
|
||
|
||
onNet("EasyAdmin:ClaimReport", async function(reportId) { | ||
var src = source | ||
if (await exports[EasyAdmin].DoesPlayerHavePermission(src, "player.reports.claim")) { | ||
if (!reports[reportId].claimed) { | ||
reports[reportId].claimed = src | ||
reports[reportId].claimedName = exports[EasyAdmin].getName(src,true) | ||
var reportMessage = generateReportEmbed(reports[reportId], true) | ||
reports[reportId].msg.edit(reportMessage) | ||
} | ||
} | ||
}) | ||
|
||
onNet("EasyAdmin:RemoveReport", async function(report) { | ||
if (await exports[EasyAdmin].DoesPlayerHavePermission(source, "player.reports.process")) { | ||
var reportId = report.id | ||
var reportMessage = generateReportEmbed(reports[reportId], true, true) | ||
reports[reportId].msg.edit(reportMessage) | ||
reports[reportId] = undefined | ||
} | ||
}) | ||
|
||
// todo: close similar reports |
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,43 @@ | ||
|
||
if (GetConvar("ea_botToken", "") != "") { | ||
|
||
|
||
async function syncDiscordRoles(player) { | ||
if (!EasyAdmin) {return} // bot is down | ||
var src = player | ||
var member = undefined | ||
try { | ||
var botGuild = await client.guilds.cache.get(guild) | ||
var user = await getDiscordAccountFromPlayer(src) | ||
member = await botGuild.members.fetch(user.id) | ||
} catch (error) { | ||
console.error(error) | ||
return | ||
} | ||
|
||
var roles = await member.roles.cache.keys() | ||
|
||
for (var role of roles) { | ||
ExecuteCommand(`add_principal identifier.discord:${member.id} role:${role}`) | ||
} | ||
} | ||
exports('syncDiscordRoles', syncDiscordRoles) | ||
|
||
client.on("guildMemberUpdate", async function(oldMember, newMember){ | ||
var player = await getPlayerFromDiscordAccount(newMember) | ||
if (player) { | ||
oldRoles = await oldMember.roles.cache.keys() | ||
|
||
for (var role of oldRoles) { | ||
ExecuteCommand(`remove_principal identifier.discord:${oldMember.id} role:${role}`) | ||
} | ||
|
||
newRoles = await newMember.roles.cache.keys() | ||
|
||
for (var role of newRoles) { | ||
ExecuteCommand(`add_principal identifier.discord:${newMember.id} role:${role}`) | ||
} | ||
} | ||
}); | ||
|
||
} |
Oops, something went wrong.