Skip to content

Commit

Permalink
wip silent messages.
Browse files Browse the repository at this point in the history
doing this without going insane requires discordjs/discord.js#9199

i attempted a monkey-patch, but then i ran into yarnpkg/yarn#2976 and i just give up, sorry.

return to this if i can fix those problems
  • Loading branch information
Foxite committed Dec 10, 2023
1 parent e5ffa6d commit 13f8551
Show file tree
Hide file tree
Showing 22 changed files with 4,589 additions and 4,252 deletions.
20 changes: 1 addition & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
"src"
],
"scripts": {
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
"typecheck": "tsc --noEmit",
"test": "npm run lint",
"start": "npm run env:set-database-url -- tsx src/scripts/migrate-and-start.ts",
Expand Down Expand Up @@ -51,23 +49,6 @@
"type-fest": "^2.12.0",
"typescript": "^4.6.4"
},
"eslintConfig": {
"extends": [
"xo",
"xo-typescript/space"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"new-cap": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-vars-experimental": "error",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"@typescript-eslint/no-implicit-any-catch": "off"
}
},
"husky": {
"hooks": {
"pre-commit": "npm test"
Expand Down Expand Up @@ -105,6 +86,7 @@
"p-retry": "4.6.2",
"pagination.djs": "^4.0.10",
"parse-duration": "1.0.2",
"patch-package": "^8.0.0",
"read-pkg": "7.1.0",
"reflect-metadata": "^0.1.13",
"spotify-uri": "^3.0.2",
Expand Down
15 changes: 15 additions & 0 deletions patches/discord.js+14.11.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/node_modules/discord.js/typings/index.d.ts b/node_modules/discord.js/typings/index.d.ts
index 78432a3..4f943d6 100644
--- a/node_modules/discord.js/typings/index.d.ts
+++ b/node_modules/discord.js/typings/index.d.ts
@@ -5671,8 +5671,8 @@ export interface InteractionReplyOptions extends BaseMessageOptions {
ephemeral?: boolean;
fetchReply?: boolean;
flags?: BitFieldResolvable<
- Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds'>,
- MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds
+ Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
+ MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
>;
}

4 changes: 2 additions & 2 deletions src/commands/clear.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {inject, injectable} from 'inversify';
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
Expand All @@ -22,6 +22,6 @@ export default class implements Command {
public async execute(interaction: ChatInputCommandInteraction) {
this.playerManager.get(interaction.guild!.id).clear();

await interaction.reply('clearer than a field after a fresh harvest');
await interaction.reply({content: 'clearer than a field after a fresh harvest', flags: MessageFlags.SuppressNotifications});
}
}
10 changes: 5 additions & 5 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SlashCommandBuilder} from '@discordjs/builders';
import {ChatInputCommandInteraction, EmbedBuilder, PermissionFlagsBits} from 'discord.js';
import {ChatInputCommandInteraction, EmbedBuilder, MessageFlags, PermissionFlagsBits} from 'discord.js';
import {injectable} from 'inversify';
import {prisma} from '../utils/db.js';
import Command from './index.js';
Expand Down Expand Up @@ -55,7 +55,7 @@ export default class implements Command {
},
});

await interaction.reply('👍 limit updated');
await interaction.reply({content: '👍 limit updated', flags: MessageFlags.SuppressNotifications});

break;
}
Expand All @@ -72,7 +72,7 @@ export default class implements Command {
},
});

await interaction.reply('👍 wait delay updated');
await interaction.reply({content: '👍 wait delay updated', flags: MessageFlags.SuppressNotifications});

break;
}
Expand All @@ -89,7 +89,7 @@ export default class implements Command {
},
});

await interaction.reply('👍 leave setting updated');
await interaction.reply({content: '👍 leave setting updated', flags: MessageFlags.SuppressNotifications});

