This commit is contained in:
DeSqBlocki
2025-02-04 21:22:50 +01:00
parent 62d92137ee
commit 7ed2031cde
5 changed files with 0 additions and 0 deletions
+115
View File
@@ -0,0 +1,115 @@
const TwitchApi = require("node-twitch").default
const { Client, Intents, MessageEmbed } = require('discord.js')
const WOKCommands = require('wokcommands')
const dotenv = require('dotenv')
const path = require('path')
dotenv.config()
const streamers = [
'x__hel__x',
]
const isLive = new Set()
const twitch = new TwitchApi({
client_id: process.env.TTV_ID,
client_secret: process.env.TTV_SECRET
});
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
]
})
client.on('ready', async () => {
//Discord Bot
new WOKCommands(client, {
commandsDir: path.join(__dirname, 'commands'),
ignoreBots: true,
testServers: [process.env.GUILD_ID],
botOwners: ['140508899064283136']
})
.setDefaultPrefix(process.env.PREFIX)
.setDisplayName('-=HelBot Commands=-')
.setCategorySettings([
{
name: 'Minecraft',
emoji: '<:Minecraft:901642179661946940>'
}, {
name: 'Twitch',
emoji: '<:Twitch:888077898400022548>'
}, {
name: 'League',
emoji: '<:LoL:901642179477389353>'
}
])
// const d = await client.api.applications(client.user.id).guilds("887425193969082379").commands.get()
// console.log(d)
//// find all slash command in guild
// client.api.applications(client.user.id).guilds("887425193969082379").commands('901640675131531314').delete();
//// delete specific slash command in guild
const guild = client.guilds.cache.get(process.env.GUILD_ID)
const botchannel = guild.channels.cache.get(process.env.CHANNEL_ID)
//const botchannel = guild.channels.cache.get(process.env.TEST_CHANNEL_ID)
//Twitch API
async function Twitch(stream) {
var streamData
await twitch.getStreams({ channel: stream }).then(async data => {
const r = data.data[0]
if (r) {
//stream online
if (!isLive.has(stream)) {
//not yet in memory
streamData = {
"game": r.game_name,
"title": r.title,
}
} else {
//already in memory
}
} else {
//stream offline
if (isLive.has(stream)) {
//was in memory
console.log(`${stream} went offline :c`)
isLive.delete(stream)
} else {
//was not in memory
}
}
})
return streamData
}
for (var i = 0; i < streamers.length; i++) {
let channel = streamers[i]
setInterval(async () => {
let streamdata = await Twitch(channel)
if (streamdata) {
const imageUrl = `https://static-cdn.jtvnw.net/previews-ttv/live_user_${channel.toLowerCase()}.jpg`
const embed = new MessageEmbed()
.setTitle(`Stream Notice!`)
.setURL(`https://twitch.tv/${channel}`)
.setDescription(`*${streamdata.title}*\nThey're playing **${streamdata.game}**`)
.setTimestamp()
.setFooter('HelBot by DeSqBlocki', 'https://cdn.discordapp.com/attachments/345238918582763520/901262809466282034/HelBotIcon.png')
.setImage(imageUrl)
botchannel.send({
content: `<@&${process.env.NOTIFY_ROLE_ID}> im live <:helcomf:963147337134399508> <a:sparkles:963229266991001630>`,
embeds: [embed]
})
isLive.add(channel)
}
}, 15000);
}
})
client.login(process.env.TOKEN)
+65
View File
@@ -0,0 +1,65 @@
const { MessageEmbed } = require("discord.js")
const TwitchApi = require("node-twitch").default
const twitch = new TwitchApi({
client_id: process.env.TTV_ID,
client_secret: process.env.TTV_SECRET
});
module.exports = {
category: 'Twitch',
description: 'Shows You If A Stream Is Online',
testOnly: true,
expectedArgs: '<channel>',
callback: async ({ client, args, interaction, message }) => {
var channel = args[0]
if (!args.length) {
channel = 'x__hel__x' //default
}
async function Twitch(stream) {
var streamData = undefined
await twitch.getStreams({ channel: stream }).then(async data => {
const r = data.data[0]
if (r) {
streamData = {
"game": r.game_name,
"title": r.title,
}
} else {
}
})
return streamData
}
const streamdata = await Twitch(channel)
var reply
var embed
if (!streamdata || streamdata === undefined) {
reply = `<https://twitch.tv/${channel}> is currently offline!`
} else {
const imageUrl = `https://static-cdn.jtvnw.net/previews-ttv/live_user_${channel.toLowerCase()}.jpg`
embed = new MessageEmbed()
.setTitle(`twitch.tv/${channel}`)
.setURL(`https://twitch.tv/${channel}`)
.setDescription(`${channel} is **live**!\n\nThey're playing **${streamdata.game}**\n [${streamdata.title}]`)
.setTimestamp()
.setFooter('HelBot by DeSqBlocki', 'https://cdn.discordapp.com/attachments/345238918582763520/901262809466282034/HelBotIcon.png')
.setImage(imageUrl)
}
if (interaction){
if(!streamdata || streamdata === undefined){
return reply
} else {
return embed
}
}
if (message){
if(!streamdata || streamdata === undefined){
return reply
} else {
return embed
}
}
}
}
+66
View File
@@ -0,0 +1,66 @@
const { MessageEmbed } = require('discord.js')
const mcsrv = require('mcsrvstat-api')
module.exports = {
category: 'Minecraft',
description: 'Minecraft Server Information',
slash: 'both',
testOnly: true,
callback: ({ client, message, interaction }) => {
mcsrv.fetchData("bettermc.desq-gaming.de")
.then((data) => {
if (data.online === false) {
if (message) {
message.reply({ content: 'Could Not Fetch Server Info. Is It Offline?' })
.then(msg => {
setTimeout(() => {
message.delete()
return msg.delete()
}, 15000)
})
}
if (interaction) {
interaction.reply({ content: 'Could Not Get All Infos. Is It Offline?' })
.then(() => {
setTimeout(() => {
return client.api.webhooks(client.user.id, interaction.token).messages("@original").delete();
}, 15000)
})
}
} else {
const embed = new MessageEmbed()
.setTitle(data.hostname)
.setURL(`https://mcsrvstat.us/server/bettermc.desq-gaming.de`)
.setThumbnail('https://cdn.discordapp.com/attachments/345238918582763520/885475680014458900/PixelHel.png')
.setAuthor(`${data.motd.clean}`)
.addFields(
{ name: "IP:", value: `${data.ip}:${data.port}` },
{ name: "Game Version:", value: `${data.version}`, inline: true },
{ name: "Currently Online:", value: `${data.players.online}`, inline: true }
)
.setTimestamp()
.setFooter('HelBot by DeSqBlocki', 'https://cdn.discordapp.com/attachments/345238918582763520/901262809466282034/HelBotIcon.png')
if(data.mods){
embed.addFields({ name: "Mods Installed:", value: `${data.mods.names.length}`, inline: true })
}
if (message) {
message.reply({ embeds: [embed] })
.then(msg => {
setTimeout(() => {
message.delete()
return msg.delete()
}, 15000)
})
}
if (interaction) {
interaction.reply({ embeds: [embed] })
.then(msg => {
setTimeout(() => {
return client.api.webhooks(client.user.id, interaction.token).messages("@original").delete();
}, 15000)
})
}
}
})
}
}
+10
View File
@@ -0,0 +1,10 @@
module.exports = {
category: 'Admin',
description: 'Replies with pong',
slash: 'both',
testOnly: true,
callback: ({ }) => {
return "Pong!"
}
}
+40
View File
@@ -0,0 +1,40 @@
const { MessageEmbed } = require('discord.js')
const mcsrv = require('mcsrvstat-api')
module.exports = {
category: 'Minecraft',
description: 'Minecraft Server Availabilty',
slash: 'both',
testOnly: true,
callback: ({client, message, interaction}) => {
const server = "bettermc.desq-gaming.de"
mcsrv.isOnline(server)
.then((bool) =>{
const embed = new MessageEmbed()
.setTitle(server)
.setURL(`https://mcsrvstat.us/server/bettermc.desq-gaming.de`)
.setThumbnail('https://cdn.discordapp.com/attachments/345238918582763520/885475680014458900/PixelHel.png')
.setDescription(
`The Server Is **${bool?"":"Not "}Online!**`
)
.setTimestamp()
.setFooter('HelBot by DeSqBlocki', 'https://cdn.discordapp.com/attachments/345238918582763520/901262809466282034/HelBotIcon.png')
if (message) {
message.reply({ embeds: [embed] })
.then(msg => {
setTimeout(() => {
message.delete()
return msg.delete()
}, 15000)
})
}
if (interaction) {
interaction.reply({ embeds: [embed] })
.then(msg => {
setTimeout(() => {
return client.api.webhooks(client.user.id, interaction.token).messages("@original").delete();
}, 15000)
})
}
})
}
}