Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ client.once("ready", () => {
console.info(`${client.user.tag} (${client.shard.ids}) ready for business!`);
setInterval(
() => patchClusterData(client.shard.ids[0], client.shard.ids[0], clusterStats()),
5 * MINUTES
5 * MINUTES,
);
setInterval(() => reloadables.performUpdates(client), 100 * MILLISECONDS);
});
Expand All @@ -72,7 +72,7 @@ client.on("guildCreate", guild => {
console.info(`Added to ${guild.name} (${guild.id})`);
guild?.systemChannel
?.send("**Glad to be a part of your server** :heart:\nYou're probably looking for `/help`")
.catch(() => {});
.catch(err => console.error("Failed to send guild welcome message:", err.message));
});

client.on("guildDelete", guild => {
Expand Down
2 changes: 1 addition & 1 deletion modules/reloadable/command_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const allHandlers = (
fs
.readdirSync(commandsPath)
.filter(file => file.endsWith(".js"))
.map(filePath => import(path.resolve(commandsPath, filePath)))
.map(filePath => import(path.resolve(commandsPath, filePath))),
)
).map(commandFileModule => commandFileModule.handlers);

Expand Down
10 changes: 5 additions & 5 deletions modules/reloadable/commands/botstats.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const chatInputHandler = async interaction => {
name: ":red_envelope: SQLite3",
value: `**v${sqliteVersion}**`,
inline: true,
}
},
)
.setTimestamp();

