Reformat and move things around a bit

This commit is contained in:
Christopher Cookman 2023-09-12 15:30:09 -06:00
parent 7c20c269cd
commit 0e5781ca6d
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -12,6 +12,18 @@ const notif_hook = new Discord.WebhookClient({"url": config.discord.notification
const pan_hook = new Discord.WebhookClient({ "url": config.discord.pan_webhook }); const pan_hook = new Discord.WebhookClient({ "url": config.discord.pan_webhook });
let user = new SteamUser(); let user = new SteamUser();
let tf2 = new TeamFortress2(user); let tf2 = new TeamFortress2(user);
user.logOn(config.steam);
user.on("loggedOn", async (stuff) => {
//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(`${colors.cyan("[Steam]")} Logged into steam`)
await user.gamesPlayed([440]);
})
tf2.on("connectedToGC", async (ver) => {
console.log(`${colors.yellow("[TF2]")} Connected to GC, version: ${ver}`)
// Get lang file from tf wiki https://wiki.teamfortress.com/w/images/c/cf/Tf_english.txt // Get lang file from tf wiki https://wiki.teamfortress.com/w/images/c/cf/Tf_english.txt
console.log(`${colors.green("[Lang]")} Getting TF2 Lang File from wiki`); console.log(`${colors.green("[Lang]")} Getting TF2 Lang File from wiki`);
axios.get("https://wiki.teamfortress.com/w/images/c/cf/Tf_english.txt").then((res) => { axios.get("https://wiki.teamfortress.com/w/images/c/cf/Tf_english.txt").then((res) => {
@ -34,17 +46,6 @@ axios.get("https://wiki.teamfortress.com/w/images/c/cf/Tf_english.txt").then((re
console.log(`${colors.green("[Lang]")} Failed to load TF2 Lang File`); console.log(`${colors.green("[Lang]")} Failed to load TF2 Lang File`);
} }
}) })
user.logOn(config.steam);
user.on("loggedOn", async (stuff) => {
//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(`${colors.cyan("[Steam]")} Logged into steam`)
await user.gamesPlayed([440]);
})
tf2.on("connectedToGC", async (ver) => {
console.log(`${colors.yellow("[TF2]")} Connected to GC, version: ${ver}`)
}) })
tf2.on("disconnectedFromGC", (reason) => { tf2.on("disconnectedFromGC", (reason) => {
@ -53,32 +54,38 @@ tf2.on("disconnectedFromGC", (reason) => {
tf2.on("systemMessage", (msg) => { tf2.on("systemMessage", (msg) => {
console.log(`${colors.yellow("[TF2]")} New System Message: ${msg}`) console.log(`${colors.yellow("[TF2]")} New System Message: ${msg}`)
notif_hook.send({embeds: [ notif_hook.send({
embeds: [
{ {
description: `<:Messages:1151242960655089744> ${msg}`, description: `<:Messages:1151242960655089744> ${msg}`,
color: 0x3498DB color: 0x3498DB
} }
]}) ]
})
}) })
tf2.on("itemBroadcast", (msg, username, wasDestruction, defindex) => { tf2.on("itemBroadcast", (msg, username, wasDestruction, defindex) => {
console.log(`${colors.yellow("[TF2]")} New Item :$ {msg}`); console.log(`${colors.yellow("[TF2]")} New Item :$ {msg}`);
pan_hook.send({content: wasDestruction?"@everyone":"",embeds: [ pan_hook.send({
content: wasDestruction ? "@everyone" : "", embeds: [
{ {
description: `<:Alert:1151242961485562008> ${msg}`, description: `<:Alert:1151242961485562008> ${msg}`,
color: wasDestruction ? 0xff0000 : 0xF1C40F color: wasDestruction ? 0xff0000 : 0xF1C40F
} }
]}) ]
})
}) })
tf2.on("displayNotification", (title, body) => { tf2.on("displayNotification", (title, body) => {
console.log(`${colors.yellow("[TF2]")} New Notif: ${title}: ${body}`) console.log(`${colors.yellow("[TF2]")} New Notif: ${title}: ${body}`)
ring_hook.send({embeds: [ ring_hook.send({
embeds: [
{ {
description: `<:Alert:1151242961485562008> ${body}`, description: `<:Alert:1151242961485562008> ${body}`,
color: 0xF1C40F color: 0xF1C40F
} }
]}) ]
})
}) })
bot.on("ready", () => { bot.on("ready", () => {
@ -86,10 +93,8 @@ bot.on("ready", () => {
}) })
bot.on("messageCreate", (msg) => { bot.on("messageCreate", (msg) => {
if(msg.author.bot) return; if (!msg.webhookId) return;
if (config.discord.channels.includes(msg.channel.id)) {
msg.crosspost(); msg.crosspost();
}
}) })
const sendTestNotifications = () => { const sendTestNotifications = () => {