forked from ChrisChrome/weather-bot
Fix outlook command
This commit is contained in:
parent
46000e92ee
commit
c77577a382
6
index.js
6
index.js
|
@ -91,7 +91,7 @@ const getUniqueChannels = function () {
|
||||||
|
|
||||||
// Get first url in a string, return object {string, url} remove the url from the string
|
// Get first url in a string, return object {string, url} remove the url from the string
|
||||||
const getFirstURL = function (string) {
|
const getFirstURL = function (string) {
|
||||||
const url = string.match(/(https?:\/\/[^\s]+)/g);
|
url = string.match(/(https?:\/\/[^\s]+)/g);
|
||||||
if (!url) return { string, url: null };
|
if (!url) return { string, url: null };
|
||||||
const newString = string.replace(url[0], "");
|
const newString = string.replace(url[0], "");
|
||||||
return { string: newString, url: url[0] };
|
return { string: newString, url: url[0] };
|
||||||
|
@ -1071,7 +1071,7 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
// Get the callsign
|
// Get the callsign
|
||||||
const callsign = interaction.options.getString("callsign");
|
const callsign = interaction.options.getString("callsign");
|
||||||
// Get the URL associated with the callsign
|
// Get the URL associated with the callsign
|
||||||
const url = nwrstreams.callsigns[callsign];
|
url = nwrstreams.callsigns[callsign];
|
||||||
|
|
||||||
// Get the voice channel
|
// Get the voice channel
|
||||||
channel = interaction.member.voice?.channel; // Use a unique variable name
|
channel = interaction.member.voice?.channel; // Use a unique variable name
|
||||||
|
@ -1287,7 +1287,7 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
case Discord.InteractionType.MessageComponent:
|
case Discord.InteractionType.MessageComponent:
|
||||||
if (interaction.customId) {
|
if (interaction.customId) {
|
||||||
const product_id = interaction.customId;
|
const product_id = interaction.customId;
|
||||||
const url = `https://mesonet.agron.iastate.edu/api/1/nwstext/${product_id}`;
|
url = `https://mesonet.agron.iastate.edu/api/1/nwstext/${product_id}`;
|
||||||
await interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
fetch(url).then((res) => {
|
fetch(url).then((res) => {
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
|
|
Loading…
Reference in a new issue