Skip to content

Commit

Permalink
feat: Add log message to /suggest command.
Browse files Browse the repository at this point in the history
  • Loading branch information
vxern committed Oct 30, 2022
1 parent 976006d commit a6c2e4f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/commands/server/commands/suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '../../../../deps.ts';
import { Client } from '../../../client.ts';
import configuration from '../../../configuration.ts';
import { log } from '../../../controllers/logging/logging.ts';
import { mention, MentionTypes } from '../../../formatting.ts';
import { defaultLanguage } from '../../../types.ts';
import { getTextChannel, parseArguments } from '../../../utils.ts';
Expand Down Expand Up @@ -62,7 +63,7 @@ async function makeSuggestion(
}],
});

return void sendInteractionResponse(
sendInteractionResponse(
bot,
interaction.id,
interaction.token,
Expand All @@ -80,6 +81,14 @@ async function makeSuggestion(
},
},
);

return log(
[client, bot],
guild,
'suggestionSend',
interaction.member!,
suggestion,
);
}

export default command;
16 changes: 16 additions & 0 deletions src/controllers/logging/generators/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type GuildEvents = {

/** A member has been praised. */
praiseAdd: [member: Member, praise: Praise, by: User];

/** A suggestion has been made. */
suggestionSend: [member: Member, suggestion: string];
};

/** Contains the message generators for (custom) guild events. */
Expand Down Expand Up @@ -363,6 +366,19 @@ ${trim(change.content.body, 300)}`;
originGuildId === member.guildId,
color: configuration.interactions.responses.colors.green,
},
suggestionSend: {
title: `🌿 Suggestion made`,
message: (client, member, suggestion) => {
const memberUser = client.cache.users.get(member.id);
if (!memberUser) return;

return `${diagnosticMentionUser(memberUser)} has made a suggestion.\n\n` +
`Suggestion: **${suggestion}**`;
},
filter: (_client, originGuildId, member, _suggestion) =>
originGuildId === member.guildId,
color: configuration.interactions.responses.colors.darkGreen,
},
};

export default generators;
Expand Down

0 comments on commit a6c2e4f

Please sign in to comment.