Making interaction.options nullable in play.js

This commit is contained in:
Christer Warén 2021-08-31 10:48:04 +03:00
parent b5d5ca1fe6
commit 277b67e3df

View File

@ -17,7 +17,7 @@ module.exports = {
category: "radio", category: "radio",
async execute(interaction, client, Discord, command) { async execute(interaction, client, Discord, command) {
let message = {}; let message = {};
let query = interaction.options.getString("query"); let query = interaction.options?.getString("query");
let url = query ? query.replace(/<(.+)>/g, "$1") : ""; let url = query ? query.replace(/<(.+)>/g, "$1") : "";
const radio = client.radio.get(interaction.guild.id); const radio = client.radio.get(interaction.guild.id);
const voiceChannel = interaction.member.voice.channel; const voiceChannel = interaction.member.voice.channel;
@ -182,7 +182,6 @@ async function play(interaction, guild, client, url, Discord) {
.setCustomId('list') .setCustomId('list')
.setEmoji(client.messageEmojis["list"]) .setEmoji(client.messageEmojis["list"])
.setStyle('PRIMARY') .setStyle('PRIMARY')
.setDisabled(true)
) )
.addComponents( .addComponents(
new Discord.MessageButton() new Discord.MessageButton()
@ -193,10 +192,9 @@ async function play(interaction, guild, client, url, Discord) {
) )
.addComponents( .addComponents(
new Discord.MessageButton() new Discord.MessageButton()
.setCustomId('play') .setCustomId('stop')
.setEmoji(client.messageEmojis["stop"]) .setEmoji(client.messageEmojis["stop"])
.setStyle('PRIMARY') .setStyle('PRIMARY')
.setDisabled(true)
) )
.addComponents( .addComponents(
new Discord.MessageButton() new Discord.MessageButton()
@ -210,7 +208,6 @@ async function play(interaction, guild, client, url, Discord) {
.setCustomId('statistics') .setCustomId('statistics')
.setEmoji(client.messageEmojis["statistics"]) .setEmoji(client.messageEmojis["statistics"])
.setStyle('PRIMARY') .setStyle('PRIMARY')
.setDisabled(true)
); );
if(!radio.message){ if(!radio.message){