我使用distube库编写了一个不和谐的音乐机器人,该库工作正常,没有在本地主机或heroku上显示此错误,但当我转到数字海洋时,它开始顺利工作,但过了一段时间,我开始收到与wasm-function和RuntimeError: memory access out of bounds相关的错误。我增加了屏幕截图和下面错误的代码,并提供了我为这个机器人编写的代码。我对wasm函数和内存访问越界错误几乎一无所知,所以如果有人能帮我解决这个问题,将会有很大的帮助。
不和谐机器人代码
const Discord = require('discord.js');
const client = new Discord.Client();
const fs = require('fs');
const {
AutoPoster
} = require('topgg-autoposter')
const DisTube = require('distube'),
config = {
prefix: "b.",
};
AutoPoster("Top.gg TOKEN", client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
const distube = new DisTube(client, {
searchSongs: true,
emitNewSongOnly: true
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("message", async(message) => {
if (message.author.bot) return;
if (!message.content.startsWith(config.prefix)) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift();
if (command == "play")
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
distube.play(message, args.join(" "));
}
if (command == "loop" || command == "repeat") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
distube.setRepeatMode(message, parseInt(args[0]));
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle('Current Song has been Looped!')
message.channel.send(exampleEmbed);
}
}
if (command == "stop") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
distube.stop(message);
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle('Bot has left the voice channel!')
message.channel.send(exampleEmbed);
}
}
if (command == "skip") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
distube.skip(message);
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle('Song has been skipped!')
message.channel.send(exampleEmbed);
}
}
if (command == "volume") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
distube.setVolume(message, args[0]);
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle(`Volume has been set to ${args[0]}% `)
message.channel.send(exampleEmbed);
}
}
if (command == "jump") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
distube.jump(message, parseInt(args[0] - 1));
}
}
if (command == "shuffle") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
distube.shuffle(message);
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle(`Queue has been shuffled!`)
message.channel.send(exampleEmbed);
}
}
if (command == "pause") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
distube.pause(message);
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle(`Current Song has been paused!`)
message.channel.send(exampleEmbed);
}
}
if (command == "resume") {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
distube.resume(message);
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle(`Current Song has been resumed!`)
message.channel.send(exampleEmbed);
}
}
if (command == "queue") {
let queue = distube.getQueue(message);
if (!queue) return message.channel.send("There is no queue.")
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle('Current Queue')
.setDescription(queue.songs.map((song, id) =>
`**${id + 1}**) ${song.name} - \`${song.formattedDuration}\``).slice(0, 40).join("\n"))
message.channel.send(exampleEmbed);
}
if ([`3d`, `bassboost`, `echo`, `karaoke`, `nightcore`, `vaporwave`, `reverse`, `surround`, `earwax`].includes(command)) {
if (!message.member.voice.channel) {
message.channel.send("You are not in a voice channel.")
}
if (message.member.voice.channel) {
let filter = distube.setFilter(message, command);
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle('Current Filter')
.setDescription(filter || 'Off')
message.channel.send(exampleEmbed);
}
}
});
// Queue status template
const status = (queue) => `Volume: \`${queue.volume}%\` | Filter: \`${queue.filter || "Off"}\` | Loop: \`${queue.repeatMode ? queue.repeatMode == 2 ? "All Queue" : "This Song" : "Off"}\` | Autoplay: \`${queue.autoplay ? "On" : "Off"}\``;
// DisTube event listeners, more in the documentation page
distube
.on("playSong", (message, queue, song) => {
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle('Currently Playing')
.addFields({
name: 'Song Name',
value: song.name
}, {
name: 'Duration',
value: song.formattedDuration,
inline: true
}, {
name: 'Requested By',
value: song.user,
inline: true
}, {
name: 'Status',
value: status(queue)
}, )
message.channel.send(exampleEmbed);
})
.on("addSong", (message, queue, song) => message.channel.send(
`Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`
))
.on("playList", (message, queue, playlist, song) => message.channel.send(
`Play \`${playlist.name}\` playlist (${playlist.songs.length} songs).\nRequested by: ${song.user}\nNow playing \`${song.name}\` - \`${song.formattedDuration}\`\n${status(queue)}`
))
.on("addList", (message, queue, playlist) => message.channel.send(
`Added \`${playlist.name}\` playlist (${playlist.songs.length} songs) to queue\n${status(queue)}`
))
// DisTubeOptions.searchSongs = true
.on("searchResult", (message, result) => {
if (!message.member.guild.me.hasPermission(["CONNECT"])) return message.channel.send("I don't have the permissions to join the voice channel.")
if (!message.member.guild.me.hasPermission(["SPEAK"])) return message.channel.send("I don't have the permissions to speak in the voice channel.")
if (!message.member.guild.me.hasPermission(["SEND_MESSAGES"])) return console.log("I don't have the permissions to send messages.")
let i = 0;
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#9966CC')
.setTitle('Choose an option from below')
.setDescription(`${result.map(song => `**${++i}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")}\n\n*Enter anything else or wait 60 seconds to cancel*`)
message.channel.send(exampleEmbed);
})
// DisTubeOptions.searchSongs = true
.on("searchCancel", (message) => message.channel.send(`Searching canceled`))
.on("error", (message, e) => {
console.error(e)
message.channel.send("An error encountered: " + e);
});
client.commands = new Discord.Collection();
client.events = new Discord.Collection();
['command_handler', 'event_handler'].forEach(handler => {
require(`./handlers/${handler}`)(client, Discord);
})
client.once('ready', () => {
client.user.setActivity("BlurryBot | b.help");
});
client.login("BOT_TOKEN");
控制台中的错误消息
0|. | at Decoder.Transform._read (internal/streams/transform.js:205:10)
0|. | at Decoder.Transform._write (internal/streams/transform.js:193:12)
0|. | at writeOrBuffer (internal/streams/writable.js:358:12)
0|. | at Decoder.Writable.write (internal/streams/writable.js:303:10)
0|. | RuntimeError: memory access out of bounds
0|. | at <anonymous>:wasm-function[268]:0x2177a
0|. | at <anonymous>:wasm-function[267]:0x21732
0|. | at OpusScriptHandler$_decode [as _decode] (eval at Db (/root/BlurryBot/node_modules/opusscript/build/opusscript_native_wasm.js:1:1), <anonymous>:11:10)
0|. | at OpusScript.decode (/root/BlurryBot/node_modules/opusscript/index.js:80:28)
0|. | at Decoder._decode (/root/BlurryBot/node_modules/prism-media/src/opus/Opus.js:64:25)
0|. | at Decoder._transform (/root/BlurryBot/node_modules/prism-media/src/opus/Opus.js:189:20)
0|. | at Decoder.Transform._read (internal/streams/transform.js:205:10)
0|. | at Decoder.Transform._write (internal/streams/transform.js:193:12)
0|. | at writeOrBuffer (internal/streams/writable.js:358:12)
0|. | at Decoder.Writable.write (internal/streams/writable.js:303:10)
不和谐上的错误消息

当我转移到数字海洋时,我才开始收到这个错误,而在此之前它并没有发生。
发布于 2021-09-02 08:48:49
有几件事你可以支配:
var encoder = new OpusScript(samplingRate, channels, OpusScript.Application.AUDIO, {
wasm: false
});https://stackoverflow.com/questions/69024680
复制相似问题