I want to create a command on a discord bot that basically is /hello
the bot will then send the information to the ROBLOX Game printing the statement “Hello from discord” within the console.
Any ideas would be great
I want to create a command on a discord bot that basically is /hello
the bot will then send the information to the ROBLOX Game printing the statement “Hello from discord” within the console.
Any ideas would be great
I’d recommend looking into Roblox API LuauExecutionSessionTask through OpenCloud, I think you could achieve this. (docs: here, announcement: here.) If you create an OpenCloud API key to perform this, your code could look something like this:
//Node.js
const {Client, GatewayIntentBits, Partials} = require("discord.js");
const bot = new Client({
Intents: [/*GatewayIntentBits*/],
Partials: [/*Partials (optional)*/]
});
const placeId = //place id
const universeId = //universe id
const apiKey = //your api key
bot.once("ready", () => console.log("Bot online.")); //when logged in
async function sendMessageAsync() {
let response = await fetch(`/cloud/v2/universes/${universe}/places/${place}/luau-execution-session-tasks`, {
method: "POST", //sending a POST request
headers: {
"x-api-key": apiKey,
//other headers you need
},
body: //any stuff u need to send with the request
});
if (!response.ok) {throw new Error("FAILED: " + String(response.status))};
//do stuff with response
};
bot.on("messageCreate", message => {
//check message
if (!message.content.startsWith("/hello")) {return null;};
sendMessageAsync().catch(error => message.channel.send("Failed: " + String(error))}; //send message
});
bot.login("YOUR_BOT_TOKEN"); //log the bot in
npm init -y
npm install discord.js
So, you could cause a Luau script to execute with this API.
Would there be anything on the ROBLOX side like print statement through the server?
Well yes, since you could cause any code (without restrictions, see docs I linked), to execute, such as a print statement.
If you are looking to do something like running commands in every server, your best option is the MessagingService. OpenCloud has documentation for tying into that from outside. The execution stuff 12345koip has mentioned is for running arbitrary code
Yup figured how to do through open cloud and messaging service just a problem now with returning it back.
You’ll need your own web server to process the request back. The servers will have to report to you that it ran (you will get multiple responses if you have multiple servers).