Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4d05039
deps: update deps
Dwigoric Aug 20, 2022
08adf07
deps: discord.js v13 LTS
Dwigoric Aug 20, 2022
b30b25e
misc: use v3.1
Dwigoric Aug 21, 2022
dade2a8
fix: update Subcommand class name
Dwigoric Aug 21, 2022
3efe010
fix(preconditions): rename run methods to messageRun
Dwigoric Aug 21, 2022
3a8c318
fix(preconditions): rename event to listen to
Dwigoric Aug 21, 2022
c54b501
fix(CommandError): rename event object
Dwigoric Aug 21, 2022
4b5554a
src: add new ClientOptions in config
Dwigoric Aug 21, 2022
5836448
deps: update deps
Dwigoric Aug 21, 2022
5ddbccd
fix: argument options
Dwigoric Aug 21, 2022
514fcb3
feat: add listeners on chat input and message command when denied
Dwigoric Aug 28, 2022
7babed5
fix: implement chatInputRun handlers on global preconditions
Dwigoric Aug 28, 2022
f594208
misc: use command denied handlers for standard error message
Dwigoric Aug 28, 2022
4da615b
fix: implement chatInputRun handler for local preconditions
Dwigoric Aug 28, 2022
533708d
fix: update subcommand list
Dwigoric Aug 29, 2022
1510906
fix: trim resolved rest strings
Dwigoric Aug 29, 2022
0af66d2
deps: update deps
Dwigoric Aug 30, 2022
b054149
Revert "fix: argument options"
Dwigoric Aug 30, 2022
26ec74f
refactor: move db url to .env
Dwigoric Aug 30, 2022
edb9662
misc: add dev server config
Dwigoric Aug 30, 2022
300927b
fix: config dotenv before calling config file
Dwigoric Aug 30, 2022
a953427
ci: remove PR trigger on lint workflow
Dwigoric Aug 31, 2022
e962ea4
fix: chat input method for OwnersOnly precondition
Dwigoric Sep 3, 2022
99d6815
feat: implement application commands for Admin/Bot Owner commands
Dwigoric Sep 3, 2022
e56df82
Merge branch 'main' into application-commands
Dwigoric Oct 1, 2022
80984ed
deps: fix after merge
Dwigoric Oct 1, 2022
3cb732c
deps: remove erela.js-spotify
Dwigoric Oct 1, 2022
1b2629c
Merge branch 'main' into application-commands
Dwigoric Oct 1, 2022
95f5c61
Merge branch 'main' into application-commands
Dwigoric Nov 8, 2022
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
3 changes: 3 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ STEAM_API_KEY=
TMDB_API_KEY=
TWITCH_API_KEY=
TWITCH_CLIENT_ID=

