mirror of
https://github.com/Alee14/DLAP.git
synced 2025-01-22 10:52:03 -05:00
Added another eslint rule
This commit is contained in:
parent
e5020f2c62
commit
626cef8516
14 changed files with 26 additions and 26 deletions
|
@ -11,6 +11,7 @@
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"semi": [2, "always"]
|
"semi": [2, "always"],
|
||||||
|
"space-before-function-paren": [2, "never"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ export let currentTrack;
|
||||||
export let playerState;
|
export let playerState;
|
||||||
export let isAudioStatePaused;
|
export let isAudioStatePaused;
|
||||||
|
|
||||||
export async function voiceInit (bot) {
|
export async function voiceInit(bot) {
|
||||||
bot.channels.fetch(config.voiceChannel).then(async channel => {
|
bot.channels.fetch(config.voiceChannel).then(async channel => {
|
||||||
const connection = joinVoiceChannel({
|
const connection = joinVoiceChannel({
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
|
@ -49,7 +49,7 @@ export async function voiceInit (bot) {
|
||||||
adapterCreator: channel.guild.voiceAdapterCreator
|
adapterCreator: channel.guild.voiceAdapterCreator
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.on(VoiceConnectionStatus.Ready, async () => {
|
connection.on(VoiceConnectionStatus.Ready, async() => {
|
||||||
console.log('Ready to blast some beats!');
|
console.log('Ready to blast some beats!');
|
||||||
await shufflePlaylist(bot);
|
await shufflePlaylist(bot);
|
||||||
});
|
});
|
||||||
|
@ -72,14 +72,14 @@ export async function voiceInit (bot) {
|
||||||
}).catch(e => { console.error(e); });
|
}).catch(e => { console.error(e); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function shuffleArray (array) {
|
function shuffleArray(array) {
|
||||||
for (let i = array.length - 1; i > 0; i--) {
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
[array[i], array[j]] = [array[j], array[i]];
|
[array[i], array[j]] = [array[j], array[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function shufflePlaylist (bot) {
|
export async function shufflePlaylist(bot) {
|
||||||
console.log('Shuffling beats...');
|
console.log('Shuffling beats...');
|
||||||
currentTrack = 0;
|
currentTrack = 0;
|
||||||
audioArray = files;
|
audioArray = files;
|
||||||
|
@ -89,7 +89,7 @@ export async function shufflePlaylist (bot) {
|
||||||
return await playAudio(bot);
|
return await playAudio(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function nextAudio (bot) {
|
export async function nextAudio(bot) {
|
||||||
let totalTrack = files.length;
|
let totalTrack = files.length;
|
||||||
totalTrack--;
|
totalTrack--;
|
||||||
|
|
||||||
|
@ -104,13 +104,13 @@ export async function nextAudio (bot) {
|
||||||
return await playAudio(bot);
|
return await playAudio(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function inputAudio (bot, integer) {
|
export async function inputAudio(bot, integer) {
|
||||||
const inputFiles = readdirSync('music');
|
const inputFiles = readdirSync('music');
|
||||||
audio = inputFiles[integer];
|
audio = inputFiles[integer];
|
||||||
return await playAudio(bot);
|
return await playAudio(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function playAudio (bot) {
|
export async function playAudio(bot) {
|
||||||
const resource = createAudioResource('music/' + audio);
|
const resource = createAudioResource('music/' + audio);
|
||||||
|
|
||||||
player.play(resource);
|
player.play(resource);
|
||||||
|
@ -138,7 +138,7 @@ export async function playAudio (bot) {
|
||||||
return await statusChannel.send({ embeds: [statusEmbed] });
|
return await statusChannel.send({ embeds: [statusEmbed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function destroyAudio (interaction) {
|
export async function destroyAudio(interaction) {
|
||||||
if (config.txtFile === true) {
|
if (config.txtFile === true) {
|
||||||
fileData = 'Now Playing: Nothing';
|
fileData = 'Now Playing: Nothing';
|
||||||
writeFile('now-playing.txt', fileData, (err) => {
|
writeFile('now-playing.txt', fileData, (err) => {
|
||||||
|
@ -157,7 +157,7 @@ export async function destroyAudio (interaction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function audioState () {
|
export function audioState() {
|
||||||
if (isAudioStatePaused === false) {
|
if (isAudioStatePaused === false) {
|
||||||
isAudioStatePaused = true;
|
isAudioStatePaused = true;
|
||||||
playerState = 'Paused';
|
playerState = 'Paused';
|
||||||
|
@ -167,7 +167,7 @@ export function audioState () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function stopBot (bot, interaction) {
|
export async function stopBot(bot, interaction) {
|
||||||
const statusEmbed = new MessageEmbed()
|
const statusEmbed = new MessageEmbed()
|
||||||
.setAuthor({ name: bot.user.username, iconURL: bot.user.avatarURL() })
|
.setAuthor({ name: bot.user.username, iconURL: bot.user.avatarURL() })
|
||||||
.setDescription(`That's all folks! Powering down ${bot.user.username}...`)
|
.setDescription(`That's all folks! Powering down ${bot.user.username}...`)
|
||||||
|
|
4
bot.js
4
bot.js
|
@ -44,7 +44,7 @@ for (const file of commandFiles) {
|
||||||
bot.commands.set(command.data.name, command);
|
bot.commands.set(command.data.name, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.once('ready', async () => {
|
bot.once('ready', async() => {
|
||||||
console.log('Bot is ready!');
|
console.log('Bot is ready!');
|
||||||
console.log(`Logged in as ${bot.user.tag}!`);
|
console.log(`Logged in as ${bot.user.tag}!`);
|
||||||
console.log(`Running on Discord.JS ${version}`);
|
console.log(`Running on Discord.JS ${version}`);
|
||||||
|
@ -73,7 +73,7 @@ bot.once('ready', async () => {
|
||||||
if (!statusChannel) return console.error('The status channel does not exist! Skipping.');
|
if (!statusChannel) return console.error('The status channel does not exist! Skipping.');
|
||||||
await statusChannel.send({ embeds: [readyEmbed] });
|
await statusChannel.send({ embeds: [readyEmbed] });
|
||||||
|
|
||||||
await voiceInit(bot);
|
return await voiceInit(bot);
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.on('interactionCreate', async interaction => {
|
bot.on('interactionCreate', async interaction => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('about')
|
.setName('about')
|
||||||
.setDescription('Information about the bot'),
|
.setDescription('Information about the bot'),
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
const aboutEmbed = new MessageEmbed()
|
const aboutEmbed = new MessageEmbed()
|
||||||
.setAuthor({ name: `About ${bot.user.username}`, iconURL: bot.user.avatarURL() })
|
.setAuthor({ name: `About ${bot.user.username}`, iconURL: bot.user.avatarURL() })
|
||||||
.addField('Information', 'A Discord bot that plays local audio tracks.')
|
.addField('Information', 'A Discord bot that plays local audio tracks.')
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default {
|
||||||
.setName('join')
|
.setName('join')
|
||||||
.setDescription('Joins voice chat')
|
.setDescription('Joins voice chat')
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
await interaction.reply({ content: 'Joining voice channel', ephemeral: true });
|
await interaction.reply({ content: 'Joining voice channel', ephemeral: true });
|
||||||
return await voiceInit(bot);
|
return await voiceInit(bot);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default {
|
||||||
.setName('leave')
|
.setName('leave')
|
||||||
.setDescription('Leaves the voice chat')
|
.setDescription('Leaves the voice chat')
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||||
async execute (interaction) {
|
async execute(interaction) {
|
||||||
console.log('Leaving voice channel...');
|
console.log('Leaving voice channel...');
|
||||||
await destroyAudio(interaction);
|
await destroyAudio(interaction);
|
||||||
return await interaction.reply({ content: 'Leaving voice channel', ephemeral: true });
|
return await interaction.reply({ content: 'Leaving voice channel', ephemeral: true });
|
||||||
|
|
|
@ -28,11 +28,11 @@ export default {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('list')
|
.setName('list')
|
||||||
.setDescription('Lists the available audio tracks'),
|
.setDescription('Lists the available audio tracks'),
|
||||||
async execute (interaction) {
|
async execute(interaction) {
|
||||||
// If someone figures out how to either split the list or make pages when the max character reaches, please do so and make a pull request.
|
// If someone figures out how to either split the list or make pages when the max character reaches, please do so and make a pull request.
|
||||||
|
|
||||||
const beats = readdirSync(musicFolder).join('\n');
|
const beats = readdirSync(musicFolder).join('\n');
|
||||||
readdir(musicFolder, async (err, files) => {
|
readdir(musicFolder, async(err, files) => {
|
||||||
await interaction.reply(
|
await interaction.reply(
|
||||||
`Listing ${files.length} audio tracks...\n\`\`\`\n${beats}\n\`\`\``
|
`Listing ${files.length} audio tracks...\n\`\`\`\n${beats}\n\`\`\``
|
||||||
);
|
);
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default {
|
||||||
.setName('pause')
|
.setName('pause')
|
||||||
.setDescription('Pauses music')
|
.setDescription('Pauses music')
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||||
async execute (interaction) {
|
async execute(interaction) {
|
||||||
if (isAudioStatePaused === false) {
|
if (isAudioStatePaused === false) {
|
||||||
audioState();
|
audioState();
|
||||||
player.pause();
|
player.pause();
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('ping')
|
.setName('ping')
|
||||||
.setDescription('Pong!'),
|
.setDescription('Pong!'),
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
return await interaction.reply(`Pong! ${Math.round(bot.ws.ping)}ms`);
|
return await interaction.reply(`Pong! ${Math.round(bot.ws.ping)}ms`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,7 @@ export default {
|
||||||
)
|
)
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||||
|
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
integer = interaction.options.getInteger('int');
|
integer = interaction.options.getInteger('int');
|
||||||
if (integer) {
|
if (integer) {
|
||||||
if (integer < files.length) {
|
if (integer < files.length) {
|
||||||
|
|
|
@ -28,8 +28,7 @@ export default {
|
||||||
.setName('reshuffle')
|
.setName('reshuffle')
|
||||||
.setDescription('Reshuffles the playlist')
|
.setDescription('Reshuffles the playlist')
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
// Command not fully functional yet
|
|
||||||
await interaction.reply({ content: 'Reshuffling the playlist...', ephemeral: true });
|
await interaction.reply({ content: 'Reshuffling the playlist...', ephemeral: true });
|
||||||
player.stop();
|
player.stop();
|
||||||
return await shufflePlaylist(bot);
|
return await shufflePlaylist(bot);
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default {
|
||||||
.setName('shutdown')
|
.setName('shutdown')
|
||||||
.setDescription('Powers off the bot')
|
.setDescription('Powers off the bot')
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
await interaction.reply({ content: 'Powering off...', ephemeral: true });
|
await interaction.reply({ content: 'Powering off...', ephemeral: true });
|
||||||
return await stopBot(bot, interaction);
|
return await stopBot(bot, interaction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default {
|
||||||
.setName('skip')
|
.setName('skip')
|
||||||
.setDescription('Skips the audio track')
|
.setDescription('Skips the audio track')
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
await interaction.reply({ content: `Skipping ${audio}`, ephemeral: true });
|
await interaction.reply({ content: `Skipping ${audio}`, ephemeral: true });
|
||||||
player.stop();
|
player.stop();
|
||||||
return await nextAudio(bot, interaction);
|
return await nextAudio(bot, interaction);
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('status')
|
.setName('status')
|
||||||
.setDescription('Checks what audio file is playing currently'),
|
.setDescription('Checks what audio file is playing currently'),
|
||||||
async execute (interaction, bot) {
|
async execute(interaction, bot) {
|
||||||
let audioID = currentTrack;
|
let audioID = currentTrack;
|
||||||
audioID++;
|
audioID++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue