Discord.js v14 | How To Make a Discord to Roblox Verification System?

Hello, and welcome to my tutorial! Today I’ll show you how to host a Discord-Roblox verification system via friend requests.

Note: I’ll not show you how to host a bot, I will show you how to make the command only.

Packages needed:
discord.js
noblox.js

How to install packages at Glitch?

What is glitch?

  • Glitch is a free-to-use platform to host your bots. But it’s free packages allow everybody to see your project, and they can clone your project easily.

How to install the package I want?

  • Go to your project.
  • Go to package.json which you are always supposed to have for your bot.
  • Press ADD PACKAGE button in the top of your screen.
  • Type the name of the package, then click on it.

Logging In With noblox.js
Use that in your main folder such as index.js, bot.js

const noblox = require("noblox.js");

noblox.setCookie(process.env.COOKIE).then(function() { //Use COOKIE from our .env file.
    console.log("Logged in!")
}).catch(function(err) {
    console.log("Unable to log in!", err)
})

Requiring The Packages

const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, Client } = require('discord.js')
const Noblox = require('noblox.js')

Slowly Moving Up! (Receiving The Interaction)

const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, Client } = require('discord.js')
const Noblox = require('noblox.js')
module.exports = {
  name: "verify",
  description: "To verify your roblox account.",
  type: 1,
  options: [{
	  type: 3,
	  name: "account",
	  description: "Your account's username",
      required: true
  }],
 run: async(client, interaction) => { // That is how I use it for my bot, it is actually up to your bot style.
const Username = interaction.options.getString('Username') // We use that to receive a slash command option.
}}

Sending a Reply!

const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, Client } = require('discord.js')
const Noblox = require('noblox.js')
module.exports = {
  name: "verify",
  description: "To verify your roblox account.",
  type: 1,
  options: [{
	  type: 3,
	  name: "account",
	  description: "Your account's username",
required: true
  }],
 run: async(client, interaction) => { // That is how I use it for my bot, it is actually up to your bot style.
const Username = interaction.options.getString('Username') // We use that to receive a slash command option.
const Embed = new EmbedBuilder() // That's how we start building the embed.
.setTitle('Hello, '+Username+'!') // Ex: Hello, BaconKral!
.setDescription(`In order to make us able to verify that you are the user, please send a friend request to [that account](The profile link of the account you will take the requests to).`)

// Now, we will build a button!
const Row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('Verification') // That will not matter anything for us.
.setLabel('Done') // The text of the button.
.setStyle(ButtonStyle.Primary)
)
const Reply = await interaction.reply({embeds: [Embed],components:[Row]}) // Replying the slash command.
}}

We Still Gotta Connect The Button!

const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, Client } = require('discord.js')
const Noblox = require('noblox.js')
module.exports = {
  name: "verify",
  description: "To verify your roblox account.",
  type: 1,
  options: [{
	  type: 3,
	  name: "account",
	  description: "Your account's username",
required: true
  }],
 run: async(client, interaction) => { // That is how I use it for my bot, it is actually up to your bot style.
const Username = interaction.options.getString('Username') // We use that to receive a slash command option.
const Embed = new EmbedBuilder() // That's how we start building the embed.
.setTitle('Hello, '+Username+'!') // Ex: Hello, BaconKral!
.setDescription(`In order to make us able to verify that you are the user, please send a friend request to [that account](The profile link of the account you will take the requests to).`)

// Now, we will build a button!
const Row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('Verification') // That will not matter anything for us.
.setLabel('Done') // The text of the button.
.setStyle(ButtonStyle.Primary)
)
const Reply = await interaction.reply({embeds: [Embed],components:[Row]}) // Replying the slash command.

 const Collector = Reply.createMessageComponentCollector({max:1}) // We've created a button collector with a limitation of clicks 1. It is up to you to put that, if you don't want to add it then just delete it.

collector.on('collect', async Button => { // We are connecting the button, like :Connect(function() in Luau.
const FriendRequests = Noblox.getFriendRequests() // Now we have the requests!
if(FriendRequests === nil) {return} // If there is NONE of the friend requests, the bot will just do nothing. (I'll edit it to send a message ASAP. I don't have much time right now.)
let Found = false // The difference of 'let' than 'const' is that 'let' variables can be changed while 'const' variables can't.
FriendRequests.forEach(Request => {
if(Request.username === Username) {Found = true}
}) //We are using forEach loop which is like for in pair loop in Luau.
if(Found === true) {
// Your function here, I will probably make one tomorrow since it is night for me right now. Stay for the continuous!
}
}
}}

Important Notes

  • I didn’t have much time today, I will improve the post really much tomorrow such as getting username properly (like if I enter “baconkral”, it will fix it to “BaconKral”.).
  • Building a command with noblox.js in Glitch will probably not work because of one of Roblox’s updates.
  • The code might not work as I could not test it today, it is late for me.
    Please let me know your ideas!
9 Likes

Only issue of course is that you never unfriend them once verified or after a while of the verification process happening which will cause the account to have a large amount of friends until it reaches the threshold of 100 friends.

1 Like

Hello. I had actually forgotten about this. Tomorrow, I will make a prevention for that. Have a good day, and also thank you for your comment!

Wouldn’t it be a better idea to, generate a random string that is safe for Roblox and check that then simply add them to a database, for example, if this is connected to a game you can use the cloud to add it to a Roblox datastore.

2 Likes

Yep, it was a safer verification. But why I have made this one is actually that it takes really less amount of time, especially for people who have 2FA PIN code on.
Have a good day!

1 Like