ed25116851
* postgres: use transaction-scoped sql for upgrade
* database: combine fixGuild and addGuild into getGuild
* postgres, sqlite: simplify upgrade()
* allow running commands in DMs without prefix
this functionality was broken in
16095c0256
but is now fixed
* allow running esmBot without a database
Before this change, the only way to run esmBot without a database is to use the
dummy database driver which is broken but fails silently. THis can lead to a
confusing user experience. For instance, using `&command disable` with the
dummy database driver will tell you that the command has been disabled even
though it has not been.
This change adds support for running esmBot with no database driver by leaving
the DB= config option empty, and explicitly telling the user that some
functionality is now unavailable rather than failing silently like the dummy
driver.
* remove dummy database driver
52 lines
No EOL
1.4 KiB
JavaScript
52 lines
No EOL
1.4 KiB
JavaScript
import Command from "../../classes/command.js";
|
|
import database from "../../utils/database.js";
|
|
import { endBroadcast, startBroadcast } from "../../utils/misc.js";
|
|
|
|
class BroadcastCommand extends Command {
|
|
async run() {
|
|
const owners = process.env.OWNER.split(",");
|
|
if (!owners.includes(this.author.id)) {
|
|
this.success = false;
|
|
return "Only the bot owner can broadcast messages!";
|
|
}
|
|
const message = this.options.message ?? this.args.join(" ");
|
|
if (message?.trim()) {
|
|
await database.setBroadcast(message);
|
|
startBroadcast(this.client, message);
|
|
if (process.env.PM2_USAGE) {
|
|
process.send({
|
|
type: "process:msg",
|
|
data: {
|
|
type: "broadcastStart",
|
|
message
|
|
}
|
|
});
|
|
}
|
|
return "Started broadcast.";
|
|
} else {
|
|
await database.setBroadcast(null);
|
|
endBroadcast(this.client);
|
|
if (process.env.PM2_USAGE) {
|
|
process.send({
|
|
type: "process:msg",
|
|
data: {
|
|
type: "broadcastEnd"
|
|
}
|
|
});
|
|
}
|
|
return "Ended broadcast.";
|
|
}
|
|
}
|
|
|
|
static flags = [{
|
|
name: "message",
|
|
type: 3,
|
|
description: "The message to broadcast"
|
|
}];
|
|
|
|
static description = "Broadcasts a playing message until the command is run again or the bot restarts";
|
|
static adminOnly = true;
|
|
static dbRequired = true;
|
|
}
|
|
|
|
export default BroadcastCommand; |