Updated commands

This commit is contained in:
Christer Warén 2021-08-19 01:52:16 +03:00
parent cecadb2bef
commit 2d68eb1ffd
10 changed files with 120 additions and 66 deletions

View File

@ -1,3 +1,5 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'bug',
alias: 'none',
@ -5,7 +7,10 @@ module.exports = {
description: 'Report a bug',
permission: 'none',
category: 'info',
async execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('bug')
.setDescription('Report a bug'),
async execute(interaction, client, Discord, command) {
let message = {};
message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username);
@ -17,7 +22,7 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(message.bugDescription)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
msg.channel.send({ embeds: [embed] });
interaction.reply({ embeds: [embed] });
}
};

View File

@ -1,3 +1,5 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'help',
alias: 'h',
@ -5,11 +7,14 @@ module.exports = {
description: 'Get help using bot',
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Get help using bot'),
execute(interaction, client, Discord, command) {
let message = {};
if (args[1]) {
if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true)) return msg.channel.send('That command does not exist');
if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true)) return interaction.reply('That command does not exist');
const command = client.commands.get(args[1]);
message.helpCommandTitle = client.messages.helpCommandTitle.replace("%client.config.prefix%", client.config.prefix);
@ -24,7 +29,7 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(message.helpCommandDescription)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
msg.channel.send({ embeds: [embed] });
interaction.reply({ embeds: [embed] });
} else {
const categories = [];
for (let i = 0; i < client.commands.size; i++) {
@ -45,7 +50,7 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(message.helpDescription)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
msg.channel.send({ embeds: [embed] });
interaction.reply({ embeds: [embed] });
}
}
};

View File

@ -1,3 +1,5 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'invite',
alias: 'i',
@ -5,7 +7,10 @@ module.exports = {
description: 'Invite Bot',
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('invite')
.setDescription('Invite Bot'),
execute(interaction, client, Discord, command) {
let message = {};
message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);
const embed = new Discord.MessageEmbed()
@ -13,6 +18,6 @@ module.exports = {
.setColor(client.config.embedColor)
.setURL("https://discordapp.com/api/oauth2/authorize?client_id=" + client.user.id + "&permissions=2184465408&scope=applications.commands%20bot") //View Channels, Send Messages, Embed Links, Use External Emojis, Use Slash Commands, Connect, Speak, Use Voice Activity
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return msg.channel.send({ embeds: [embed] });
return interaction.reply({ embeds: [embed] });
}
};

View File

@ -1,3 +1,5 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'list',
alias: 'l',
@ -5,11 +7,14 @@ module.exports = {
description: 'List radio stations.',
permission: 'none',
category: 'radio',
execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('list')
.setDescription('List radio stations.'),
execute(interaction, client, Discord, command) {
let message = {};
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}`
const hashs = stations.split('**#**').length;
@ -23,6 +28,6 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(stations)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return msg.channel.send({ embeds: [embed] });
return interaction.reply({ embeds: [embed] });
}
};

View File

@ -1,3 +1,5 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'maintenance',
alias: 'm',
@ -5,14 +7,17 @@ module.exports = {
description: 'Bot Maintenance',
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('maintenance')
.setDescription('Bot Maintenance'),
execute(interaction, client, Discord, command) {
let message = {};
if(!client.funcs.isDev(client.config.devId, msg.author.id)) return msg.channel.send(client.messageEmojis["error"] + client.messages.notAllowed);
if(!client.funcs.isDev(client.config.devId, interaction.user.id)) return interaction.reply(client.messageEmojis["error"] + client.messages.notAllowed);
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
let currentRadios = client.radio.keys();
@ -48,6 +53,6 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription("Stopped all radios" + "\n" + stoppedRadios)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return msg.channel.send({ embeds: [embed] });
return interaction.reply({ embeds: [embed] });
}
};

View File

@ -1,3 +1,5 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'nowplaying',
alias: 'np',
@ -5,13 +7,16 @@ module.exports = {
description: 'Current Radio Station',
permission: 'none',
category: 'radio',
async execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('nowplaying')
.setDescription('Current Radio Station'),
async execute(interaction, client, Discord, command) {
let message = {};
const radio = client.radio.get(msg.guild.id);
if (!radio) return msg.channel.send('There is nothing playing.');
const radio = client.radio.get(interaction.guild.id);
if (!radio) return interaction.reply('There is nothing playing.');
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
const completed = (radio.connection.dispatcher.streamTime.toFixed(0));
@ -25,6 +30,6 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(message.nowplayingDescription)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return msg.channel.send({ embeds: [embed] });
return interaction.reply({ embeds: [embed] });
}
};

View File

@ -4,28 +4,37 @@ const {
getVoiceConnection,
joinVoiceChannel
} = require("@discordjs/voice");
const { SlashCommandBuilder } = require('@discordjs/builders');
const { createDiscordJSAdapter } = require("../utils/adapter");
module.exports = {
name: "play",
alias: "p",
usage: "<song name>",
description: "Play some music.",
description: "Play radio.",
permission: "none",
category: "radio",
async execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play radio.')
.addStringOption(option =>
option.setName('query')
.setDescription('Select station')
.setRequired(true)),
async execute(interaction, client, Discord, command) {
let message = {};
let url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
const radio = client.radio.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
let query = interaction.options.getString("query");
let url = query ? query.replace(/<(.+)>/g, "$1") : "";
const radio = client.radio.get(interaction.guild.id);
const voiceChannel = interaction.member.voice.channel;
if (!radio) {
if (!msg.member.voice.channel)
return msg.channel.send(
if (!interaction.member.voice.channel)
return interaction.reply(
client.messageEmojis["error"] + client.messages.noVoiceChannel
);
} else {
if (voiceChannel !== radio.voiceChannel)
return msg.channel.send(
return interaction.reply(
client.messageEmojis["error"] + client.messages.wrongVoiceChannel
);
}
@ -34,25 +43,25 @@ module.exports = {
"%client.config.supportGuild%",
client.config.supportGuild
);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
if (!args[1]) return msg.channel.send(client.messages.noQuery);
const permissions = voiceChannel.permissionsFor(msg.client.user);
if (!query) return interaction.reply(client.messages.noQuery);
const permissions = voiceChannel.permissionsFor(interaction.client.user);
if (!permissions.has("CONNECT")) {
return msg.channel.send(client.messageEmojis["error"] + client.messages.noPermsConnect);
return interaction.reply(client.messageEmojis["error"] + client.messages.noPermsConnect);
}
if (!permissions.has("SPEAK")) {
return msg.channel.send(client.messageEmojis["error"] + client.messages.noPermsSpeak);
return interaction.reply(client.messageEmojis["error"] + client.messages.noPermsSpeak);
}
let station;
const number = parseInt(args[1] - 1);
const number = parseInt(query - 1);
if (url.startsWith("http")) {
return msg.channel.send(
return interaction.reply(
client.messageEmojis["error"] + client.messages.errorStationURL
);
} else if (!isNaN(number)) {
if (number > client.stations.length - 1) {
return msg.channel.send(
return interaction.reply(
client.messageEmojis["error"] + client.messages.wrongStationNumber
);
} else {
@ -60,13 +69,13 @@ module.exports = {
station = client.stations[number];
}
} else {
if (args[1].length < 3)
return msg.channel.send(
if (query.length < 3)
return interaction.reply(
client.messageEmojis["error"] + client.messages.tooShortSearch
);
const sstation = await searchStation(args.slice(1).join(" "), client);
const sstation = await searchStation(query.slice(1), client);
if (!sstation)
return msg.channel.send(
return interaction.reply(
client.messageEmojis["error"] + client.messages.noSearchResults
);
url = sstation.stream[sstation.stream.default];
@ -74,24 +83,24 @@ module.exports = {
}
if (radio) {
client.funcs.statisticsUpdate(client, msg.guild, radio);
client.funcs.statisticsUpdate(client, interaction.guild, radio);
radio.audioPlayer.stop();
radio.station = station;
radio.textChannel = msg.channel;
play(msg.guild, client, url);
radio.textChannel = interaction.channel;
play(interaction.guild, client, url);
return;
}
const construct = {
textChannel: msg.channel,
textChannel: interaction.channel,
voiceChannel: voiceChannel,
connection: null,
audioPlayer: createAudioPlayer(),
station: station
};
client.radio.set(msg.guild.id, construct);
client.radio.set(interaction.guild.id, construct);
try {
const connection =
@ -104,21 +113,21 @@ module.exports = {
construct.connection = connection;
let date = new Date();
construct.startTime = date.getTime();
play(msg.guild, client, url);
play(interaction.guild, client, url);
client.datastore.checkEntry(msg.guild.id);
construct.currentGuild = client.datastore.getEntry(msg.guild.id);
client.datastore.checkEntry(interaction.guild.id);
construct.currentGuild = client.datastore.getEntry(interaction.guild.id);
if (!construct.currentGuild.statistics[construct.station.name]) {
construct.currentGuild.statistics[construct.station.name] = {};
construct.currentGuild.statistics[construct.station.name].time = 0;
construct.currentGuild.statistics[construct.station.name].used = 0;
client.datastore.updateEntry(msg.guild, construct.currentGuild);
client.datastore.updateEntry(interaction.guild, construct.currentGuild);
}
} catch (error) {
console.log(error);
client.radio.delete(msg.guild.id);
return msg.channel.send(client.messageEmojis["error"] + `An error occured: ${error}`);
client.radio.delete(interaction.guild.id);
return interaction.reply(client.messageEmojis["error"] + `An error occured: ${error}`);
}
}
};

View File

@ -1,3 +1,5 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'statistics',
alias: 'stats',
@ -5,15 +7,18 @@ module.exports = {
description: 'Show usage statistics.',
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('statistics')
.setDescription('Show usage statistics.'),
execute(interaction, client, Discord, command) {
let message = {};
let stations = client.stations;
let currentGuild = client.datastore.getEntry(msg.guild.id);
let currentGuild = client.datastore.getEntry(interaction.guild.id);
let statistics = "";
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
if(!currentGuild || currentGuild && !currentGuild.statistics){
@ -34,6 +39,6 @@ module.exports = {
.setColor(client.config.embedColor)
.setDescription(statistics)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
return msg.channel.send({ embeds: [embed] });
return interaction.reply({ embeds: [embed] });
}
};

View File

@ -1,11 +1,16 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'status',
alias: 'none',
alias: 'st',
usage: '',
description: 'Bot Status',
permission: 'none',
category: 'info',
async execute(msg, args, client, Discord, command) {
data: new SlashCommandBuilder()
.setName('status')
.setDescription('Bot Status'),
async execute(interaction, client, Discord, command) {
let message = {};
message.statusTitle = client.messages.statusTitle.replace("%client.user.username%", client.user.username);
@ -15,13 +20,13 @@ module.exports = {
.setTitle(message.statusTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.addField(client.messages.statusField1, Date.now() - msg.createdTimestamp + "ms", true)
.addField(client.messages.statusField1, Date.now() - interaction.createdTimestamp + "ms", true)
.addField(client.messages.statusField2, client.ws.ping + "ms", true)
.addField(client.messages.statusField3, uptime, true)
.addField(client.messages.statusField4, client.config.version, true)
.addField(client.messages.statusField5, client.config.hostedBy, true)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
msg.channel.send({ embeds: [embed] });
interaction.reply({ embeds: [embed] });
}
};

View File

@ -1,18 +1,23 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'stop',
description: 'Stop command.',
description: 'Stop radio.',
alias: 's',
usage: '',
permission: 'none',
category: 'radio',
execute(msg, args, client, Discord, command) {
const radio = client.radio.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
client.funcs.statisticsUpdate(client, msg.guild, radio);
data: new SlashCommandBuilder()
.setName('stop')
.setDescription('Stop radio.'),
execute(interaction, client, Discord, command) {
const radio = client.radio.get(interaction.guild.id);
if (client.funcs.check(client, interaction, command)) {
client.funcs.statisticsUpdate(client, interaction.guild, radio);
radio.connection?.destroy();
radio.audioPlayer?.stop();
client.radio.delete(msg.guild.id);
msg.channel.send(client.messageEmojis["stop"] + client.messages.stop);
client.radio.delete(interaction.guild.id);
interaction.reply(client.messageEmojis["stop"] + client.messages.stop);
}
}
};