feature/verify-submit #1
@ -2,8 +2,34 @@ const { SlashCommandBuilder } = require('@discordjs/builders');
|
|||||||
const { parse } = require("csv-parse/sync");
|
const { parse } = require("csv-parse/sync");
|
||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
const noblox = require("noblox.js");
|
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) {
|
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");
|
const game = interaction.options.getString("game");
|
||||||
|
|
||||||
let fname;
|
let fname;
|
||||||
@ -26,6 +52,13 @@ async function execute(interaction) {
|
|||||||
await interaction.reply({content: `(id: ${id}) is not a valid model ID.`, ephemeral: true});
|
await interaction.reply({content: `(id: ${id}) is not a valid model ID.`, ephemeral: true});
|
||||||
return;
|
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) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
await interaction.reply({content: `There is a problem with this asset ID (id: ${id}).`, ephemeral: true});
|
await interaction.reply({content: `There is a problem with this asset ID (id: ${id}).`, ephemeral: true});
|
||||||
|
2
config/.gitignore
vendored
Normal file
2
config/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
@ -2,6 +2,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^0.13.0",
|
"@discordjs/builders": "^0.13.0",
|
||||||
"@discordjs/rest": "^0.4.1",
|
"@discordjs/rest": "^0.4.1",
|
||||||
|
"axios": "^0.27.2",
|
||||||
"csv-parse": "^5.0.4",
|
"csv-parse": "^5.0.4",
|
||||||
"discord-api-types": "^0.32.1",
|
"discord-api-types": "^0.32.1",
|
||||||
"discord.js": "^13.6.0",
|
"discord.js": "^13.6.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user