Thingus
This commit is contained in:
commit
4fb4c02c92
6
.env.example
Normal file
6
.env.example
Normal file
|
@ -0,0 +1,6 @@
|
|||
RBX_TOKEN=ROBLOSECURITY_Cookie_data
|
||||
DISCORD_TOKEN=discordtoken
|
||||
CURRENCY="R$"
|
||||
PENDING=":alarm_clock"
|
||||
SUMMARY_CHANNEL_ID=
|
||||
GROUPID=
|
130
.gitignore
vendored
Normal file
130
.gitignore
vendored
Normal file
|
@ -0,0 +1,130 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
16
clock.svg
Normal file
16
clock.svg
Normal file
|
@ -0,0 +1,16 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 1008 28 28" id="alarmclock">
|
||||
<g id="XMLID_301_">
|
||||
<path id="XMLID_302_" fill="#FFFFFF" d="M14,1033c-5.5,0-10-4.5-10-10s4.5-10,10-10s10,4.5,10,10S19.5,1033,14,1033z M14,1015 c-4.4,0-8,3.6-8,8s3.6,8,8,8s8-3.6,8-8S18.4,1015,14,1015z"/>
|
||||
</g>
|
||||
<g id="XMLID_296_">
|
||||
<g id="XMLID_299_">
|
||||
<path id="XMLID_300_" fill="#FFFFFF" d="M23.2,1016.3c-0.3,0-0.6-0.1-0.8-0.4c-1.2-1.5-2.8-2.6-4.7-3.3c-0.5-0.2-0.8-0.8-0.6-1.3 c0.2-0.5,0.8-0.8,1.3-0.6c2.1,0.8,4.1,2.1,5.5,3.9c0.4,0.4,0.3,1.1-0.1,1.4C23.6,1016.2,23.4,1016.3,23.2,1016.3z"/>
|
||||
</g>
|
||||
<g id="XMLID_297_">
|
||||
<path id="XMLID_298_" fill="#FFFFFF" d="M4.8,1016.3c-0.2,0-0.5-0.1-0.6-0.2c-0.4-0.4-0.5-1-0.1-1.4c1.5-1.7,3.4-3.1,5.5-3.9 c0.5-0.2,1.1,0.1,1.3,0.6s-0.1,1.1-0.6,1.3c-1.8,0.7-3.4,1.8-4.7,3.3C5.4,1016.2,5.1,1016.3,4.8,1016.3z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="XMLID_294_">
|
||||
<path id="XMLID_295_" fill="#FFFFFF" d="M17,1027c-0.3,0-0.5-0.1-0.7-0.3l-3-3c-0.2-0.2-0.3-0.4-0.3-0.7v-6c0-0.6,0.4-1,1-1 s1,0.4,1,1v5.6l2.7,2.7c0.4,0.4,0.4,1,0,1.4C17.5,1026.9,17.3,1027,17,1027z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
121
index.js
Normal file
121
index.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
require("dotenv").config();
|
||||
const noblox = require('noblox.js')
|
||||
const Discord = require('discord.js')
|
||||
const colors = require('colors')
|
||||
|
||||
const discord = new Discord.Client(
|
||||
{
|
||||
intents: [
|
||||
"Guilds",
|
||||
"GuildWebhooks",
|
||||
"GuildMessages"
|
||||
]
|
||||
}
|
||||
)
|
||||
const currency = process.env.CURRENCY
|
||||
const pending = process.env.PENDING
|
||||
function makeSummaryString(summaryData) {
|
||||
const grandTotal = summaryData.recurringRobuxStipend + summaryData.itemSaleRobux + summaryData.purchasedRobux + summaryData.tradeSystemRobux + summaryData.pendingRobux + summaryData.groupPayoutRobux + summaryData.individualToGroupRobux + summaryData.premiumPayouts + summaryData.groupPremiumPayouts + summaryData.adjustmentRobux + summaryData.immersiveAdPayouts + summaryData.subscriptionPayouts + summaryData.subscriptionClawbacks + summaryData.commissionRobux + summaryData.publishingAdvanceRebates
|
||||
const total = grandTotal - summaryData.pendingRobux
|
||||
const summaryString = `Sales: **${currency}${summaryData.itemSaleRobux.toLocaleString()}**
|
||||
Pending Robux: **${currency}${pending}${summaryData.pendingRobux.toLocaleString()}**
|
||||
Group Revenue Payouts: **${currency}${summaryData.groupPayoutRobux.toLocaleString()}**
|
||||
Group Premium Payouts: **${currency}${summaryData.groupPremiumPayouts.toLocaleString()}**
|
||||
|
||||
__Total: **${currency}${grandTotal.toLocaleString()}**__
|
||||
__**Grand Total: ${currency}${total.toLocaleString()}**__`;
|
||||
return summaryString
|
||||
}
|
||||
|
||||
const updateWebhook = async function () {
|
||||
const fundsSummaryEmbeds = {
|
||||
title: `Funds Summary for ${groupData.name}`,
|
||||
color: 0x00ff00,
|
||||
thumbnail: {
|
||||
url: groupLogoUrl
|
||||
},
|
||||
timestamp: new Date(),
|
||||
footer: {
|
||||
text: "Last updated"
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: "Today",
|
||||
value: makeSummaryString(await noblox.getGroupRevenueSummary(process.env.GROUPID, "Day")),
|
||||
},
|
||||
{
|
||||
name: "This Week",
|
||||
value: makeSummaryString(await noblox.getGroupRevenueSummary(process.env.GROUPID, "Week")),
|
||||
},
|
||||
{
|
||||
name: "This Month",
|
||||
value: makeSummaryString(await noblox.getGroupRevenueSummary(process.env.GROUPID, "Month")),
|
||||
},
|
||||
{
|
||||
name: "This Year",
|
||||
value: makeSummaryString(await noblox.getGroupRevenueSummary(process.env.GROUPID, "Year")),
|
||||
},
|
||||
{
|
||||
name: "All Time",
|
||||
value: makeSummaryString(await noblox.getGroupRevenueSummary(process.env.GROUPID))
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
webhook.editMessage(message.id, {
|
||||
embeds: [fundsSummaryEmbeds]
|
||||
}).then(() => {
|
||||
console.log(`${colors.green("[DISCORD]")} Updated webhook message with new funds summary`);
|
||||
}).catch((err) => {
|
||||
console.log(`${colors.red("[DISCORD]")} Error: ${err.stack}`);
|
||||
})
|
||||
|
||||
};
|
||||
var groupLogoUrl;
|
||||
var groupData;
|
||||
var webhook;
|
||||
var message;
|
||||
var channel;
|
||||
discord.on('ready', async () => {
|
||||
console.log(`${colors.cyan("[DISCORD")} Logged in as ${discord.user.displayName}`);
|
||||
channel = await discord.channels.cache.get(process.env.SUMMARY_CHANNEL_ID);
|
||||
|
||||
noblox.setCookie(process.env.RBX_TOKEN).then(async (current) => {
|
||||
console.log(`${colors.cyan("[ROBLOX]")} Logged in as ${current.displayName}`);
|
||||
console.log(`${colors.cyan("[ROBLOX]")} Fetching group data...`);
|
||||
groupData = await noblox.getGroup(process.env.GROUPID)
|
||||
groupLogoUrl = await noblox.getLogo(process.env.GROUPID)
|
||||
console.log(`${colors.cyan("[ROBLOX]")} Fetched group data for ${groupData.name}`);
|
||||
const transactionEvent = noblox.onGroupTransaction(process.env.GROUPID, "Sale")
|
||||
transactionEvent.on("data", async function (data) {
|
||||
console.log(`${colors.green("[ROBLOX]")} New Transaction: ${data.idHash}`);
|
||||
updateWebhook();
|
||||
})
|
||||
transactionEvent.on("error", function (err) {
|
||||
console.log(`${colors.red("[ROBLOX]")} Error: ${err.stack}`);
|
||||
});
|
||||
// Try to find an existing webhook made by discord.user.id, if not exists make one named ${groupData.name} Funds Summary with the group logo as the icon
|
||||
const webhooks = await channel.fetchWebhooks();
|
||||
webhook = webhooks.find(w => w.owner.id === discord.user.id && w.channelId == process.env.SUMMARY_CHANNEL_ID)
|
||||
if (!webhook) {
|
||||
webhook = await channel.createWebhook({
|
||||
name: `${groupData.name} Funds Summary`,
|
||||
avatar: groupLogoUrl,
|
||||
reason: "Funds Summary Webhook"
|
||||
});
|
||||
}
|
||||
// Try to find the latest message from our webhook, if it doesnt exist send a new one
|
||||
message = await channel.messages.fetch({ limit: 1 }).then(messages => messages.find(m => m.author.id === webhook.id));
|
||||
if (!message) {
|
||||
message = await webhook.send({
|
||||
embeds: [{
|
||||
title: "Please wait..."
|
||||
}]
|
||||
})
|
||||
}
|
||||
updateWebhook();
|
||||
setInterval(updateWebhook, 1 * 60 * 60 * 1000); // Update every hour
|
||||
});
|
||||
})
|
||||
|
||||
discord.login(process.env.DISCORD_TOKEN)
|
1249
package-lock.json
generated
Normal file
1249
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
19
package.json
Normal file
19
package.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"crypto": "^1.0.1",
|
||||
"discord.js": "^14.15.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"noblox.js": "^6.0.2"
|
||||
},
|
||||
"name": "roblortest",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": ""
|
||||
}
|
Loading…
Reference in a new issue