From 1af0223042ef3686101524275dff0d98875ea202 Mon Sep 17 00:00:00 2001 From: Carter Penterman Date: Sat, 9 Jul 2022 15:22:33 -0500 Subject: [PATCH 1/3] submit command verifies roblox acct with discord acct --- commands/submit.js | 33 +++++++++++++++++++++++++++++++++ config/.gitignore | 2 ++ package.json | 1 + 3 files changed, 36 insertions(+) create mode 100644 config/.gitignore diff --git a/commands/submit.js b/commands/submit.js index 8d98559..b4f0dd0 100644 --- a/commands/submit.js +++ b/commands/submit.js @@ -2,8 +2,34 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); const { parse } = require("csv-parse/sync"); const fs = require('node:fs'); const noblox = require("noblox.js"); +const axios = require("axios").default + +async function robloxUserFromDiscord(id) { + if (isNaN(id)) return undefined; + try { + const res = await axios.get(`https://verify.eryn.io/api/user/${id}`) + return res.data.robloxId + } catch (error) { + return undefined; + } +} + +async function robloxUsernameFromId(id) { + if (isNaN(id)) return undefined; + try { + const res = await axios.get(`https://users.roblox.com/v1/users/${id}`) + return res.data.name + } catch (error) { + return undefined; + } +} async function execute(interaction) { + const userId = await robloxUserFromDiscord(interaction.user.id) + if (!userId) { + const msg = "You don't have a Roblox account linked with your Discord account. Visit https://verify.eryn.io/"; + await interaction.reply({content: msg, ephemeral: true}); + } const game = interaction.options.getString("game"); let fname; @@ -26,6 +52,13 @@ async function execute(interaction) { await interaction.reply({content: `(id: ${id}) is not a valid model ID.`, ephemeral: true}); return; } + if (info.Creator.Id != userId) { + const assetUsername = await robloxUsernameFromId(info.Creator.Id); + const interactionUsername = await robloxUsernameFromId(userId); + const msg = `The account linked to your Discord (${interactionUsername}) is not the owner of this model (${assetUsername}), so you cannot submit it.` + await interaction.reply({content: msg, ephemeral: true}); + return + } } catch (error) { console.log(error); await interaction.reply({content: `There is a problem with this asset ID (id: ${id}).`, ephemeral: true}); diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/config/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/package.json b/package.json index 3e5a6fd..d34d389 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "dependencies": { "@discordjs/builders": "^0.13.0", "@discordjs/rest": "^0.4.1", + "axios": "^0.27.2", "csv-parse": "^5.0.4", "discord-api-types": "^0.32.1", "discord.js": "^13.6.0", -- 2.45.2 From 444e8d78aa2f51a3555af6095bd2db7bfdad93e8 Mon Sep 17 00:00:00 2001 From: Carter Penterman Date: Sun, 10 Jul 2022 12:55:33 -0500 Subject: [PATCH 2/3] updated config file readme --- README.md | 2 +- config/.gitignore | 1 + example_config.json => config/example_config.json | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename example_config.json => config/example_config.json (100%) diff --git a/README.md b/README.md index 0e08b54..791a932 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ to setup (requires node.js): -* create a copy of example_config.json named config.json +* (in the config folder) create a copy of example_config.json named config.json * fill out empty values with correct values in config.json (token is discord token, cookie is .ROBLOSECURITY cookie, clientId is the bot's ID (right click bot in discord then choose copy ID with developer mode enabled)) * install dependencies ``` diff --git a/config/.gitignore b/config/.gitignore index c96a04f..bdf2e35 100644 --- a/config/.gitignore +++ b/config/.gitignore @@ -1,2 +1,3 @@ * +!example_config.json !.gitignore \ No newline at end of file diff --git a/example_config.json b/config/example_config.json similarity index 100% rename from example_config.json rename to config/example_config.json -- 2.45.2 From cbd9ceceafea9dad0fd373b604c77a0bd1d28155 Mon Sep 17 00:00:00 2001 From: fiveman1 Date: Mon, 11 Jul 2022 15:00:40 +0000 Subject: [PATCH 3/3] no discord account link fix --- commands/submit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/submit.js b/commands/submit.js index b4f0dd0..b240145 100644 --- a/commands/submit.js +++ b/commands/submit.js @@ -29,6 +29,7 @@ async function execute(interaction) { if (!userId) { const msg = "You don't have a Roblox account linked with your Discord account. Visit https://verify.eryn.io/"; await interaction.reply({content: msg, ephemeral: true}); + return; } const game = interaction.options.getString("game"); -- 2.45.2