fix(command): 🐛 fix bot address regex returning undefined
Waits till spawn to make sure `bot.username` is definitely initialized
This commit is contained in:
parent
72c4622091
commit
22490f7ec1
|
@ -88,7 +88,6 @@ fs.watch('./lib/plugins', reloadplugin)
|
||||||
cfg.bot = bot
|
cfg.bot = bot
|
||||||
// TODO better name, or switch to array
|
// TODO better name, or switch to array
|
||||||
cfg.botAddressPrefix = '!'
|
cfg.botAddressPrefix = '!'
|
||||||
cfg.botAddressRegex = new RegExp(`^${bot.username} (${cfg.botAddressPrefix}.+)`)
|
|
||||||
cfg.quiet = true
|
cfg.quiet = true
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,6 +109,7 @@ bot.once("spawn", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.plugins = plugins
|
cfg.plugins = plugins
|
||||||
|
cfg.botAddressRegex = new RegExp(`^${bot.username} (${cfg.botAddressPrefix}.+)`)
|
||||||
|
|
||||||
for (const plugin of Object.values(plugins)) {
|
for (const plugin of Object.values(plugins)) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -30,11 +30,10 @@ const events = {
|
||||||
whisper: function command_whisper(username, message) {
|
whisper: function command_whisper(username, message) {
|
||||||
if ([bot.username, "me"].includes(username)) return
|
if ([bot.username, "me"].includes(username)) return
|
||||||
if (/^gossip/.test(message)) return
|
if (/^gossip/.test(message)) return
|
||||||
// if (/^!/.test(message) && username === cfg.admin){
|
|
||||||
if (username === cfg.admin) {
|
if (username === cfg.admin) {
|
||||||
message = message.replace("\\", "@")
|
message = message.replace("\\", "@")
|
||||||
console.info("whispered command", message)
|
console.info("whispered command", message)
|
||||||
if (/^!/.test(message)) {
|
if (message.startsWith(cfg.botAddressPrefix)) {
|
||||||
command(username, message)
|
command(username, message)
|
||||||
} else {
|
} else {
|
||||||
bot.chat(message)
|
bot.chat(message)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user