-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
208 lines (188 loc) · 8.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
const { Client, Intents, MessageEmbed } = require('discord.js');
const noblox = require("noblox.js");
const cheerio = require('cheerio');
const rassets = require("rassets")
const axios = require('axios');
const fs = require('fs');
const config = require("./config.json");
const channel = config.upload_channel;
const name = config.game_name;
const desc = config.game_description;
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES]
});
function removeFirstLineOfFile(filePath) {
let data = fs.readFileSync(filePath, 'utf8');
data = data.substr(data.indexOf('\n') + 1);
fs.writeFileSync(filePath, data, 'utf8');
}
function getFirstLineOfFile(filePath) {
let data = fs.readFileSync(filePath, 'utf8');
return data.substr(0, data.indexOf('\n'));
}
function getRandomFile(dir) {
const files = fs.readdirSync(dir)
const file = files[Math.floor(Math.random() * files.length)]
return dir + file
}
async function upload() {
client.channels.cache.get(channel).bulkDelete(100);
setTimeout(function() {
const embed = new MessageEmbed()
.setTitle("Uploading...")
.setColor("#8c03fc")
client.channels.cache.get(channel).send({embeds: [ embed ]}).then(async msg => {
const confile = getRandomFile("games/")
const cookie = getFirstLineOfFile("cookies.txt").replace("\n", "").replace("\r", "")
removeFirstLineOfFile("cookies.txt")
noblox.setCookie(cookie).then(user => {
axios({
method: "get",
url: "https://www.roblox.com/users/inventory/list-json?assetTypeId=9&cursor=&itemsPerPage=100&pageNumber=1&placeTab=Created&userId=" + user.UserID,
}).then(info => {
const placeid = info.data.Data.Items[0].Item.AssetId
rassets.upload(cookie, {
file: fs.createReadStream(confile),
assetType: "Place",
name: name,
assetid: placeid,
description: desc,
ispublic: true,
}).then(() => {
const preparing = new MessageEmbed()
.setTitle("Preparing...")
.setColor("#8c03fc")
msg.edit({embeds: [ preparing ]})
axios({
method: "get",
url: "https://api.roblox.com/universes/get-universe-containing-place?placeid=" + placeid,
}).then(re => {
noblox.updateUniverseAccess(re.data.UniverseId, true)
noblox.getGeneralToken().then(token => {
axios({
method: "patch",
url: `https://develop.roblox.com/v2/universes/${re.data.UniverseId}/configuration`,
headers: {
"x-csrf-token": token,
"content-type": "application/json",
"cookie": ".ROBLOSECURITY=" + cookie,
},
data: {
allowPrivateServers: true,
privateServerPrice: 0,
name: name,
description: desc,
universeAvatarType: "MorphToR6",
universeAnimationType: "Standard",
universeCollisionType: "InnerBox",
universeJointPositioningType: "Standard",
isArchived: false,
isFriendsOnly: false,
genre: "All",
isForSale: false,
price: 0,
studioAccessToApisAllowed: true,
permissions: {
isThirdPartyTeleportAllowed: true,
IsThirdPartyAssetAllowed: true,
IsThirdPartyPurchaseAllowed: true,
}
}
}).catch(err => {
axios({
method: "patch",
url: `https://develop.roblox.com/v2/universes/${re.data.UniverseId}/configuration`,
headers: {
"x-csrf-token": token,
"content-type": "application/json",
"cookie": ".ROBLOSECURITY=" + cookie,
},
data: {
allowPrivateServers: true,
privateServerPrice: 0,
name: name,
description: desc,
universeAvatarType: "MorphToR6",
universeAnimationType: "Standard",
universeCollisionType: "InnerBox",
universeJointPositioningType: "Standard",
isArchived: false,
isFriendsOnly: false,
genre: "All",
isForSale: false,
price: 0,
studioAccessToApisAllowed: true,
permissions: {
isThirdPartyTeleportAllowed: true,
IsThirdPartyAssetAllowed: true,
IsThirdPartyPurchaseAllowed: true,
}
}
}).catch(err => { })
})
axios({
method: "patch",
url: `https://develop.roblox.com/v2/places/${placeid}`,
headers: {
"x-csrf-token": token,
"content-type": "application/json",
"cookie": ".ROBLOSECURITY=" + cookie,
},
data: {
name: name,
description: desc,
maxPlayerCount: config.player_count
}
}).catch(err => { console.log(err) })
setTimeout(function() {
noblox.getPlaceInfo(placeid).then(info => {
if (info.IsPlayable.toString() == "true") {
const ready = new MessageEmbed()
.setTitle(`https://www.roblox.com/games/${placeid}/-`)
.setColor("#8c03fc")
msg.edit({embeds: [ ready ]})
var startNew = false
setInterval(function() {
try {
noblox.getPlaceInfo(placeid).then(info2 => {
if (info2.IsPlayable.toString() == "false" || info2.Name == "[ Content Deleted ]" && startNew == false) {
startNew = true
upload()
clearInterval(this)
}
}).catch(err => {
if (startNew == false) {
startNew = true
upload()
clearInterval(this)
}
})
} catch {
}
}, 5000)
} else {
upload()
}
})
}, 500)
})
})
}).catch(err => {
console.log("Failed to upload. Possibly corrupted file")
})
}).catch(err => {
upload()
})
}).catch(err => {
upload()
})
})
}, 2000)
}
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
setTimeout(function() {
upload()
}, 2000)
client.login(config.bot_token);