Skip to content

Commit

Permalink
Added verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-NCSU committed Aug 8, 2022
1 parent ba3b509 commit 19c09c5
Show file tree
Hide file tree
Showing 21 changed files with 372 additions and 305 deletions.
16 changes: 16 additions & 0 deletions ButtonInteractions/reject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const tokens = require("../index.js");

/**
* Returns options depending on previously selected option
*/
module.exports = {
data: 'reject',
async execute(params) {
const { interaction } = params;
interaction.message.embeds[0].fields.push({ name: 'Rejected by:', value: `<@${interaction.user.id}>`})
await interaction.update({
embeds: interaction.message.embeds,
components: []
})
},
};
22 changes: 22 additions & 0 deletions ButtonInteractions/verify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const tokens = require("../index.js");

/**
* Returns options depending on previously selected option
*/
module.exports = {
data: 'verify',
async execute(params) {
const { interaction } = params;
const {discordID, srcID} = JSON.parse(interaction.customId);
tokens.db.db("accounts").collection("users").insertOne({
discordID,
srcID,
minecraftUUIDs: [],
});
interaction.message.embeds[0].fields.push({ name: 'Verified by:', value: `<@${interaction.user.id}>`})
await interaction.update({
embeds: interaction.message.embeds,
components: []
})
},
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions GuildCommandInteractions/hypixel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { ActionRowBuilder, SelectMenuBuilder, ButtonBuilder, InteractionType, ButtonStyle } = require("discord.js");
const { SlashCommandBuilder } = require("@discordjs/builders");

/**
* Function to provide a link to a requested site
*/
module.exports = {
/**
* Builds /hypixel
*/
data: new SlashCommandBuilder()
.setName("hypixel")
.setDescription("Provides helpful links for Hypixel Speedruns"),
async execute(params) {
const { interaction } = params;
const row = new ActionRowBuilder()
.addComponents(
new SelectMenuBuilder()
.setCustomId("category")
.setPlaceholder("Nothing selected")
.addOptions([
{
label: "General",
description: "Get links to general Hypixel Speedruns Information",
value: "General",
},
{
label: "Games",
description: "Get links to Hypixel Speedrun Games",
value: "Games",
},
{
label: "Maps",
description: "Get links to Hypixel Speedrun Maps",
value: "Maps",
},
{
label: "Speedrun.com",
description: "Links to speedrun.com resources",
value: "Speedrun.com",
},
]),
);
return await interaction.editReply({ content: "Please select a category!", components: [row] });
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const { EmbedBuilder } = require("discord.js");
const { SlashCommandBuilder } = require("@discordjs/builders");

/**
* Function to provide a list of categories for the given game
* Function to create a suggestion
*/
module.exports = {
/**
* Builds /categories [string:game]
* Builds /suggest [title:string] [description:string]
*/
data: new SlashCommandBuilder()
.setName("suggest")
Expand Down
77 changes: 77 additions & 0 deletions GuildCommandInteractions/verify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const { ActionRowBuilder, SlashCommandBuilder, ButtonBuilder } = require("@discordjs/builders");
const { EmbedBuilder, ButtonStyle } = require("discord.js");
const tokens = require("../index.js");

/**
* Function to link Discord account and SRC account
*/
module.exports = {
/**
* Builds /verify [username:string]
*/
data: new SlashCommandBuilder()
.setName("verify")
.setDescription("Link your Discord account to your SRC account.")
.addStringOption(option =>
option.setName("username")
.setDescription("Speedrun.com username")
.setRequired(true)
),
async execute(params) {
const { interaction, client } = params;
const channel = await client.channels.cache.get("815040942930919425");
const username = interaction.options.get("username").value;
const isVerified = !!(await tokens.db.db("accounts").collection("users").findOne({
discordID: interaction.user.id
}));
if(isVerified) {
await interaction.editReply({
content: 'You are already verified. Please contact <@168420049462362112> if this is a mistake or to unverify.'
});
return;
}
const srcAccount = await tokens.fetch(`https://www.speedrun.com/api/v1/users/${username}`);
if(!srcAccount.data) {
interaction.editReply({
content: `User ${username} not found.`
});
return;
}

let date = new Date().toISOString().slice(0, 10);
let embed = new EmbedBuilder()
.setColor("#118855")
.setTitle('User Requesting Verification')
.setFooter({ text: `${date}` })
.setThumbnail(srcAccount.data.assets.image.uri)
.addFields([
{ name: 'User:', value: `<@${interaction.user.id}>` },
{ name: 'Tag:', value: interaction.user.tag },
{ name: "Speedrun.com account:", value: `[${srcAccount.data.names.international}](${srcAccount.data.weblink})`}
]);
const verifyId = JSON.stringify({
discordID: interaction.user.id,
srcID: srcAccount.data.id,
customId: 'verify',
});
const rejectId = JSON.stringify({
customId: 'reject'
});
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(verifyId)
.setLabel('Accept')
.setStyle(ButtonStyle.Success),
new ButtonBuilder()
.setCustomId(rejectId)
.setLabel('Reject')
.setStyle(ButtonStyle.Danger),
);

await channel.send({ embeds: [embed], components: [row] });
await interaction.editReply({
content: 'Your request has been submitted. You will receive the verified role when reviewed.'
});
},
};
136 changes: 136 additions & 0 deletions SelectMenuInteractions/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
const { ActionRowBuilder, SelectMenuBuilder } = require("discord.js");
const { SlashCommandBuilder } = require("@discordjs/builders");

/**
* Returns options depending on previously selected option
*/
module.exports = {
data: 'category',
async execute(params) {
const { interaction } = params;
let options = {
"General": [
{
label: "Hypixel Speedruns Discord",
description: "Hypixel Speedruns Discord Link",
value: "Hypixel Speedruns Discord",
},
{
label: "Hypixel Server Parkour Discord",
description: "Hypixel Server Parkour Discord Link",
value: "Hypixel Server Parkour Discord",
},
{
label: "Hypixel SkyBlock Speedruns Discord",
description: "Hypixel SkyBlock Speedruns Discord Link",
value: "Hypixel SkyBlock Speedruns Discord",
},
{
label: "Series",
description: "Hypixel Series Link",
value: "Series",
},
{
label: "Twitter",
description: "Hypixel Speedruns Twitter",
value: "Twitter",
},
],
"Games": [
{
label: "SkyWars",
value: "SkyWars",
},
{
label: "BedWars",
value: "BedWars",
},
{
label: "Category Extensions",
value: "Category Extensions",
},
{
label: "Arcade Games",
value: "Arcade Games",
},
{
label: "Classic Games",
value: "Classic Games",
},
{
label: "SMP",
value: "SMP",
},
{
label: "The Pit",
value: "The Pit",
},
{
label: "Server Parkour",
value: "Server Parkour",
},
],
"Maps": [
{
label: "Zombie Apocalypse",
value: "Zombie Apocalypse",
},
{
label: "Wrath of the Fallen",
value: "Wrath of the Fallen",
},
{
label: "Herobrine's Mansion",
value: "Herobrine's Mansion",
},
{
label: "Herobrine's Return",
value: "Herobrine's Return",
},
{
label: "Minecraft Star Wars",
value: "Minecraft Star Wars",
},
{
label: "Creeper Dungeon",
value: "Creeper Dungeon",
},
],
"Speedrun.com": [
{
label: "Support Hub",
description: "Speedrun.com support",
value: "Support Hub",
},
{
label: "Knowledge Base",
description: "Speedrun.com general site information",
value: "Knowledge Base",
},
{
label: "Speedrun.com Discord",
description: "Speedrun.com general Discord",
value: "Speedrun.com Discord",
},
{
label: "Graphic Assets",
description: "Speedrun.com Assets",
value: "Graphic Assets",
},
{
label: "Speedrun.com Twitter",
description: "Speedrun.com general Twitter",
value: "Speedrun.com Twitter",
},
]
}[interaction.values[0]];
const row = new ActionRowBuilder()
.addComponents(
new SelectMenuBuilder()
.setCustomId("link")
.setPlaceholder("Nothing selected")
.addOptions(options),
);
return await interaction.update({ content: "Please select a link!", components: [row] });
},
};
45 changes: 45 additions & 0 deletions SelectMenuInteractions/link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");

/**
* Returns links for /hypixel
*/
module.exports = {
data: "link",
async execute(params) {
const { interaction } = params;
const url = {
"Hypixel Speedruns Discord": "https://discord.gg/HhNKdB9FJk",
"Hypixel Server Parkour Discord": "https://discord.gg/RJTk7Bv",
"Hypixel SkyBlock Speedruns Discord": "https://discord.gg/vskJtfR",
"Series": "https://www.speedrun.com/hypixel",
"Twitter": "https://twitter.com/HSpeedrunning",
"SkyWars": "https://www.speedrun.com/hypixel_sw",
"BedWars": "https://www.speedrun.com/hypixel_bw",
"Category Extensions": "https://www.speedrun.com/hypixel_ce",
"Arcade Games": "https://www.speedrun.com/hypixel_ag",
"Classic Games": "https://www.speedrun.com/hypixel_cg",
"SMP": "https://www.speedrun.com/hypixel_smp",
"The Pit": "https://www.speedrun.com/hypixel_tp",
"Server Parkour": "https://www.speedrun.com/mcm_hsp",
"Zombie Apocalypse": "https://www.speedrun.com/mcm_za",
"Wrath of the Fallen": "https://www.speedrun.com/mcm_wotf",
"Herobrine's Mansion": "https://www.speedrun.com/mcm_hm",
"Herobrine's Return": "https://www.speedrun.com/mcm_hr",
"Minecraft Star Wars": "https://www.speedrun.com/mcm_sw",
"Creeper Dungeon": "https://www.speedrun.com/mcm_cd",
"Support Hub": "https://www.speedrun.com/knowledgebase/supporthub",
"Knowledge Base": "https://www.speedrun.com/knowledgebase",
"Speedrun.com Discord": "https://discord.gg/0h6sul1ZwHVpXJmK",
"Graphic Assets": "https://www.speedrun.com/knowledgebase/graphic-assets",
"Speedrun.com Twitter": "https://twitter.com/speedruncom",
}[interaction.values[0]];
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel(interaction.values[0])
.setStyle(ButtonStyle.Link)
.setURL(url),
);
await interaction.update({ content: interaction.values[0] + " Link:", components: [row] });
},
};
Loading

0 comments on commit 19c09c5

Please sign in to comment.