Okay, this should work
This commit is contained in:
parent
e7b8facf0a
commit
d1e7653708
52
index.js
52
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 SteamUser = require("steam-user");
|
||||||
const TeamFortress2 = require("tf2");
|
const TeamFortress2 = require("tf2");
|
||||||
let user = new SteamUser()
|
const Discord = require("discord.js");
|
||||||
let tf2 = new TeamFortress2(user)
|
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.on("loggedOn", (stuff) => {
|
||||||
user.setPersona(1);
|
//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 IN TO STEAM")
|
console.log("Logged into steam")
|
||||||
user.gamesPlayed([440]);
|
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) => {
|
tf2.on("connectedToGC", (ver) => {
|
||||||
console.log(`CONNECTED TO GC`)
|
console.log(`Connected to Game Coordinator, Listening for events!`)
|
||||||
})
|
})
|
||||||
|
|
||||||
tf2.on("systemMessage", (msg) => {
|
tf2.on("systemMessage", (msg) => {
|
||||||
console.log(`New System Message: ${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) => {
|
tf2.on("itemBroadcast", (msg, username, wasDestruction, defindex) => {
|
||||||
console.log(`New Item BC:\nMsg:${msg}\nUser:${username}\nDestroy?:${wasDestruction}`)
|
console.log(`New Item BC:\nMsg:${msg}\nUser:${username}\nDestroy?:${wasDestruction}`)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
tf2.on("displayNotification", (title, body) => {
|
tf2.on("displayNotification", (title, body) => {
|
||||||
console.log(`New Notif: ${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