Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const bot = new Discord.Client();
- const Command = require('command');
- const items = [ //Dragons
- {name: 'Dragon skill ancient mighty fire', id: 99104, price: 'undefined'},
- {name: 'Dragon skill ancient mighty armored', id: 99120, price: 'undefined'},
- //Costumes
- {name: 'Smart box: Designer shirt', id: 246112, price: 'undefined'},
- {name: 'Elin designer shirt', id: 246112, price: 'undefined'},
- {name: 'Smart box: Dyeable Chambermaid', id: 246081, price: 100000},
- {name: 'Elleon moon', id: 246003, price: 50000}];
- {name: 'Dyeable black stocking', id: 177896, price: 'undefined'},
- {name: 'Dyeable white stocking', id: 177761, price: 'undefined'},
- //Expensive products
- {name: 'Liberation scroll', id: 94002, price: 100000},
- {name: 'Noble enigmatic', id: 179886, price: 100000},
- //Innerwears
- {name: 'Quality fresh', id: 99462, price: 120000},
- {name: 'Splendid sporty', id: 97938, price: 90000},
- {name: 'Splendid fresh', id: 97936, price: 40000},
- //Regular supplies
- {name: 'Semi-enigmatic scroll', id: 399, price: 1000},
- {name: 'Spellbind', id: 445, price: 120},
- {name: 'Combat acc', id: 150940, price: 120},
- {name: 'Master enigmatic scroll', id: 71, price: 110},
- {name: 'Lamb bulgogi', id: 71418, price: 350},
- {name: 'Strong cane', id: 150535, price: 300},
- {name: 'Noctenium infusion', id: 1300, price: 1.3}]
- module.exports = function brokerAlerter(dispatch) {
- let enabled = false;
- let timer = null;
- let i = 0;
- const command = Command(dispatch)
- //Commands
- command.add('camper', () => {
- if(!enabled) {
- enabled = true;
- console.log('Starting.');
- command.message('Broker Checker: <font color="#00FF00">enabled</font><font color="#F86EFF">.</font>');
- searchPrices();
- }
- else {
- console.log('Stopping.');
- command.message('Broker Checker: <font color="#FF0000">disabled</font><font color="#F86EFF">.</font>');
- stop();
- }
- })
- //Turning off when logging out
- dispatch.hook('C_RETURN_TO_LOBBY', 1, () => {
- if(enabled) {
- command.message('<font color="#fc0008">Stopping cuz you chose to log out.</font>');
- stop();
- }
- })
- //Turning on when logging in
- dispatch.hook('S_LOGIN', 1, event => {
- enabled = true;
- searchPrices();
- });
- //Hooking the results of the broker search
- dispatch.hook('S_TRADE_BROKER_WAITING_ITEM_LIST', 1, event => {
- if(enabled && event.listings.length > 0) {
- var itemID = event.listings[0].item;
- var itemPrice = event.listings[0].price.low/event.listings[0].quantity/10000;
- for(var j = 0; j < items.length; j++) {
- if(items[j].id == itemID && (items[j].price == 'undefined' || itemPrice <= items[j].price)) {
- console.log('found product');
- message(items[j].name + ' at broker for ' + itemPrice + 'g each!');
- }
- }
- }
- })
- //Function to search broker for items
- function searchPrices() {
- if(enabled) {
- if(i >= items.length) {
- i = 0;
- }
- console.log("Searching for product: " + items[i].name);
- dispatch.toServer('C_TRADE_BROKER_WAITING_ITEM_LIST_NEW', 1, {
- lvlMin: 1,
- lvlMax: 65,
- rarity: 0,
- negotiable: 0,
- idStatus: 0,
- masterwork: 0,
- enchantable: 0,
- itemLvlMin: 0,
- itemLvlMax: 597,
- tierMin: 0,
- tierMax: 12,
- enchantMin: 0,
- enchantMax: 15,
- priceMin: { low: 1, high: 0, unsigned: false },
- priceMax: { low: 1115752192, high: 23, unsigned: false },
- unk1: 0,
- unk11: 1,
- exact: 0,
- unk2: 0,
- unk3: 0,
- unk4: 90000000,
- unk5: 0,
- unk6: 0,
- query: items[i].name,
- categories: '',
- items: '',
- query2: ''
- })
- i++;
- }
- timer = setTimeout(searchPrices, Math.floor(Math.random() * 5000) + 5000)
- }
- //Function to stop
- function stop() {
- clearTimeout(timer)
- enabled = false
- }
- bot.login('MzQ2MDAyMzA2ODYyNTQ2OTQ0.DHDlaQ.Ul7HvRdNZ-cHteNEfZGsfei0e0M');
- var channel;
- bot.on('ready', () => {
- channel = bot.channels.get('346011481869123595');
- channel.send('Broker bot activated.');
- });
- function message(msg) {
- channel.send(msg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement