forked from ChrisChrome/weather-bot
NWR Play Works
This commit is contained in:
parent
0a9376d4d7
commit
e5d9a687d4
11
index.js
11
index.js
|
@ -632,6 +632,7 @@ discord.on('ready', async () => {
|
|||
},
|
||||
{
|
||||
"name": "play",
|
||||
"type": 1,
|
||||
"description": "Play a stream",
|
||||
"options": [
|
||||
{
|
||||
|
@ -644,11 +645,12 @@ discord.on('ready', async () => {
|
|||
},
|
||||
{
|
||||
"name": "nwrplay",
|
||||
"description": "Play a NWR stream",
|
||||
"description": "Nwr stream",
|
||||
"type": 1,
|
||||
"options": [
|
||||
{
|
||||
"name": "Callsign",
|
||||
"description": "Enter a Valid NWR Callsign",
|
||||
"name": "callsign",
|
||||
"description": "The URL of the stream to play",
|
||||
"type": 3,
|
||||
"required": true
|
||||
}
|
||||
|
@ -1037,6 +1039,7 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
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 });
|
||||
// Get the channel
|
||||
|
@ -1056,7 +1059,7 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
// Get the callsign
|
||||
const callsign = interaction.options.getString("callsign");
|
||||
// Read the JSON file
|
||||
const data = JSON.parse(nwrstreams.readFileSync('./data/nwrstreams.json', 'utf8'));
|
||||
const data = nwrstreams
|
||||
// Get the URL associated with the callsign
|
||||
const url = data.callsigns[callsign];
|
||||
// Sanity check URL for funny stuff
|
||||
|
|
Loading…
Reference in a new issue