Remove creation date from mkdocs, added ability to limit owner commands to certain server, don't append help command to end of playing message if classic commands are disabled, fix interaction upload size
This commit is contained in:
parent
3477f5c39f
commit
603e732704
14 changed files with 40 additions and 24 deletions
|
@ -53,4 +53,7 @@ API_TYPE=none
|
||||||
# If API_TYPE is `azure`, set this to your Azure webhook URL
|
# If API_TYPE is `azure`, set this to your Azure webhook URL
|
||||||
AZURE_URL=
|
AZURE_URL=
|
||||||
# If API_TYPE is `azure`, set an optional password for webhook responses
|
# If API_TYPE is `azure`, set an optional password for webhook responses
|
||||||
AZURE_PASS=
|
AZURE_PASS=
|
||||||
|
|
||||||
|
# Put ID of server to limit owner-only commands to
|
||||||
|
ADMIN_SERVER=
|
|
@ -66,6 +66,7 @@ class Command {
|
||||||
static requires = [];
|
static requires = [];
|
||||||
static slashAllowed = true;
|
static slashAllowed = true;
|
||||||
static directAllowed = true;
|
static directAllowed = true;
|
||||||
|
static adminOnly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Command;
|
export default Command;
|
|
@ -8,6 +8,7 @@ class BroadcastCommand extends Command {
|
||||||
if (!owners.includes(this.author.id)) {
|
if (!owners.includes(this.author.id)) {
|
||||||
this.success = false;
|
this.success = false;
|
||||||
resolve("Only the bot owner can broadcast messages!");
|
resolve("Only the bot owner can broadcast messages!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const message = this.options.message ?? this.args.join(" ");
|
const message = this.options.message ?? this.args.join(" ");
|
||||||
if (message?.trim()) {
|
if (message?.trim()) {
|
||||||
|
@ -35,6 +36,7 @@ class BroadcastCommand extends Command {
|
||||||
}];
|
}];
|
||||||
|
|
||||||
static description = "Broadcasts a playing message until the command is run again or the bot restarts";
|
static description = "Broadcasts a playing message until the command is run again or the bot restarts";
|
||||||
|
static adminOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BroadcastCommand;
|
export default BroadcastCommand;
|
|
@ -38,6 +38,7 @@ class EvalCommand extends Command {
|
||||||
static description = "Executes JavaScript code";
|
static description = "Executes JavaScript code";
|
||||||
static aliases = ["run"];
|
static aliases = ["run"];
|
||||||
static arguments = ["[code]"];
|
static arguments = ["[code]"];
|
||||||
|
static adminOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EvalCommand;
|
export default EvalCommand;
|
|
@ -42,6 +42,7 @@ class ExecCommand extends Command {
|
||||||
static description = "Executes a shell command";
|
static description = "Executes a shell command";
|
||||||
static aliases = ["runcmd"];
|
static aliases = ["runcmd"];
|
||||||
static arguments = ["[command]"];
|
static arguments = ["[command]"];
|
||||||
|
static adminOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ExecCommand;
|
export default ExecCommand;
|
|
@ -16,7 +16,7 @@ class ImageReloadCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
static description = "Attempts to reconnect to all available image processing servers";
|
static description = "Attempts to reconnect to all available image processing servers";
|
||||||
static aliases = ["magickconnect", "magick"];
|
static adminOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ImageReloadCommand;
|
export default ImageReloadCommand;
|
||||||
|
|
|
@ -33,6 +33,7 @@ class ReloadCommand extends Command {
|
||||||
|
|
||||||
static description = "Reloads a command";
|
static description = "Reloads a command";
|
||||||
static arguments = ["[command]"];
|
static arguments = ["[command]"];
|
||||||
|
static adminOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ReloadCommand;
|
export default ReloadCommand;
|
||||||
|
|
|
@ -16,6 +16,7 @@ class RestartCommand extends Command {
|
||||||
|
|
||||||
static description = "Restarts me";
|
static description = "Restarts me";
|
||||||
static aliases = ["reboot"];
|
static aliases = ["reboot"];
|
||||||
|
static adminOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RestartCommand;
|
export default RestartCommand;
|
|
@ -28,6 +28,7 @@ class SoundReloadCommand extends Command {
|
||||||
|
|
||||||
static description = "Attempts to reconnect to all available Lavalink nodes";
|
static description = "Attempts to reconnect to all available Lavalink nodes";
|
||||||
static aliases = ["lava", "lavalink", "lavaconnect", "soundconnect"];
|
static aliases = ["lava", "lavalink", "lavaconnect", "soundconnect"];
|
||||||
|
static adminOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SoundReloadCommand;
|
export default SoundReloadCommand;
|
|
@ -21,4 +21,5 @@ Here's an overview of the variables that are not necessarily required for the bo
|
||||||
- `METRICS`: The HTTP port to serve [Prometheus](https://prometheus.io/)-compatible metrics on.
|
- `METRICS`: The HTTP port to serve [Prometheus](https://prometheus.io/)-compatible metrics on.
|
||||||
- `API`: Set this to "none" if you want to process all images locally. Alternatively, set it to "ws" to use an image API server specified in the `image` block of `servers.json`, or "azure" to use the Azure Functions-based API.
|
- `API`: Set this to "none" if you want to process all images locally. Alternatively, set it to "ws" to use an image API server specified in the `image` block of `servers.json`, or "azure" to use the Azure Functions-based API.
|
||||||
- `AZURE_URL`: Your Azure webhook URL. Only applies if `API` is set to "azure".
|
- `AZURE_URL`: Your Azure webhook URL. Only applies if `API` is set to "azure".
|
||||||
- `AZURE_PASS`: An optional password used for Azure requests. Only applies if `API` is set to "azure".
|
- `AZURE_PASS`: An optional password used for Azure requests. Only applies if `API` is set to "azure".
|
||||||
|
- `ADMIN_SERVER`: A server to limit owner-only commands to.
|
|
@ -36,17 +36,7 @@ export default async (client, cluster, worker, ipc, interaction) => {
|
||||||
flags: result.flags ?? (commandClass.success ? 0 : 64)
|
flags: result.flags ?? (commandClass.success ? 0 : 64)
|
||||||
}));
|
}));
|
||||||
} else if (typeof result === "object" && result.file) {
|
} else if (typeof result === "object" && result.file) {
|
||||||
let fileSize = 8388119;
|
const fileSize = 8388119;
|
||||||
if (interaction.channel.guild) {
|
|
||||||
switch (interaction.channel.guild.premiumTier) {
|
|
||||||
case 2:
|
|
||||||
fileSize = 52428308;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
fileSize = 104856616;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (result.file.length > fileSize) {
|
if (result.file.length > fileSize) {
|
||||||
if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
|
if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
|
||||||
await upload(client, ipc, result, interaction, true);
|
await upload(client, ipc, result, interaction, true);
|
||||||
|
|
|
@ -40,8 +40,7 @@ theme:
|
||||||
name: Switch to light mode
|
name: Switch to light mode
|
||||||
plugins:
|
plugins:
|
||||||
- glightbox
|
- glightbox
|
||||||
- git-revision-date-localized:
|
- git-revision-date-localized
|
||||||
enable_creation_date: true
|
|
||||||
extra:
|
extra:
|
||||||
social:
|
social:
|
||||||
- icon: fontawesome/brands/twitter
|
- icon: fontawesome/brands/twitter
|
||||||
|
|
19
shard.js
19
shard.js
|
@ -26,6 +26,8 @@ import { generateList, createPage } from "./utils/help.js";
|
||||||
// whether a broadcast is currently in effect
|
// whether a broadcast is currently in effect
|
||||||
let broadcast = false;
|
let broadcast = false;
|
||||||
|
|
||||||
|
const playingSuffix = !types.classic ? ` | @${this.bot.user.username} help` : "";
|
||||||
|
|
||||||
class Shard extends BaseClusterWorker {
|
class Shard extends BaseClusterWorker {
|
||||||
constructor(bot) {
|
constructor(bot) {
|
||||||
super(bot);
|
super(bot);
|
||||||
|
@ -54,7 +56,14 @@ class Shard extends BaseClusterWorker {
|
||||||
if (types.application) {
|
if (types.application) {
|
||||||
const commandArray = await update(this.bot, this.clusterID, this.workerID, this.ipc, soundStatus);
|
const commandArray = await update(this.bot, this.clusterID, this.workerID, this.ipc, soundStatus);
|
||||||
try {
|
try {
|
||||||
await this.bot.bulkEditCommands(commandArray);
|
log("info", "Sending application command data to Discord...");
|
||||||
|
let cmdArray = commandArray.main;
|
||||||
|
if (process.env.ADMIN_SERVER && process.env.ADMIN_SERVER !== "") {
|
||||||
|
await this.bot.bulkEditGuildCommands(process.env.ADMIN_SERVER, commandArray.private);
|
||||||
|
} else {
|
||||||
|
cmdArray = [...commandArray.main, ...commandArray.private];
|
||||||
|
}
|
||||||
|
await this.bot.bulkEditCommands(cmdArray);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("error", e);
|
log("error", e);
|
||||||
log("error", "Failed to send command data to Discord, slash/message commands may be unavailable.");
|
log("error", "Failed to send command data to Discord, slash/message commands may be unavailable.");
|
||||||
|
@ -111,7 +120,7 @@ class Shard extends BaseClusterWorker {
|
||||||
|
|
||||||
this.ipc.register("playbroadcast", (message) => {
|
this.ipc.register("playbroadcast", (message) => {
|
||||||
this.bot.editStatus("dnd", {
|
this.bot.editStatus("dnd", {
|
||||||
name: `${message} | @${this.bot.user.username} help`,
|
name: message + playingSuffix,
|
||||||
});
|
});
|
||||||
broadcast = true;
|
broadcast = true;
|
||||||
return this.ipc.broadcast("broadcastSuccess");
|
return this.ipc.broadcast("broadcastSuccess");
|
||||||
|
@ -119,7 +128,7 @@ class Shard extends BaseClusterWorker {
|
||||||
|
|
||||||
this.ipc.register("broadcastend", () => {
|
this.ipc.register("broadcastend", () => {
|
||||||
this.bot.editStatus("dnd", {
|
this.bot.editStatus("dnd", {
|
||||||
name: `${random(messages)} | @${this.bot.user.username} help`,
|
name: random(messages) + playingSuffix,
|
||||||
});
|
});
|
||||||
broadcast = false;
|
broadcast = false;
|
||||||
return this.ipc.broadcast("broadcastEnd");
|
return this.ipc.broadcast("broadcastEnd");
|
||||||
|
@ -132,7 +141,7 @@ class Shard extends BaseClusterWorker {
|
||||||
if (broadcastMessage) {
|
if (broadcastMessage) {
|
||||||
broadcast = true;
|
broadcast = true;
|
||||||
this.bot.editStatus("dnd", {
|
this.bot.editStatus("dnd", {
|
||||||
name: `${broadcastMessage} | @${this.bot.user.username} help`,
|
name: broadcastMessage + playingSuffix,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +154,7 @@ class Shard extends BaseClusterWorker {
|
||||||
activityChanger() {
|
activityChanger() {
|
||||||
if (!broadcast) {
|
if (!broadcast) {
|
||||||
this.bot.editStatus("dnd", {
|
this.bot.editStatus("dnd", {
|
||||||
name: `${random(messages)} | @${this.bot.user.username} help`,
|
name: random(messages) + playingSuffix,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setTimeout(this.activityChanger.bind(this), 900000);
|
setTimeout(this.activityChanger.bind(this), 900000);
|
||||||
|
|
|
@ -43,6 +43,7 @@ export async function load(client, cluster, worker, ipc, command, soundStatus, s
|
||||||
flags: props.flags,
|
flags: props.flags,
|
||||||
slashAllowed: props.slashAllowed,
|
slashAllowed: props.slashAllowed,
|
||||||
directAllowed: props.directAllowed,
|
directAllowed: props.directAllowed,
|
||||||
|
adminOnly: props.adminOnly,
|
||||||
type: 1
|
type: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ export async function load(client, cluster, worker, ipc, command, soundStatus, s
|
||||||
|
|
||||||
export async function update() {
|
export async function update() {
|
||||||
const commandArray = [];
|
const commandArray = [];
|
||||||
|
const privateCommandArray = [];
|
||||||
const merged = new Map([...commands, ...messageCommands]);
|
const merged = new Map([...commands, ...messageCommands]);
|
||||||
for (const [name, command] of merged.entries()) {
|
for (const [name, command] of merged.entries()) {
|
||||||
let cmdInfo = info.get(name);
|
let cmdInfo = info.get(name);
|
||||||
|
@ -97,18 +99,19 @@ export async function update() {
|
||||||
flags: cmd.flags,
|
flags: cmd.flags,
|
||||||
slashAllowed: cmd.slashAllowed,
|
slashAllowed: cmd.slashAllowed,
|
||||||
directAllowed: cmd.directAllowed,
|
directAllowed: cmd.directAllowed,
|
||||||
|
adminOnly: cmd.adminOnly,
|
||||||
type: cmdInfo.type
|
type: cmdInfo.type
|
||||||
};
|
};
|
||||||
info.set(name, cmdInfo);
|
info.set(name, cmdInfo);
|
||||||
}
|
}
|
||||||
if (cmdInfo?.type === 3) {
|
if (cmdInfo?.type === 3) {
|
||||||
commandArray.push({
|
(cmdInfo.adminOnly ? privateCommandArray : commandArray).push({
|
||||||
name: name,
|
name: name,
|
||||||
type: cmdInfo.type,
|
type: cmdInfo.type,
|
||||||
dm_permission: cmdInfo.directAllowed
|
dm_permission: cmdInfo.directAllowed
|
||||||
});
|
});
|
||||||
} else if (cmdInfo?.slashAllowed) {
|
} else if (cmdInfo?.slashAllowed) {
|
||||||
commandArray.push({
|
(cmdInfo.adminOnly ? privateCommandArray : commandArray).push({
|
||||||
name,
|
name,
|
||||||
type: cmdInfo.type,
|
type: cmdInfo.type,
|
||||||
description: cmdInfo.description,
|
description: cmdInfo.description,
|
||||||
|
@ -117,5 +120,8 @@ export async function update() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return commandArray;
|
return {
|
||||||
|
main: commandArray,
|
||||||
|
private: privateCommandArray
|
||||||
|
};
|
||||||
}
|
}
|
Loading…
Reference in a new issue