Okay, this should work
This commit is contained in:
parent
e7b8facf0a
commit
d1e7653708
50
index.js
50
index.js
|
@ -1,30 +1,64 @@
|
|||
const config = require("./config.json")
|
||||
const config = require("./config.json");
|
||||
const fs = require("fs");
|
||||
const SteamUser = require("steam-user");
|
||||
const TeamFortress2 = require("tf2");
|
||||
let user = new SteamUser()
|
||||
let tf2 = new TeamFortress2(user)
|
||||
const Discord = require("discord.js");
|
||||
const bot = new Discord.Client({intents: ["GuildMessages", "Guilds", "MessageContent"]});
|
||||
const ring_hook = new Discord.WebhookClient({"url": config.discord.ring_webhook});
|
||||
const notif_hook = new Discord.WebhookClient({"url": config.discord.notification_webhook}, {"allowedMentions": false});
|
||||
const pan_hook = new Discord.WebhookClient({"url": config.discord.pan_webhook}, {"allowedMentions": false});
|
||||
let user = new SteamUser();
|
||||
let tf2 = new TeamFortress2(user);
|
||||
|
||||
user.logOn(config.steam)
|
||||
user.logOn(config.steam);
|
||||
|
||||
user.on("loggedOn", (stuff) => {
|
||||
user.setPersona(1);
|
||||
console.log("LOGGED IN TO STEAM")
|
||||
//user.setPersona(1); //Just needed this to check that it was logging in properly, and not false reporting a successful log in lol
|
||||
console.log("Logged into steam")
|
||||
user.gamesPlayed([440]);
|
||||
tf2.setLang("./tf_english.txt")
|
||||
tf2.setLang(fs.readFileSync("./tf_english.txt").toString())
|
||||
if(tf2.lang) console.log("Updated the localization files")
|
||||
})
|
||||
|
||||
tf2.on("connectedToGC", (ver) => {
|
||||
console.log(`CONNECTED TO GC`)
|
||||
console.log(`Connected to Game Coordinator, Listening for events!`)
|
||||
})
|
||||
|
||||
tf2.on("systemMessage", (msg) => {
|
||||
console.log(`New System Message: ${msg}`)
|
||||
notif_hook.send({embeds: [
|
||||
{
|
||||
description: msg,
|
||||
timestamp: new Date(),
|
||||
color: Discord.Colors.Gold
|
||||
}
|
||||
]})
|
||||
})
|
||||
|
||||
tf2.on("itemBroadcast", (msg, username, wasDestruction, defindex) => {
|
||||
console.log(`New Item BC:\nMsg:${msg}\nUser:${username}\nDestroy?:${wasDestruction}`)
|
||||
|
||||
})
|
||||
|
||||
tf2.on("displayNotification", (title, body) => {
|
||||
console.log(`New Notif: ${title}: ${body}`)
|
||||
ring_hook.send({embeds: [
|
||||
{
|
||||
description: body,
|
||||
timestamp: new Date(),
|
||||
color: Discord.Colors.Gold
|
||||
}
|
||||
]})
|
||||
})
|
||||
|
||||
bot.on("ready", () => {
|
||||
console.log("Logged into Discord");
|
||||
})
|
||||
|
||||
bot.on("messageCreate", (msg) => {
|
||||
if (config.discord.channels.includes(msg.channel.id)) {
|
||||
msg.crosspost();
|
||||
}
|
||||
})
|
||||
|
||||
bot.login(config.discord.token);
|
Loading…
Reference in a new issue