Expand All @@ -117,11 +117,11 @@ const chatInputHandler = async interaction => {
const { readyAt, guildCount } = JSON.parse(data);
return bold(
`<t:${toSecs(readyAt)}:R> / ${guildCount} / ${id} / <t:${toSecs(
lastInteraction[id]
)}:R>`
lastInteraction[id],
)}:R>`,
);
})
.join("\n")
.join("\n"),
)
.addFields(
{
Expand All @@ -138,7 +138,7 @@ const chatInputHandler = async interaction => {
name: ":open_file_folder: SQLite Connections",
value: bold(openConnections.toString()),
inline: true,
}
},
);
embeds.push(additionalEmbed);
interaction.editReply({ embeds, ephemeral: true });
Expand Down
8 changes: 4 additions & 4 deletions modules/reloadable/commands/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export const countdownCommand = new SlashCommandBuilder()
.setDescription("The date/time you want to countdown to")
.setRequired(true)
.setAutocomplete(true)
.setMaxLength(MAX_LENGTH_STRING_CHOICE)
.setMaxLength(MAX_LENGTH_STRING_CHOICE),
)
.addStringOption(option =>
option.setName(OptionName.timezone).setDescription("Current timezone").setAutocomplete(true)
option.setName(OptionName.timezone).setDescription("Current timezone").setAutocomplete(true),
)
.addStringOption(option => option.setName(OptionName.reason).setDescription("Description"))
.addMentionableOption(option =>
option.setName(OptionName.mention).setDescription("Mention someone once the timer is done")
option.setName(OptionName.mention).setDescription("Mention someone once the timer is done"),
)
.setDMPermission(false);

Expand Down Expand Up @@ -165,7 +165,7 @@ autocompleteOptionHandlers[OptionName.datetime] = async (interaction, value) =>
});

const suggestion = `${value.substring(0, 50)} (${dt.toLocaleString(
DateTime.DATETIME_MED
DateTime.DATETIME_MED,
)} ${timezone})`;
return [{ name: suggestion, value }];
};
Expand Down
4 changes: 2 additions & 2 deletions modules/reloadable/commands/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ const generateMessage = ({ guildId, locale }) => {
.setEmoji({
name: type === "timer" ? "⏲️" : "🕑",
});
})
}),
)
.setMaxValues(all.length)
.setMaxValues(all.length),
);

return {
Expand Down
2 changes: 1 addition & 1 deletion modules/reloadable/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const chatInputHandler = async interaction => {
name: "All is good though!",
value:
"Not to worry - The bot should be functional in around a week once the team has completed migration and deployed the new version of the bot.",
}
},
);
embeds.push(helpEmbed);

Expand Down
2 changes: 1 addition & 1 deletion modules/reloadable/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const listCommand = new SlashCommandBuilder()
const nothingFoundEmbed = new EmbedBuilder()
.setTitle("No countdowns or timers found!")
.setDescription(
"For timers or countdowns to show up in this list, a `reason` must be provided when creating a timer or countdown."
"For timers or countdowns to show up in this list, a `reason` must be provided when creating a timer or countdown.",
);

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/reloadable/commands/newsitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const newsitemCommand = new SlashCommandBuilder()
option
.setName("text")
.setDescription("What would you like to tell the users of the bot?")
.setRequired(true)
)
.setRequired(true),
),
)
.setDefaultMemberPermissions(0)
.setDMPermission(false);
Expand Down
10 changes: 5 additions & 5 deletions modules/reloadable/commands/please.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ export const pleaseCommand = new SlashCommandBuilder()
.addSubcommand(subcommand =>
subcommand
.setName("postservercount")
.setDescription("Post server counts to top.gg and discord.bots.gg")
.setDescription("Post server counts to top.gg and discord.bots.gg"),
)
.addSubcommand(subcommand => subcommand.setName("register").setDescription("Register commands"))
.addSubcommand(subcommand =>
subcommand.setName("reload").setDescription("Reload code without a restart (Zero downtime)")
subcommand.setName("reload").setDescription("Reload code without a restart (Zero downtime)"),
)
.addSubcommand(subcommand =>
subcommand.setName("respawn").setDescription("Respawn all shards one by one")
subcommand.setName("respawn").setDescription("Respawn all shards one by one"),
)
.addSubcommand(subcommand =>
subcommand
.setName("run")
.setDescription("Evaluate code on the bot")
.addStringOption(option =>
option.setName("code").setDescription("Code to be evaluated").setRequired(true)
)
option.setName("code").setDescription("Code to be evaluated").setRequired(true),
),
);

/**
Expand Down
10 changes: 5 additions & 5 deletions modules/reloadable/commands/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ export const timerCommand = new SlashCommandBuilder()
.setName("timer")
.setDescription("Set a timer")
.addIntegerOption(option =>
option.setName(options.seconds).setDescription("Number of seconds to set the timer for")
option.setName(options.seconds).setDescription("Number of seconds to set the timer for"),
)
.addIntegerOption(option =>
option.setName(options.minutes).setDescription("Number of minutes to set the timer for")
option.setName(options.minutes).setDescription("Number of minutes to set the timer for"),
)
.addIntegerOption(option =>
option.setName(options.hours).setDescription("Number of hours to set the timer for")
option.setName(options.hours).setDescription("Number of hours to set the timer for"),
)
.addIntegerOption(option =>
option.setName(options.days).setDescription("Number of days to set the timer for")
option.setName(options.days).setDescription("Number of days to set the timer for"),
)
.addStringOption(option => option.setName(options.reason).setDescription("Description"))
.addMentionableOption(option =>
option.setName(options.mention).setDescription("Mention someone once the timer is done")
option.setName(options.mention).setDescription("Mention someone once the timer is done"),
)
.setDMPermission(false);

Expand Down
8 changes: 4 additions & 4 deletions modules/reloadable/commands/timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ export const timestampCommand = new SlashCommandBuilder()
.setName(OptionName.datetime)
.setDescription("The date/time for the timestamp")
.setRequired(true)
.setAutocomplete(true)
.setAutocomplete(true),
)
.addStringOption(option =>
option.setName(OptionName.timezone).setDescription("Current timezone").setAutocomplete(true)
option.setName(OptionName.timezone).setDescription("Current timezone").setAutocomplete(true),
)
.addStringOption(option =>
option
.setName(OptionName.format)
.setDescription("Formatting of the generated time tag")
.addChoices(
{ name: "Show all", value: "all" },
...Object.entries(formats).map(([name, value]) => ({ name, value }))
)
...Object.entries(formats).map(([name, value]) => ({ name, value })),
),
);

/**
Expand Down
22 changes: 11 additions & 11 deletions modules/reloadable/sqlite3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ db.prepare(
key TEXT PRIMARY KEY NOT NULL,
value JSON
)
`
`,
).run();

/*
Expand All @@ -23,7 +23,7 @@ db.prepare(
runId INTEGER UNIQUE NOT NULL,
data TEXT NOT NULL
) STRICT
`
`,
).run();

db.prepare(
Expand All @@ -33,7 +33,7 @@ db.prepare(
runId INTEGER NOT NULL,
data TEXT
) STRICT
`
`,
).run();

// covering index
Expand All @@ -42,7 +42,7 @@ db.prepare(
CREATE INDEX IF NOT EXISTS guildRunIdIndex ON guilds (
id, runId
)
`
`,
).run();

db.prepare(
Expand All @@ -51,7 +51,7 @@ db.prepare(
id TEXT PRIMARY KEY NOT NULL,
data TEXT
) STRICT
`
`,
).run();

db.prepare(
Expand All @@ -67,15 +67,15 @@ db.prepare(
REFERENCES guilds (id)
ON DELETE CASCADE
) STRICT
`
`,
).run();

db.prepare(
`
CREATE INDEX IF NOT EXISTS nextCountdownIndex ON countdowns (
updateTime, priority
)
`
`,
).run();

/// Key-Value Load & Store
Expand All @@ -84,7 +84,7 @@ const setValueStmt = db.prepare(
`
INSERT INTO kv (key, value) VALUES (@key, @value)
ON CONFLICT(key) DO UPDATE SET value = excluded.value
`
`,
);
export const kv = new Proxy(
{},
Expand All @@ -95,7 +95,7 @@ export const kv = new Proxy(
set(_, key, value) {
return setValueStmt.run({ key, value }).changes === 1;
},
}
},
);

/// Cluster Table
Expand All @@ -108,7 +108,7 @@ const patchClusterDataStmt = db.prepare(
ON CONFLICT(id) DO UPDATE SET
runId = excluded.runId,
data = json_patch(clusters.data, excluded.data);
`
`,
);
export const patchClusterData = (clusterId, runId, dataObj) =>
patchClusterDataStmt.run({ clusterId, runId, data: JSON.stringify(dataObj) });
Expand Down Expand Up @@ -154,7 +154,7 @@ const insertCountdownStmt = db.prepare(
INSERT INTO countdowns (guild, channel, author, updateTime, priority, data)
VALUES (@guildId, @channelId, @authorId, @updateTime, @priority, json(@data))
RETURNING rowid, *
`
`,
);

export const insertCountdown = (guildId, channelId, authorId, updateTime, data, priority = 42) =>
Expand Down
Loading