break;
}
Expand All @@ -114,7 +114,7 @@ export default class implements Command {

embed.setDescription(description);

await interaction.reply({embeds: [embed]});
await interaction.reply({embeds: [embed], flags: MessageFlags.SuppressNotifications});

break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/disconnect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
Expand Down Expand Up @@ -28,6 +28,6 @@ export default class implements Command {

player.disconnect();

await interaction.reply('u betcha, disconnected');
await interaction.reply({content: 'u betcha, disconnected', flags: MessageFlags.SuppressNotifications});
}
}
8 changes: 4 additions & 4 deletions src/commands/favorites.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SlashCommandBuilder} from '@discordjs/builders';
import {APIEmbedField, AutocompleteInteraction, ChatInputCommandInteraction} from 'discord.js';
import {APIEmbedField, AutocompleteInteraction, ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {inject, injectable} from 'inversify';
import Command from '.';
import AddQueryToQueue from '../services/add-query-to-queue.js';
Expand Down Expand Up @@ -135,7 +135,7 @@ export default class implements Command {
});

if (favorites.length === 0) {
await interaction.reply('there aren\'t any favorites yet');
await interaction.reply({content: 'there aren\'t any favorites yet', flags: MessageFlags.SuppressNotifications});
return;
}

Expand Down Expand Up @@ -179,7 +179,7 @@ export default class implements Command {
},
});

await interaction.reply('👍 favorite created');
await interaction.reply({content: '👍 favorite created', flags: MessageFlags.SuppressNotifications});
}

private async remove(interaction: ChatInputCommandInteraction) {
Expand All @@ -202,6 +202,6 @@ export default class implements Command {

await prisma.favoriteQuery.delete({where: {id: favorite.id}});

await interaction.reply('👍 favorite removed');
await interaction.reply({content: '👍 favorite removed', flags: MessageFlags.SuppressNotifications});
}
}
4 changes: 2 additions & 2 deletions src/commands/fseek.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
Expand Down Expand Up @@ -55,6 +55,6 @@ export default class implements Command {
interaction.deferReply(),
]);

await interaction.editReply(`👍 seeked to ${prettyTime(player.getPosition())}`);
await interaction.followUp({content: `👍 seeked to ${prettyTime(player.getPosition())}`, flags: MessageFlags.SuppressNotifications});
}
}
4 changes: 2 additions & 2 deletions src/commands/loop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -29,6 +29,6 @@ export default class implements Command {

player.loopCurrentSong = !player.loopCurrentSong;

await interaction.reply((player.loopCurrentSong ? 'looped :)' : 'stopped looping :('));
await interaction.reply({content: (player.loopCurrentSong ? 'looped :)' : 'stopped looping :('), flags: MessageFlags.SuppressNotifications});
}
}
4 changes: 2 additions & 2 deletions src/commands/move.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {inject, injectable} from 'inversify';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -42,6 +42,6 @@ export default class implements Command {

const {title} = player.move(from, to);

await interaction.reply('moved **' + title + '** to position **' + String(to) + '**');
await interaction.reply({content: 'moved **' + title + '** to position **' + String(to) + '**', flags: MessageFlags.SuppressNotifications});
}
}
3 changes: 2 additions & 1 deletion src/commands/now-playing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -27,6 +27,7 @@ export default class implements Command {

await interaction.reply({
embeds: [buildPlayingMessageEmbed(player)],
flags: MessageFlags.SuppressNotifications,
});
}
}
4 changes: 2 additions & 2 deletions src/commands/pause.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
Expand Down Expand Up @@ -28,6 +28,6 @@ export default class implements Command {
}

player.pause();
await interaction.reply('the stop-and-go light is now red');
await interaction.reply({content: 'the stop-and-go light is now red', flags: MessageFlags.SuppressNotifications});
}
}
4 changes: 2 additions & 2 deletions src/commands/queue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {inject, injectable} from 'inversify';
import {TYPES} from '../types.js';
Expand Down Expand Up @@ -27,6 +27,6 @@ export default class implements Command {

const embed = buildQueueEmbed(player, interaction.options.getInteger('page') ?? 1);

await interaction.reply({embeds: [embed]});
await interaction.reply({embeds: [embed], flags: MessageFlags.SuppressNotifications});
}
}
4 changes: 2 additions & 2 deletions src/commands/remove.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {inject, injectable} from 'inversify';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -42,6 +42,6 @@ export default class implements Command {

player.removeFromQueue(position, range);

await interaction.reply(':wastebasket: removed');
await interaction.reply({content: ':wastebasket: removed', flags: MessageFlags.SuppressNotifications});
}
}
4 changes: 2 additions & 2 deletions src/commands/replay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -37,6 +37,6 @@ export default class implements Command {
interaction.deferReply(),
]);

