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"
|
||||
}
|
||||
}
|
46
index.js
46
index.js
|
@ -6,6 +6,7 @@ const blacklist = require("./data/blacklist.json");
|
|||
const events = require("./data/events.json");
|
||||
const outlookURLs = require("./data/outlook.json");
|
||||
const sattelites = require("./data/sattelites.json");
|
||||
const nwrstreams = require("./data/nwrstreams.json")
|
||||
const Jimp = require("jimp");
|
||||
const { client, xml } = require("@xmpp/client");
|
||||
const fetch = require("node-fetch");
|
||||
|
@ -30,6 +31,7 @@ const rest = new REST({
|
|||
version: '10'
|
||||
}).setToken(config.discord.token);
|
||||
|
||||
|
||||
// Setup SQlite DB
|
||||
const db = new sqlite3.Database("channels.db", (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",
|
||||
"description": "Pause/Unpause the current stream",
|
||||
|
@ -1000,7 +1014,7 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
break;
|
||||
|
||||
case "playbcfy": // Play broadcastify stream
|
||||
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 });
|
||||
if (!config.broadcastify.enabled) return interaction.reply({ content: "Broadcastify is not enabled", ephemeral: true });
|
||||
streamID = interaction.options.getString("id");
|
||||
// Check if the stream ID is valid (up to 10 digit alphanumeric)
|
||||
|
@ -1020,7 +1034,7 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
break;
|
||||
|
||||
case "play": // Play generic stream
|
||||
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 });
|
||||
// Get the URL
|
||||
url = interaction.options.getString("url");
|
||||
// Sanity check URL for funny stuff
|
||||
|
@ -1037,7 +1051,29 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
}
|
||||
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 });
|
||||
channel = interaction.member.voice.channel;
|
||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||
|
@ -1050,7 +1086,7 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
|
||||
break;
|
||||
case "pause": // Pause/unpause stream
|
||||
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;
|
||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||
res = toggleVoicePause(channel)
|
||||
|
@ -1061,7 +1097,7 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
}
|
||||
break;
|
||||
case "volume": // Set volume
|
||||
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;
|
||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||
volume = interaction.options.getInteger("volume") / 100;
|
||||
|
|
Loading…
Reference in a new issue