2022-05-12 19:56:35 +00:00
|
|
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
|
|
|
const noblox = require("noblox.js");
|
2022-05-13 05:06:45 +00:00
|
|
|
const { bhopCookie, surfCookie, deathrunCookie } = require("../config.json");
|
2022-05-12 19:56:35 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
.setName('take')
|
|
|
|
.setDescription('Takes an asset ID')
|
2022-05-13 05:06:45 +00:00
|
|
|
.addStringOption(option =>
|
|
|
|
option.setName("game")
|
|
|
|
.setDescription("Select the maptest game")
|
|
|
|
.setRequired(true)
|
|
|
|
.addChoices({name: "bhop", value: "bhop"}, {name: "surf", value: "surf"}, {name: "deathrun", value: "deathrun"}))
|
2022-05-12 19:56:35 +00:00
|
|
|
.addIntegerOption(option =>
|
|
|
|
option.setName("asset_id")
|
|
|
|
.setDescription("The asset ID of the model")
|
|
|
|
.setRequired(true))
|
|
|
|
,
|
|
|
|
async execute(interaction) {
|
2022-05-13 05:06:45 +00:00
|
|
|
const game = interaction.options.getString("game");
|
|
|
|
let cookie;
|
|
|
|
if (game == "bhop") cookie = bhopCookie;
|
|
|
|
else if (game == "surf") cookie = surfCookie;
|
|
|
|
else if (game == "deathrun") cookie = deathrunCookie;
|
|
|
|
else {
|
|
|
|
await interaction.reply("Invalid game specified!");
|
|
|
|
return;
|
|
|
|
}
|
2022-05-12 19:56:35 +00:00
|
|
|
const id = interaction.options.getInteger("asset_id");
|
2022-05-13 05:06:45 +00:00
|
|
|
await noblox.setCookie(cookie).then(async () => {
|
|
|
|
noblox.buy(id, 0).then(async () => {
|
|
|
|
await interaction.reply(
|
|
|
|
`
|
|
|
|
Now that your map (id: ${id}) has been taken by the ${game} maptest bot you can load it into the ${game} maptest place. To load your map, join the game and say
|
|
|
|
\`\`\`
|
|
|
|
!map ${id}
|
|
|
|
\`\`\`Read what it says. If your map successfully loaded type !rtv and then choose your map.
|
|
|
|
If it did not load successfully, you can expand the chat to view the full error message by clicking and dragging on the edge of the chat.
|
|
|
|
`
|
|
|
|
);
|
|
|
|
})
|
2022-05-12 19:56:35 +00:00
|
|
|
.catch(async (error) => {
|
2022-05-13 05:06:45 +00:00
|
|
|
if (error.message == "You already own this item.") {
|
|
|
|
await interaction.reply("The bot has already taken this model!");
|
|
|
|
} else {
|
|
|
|
await interaction.reply(`An error occured trying to take the model (id: ${id}). Make sure it is uncopylocked!`);
|
|
|
|
console.log(`Could not take asset ID ${id}: `);
|
|
|
|
console.log(error);
|
|
|
|
}
|
2022-05-12 19:56:35 +00:00
|
|
|
});
|
|
|
|
});
|
2022-05-13 05:06:45 +00:00
|
|
|
}
|
2022-05-12 19:56:35 +00:00
|
|
|
};
|