34
loading...
This website collects cookies to deliver better user experience
app.js
i've got the basics requires.const Discord = require('discord.js')
const client = new Discord.Client()
const TwitchAPI = require('node-twitch').default
const config = require('./config')
const twitch = new TwitchAPI({
client_id: config.twitch.AppClientID,
client_secret: config.twitch.AppSecretToken
})
IsLiveMemory
.let IsLiveMemory = false
const run = async function Run() {
await twitch.getStreams({ channel: "thomasbnt" }).then(async data => {
const r = data.data[0]
let ThisGuildOnly = client.guilds.cache.get("GuildID")
const ChannelAnnounceLive = ThisGuildOnly.channels.cache.find(x => x.id === "ChannelAnnounceLiveID")
if (r !== undefined) {
if (r.type === "live") {
if (IsLiveMemory === false || IsLiveMemory === undefined) {
IsLiveMemory = true
} else if (IsLiveMemory === true) {
} else {}
} else {
if (IsLiveMemory === true) {
IsLiveMemory = false
} else {}
}
} else {
if (IsLiveMemory === true) {
IsLiveMemory = false
} else {
}
}
})
}
setInterval(
run, 15000)
"type": "live"
), check if the Memory is false to avoid duplicating messages, if these two conditions are true, then send the message to general channel.true
, don't send message to avoid a duplicate message.☕ | Check my Twitter account. You can see many projects and updates. You can also support me on BuyMeaCoffee. |
---|