Skip to content

Commit

Permalink
fix: quote searchdate (#2931) (#2932)
Browse files Browse the repository at this point in the history
  • Loading branch information
CKY- authored Dec 21, 2024
1 parent 837fd53 commit 9b566f6
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/backend/chat/commands/builtin/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,24 @@ export const QuotesManagementSystemCommand: SystemCommand<{

switch (triggeredArg) {
case "add": {
const shouldInsertStreamerUsername = (commandOptions.defaultStreamerAttribution && args.length === 1)
|| (commandOptions.defaultStreamerAttribution && !args[1].includes("@"));
const shouldInsertStreamerUsername =
(commandOptions.defaultStreamerAttribution && args.length === 1) ||
(commandOptions.defaultStreamerAttribution && !args[1].includes("@"));
const expectedArgs = shouldInsertStreamerUsername
? 2
: 3;
? 2
: 3;

if (args.length < expectedArgs) {
await twitchChat.sendChatMessage(`Please provide some quote text!`);
return resolve();
await twitchChat.sendChatMessage(`Please provide some quote text!`);
return resolve();
}
// Once we've evaluated that the syntax is correct we make our API calls
const channelData = await TwitchApi.channels.getChannelInformation();
const currentGameName = channelData && channelData.gameName ? channelData.gameName : "Unknown game";

// If shouldInsertStreamerUsername and no @ is included in the originator arg, set originator @streamerName and treat the rest as the quote
if (shouldInsertStreamerUsername) {
args.splice(1,0,`@${channelData.displayName}`)
args.splice(1, 0, `@${channelData.displayName}`);
}

const newQuote = {
Expand Down Expand Up @@ -404,8 +405,8 @@ export const QuotesManagementSystemCommand: SystemCommand<{
}
case "searchdate": {
const rawDay = parseInt(args[1]);
const rawMonth = parseInt(args[1]);
const rawYear = parseInt(args[1]);
const rawMonth = parseInt(args[2]);
const rawYear = parseInt(args[3]);

const day = !isNaN(rawDay) ? rawDay : null;
const month = !isNaN(rawMonth) ? rawMonth : null;
Expand Down

0 comments on commit 9b566f6

Please sign in to comment.