Added broadcast
This commit is contained in:
parent
5fa457958b
commit
7b07f82285
2 changed files with 55 additions and 6 deletions
27
commands/general/broadcast.js
Normal file
27
commands/general/broadcast.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const Command = require("../../classes/command.js");
|
||||||
|
|
||||||
|
class BroadcastCommand extends Command {
|
||||||
|
// yet another very hacky command
|
||||||
|
run() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can broadcast messages!";
|
||||||
|
if (this.args.length !== 0) {
|
||||||
|
this.ipc.broadcast("playbroadcast", this.args.join(" "));
|
||||||
|
this.ipc.register("broadcastSuccess", () => {
|
||||||
|
this.ipc.unregister("broadcastSuccess");
|
||||||
|
resolve("Successfully broadcasted message.");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.ipc.broadcast("broadcastend");
|
||||||
|
this.ipc.register("broadcastEnd", () => {
|
||||||
|
this.ipc.unregister("broadcastEnd");
|
||||||
|
resolve("Successfully ended broadcast.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static description = "Broadcasts a playing message until the command is run again or the bot restarts";
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = BroadcastCommand;
|
32
shard.js
32
shard.js
|
@ -19,6 +19,8 @@ const misc = require("./utils/misc.js");
|
||||||
// generate help page
|
// generate help page
|
||||||
const helpGenerator =
|
const helpGenerator =
|
||||||
process.env.OUTPUT !== "" ? require("./utils/help.js") : null;
|
process.env.OUTPUT !== "" ? require("./utils/help.js") : null;
|
||||||
|
// whether a broadcast is currently in effect
|
||||||
|
let broadcast = false;
|
||||||
|
|
||||||
class Shard extends BaseClusterWorker {
|
class Shard extends BaseClusterWorker {
|
||||||
constructor(bot) {
|
constructor(bot) {
|
||||||
|
@ -79,20 +81,40 @@ class Shard extends BaseClusterWorker {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.ipc.register("playbroadcast", async (message) => {
|
||||||
|
this.bot.editStatus("dnd", {
|
||||||
|
name: `${message.msg} | @${this.bot.user.username} help`,
|
||||||
|
});
|
||||||
|
broadcast = true;
|
||||||
|
return this.ipc.broadcast("broadcastSuccess");
|
||||||
|
});
|
||||||
|
|
||||||
|
this.ipc.register("broadcastend", async () => {
|
||||||
|
this.bot.editStatus("dnd", {
|
||||||
|
name: `${misc.random(messages)} | @${this.bot.user.username} help`,
|
||||||
|
});
|
||||||
|
broadcast = false;
|
||||||
|
return this.ipc.broadcast("broadcastEnd");
|
||||||
|
});
|
||||||
|
|
||||||
// connect to lavalink
|
// connect to lavalink
|
||||||
if (!sound.status && !sound.connected) sound.connect(this.bot);
|
if (!sound.status && !sound.connected) sound.connect(this.bot);
|
||||||
|
|
||||||
database.setup();
|
database.setup();
|
||||||
|
|
||||||
|
this.activityChanger();
|
||||||
|
|
||||||
|
logger.log("info", `Started worker ${this.workerID}.`);
|
||||||
|
}
|
||||||
|
|
||||||
// set activity (a.k.a. the gamer code)
|
// set activity (a.k.a. the gamer code)
|
||||||
(async function activityChanger() {
|
activityChanger() {
|
||||||
|
if (!broadcast) {
|
||||||
this.bot.editStatus("dnd", {
|
this.bot.editStatus("dnd", {
|
||||||
name: `${misc.random(messages)} | @${this.bot.user.username} help`,
|
name: `${misc.random(messages)} | @${this.bot.user.username} help`,
|
||||||
});
|
});
|
||||||
setTimeout(activityChanger.bind(this), 900000);
|
}
|
||||||
}).bind(this)();
|
setTimeout(this.activityChanger, 900000);
|
||||||
|
|
||||||
logger.log("info", `Started worker ${this.workerID}.`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async* getFiles(dir) {
|
async* getFiles(dir) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue