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": {
|
"callsigns": {
|
||||||
"WXL46": "https://icecast.sirenarchive.xyz/NWR/WXL46",
|
"WXL46": "http://192.168.2.3:8000/NWR/WXL46",
|
||||||
"KZZ30": "https://icecast.sirenarchive.xyz/NWR/KZZ30",
|
"KZZ30": "http://192.168.2.3:8000/NWR/KZZ30",
|
||||||
"KGRX": "https://icecast.sirenarchive.xyz/AAC/KGRX"
|
"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
|
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
|
// Use local variables & Get the URL
|
||||||
url = interaction.options.getString("url");
|
const interactionUrl = 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 });
|
|
||||||
// Get the channel
|
// 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 });
|
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
||||||
// Join the channel and play the stream
|
// Join the channel and play the stream
|
||||||
st = JoinChannel(channel, url, .1, interaction)
|
const st = JoinChannel(channel, interactionUrl, .1, interaction);
|
||||||
|
|
||||||
if (st) {
|
if (st) {
|
||||||
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
|
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
|
||||||
} else {
|
} else {
|
||||||
|
@ -1066,25 +1065,32 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
|
|
||||||
case "nwrplay": // Play NWR stream
|
case "nwrplay": // Play NWR 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 callsign
|
// Get the callsign
|
||||||
const callsign = interaction.options.getString("callsign");
|
const callsign = interaction.options.getString("callsign");
|
||||||
|
|
||||||
// Read the JSON file
|
// Read the JSON file
|
||||||
const data = nwrstreams
|
const data = nwrstreams;
|
||||||
|
|
||||||
// Get the URL associated with the callsign
|
// Get the URL associated with the callsign
|
||||||
const url = data.callsigns[callsign];
|
const url = data.callsigns[callsign];
|
||||||
|
|
||||||
// Sanity check URL for funny stuff
|
// Sanity check URL for funny stuff
|
||||||
if (!url.match(/https?:\/\/[^\s]+/)) return interaction.reply({ content: "Invalid URL", ephemeral: true });
|
if (!url.match(/https?:\/\/[^\s]+/)) return interaction.reply({ content: "Invalid URL", ephemeral: true });
|
||||||
// Get the channel
|
|
||||||
channel = interaction.member.voice.channel;
|
// Get the voice channel
|
||||||
if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true });
|
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
|
// Join the channel and play the stream
|
||||||
st = JoinChannel(channel, url, .1, interaction)
|
const streamStatus = JoinChannel(voiceChannel, url, .1, interaction); // Use a unique variable name
|
||||||
if (st) {
|
if (streamStatus) {
|
||||||
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
|
interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true });
|
||||||
} else {
|
} else {
|
||||||
interaction.reply({ content: `Failed to play stream`, ephemeral: true });
|
interaction.reply({ content: `Failed to play stream`, ephemeral: true });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "leave": // Leave Channel
|
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 });
|
||||||
|
|
Loading…
Reference in a new issue