Skip to content

Commit

Permalink
Added config to make add to queue responses for requester only (#1021)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Isom <[email protected]>
  • Loading branch information
Sheeley7 and codetheweb authored Apr 28, 2024
1 parent cf775c4 commit 8e08919
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Setting" (
"guildId" TEXT NOT NULL PRIMARY KEY,
"playlistLimit" INTEGER NOT NULL DEFAULT 50,
"secondsToWaitAfterQueueEmpties" INTEGER NOT NULL DEFAULT 30,
"leaveIfNoListeners" BOOLEAN NOT NULL DEFAULT true,
"queueAddResponseEphemeral" BOOLEAN NOT NULL DEFAULT false,
"autoAnnounceNextSong" BOOLEAN NOT NULL DEFAULT false,
"defaultVolume" INTEGER NOT NULL DEFAULT 100,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_Setting" ("autoAnnounceNextSong", "createdAt", "defaultVolume", "guildId", "leaveIfNoListeners", "playlistLimit", "secondsToWaitAfterQueueEmpties", "updatedAt") SELECT "autoAnnounceNextSong", "createdAt", "defaultVolume", "guildId", "leaveIfNoListeners", "playlistLimit", "secondsToWaitAfterQueueEmpties", "updatedAt" FROM "Setting";
DROP TABLE "Setting";
ALTER TABLE "new_Setting" RENAME TO "Setting";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
1 change: 1 addition & 0 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ model Setting {
playlistLimit Int @default(50)
secondsToWaitAfterQueueEmpties Int @default(30)
leaveIfNoListeners Boolean @default(true)
queueAddResponseEphemeral Boolean @default(false)
autoAnnounceNextSong Boolean @default(false)
defaultVolume Int @default(100)
createdAt DateTime @default(now())
Expand Down
25 changes: 25 additions & 0 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export default class implements Command {
.setName('value')
.setDescription('whether to leave when everyone else leaves')
.setRequired(true)))
.addSubcommand(subcommand => subcommand
.setName('set-queue-add-response-hidden')
.setDescription('set whether bot responses to queue additions are only displayed to the requester')
.addBooleanOption(option => option
.setName('value')
.setDescription('whether bot responses to queue additions are only displayed to the requester')
.setRequired(true)))
.addSubcommand(subcommand => subcommand
.setName('set-auto-announce-next-song')
.setDescription('set whether to announce the next song in the queue automatically')
Expand Down Expand Up @@ -113,6 +120,23 @@ export default class implements Command {
break;
}

case 'set-queue-add-response-eph': {
const value = interaction.options.getBoolean('value')!;

await prisma.setting.update({
where: {
guildId: interaction.guild!.id,
},
data: {
queueAddResponseEphemeral: value,
},
});

await interaction.reply('👍 queue add notification setting updated');

break;
}

case 'set-auto-announce-next-song': {
const value = interaction.options.getBoolean('value')!;

Expand Down Expand Up @@ -159,6 +183,7 @@ export default class implements Command {
: `${config.secondsToWaitAfterQueueEmpties}s`,
'Leave if there are no listeners': config.leaveIfNoListeners ? 'yes' : 'no',
'Auto announce next song in queue': config.autoAnnounceNextSong ? 'yes' : 'no',
'Add to queue reponses show for requester only': config.autoAnnounceNextSong ? 'yes' : 'no',
'Default Volume': config.defaultVolume,
};

Expand Down
4 changes: 2 additions & 2 deletions src/services/add-query-to-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default class AddQueryToQueue {

const settings = await getGuildSettings(guildId);

const {playlistLimit} = settings;
const {playlistLimit, queueAddResponseEphemeral} = settings;

await interaction.deferReply();
await interaction.deferReply({ephemeral: queueAddResponseEphemeral});

let newSongs: SongMetadata[] = [];
let extraMsg = '';
Expand Down

0 comments on commit 8e08919

Please sign in to comment.