Fix anthony's code :P

This commit is contained in:
Christopher Cookman 2024-06-18 00:09:40 -06:00
parent ec176a87c2
commit 0f495feb55
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 20 additions and 27 deletions

View file

@ -1,12 +1,12 @@
{
"callsigns": {
"WXL46": "http://192.168.2.3:8000/NWR/WXL46",
"KZZ30": "http://192.168.2.3:8000/NWR/KZZ30",
"WXL46": "https://icecast.sirenarchive.xyz/NWR/WXL46",
"KZZ30": "https://icecast.sirenarchive.xyz/NWR/KZZ30",
"KZZ57": "https://wxradio.org/IL-Rockford-KZZ57",
"KXI41": "https://wxradio.org/IL-CrystalLake-KXI41",
"KHB34": "https://wxradio.org/FL-Miami-KHB34",
"WNG663": "https://wxradio.org/FL-Princeton-WNG663",
"KEC80": "https://wxradio.org/GA-Atlanta-KEC80",
"KGRX_NOT_NWR": "http://192.168.2.3:8000/AAC/KGRX"
}
"KGRX_NOT_NWR": "https://icecast.sirenarchive.xyz/AAC/KGRX"
}
}

View file

@ -1034,7 +1034,7 @@ discord.on("interactionCreate", async (interaction) => {
// Get the stream URL
url = `https://${config.broadcastify.username}:${config.broadcastify.password}@audio.broadcastify.com/${streamID}.mp3`;
// Get the channel
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 });
// Join the channel and play the stream
res = JoinChannel(channel, url, .1, interaction)
@ -1048,13 +1048,13 @@ discord.on("interactionCreate", async (interaction) => {
case "play": // Play generic stream
if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true });
// Use local variables & Get the URL
const interactionUrl = interaction.options.getString("url");
interactionUrl = interaction.options.getString("url");
// Get the channel
const channel = interaction.member.voice.channel;
channel = interaction.member.voice?.channel;
// Check if in channel
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
// Join the channel and play the stream
const st = JoinChannel(channel, interactionUrl, .1, interaction);
st = JoinChannel(channel, interactionUrl, .1, interaction);
if (st) {
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
@ -1068,22 +1068,15 @@ discord.on("interactionCreate", async (interaction) => {
// Get the callsign
const callsign = interaction.options.getString("callsign");
// Read the JSON file
const data = nwrstreams;
// 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 });
const url = nwrstreams.callsigns[callsign];
// Get the voice channel
const voiceChannel = interaction.member.voice.channel; // Use a unique variable name
if (!voiceChannel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
channel = interaction.member.voice?.channel; // Use a unique variable name
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
// Join the channel and play the stream
const streamStatus = JoinChannel(voiceChannel, url, .1, interaction); // Use a unique variable name
const streamStatus = JoinChannel(channel, url, .1, interaction); // Use a unique variable name
if (streamStatus) {
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
} else {