await interaction.editReply('👍 replayed the current song');
await interaction.editReply({content: '👍 replayed the current song', flags: MessageFlags.SuppressNotifications});
}
}
3 changes: 2 additions & 1 deletion src/commands/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PlayerManager from '../managers/player.js';
import {STATUS} from '../services/player.js';
import {buildPlayingMessageEmbed} from '../utils/build-embed.js';
import {getMemberVoiceChannel, getMostPopularVoiceChannel} from '../utils/channels.js';
import {ChatInputCommandInteraction, GuildMember} from 'discord.js';
import {ChatInputCommandInteraction, GuildMember, MessageFlags} from 'discord.js';

@injectable()
export default class implements Command {
Expand Down Expand Up @@ -40,6 +40,7 @@ export default class implements Command {
await interaction.reply({
content: 'the stop-and-go light is now green',
embeds: [buildPlayingMessageEmbed(player)],
flags: MessageFlags.SuppressNotifications,
});
}
}
4 changes: 2 additions & 2 deletions src/commands/seek.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -58,6 +58,6 @@ export default class implements Command {
interaction.deferReply(),
]);

await interaction.editReply(`👍 seeked to ${prettyTime(player.getPosition())}`);
await interaction.followUp({content: `👍 seeked to ${prettyTime(player.getPosition())}`, flags: MessageFlags.SuppressNotifications});
}
}
4 changes: 2 additions & 2 deletions src/commands/shuffle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -28,6 +28,6 @@ export default class implements Command {

player.shuffle();

await interaction.reply('shuffled');
await interaction.reply({content: 'shuffled', flags: MessageFlags.SuppressNotifications});
}
}
3 changes: 2 additions & 1 deletion src/commands/skip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -38,6 +38,7 @@ export default class implements Command {
await interaction.reply({
content: 'keep \'er movin\'',
embeds: player.getCurrent() ? [buildPlayingMessageEmbed(player)] : [],
flags: MessageFlags.SuppressNotifications,
});
} catch (_: unknown) {
throw new Error('no song to skip to');
Expand Down
4 changes: 2 additions & 2 deletions src/commands/stop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
Expand Down Expand Up @@ -32,6 +32,6 @@ export default class implements Command {
}

player.stop();
await interaction.reply('u betcha, stopped');
await interaction.reply({content: 'u betcha, stopped', flags: MessageFlags.SuppressNotifications});
}
}
3 changes: 2 additions & 1 deletion src/commands/unskip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {ChatInputCommandInteraction, MessageFlags} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
Expand Down Expand Up @@ -28,6 +28,7 @@ export default class implements Command {
await interaction.reply({
content: 'back \'er up\'',
embeds: player.getCurrent() ? [buildPlayingMessageEmbed(player)] : [],
flags: MessageFlags.SuppressNotifications,
});
} catch (_: unknown) {
throw new Error('no song to go back to');
Expand Down
9 changes: 5 additions & 4 deletions src/services/add-query-to-queue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable complexity */
import {ChatInputCommandInteraction, GuildMember} from 'discord.js';
import {ChatInputCommandInteraction, GuildMember, MessageFlags} from 'discord.js';
import {URL} from 'node:url';
import {inject, injectable} from 'inversify';
import shuffle from 'array-shuffle';
Expand Down Expand Up @@ -140,8 +140,9 @@ export default class AddQueryToQueue {
statusMsg = 'resuming playback';
}

await interaction.editReply({
await interaction.followUp({
embeds: [buildPlayingMessageEmbed(player)],
flags: MessageFlags.SuppressNotifications,
});
} else if (player.status === STATUS.IDLE) {
// Player is idle, start playback instead
Expand All @@ -162,9 +163,9 @@ export default class AddQueryToQueue {
}

if (newSongs.length === 1) {
await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`);
await interaction.editReply({content: `u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`, flags: MessageFlags.SuppressNotifications});
} else {
await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`);
await interaction.editReply({content: `u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`, flags: MessageFlags.SuppressNotifications});
}
}
}
Loading

0 comments on commit 13f8551

Please sign in to comment.