# The database URL
DATABASE_URL=
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stalwartle",
"description": "A Discord Bot for Discordians' basic needs",
"version": "3.0.0",
"version": "3.1.0",
"main": "src/app.js",
"scripts": {
"start": "pm2 start src/app.js --name Stalwartle --node-args=\"--expose_gc --always_compact\"",
Expand All @@ -18,19 +18,19 @@
},
"homepage": "https://github.com/insane-devs/stalwartle#readme",
"dependencies": {
"@sapphire/discord.js-utilities": "^4.11.3",
"@sapphire/discord.js-utilities": "^5.0.0",
"@sapphire/duration": "^1.0.0",
"@sapphire/framework": "^2.5.1",
"@sapphire/pieces": "^3.3.4",
"@sapphire/plugin-editable-commands": "^1.2.2",
"@sapphire/plugin-logger": "^2.2.3",
"@sapphire/plugin-scheduled-tasks": "3.0.0",
"@sapphire/plugin-subcommands": "^2.2.2",
"@sapphire/framework": "^3.1.0",
"@sapphire/pieces": "^3.5.1",
"@sapphire/plugin-editable-commands": "^2.0.1",
"@sapphire/plugin-logger": "^3.0.0",
"@sapphire/plugin-scheduled-tasks": "4.0.0",
"@sapphire/plugin-subcommands": "^3.2.0",
"@sapphire/stopwatch": "^1.4.1",
"@sapphire/timestamp": "^1.0.0",
"@sapphire/type": "^2.2.4",
"@sapphire/utilities": "^3.7.0",
"bullmq": "^1.86.7",
"@sapphire/utilities": "^3.9.2",
"bullmq": "^1.90.0",
"cron-validator": "^1.3.1",
"discord.js": "^13.11.0",
"dotenv": "^16.0.3",
Expand Down
32 changes: 31 additions & 1 deletion src/commands/Admin/Bot Owner/addcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,38 @@ module.exports = class extends Command {
this.usage = '<Content:string>';
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand(builder =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption(option =>
option
.setName('changelog')
.setDescription('The changelog to post.')
.setRequired(true))
, {
guildIds: [this.container.client.options.devServer],
idHints: ['1014142821265068133']
});
}

chatInputRun(interaction) {
const changelog = interaction.options.getString('changelog');

this.container.client.channels.cache.get(this.container.client.settings.changelogs).send({
embeds: [
new MessageEmbed()
.setTitle(`<a:updating:417233654545383424> ${this.container.client.user.username}'s Changelog`)
.setDescription(changelog)
.setTimestamp()]
});

return interaction.reply({ content: `${this.container.constants.EMOTES.tick} :: Successfully posted changelog!`, ephemeral: true });
}

async messageRun(msg, args) {
const changelog = await args.rest('string').catch(() => null);
const changelog = await args.rest('string').then(str => str.trim()).catch(() => null);
if (changelog === null) return reply(msg, `${this.container.constants.EMOTES.xmark} :: Please supply the new changelog.`);

this.container.client.channels.cache.get(this.container.client.settings.changelogs).send({
Expand Down
38 changes: 38 additions & 0 deletions src/commands/Admin/Bot Owner/blacklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { Command } = require('@sapphire/framework');
const { reply } = require('@sapphire/plugin-editable-commands');
const { codeBlock } = require('@sapphire/utilities');
const { User } = require('discord.js');
const { promisify } = require('util');

module.exports = class extends Command {

Expand All @@ -16,6 +17,43 @@ module.exports = class extends Command {
this.terms = ['usersAdded', 'usersRemoved', 'guildsAdded', 'guildsRemoved'];
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand(builder =>
builder
.setName(this.name)
.setDescription(this.description)
.addUserOption(option =>
option
.setName('user')
.setDescription('The user to blacklist.'))
.addStringOption(option =>
option
.setName('server')
.setDescription('The ID of the server to blacklist.'))
, {
guildIds: [this.container.client.options.devServer],
idHints: ['1014174483562647632']
});
}

async chatInputRun(interaction) {
const user = await promisify(interaction.options.getUser)('user', true).catch(() => null);
const guild = await promisify(interaction.options.getString)('server', true).catch(() => null);

if (user === null && guild === null) return interaction.reply({ content: `${this.container.constants.EMOTES.xmark} :: Please give the user or guild ID to blacklist.`, ephemeral: true });

const { userBlacklist, guildBlacklist } = this.container.client.settings;
if (user !== null) userBlacklist.push(user.id);
if (guild !== null) guildBlacklist.push(guild);

await this.container.stores.get('gateways').get('clientGateway').update(this.container.client.user.id, { userBlacklist, guildBlacklist });

return interaction.reply({
content: `${this.container.constants.EMOTES.check} :: Successfully blacklisted ${user ? 'user' : 'guild'} ${user ? `**${user.tag}**` : guild}${guild && user ? ` and guild **${guild}**` : ''}.`,
ephemeral: true
});
}

async messageRun(message, args) {
let usersAndGuilds = await args.pickResult('user');
if (!usersAndGuilds.success) usersAndGuilds = await args.restResult('string');
Expand Down
32 changes: 31 additions & 1 deletion src/commands/Admin/Bot Owner/disable.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
const { Command } = require('@sapphire/framework');
const { reply } = require('@sapphire/plugin-editable-commands');
const { promisify } = require('util');

module.exports = class extends Command {

constructor(context, options) {
super(context, {
...options,
preconditions: ['OwnersOnly'],
description: 'Re-enables or temporarily disables a piece. Default state restored on reboot.'
description: 'Re-disables or temporarily disables a piece. Default state restored on reboot.'
});
this.usage = '<Piece:piece>';
this.guarded = true;
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand(builder =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption(option =>
option
.setName('piece')
.setDescription('The name of the piece to disable.')
.setRequired(true))
, {
guildIds: [this.container.client.options.devServer],
idHints: ['1015443730473426984']
});
}

async chatInputRun(interaction) {
const piece = await promisify(interaction.options.getString).bind(this)('piece').then(str => this.container.stores.get('arguments').get('piece').run(str)).catch(() => null);
if (piece === null) return interaction.reply({ content: `${this.container.constants.EMOTES.xmark} :: Invalid piece name.`, ephemeral: true });

piece.enabled = false;
if (this.container.client.shard) {
await this.container.client.shard.broadcastEval(`
if (String(this.options.shards) !== '${this.container.client.options.shards}') this.container.stores.get('${piece.store.name}').get('${piece.name}').enabled = false;
`);
}
return interaction.reply({ content: `${this.container.constants.EMOTES.tick} :: Successfully disabled \`${piece.name}\` from ${piece.store.name}.`, ephemeral: true });
}

async messageRun(message, args) {
const piece = await args.pick('piece').catch(() => null);
if (piece === null) return reply(message, `${this.container.constants.EMOTES.xmark} :: Please supply the name of the piece you want to disable.`);
Expand Down
30 changes: 30 additions & 0 deletions src/commands/Admin/Bot Owner/enable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Command } = require('@sapphire/framework');
const { reply } = require('@sapphire/plugin-editable-commands');
const { promisify } = require('util');

module.exports = class extends Command {

Expand All @@ -13,6 +14,35 @@ module.exports = class extends Command {
this.guarded = true;
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand(builder =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption(option =>
option
.setName('piece')
.setDescription('The name of the piece to enable.')
.setRequired(true))
, {
guildIds: [this.container.client.options.devServer],
idHints: ['1015443731895304283']
});
}

async chatInputRun(interaction) {
const piece = await promisify(interaction.options.getString).bind(this)('piece').then(str => this.container.stores.get('arguments').get('piece').run(str)).catch(() => null);
if (piece === null) return interaction.reply({ content: `${this.container.constants.EMOTES.xmark} :: Invalid piece name.`, ephemeral: true });

piece.enabled = true;
if (this.container.client.shard) {
interaction.client.shard.broadcastEval(`
if (String(this.options.shards) !== '${this.container.client.options.shards}') this.container.stores.get('${piece.store.name}').get('${piece.name}').enabled = true;
`);
}
return interaction.reply({ content: `${this.container.constants.EMOTES.tick} :: Successfully enabled \`${piece.name}\` to ${piece.store.name}.`, ephemeral: true });
}

async messageRun(message, args) {
const piece = await args.pick('piece').catch(() => null);
if (piece === null) return reply(message, `${this.container.constants.EMOTES.xmark} :: Please supply the name of the piece you want to enable.`);
Expand Down
Loading