forked from ChrisChrome/weather-bot
Trial For NWR Streams with own command.
This commit is contained in:
parent
e9b206afff
commit
0a9376d4d7
7
data/nwrstreams.json
Normal file
7
data/nwrstreams.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"callsigns": {
|
||||||
|
"WXL46": "https://icecast.sirenarchive.xyz/NWR/WXL46",
|
||||||
|
"KZZ30": "https://icecast.sirenarchive.xyz/NWR/KZZ30",
|
||||||
|
"KGRX": "https://icecast.sirenarchive.xyz/AAC/KGRX"
|
||||||
|
}
|
||||||
|
}
|
38
index.js
38
index.js
|
@ -6,6 +6,7 @@ const blacklist = require("./data/blacklist.json");
|
||||||
const events = require("./data/events.json");
|
const events = require("./data/events.json");
|
||||||
const outlookURLs = require("./data/outlook.json");
|
const outlookURLs = require("./data/outlook.json");
|
||||||
const sattelites = require("./data/sattelites.json");
|
const sattelites = require("./data/sattelites.json");
|
||||||
|
const nwrstreams = require("./data/nwrstreams.json")
|
||||||
const Jimp = require("jimp");
|
const Jimp = require("jimp");
|
||||||
const { client, xml } = require("@xmpp/client");
|
const { client, xml } = require("@xmpp/client");
|
||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
|
@ -30,6 +31,7 @@ const rest = new REST({
|
||||||
version: '10'
|
version: '10'
|
||||||
}).setToken(config.discord.token);
|
}).setToken(config.discord.token);
|
||||||
|
|
||||||
|
|
||||||
// Setup SQlite DB
|
// Setup SQlite DB
|
||||||
const db = new sqlite3.Database("channels.db", (err) => {
|
const db = new sqlite3.Database("channels.db", (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -640,6 +642,18 @@ discord.on('ready', async () => {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "nwrplay",
|
||||||
|
"description": "Play a NWR stream",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"name": "Callsign",
|
||||||
|
"description": "Enter a Valid NWR Callsign",
|
||||||
|
"type": 3,
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "pause",
|
"name": "pause",
|
||||||
"description": "Pause/Unpause the current stream",
|
"description": "Pause/Unpause the current stream",
|
||||||
|
@ -1037,7 +1051,29 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "leave": // Leaves Channel
|
case "nwrplay": // Play NWR stream
|
||||||
|
if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true });
|
||||||
|
// Get the callsign
|
||||||
|
const callsign = interaction.options.getString("callsign");
|
||||||
|
// Read the JSON file
|
||||||
|
const data = JSON.parse(nwrstreams.readFileSync('./data/nwrstreams.json', 'utf8'));
|
||||||
|
// Get the URL associated with the callsign
|
||||||
|
const url = data.callsigns[callsign];
|
||||||
|
// Sanity check URL for funny stuff
|
||||||
|
if (!url.match(/https?:\/\/[^\s]+/)) return interaction.reply({ content: "Invalid URL", ephemeral: true });
|
||||||
|
// Get the channel
|
||||||
|
channel = interaction.member.voice.channel;
|
||||||
|
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||||
|
// Join the channel and play the stream
|
||||||
|
st = JoinChannel(channel, url, .1, interaction)
|
||||||
|
if (st) {
|
||||||
|
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
|
||||||
|
} else {
|
||||||
|
interaction.reply({ content: `Failed to play stream`, ephemeral: true });
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "leave": // Leave Channel
|
||||||
if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true });
|
if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true });
|
||||||
channel = interaction.member.voice.channel;
|
channel = interaction.member.voice.channel;
|
||||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||||
|
|
Loading…
Reference in a new issue