Hi everyone! So You Want To Make A Discord-Roblox verification command Well No problem!
THIS POST IS BASED OF:
[NONE OF THE SCRIPTS ARE MINE THEY BELONG TO THEIR RESPECTIVE OWNERS:
This Tutorial Will Go Over Making A Discord Bot from Scratch (Not The actual scratch program ) With a Verify Command So Lets Get Started!
[EVERYTHING IN TUTORIAL IS BASED ON DISCORD.JS [V12] VERSION]
Setup
Make Sure You Have:
- Discord Account
- Roblox Account
There is a lot of things to do before we even Start Scripting,We need to install some applications which will Power Our Discord-Bot:
-
Node.js
Link: Download | Node.js
Setup: Download the required Application Version for your pc OS and Run the Setup we are not going to do anything in here for now. -
CodeEditor
If you have a Code Editor You Can use it,But If You donโt then You Can Get VScode for Free!
Link: Download Visual Studio Code - Mac, Linux, Windows
Setup: Install The required Application Version for your pc OS,Run The Setup And Start The Application.
After Installing These We Can Make Our Own Discord bot Account:
Bot Account
You Need a Discord Account At This Stage if you donโt have one,You Can get it for free!
Link: https://discord.com/new
Now You Need to make a Discord Bot Account.
NOTE: DO NOT SHARE ANY OF YOUR BOT DETAILS.
Head Over To Discord Developer Portal:
Discord Developer Portal
If Asked To Login,then you have to login with your Discord Account
After Going to Discord Developer Portal,Click on New Application
Write A Name for your Application You Can name it anything totally up to you.
Click Create.
Click Bot.
You Should See Something like this Click Add Bot
Click: Yes,do it!
You will see this page:
Now Head Over To OAuth2 Page:
Click on โBotโ Then Click On Administrator
Click Copy
Put The Link IN Your Browser And Invite The Bot To Your Server [If You Donโt Have One,Well Make One!]
Installing Discord.js (MAIN FILE)
In This Part We Will Start WIth Scripting Our Bot Any lines Below This Assume You Either Have Done Already Or Completed the Above Parts In This Topic/Thread
- We will Start With Making A Folder Dedicated Towards this,After This You Have To Open Command Prompt:
If youโre on Linux, you can quickly open up the terminal withCtrl + Alt + T
.
If youโre on Windows and arenโt familiar with opening up the command prompt, simply do the following:
- Open your bot project folder.
- Hold down the
Shift
key and right-click inside of the folder. - Choose the โOpen command window hereโ option.
-
With the command prompt open, run the
node -v
command to make sure youโve successfully installed Node.js. If you see something likev12.0
(Or Higher) , great! If not, go back and try installing again. -
The next command youโll be running is
npm init
. This command creates apackage.json
file for you, which is what will be used to keep track of the dependencies your bot uses, as well as other info. If youโre a bit confused by that, you can simply ignore it for the time being.
The npm init
command will ask you a sequence of questions - you should fill them out as you see fit. If youโre not sure of something or just want to skip it as a whole, simply leave it blank and press enter.
Now we Will Install Discord.js,We will use this for coding:
- To install discord.js, simply run the
npm install discord.js
. This can take a bit of time, but should be done fairly quickly.
You should See something link:
This is Totally Normal and means you have successfully installed it!
Basic Scripting
Open Your Code Editor here I am using VScode Now You need to press โCTRL + K CTRL + Oโ Together (yes)
Find Your Folder and Click Open:
After That You Can Make a new File Its recommended to name it index.js but you can name it whatever you want just make sure it ends with .js
After That Open it by Clicking on it the first thing you want to do is get the Discord.js
Module to work so write 1st line as:
const Discord = require("discord.js"); --make sure to add `;`
Now we need to make a client to run commands we do it by adding this line after first line:
const Client = new Discord.Client()
Now lets add prefix add this line after line 1:
var Prefix = "?" //--prefix here
Now we will add another line to know if bot is working or not after line 2:
Client.once("ready",Response => {console.log("Ready!")})
Now Open Terminal (Output) by Clicking (CTRL + `)
Now we can start detecting messages add this line after line 3:
Client.on("message",msg =>
{
})
As we can Detect messages using the function above,
Now we Can start with command.
Here is the code done so far:
const Discord = require("discord.js")
var Prefix = "?" //--prefix here
const Client = new Discord.Client()
Client.once("ready",Response => {console.log("Ready!")})
Client.on("message",msg =>
{
})
Full Scripting
Now lets go ahead to main command
But we need to Install a Module before so Head over to Terminal ( if not open then (CTRL + `) to open)
Type in npm install noblox.js
and wait until it finishes after that Change your code to this:
const Discord = require("discord.js");
const noblox = require("noblox.js") //--Added This Before line 2
var Prefix = "?" //--prefix here
const Client = new Discord.Client()
Client.once("ready",Response => {console.log("Ready!")})
Client.on("message",msg =>
{
})
Now we will check if message sent in any channel starts with Prefix and Verify command to do this:
This command will not be case-sensitive
Client.on("message", msg =>
{
if (msg.content.toLowerCase() == `${Prefix}verify`)
{
}
})
Now we have noblox we also have discord.js What do we need now?
ANS: Lets start The Main Part Now:
first we will create a async function to Handle everything
const Discord = require("discord.js");
const noblox = require("noblox.js") //Add This Before line 2
var Prefix = "?" //--prefix here
const Client = new Discord.Client()
Client.once("ready",Response => {console.log("Ready!")})
async function Verification(message) //Async Function
{
}
Client.on("message", msg =>
{
if (msg.content.toLowerCase() == `${Prefix}verify`)
{
Verification(msg) //Calling Function
}
})
Now the main part lets by entering info in Verification function:
async function Verification(message)//Async function
{
var EMBED = new Discord.MessageEmbed()
.setDescription("Please Wait While Message Loads")
.setColor('GREEN')
.setFooter("Loading...")
.setTimestamp()
let msg = await message.channel.send(EMBED) // Send a message for awaiting.
}
Here we are making a message and sending the player to tell that the the function is loading
Now add another function in the same function below that line:
let msg = await message.channel.send(EMBED) // Send a message for awaiting.
//Continue
function makeid() {
var text = "";
var selectFruit = ['๐','๐','๐','๐คฃ','๐','๐','๐
','๐','๐','๐ฒ','๐','๐ค','๐คฏ','๐ญ','๐','๐ถ','๐','๐','๐','๐','๐ง ','๐ผ','๐ฎ๐ป','๐๐ผ','๐๐ผ','๐ต','๐จ','โ๏ธ','๐ง','๐ฌ','๐ง','๐ฎ','๐ฒ','๐
','๐ฅ','๐ฅ','๐ฅ','๐','๐','๐','๐ซ','๐ฟ','๐ช','๐ฅ','๐ฝ','๐ด','๐','๐ฆ','๐','๐ญ','๐ฆ','๐ง','๐','๐','๐','๐','๐','๐','๐','๐ต','๐','๐ฒ','โ๏ธ','โ
๏ธ','โ๏ธ','๐']; //Replace this with "Text " (Do not forget Space)
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];// This will random the emojis
return text;
}
}
Now lets Ask the player for Username
return text;
}
//Continue
const filter = m => m.author.id === message.author.id
const collector = message.channel.createMessageCollector(filter, { max: '1', maxMatches: "1", time: "200000" }) //This is the collector to collect the Message for getting the username.
const robloxEmbed = new Discord.MessageEmbed()
.setColor("BLUE")
.setTitle("Prompt")
.setDescription("โ What's your ROBLOX username?")
.setFooter("This prompt will cancel after 200 seconds.")
.setTimestamp()
msg.channel.send(robloxEmbed) //Send the first Embed
}
Now the big part i canโt explain this because itโs way to big but what it does is it gets UserId from username and Checks if they have the emoji in status we give them Verified role (Make this role also in your discord and name it exactly Verified)
async function Verification(message)//Async function
{
var EMBED = new Discord.MessageEmbed()
.setDescription("Please Wait While Message Loads")
.setColor('GREEN')
.setFooter("Loading...")
.setTimestamp()
let msg = await message.channel.send(EMBED) // Send a message for awaiting.
function makeid() {
var text = "";
var selectFruit = ['๐','๐','๐','๐คฃ','๐','๐','๐
','๐','๐','๐ฒ','๐','๐ค','๐คฏ','๐ญ','๐','๐ถ','๐','๐','๐','๐','๐ง ','๐ผ','๐ฎ๐ป','๐๐ผ','๐๐ผ','๐ต','๐จ','โ๏ธ','๐ง','๐ฌ','๐ง','๐ฎ','๐ฒ','๐
','๐ฅ','๐ฅ','๐ฅ','๐','๐','๐','๐ซ','๐ฟ','๐ช','๐ฅ','๐ฝ','๐ด','๐','๐ฆ','๐','๐ญ','๐ฆ','๐ง','๐','๐','๐','๐','๐','๐','๐','๐ต','๐','๐ฒ','โ๏ธ','โ
๏ธ','โ๏ธ','๐'];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];// This will random the emojis
return text;
}
const filter = m => m.author.id === message.author.id
const collector = message.channel.createMessageCollector(filter, { max: '1', maxMatches: "1", time: "200000" }) //This is the collector to collect the Message for getting the username.
const robloxEmbed = new Discord.MessageEmbed()
.setColor("BLUE")
.setTitle("Prompt")
.setDescription("โ What's your ROBLOX username?")
.setFooter("This prompt will cancel after 200 seconds.")
.setTimestamp()
msg.channel.send(robloxEmbed) //Send the first Embed
collector.on("collect", m => {
if(m.content.toLowerCase() === 'cancel') {
message.channel.send('**Cancelled prompt.**')
return
} //Collector1 End
noblox.getIdFromUsername(m.content).then(foundId => { //Get the userID from username
const Id = foundId
const newString = makeid() + makeid() + makeid() + makeid() + makeid() //Emoji thing
const foundUsername = new Discord.MessageEmbed()
.setColor("BLUE")
.setTitle("Prompt")
.setDescription("Hello **" + m.content + "**, to verify that you are that user. Please put this in your **Roblox** description, or **Roblox** status. \n `" + newString + "`\n\nSay **done** when complete.\nSay **cancel** to cancel. ")
.setFooter("This will auto cancel in 200 seconds")
.setTimestamp()
msg.channel.send(foundUsername) //The part where it asks you to add the Code
const collector2 = message.channel.createMessageCollector(filter, { max: '1', maxMatches: "1", time: "200000" }) // Collector2
collector2.on('collect', async mag => {
if(mag.content.toLowerCase().includes('done') & mag.content.toLowerCase().includes("done") && mag.author.id == message.author.id) {
const fetchingBlurb = new Discord.MessageEmbed()
.setColor("BLUE")
.setTitle("Prompt")
.setDescription("Fetching your emojis, please wait as I am going to fetch it.")
.setFooter("Fetching..")
.setTimestamp()
msg.channel.send(fetchingBlurb) //Checks the Blurb / Status
setTimeout(function() { //Timeout Stuff
noblox.getStatus(foundId).then(status => { //Check status
console.log(status) //Console.log the status
noblox.getBlurb(foundId).then(blurb => { // Checks the blurb
if(status.includes(newString) || blurb.includes(newString)) { // If code is in blurb procceds with operation
const verified = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle("Prompt")
.setDescription("You have now been verified! Please wait shortly as you are going to recieve the Verified role.")
.setFooter("Verifying..")
.setTimestamp()
msg.channel.send(verified) // Sent if user has put code
let Verified = message.guild.roles.cache.find(r => r.name === 'Verified') message.member.roles.add(verified) // Add the users role
message.member.setNickname(m.content) // Sets the users nickname
} else {
noblox.getStatus(foundId).then(status => { //Check status
console.log(status)
var eMbEd = new Discord.MessageEmbed()
.setColor('RED')
.setTitle("Emoji Not Found")
.setDescription(`Your status:${status}`)
.setTimestamp()
message.channel.send(eMbEd) // Sent if user has not put code
})
}
})
}, 5000)
})
} else
if(mag.content.includes('cancel') && mag.author.id == message.author.id) {
message.channel.send('**Cancelled prompt.**') // If user says `Cancel`
return
}
})
})
})
}
Now we need your bot token Just go to discord developer portal click on the app you made click on bot And Under the TOKEN Section click copy then in your code make it:
const Discord = require("discord.js");
const noblox = require("noblox.js") //Add This Before line 2
var Prefix = "?" //--prefix here
const Client = new Discord.Client()
Client.once("ready",Response => {console.log("Ready!")})
async function Verification(message)//Async function
{
var EMBED = new Discord.MessageEmbed()
.setDescription("Please Wait While Message Loads")
.setColor('GREEN')
.setFooter("Loading...")
.setTimestamp()
let msg = await message.channel.send(EMBED) // Send a message for awaiting.
function makeid() {
var text = "";
var selectFruit = ['๐','๐','๐','๐คฃ','๐','๐','๐
','๐','๐','๐ฒ','๐','๐ค','๐คฏ','๐ญ','๐','๐ถ','๐','๐','๐','๐','๐ง ','๐ผ','๐ฎ๐ป','๐๐ผ','๐๐ผ','๐ต','๐จ','โ๏ธ','๐ง','๐ฌ','๐ง','๐ฎ','๐ฒ','๐
','๐ฅ','๐ฅ','๐ฅ','๐','๐','๐','๐ซ','๐ฟ','๐ช','๐ฅ','๐ฝ','๐ด','๐','๐ฆ','๐','๐ญ','๐ฆ','๐ง','๐','๐','๐','๐','๐','๐','๐','๐ต','๐','๐ฒ','โ๏ธ','โ
๏ธ','โ๏ธ','๐'];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];
text += selectFruit[Math.floor(Math.random() * selectFruit.length)];// This will random the emojis
return text;
}
const filter = m => m.author.id === message.author.id
const collector = message.channel.createMessageCollector(filter, { max: '1', maxMatches: "1", time: "200000" }) //This is the collector to collect the Message for getting the username.
const robloxEmbed = new Discord.MessageEmbed()
.setColor("BLUE")
.setTitle("Prompt")
.setDescription("โ What's your ROBLOX username?")
.setFooter("This prompt will cancel after 200 seconds.")
.setTimestamp()
msg.channel.send(robloxEmbed) //Send the first Embed
collector.on("collect", m => {
if(m.content.toLowerCase() === 'cancel') {
message.channel.send('**Cancelled prompt.**')
return
} //Collector1 End
noblox.getIdFromUsername(m.content).then(foundId => { //Get the userID from username
const Id = foundId
const newString = makeid() + makeid() + makeid() + makeid() + makeid() //Emoji thing
const foundUsername = new Discord.MessageEmbed()
.setColor("BLUE")
.setTitle("Prompt")
.setDescription("Hello **" + m.content + "**, to verify that you are that user. Please put this in your **Roblox** description, or **Roblox** status. \n `" + newString + "`\n\nSay **done** when complete.\nSay **cancel** to cancel. ")
.setFooter("This will auto cancel in 200 seconds")
.setTimestamp()
msg.channel.send(foundUsername) //The part where it asks you to add the Code
const collector2 = message.channel.createMessageCollector(filter, { max: '1', maxMatches: "1", time: "200000" }) // Collector2
collector2.on('collect', async mag => {
if(mag.content.toLowerCase().includes('done') & mag.content.toLowerCase().includes("done") && mag.author.id == message.author.id) {
const fetchingBlurb = new Discord.MessageEmbed()
.setColor("BLUE")
.setTitle("Prompt")
.setDescription("Fetching your emojis, please wait as I am going to fetch it.")
.setFooter("Fetching..")
.setTimestamp()
msg.channel.send(fetchingBlurb) //Checks the Blurb / Status
setTimeout(function() { //Timeout Stuff
noblox.getStatus(foundId).then(status => { //Check status
console.log(status) //Console.log the status
noblox.getBlurb(foundId).then(blurb => { // Checks the blurb
if(status.includes(newString) || blurb.includes(newString)) { // If code is in blurb procceds with operation
const verified = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle("Prompt")
.setDescription("You have now been verified! Please wait shortly as you are going to recieve the Verified role.")
.setFooter("Verifying..")
.setTimestamp()
msg.channel.send(verified) // Sent if user has put code
let Verified = message.guild.roles.cache.find(r => r.name === 'Verified')
message.member.roles.add(Verified) // Add the users role
message.member.setNickname(m.content) // Sets the users nickname
} else {
noblox.getStatus(foundId).then(status => { //Check status
console.log(status)
var eMbEd = new Discord.MessageEmbed()
.setColor('RED')
.setTitle("Emoji Not Found")
.setDescription(`Your status:${status}`)
.setTimestamp()
message.channel.send(eMbEd) // Sent if user has not put code
})
}
})
}, 5000)
})
} else
if(mag.content.includes('cancel') && mag.author.id == message.author.id) {
message.channel.send('**Cancelled prompt.**') // If user says `Cancel`
return
}
})
})
})
}
Client.on("message", msg =>
{
if (msg.content.toLowerCase() == `${Prefix}verify`)
{
Verification(msg) //Calling Function
}
})
Client.login("TOKEN HERE") //Insert your token here make sure it is in `" "`
Now in Terminal (CTRL + `) type node [file name]
for me it is:
node index.js
More Help
So you need more help or maybe you didnโt understand my grammar There are more posts on DevForum like these so you can read them as well:
[TUTORIAL] How to make a Verification Command! [NODE.JS]
After this you can save file using CTRL + S or Using File button [MAKE SURE TO SAVE OR IT WONโT WORK]
If You have any info My Twitter is @Megatank9 you can tag me there this is my 1st tutorial hope you enjoyed!
THIS MAY OR MAY NOT BE UPDATED IN FUTURE.