forked from ChrisChrome/weather-bot
Somewhat of a fix still issues where some commands dont show in certian servers.
This commit is contained in:
parent
081b4ef261
commit
ec176a87c2
|
@ -1,7 +1,12 @@
|
|||
{
|
||||
"callsigns": {
|
||||
"WXL46": "https://icecast.sirenarchive.xyz/NWR/WXL46",
|
||||
"KZZ30": "https://icecast.sirenarchive.xyz/NWR/KZZ30",
|
||||
"KGRX": "https://icecast.sirenarchive.xyz/AAC/KGRX"
|
||||
"WXL46": "http://192.168.2.3:8000/NWR/WXL46",
|
||||
"KZZ30": "http://192.168.2.3:8000/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"
|
||||
}
|
||||
}
|
32
index.js
32
index.js
|
@ -1047,16 +1047,15 @@ 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 });
|
||||
// Get the URL
|
||||
url = interaction.options.getString("url");
|
||||
const data2 = JSON.parse(nwrstreams.readFileSync('./data/nwrstreams.json', 'utf8'));
|
||||
// Sanity check URL for funny stuff
|
||||
if (!url.match(/https?:\/\/[^\s]+/)) return interaction.reply({ content: "Invalid URL", ephemeral: true });
|
||||
// Use local variables & Get the URL
|
||||
const interactionUrl = interaction.options.getString("url");
|
||||
// Get the channel
|
||||
channel = interaction.member.voice.channel;
|
||||
const 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
|
||||
st = JoinChannel(channel, url, .1, interaction)
|
||||
const st = JoinChannel(channel, interactionUrl, .1, interaction);
|
||||
|
||||
if (st) {
|
||||
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
|
||||
} else {
|
||||
|
@ -1066,25 +1065,32 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
|
||||
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 = nwrstreams
|
||||
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 });
|
||||
// Get the channel
|
||||
channel = interaction.member.voice.channel;
|
||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||
|
||||
// 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 });
|
||||
|
||||
// Join the channel and play the stream
|
||||
st = JoinChannel(channel, url, .1, interaction)
|
||||
if (st) {
|
||||
const streamStatus = JoinChannel(voiceChannel, url, .1, interaction); // Use a unique variable name
|
||||
if (streamStatus) {
|
||||
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 });
|
||||
|
|
Loading…
Reference in a new issue