Roblox Search Discord Bot

Although noblox.js will get the job done fine, there is a newer library that has arguably better code structure and uses the latest APIs (I’m pretty sure noblox still uses a few outdated APIs, but don’t quote me on that).

If you’re interested in trying it out, here’s the link to its GitHub repository: GitHub - affenity/bloxy: Interact with the Roblox website and API

4 Likes

I see, I’ll familiarise myself with it and hope to make the same tutorial using bloxy, this’ll be fun.

It is still being worked on and is missing some of the methods that noblox has, but I think that the usage is more straightforward (personally).

Good luck with that :stuck_out_tongue:

1 Like

Possible merger :eyes: and yes, it does use some outdated APIs.

2 Likes

Already made one but if you want to improve upon my insanely old article go ahead.

2 Likes

There’s been a lot of api changes since; not sure it’d still work

1 Like

I simply direct them to use noblox and the new login method.

1 Like

What is wrong with bloxy? Is there something bad about it, or is it that you don’t like dealing with classes?

1 Like

Nothing wrong with it, just more comfortable with noblox.

Going to quickly bump this so more people are enticed to try this on their own.

(if you recreate this in Lua, please let me know and I’ll add it onto the tutorial)

The OP has been redone, thank you for your feedback.

This tutorial is fabulous, @DEMOLURKS is not only a talented User Interfaces Designer but also a great Discord Bots Programmer.

Something I would like to add on is, maybe try to make tutorials of other roblox-related commands for people who may need it.

2 Likes

Hey.

    module.exports.run = async (bot, message, args) => {
      let username = args[0]
     if (username) {
       roblox.getIdFromUsername(username).then(id => { // gets user id for the specific part of the embed
         if (id) {
           roblox.getPlayerInfo(parseInt(id)).then(function(info) {
             let date = new Date(info.joinDate) // states join date
             let dateInfo = bot.extractDate(date) 
             let embed = new discord.RichEmbed() // starts a new embed

             .setColor("#f9ae00") // sets the color of the embed
             .setURL(`https://roblox.com/users/${id}/profile`) // base link, changed by the variables 'id'
             .setTimestamp()
             .setThumbnail(`https://www.roblox.com/bust-thumbnail/image?userId=${id}&width=420&height=420&format=png`) // gets the roblox profile picture

             .addField("Username", info.username || 'Unresolvable', true) // everything in the embed is undefined, therefore can be changed by the variables
             .addField("User ID", id || 'Unresolvable', true)
             .addField("Blurb", info.blurb || 'Nothing', true)
             .addField("Status", info.status || 'Nothing', true)
             .addField("Account Age", `${info.age} days old` || 'Unresolvable')
             .addField("Register Date", `${dateInfo.month}/${dateInfo.day}/${dateInfo.year}` || 'Unresolvable')
             .addField("User Link", `https://roblox.com/users/${id}/profile`)
             .setFooter(`Powered By DEMOLURKS tutorial.`, bot.user.avatarURL)
              message.channel.send({embed})
           })
         }

       }).catch(function (err) {
         message.channel.send("Sorry, that user doesn't seem to exist, double check your spelling and try again!") // catching error
       });
    } else {
       message.channel.send("Please provide a valid username, e.g. '-search ROBLOX'.") 
     }
        }

    module.exports.help = {
        name: "search" // command name
    }

The command is well done but I think you should add a catch function to roblox.getPlayerInfo as well. If the user you try to search is banned, it will throw an error.

2 Likes

Thanks for telling me; I’ll get to it when I find some free time.

1 Like

Updated the title, it’s now more specific to what it actually is.

Just saying, instead of ```js

if(err) { return console.error(err) };

You can do:

if (err) return console.error(err);

Saves a bit of space :slight_smile:

1 Like

It’s just a force of habit haha.

Newly commented code is now here, I’m sorry it took me so long, kinda forgot I made this LOL.

Do I put the project as a hello-express, hello-webpage, or hello-sqlite?

hello-express, since it’s a node app