<rejected> TypeError: Cannot read property 'username' of null
at MusicBot.playSong (/home/runner/Hanayaa/node_modules/discord-music-system/src/MusicBot.js:594:495)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
} reason: TypeError: Cannot read property 'username' of null
at MusicBot.playSong (/home/runner/Hanayaa/node_modules/discord-music-system/src/MusicBot.js:594:495)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
The weird thing is, this only happen in my second bot, in my first bot there is no error at all.
This is the code of my second bot:
const { Client } = require('discord.js'), client = new Client();
const { MusicBot } = require('discord-music-system');
module.exports = {
name: 'play',
aliases: [
'add', 'join',
'stop', 'kill', 'destroy', 'leave',
'np', 'nowplaying', 'current',
'skip', 'next',
'queue', 'list', 'show',
'volume', 'setvolume',
'pause', 'resume',
'remove', 'delete',
'lyrics'
],
async execute(message, prefix) {
client.musicBot = new MusicBot(client, {
ytApiKey: process.env.YTAPI,
prefix: prefix.toLowerCase(),
language: 'en'
});
let theRole = message.guild.roles.cache.find(role => role.name === 'Staff Team');
if (!theRole) return message.channel.send('The **Staff Team** role is not existed.');
if (!message.member.roles.cache.has(theRole.id)) {
message.channel.send('This command is only avaiable for the **Staffs**.');
} else {
client.musicBot.onMessage(message);
}
}
}