Made command outputs post as replies, fixed status changing on cluster restart, extra stuff
This commit is contained in:
parent
08ecfc7d10
commit
364d8bf006
41 changed files with 212 additions and 159 deletions
|
@ -4,7 +4,17 @@ const MessageCollector = require("./awaitmessages.js");
|
|||
module.exports = async (client, message, pages, timeout = 120000) => {
|
||||
const manageMessages = message.channel.guild && message.channel.permissionsOf(client.user.id).has("manageMessages") ? true : false;
|
||||
let page = 0;
|
||||
let currentPage = await client.createMessage(message.channel.id, pages[page]);
|
||||
let currentPage = await client.createMessage(message.channel.id, Object.assign(pages[page], {
|
||||
messageReference: {
|
||||
channelID: message.channel.id,
|
||||
messageID: message.id,
|
||||
guildID: message.channel.guild ? message.channel.guild.id : undefined,
|
||||
failIfNotExists: false
|
||||
},
|
||||
allowedMentions: {
|
||||
repliedUser: false
|
||||
}
|
||||
}));
|
||||
const emojiList = ["◀", "🔢", "▶", "🗑"];
|
||||
for (const emoji of emojiList) {
|
||||
await currentPage.addReaction(emoji);
|
||||
|
@ -19,7 +29,17 @@ module.exports = async (client, message, pages, timeout = 120000) => {
|
|||
if (manageMessages) msg.removeReaction("◀", member.id);
|
||||
break;
|
||||
case "🔢":
|
||||
client.createMessage(message.channel.id, `${message.author.mention}, what page do you want to jump to?`).then(askMessage => {
|
||||
client.createMessage(message.channel.id, Object.assign({ content: "What page do you want to jump to?" }, {
|
||||
messageReference: {
|
||||
channelID: currentPage.channel.id,
|
||||
messageID: currentPage.id,
|
||||
guildID: currentPage.channel.guild ? currentPage.channel.guild.id : undefined,
|
||||
failIfNotExists: false
|
||||
},
|
||||
allowedMentions: {
|
||||
repliedUser: false
|
||||
}
|
||||
})).then(askMessage => {
|
||||
const messageCollector = new MessageCollector(client, askMessage.channel, (response) => response.author.id === message.author.id && !isNaN(response.content) && Number(response.content) <= pages.length && Number(response.content) > 0, {
|
||||
time: timeout,
|
||||
maxMatches: 1
|
||||
|
|
|
@ -53,21 +53,21 @@ exports.connect = async (client) => {
|
|||
};
|
||||
|
||||
exports.play = async (client, sound, message, music = false) => {
|
||||
if (!this.manager) return `${message.author.mention}, the sound commands are still starting up!`;
|
||||
if (!message.channel.guild) return `${message.author.mention}, this command only works in servers!`;
|
||||
if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
|
||||
if (!message.channel.permissionsOf(client.user.id).has("voiceConnect")) return `${message.author.mention}, I can't join this voice channel!`;
|
||||
if (!this.manager) return "The sound commands are still starting up!";
|
||||
if (!message.channel.guild) return "This command only works in servers!";
|
||||
if (!message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!message.channel.permissionsOf(client.user.id).has("voiceConnect")) return "I can't join this voice channel!";
|
||||
const voiceChannel = message.channel.guild.channels.get(message.member.voiceState.channelID);
|
||||
if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return `${message.author.mention}, I don't have permission to join this voice channel!`;
|
||||
if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return "I don't have permission to join this voice channel!";
|
||||
const player = this.players.get(message.channel.guild.id);
|
||||
if (!music && this.manager.voiceStates.has(message.channel.guild.id) && (player && player.type === "music")) return `${message.author.mention}, I can't play a sound effect while playing music!`;
|
||||
if (!music && this.manager.voiceStates.has(message.channel.guild.id) && (player && player.type === "music")) return "I can't play a sound effect while playing music!";
|
||||
const node = this.manager.idealNodes[0];
|
||||
if (!music && !nodes.filter(obj => obj.host === node.host)[0].local) {
|
||||
sound = sound.replace(/\.\//, "https://raw.githubusercontent.com/esmBot/esmBot/master/");
|
||||
}
|
||||
const { tracks } = await fetch(`http://${node.host}:${node.port}/loadtracks?identifier=${sound}`, { headers: { Authorization: node.password } }).then(res => res.json());
|
||||
const oldQueue = this.queues.get(voiceChannel.guild.id);
|
||||
if (!tracks || tracks.length === 0) return `${message.author.mention}, I couldn't find that song!`;
|
||||
if (!tracks || tracks.length === 0) return "I couldn't find that song!";
|
||||
if (music) {
|
||||
this.queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ exports.play = async (client, sound, message, music = false) => {
|
|||
}
|
||||
|
||||
if (oldQueue && music) {
|
||||
return `${message.author.mention}, your tune \`${tracks[0].info.title}\` has been added to the queue!`;
|
||||
return `Your tune \`${tracks[0].info.title}\` has been added to the queue!`;
|
||||
} else {
|
||||
this.nextSong(client, message, connection, tracks[0].track, tracks[0].info, music, voiceChannel, player ? player.loop : false);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue