-
Notifications
You must be signed in to change notification settings - Fork 12
Added Suggestion functionality #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bristermitten
merged 8 commits into
TheDeveloperDen:master
from
Pdzly:feature/134-suggest-functionality
Sep 1, 2025
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
78da89e
Removed Deprecated function arguments
Pdzly e097ca7
Implemented suggestion module with voting mechanism and Docker setup
Pdzly 7758ded
Add .env.local.example template and update .gitignore for better envi…
Pdzly 78eafae
Add suggestion management and voting review functionality
Pdzly 085ab8f
Merge remote-tracking branch 'upstream/master' into feature/134-sugge…
Pdzly f367583
Remove support for suggestion images in the suggestion module
Pdzly d337ce5
Merge branch 'master' into feature/134-suggest-functionality
Pdzly f3f928f
Clean up unused imports in `storage.ts` and format `models` array for…
Pdzly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| DDB_HOST=localhost | ||
| DDB_PORT=5432 | ||
|
|
||
| DDB_BOT_TOKEN= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| services: | ||
| postgres: | ||
| image: postgres:16-alpine | ||
| container_name: devden_db | ||
| environment: | ||
| POSTGRES_USER: root | ||
| POSTGRES_PASSWORD: password | ||
| POSTGRES_DB: database | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - postgres_data:/var/lib/postgresql/data | ||
| restart: unless-stopped | ||
|
|
||
| volumes: | ||
| postgres_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import { | ||
| ActionRowBuilder, | ||
| ApplicationCommandOptionType, | ||
| ApplicationCommandType, | ||
| ButtonBuilder, | ||
| ButtonStyle, | ||
| ChatInputCommandInteraction, | ||
| GuildMember, | ||
| } from "discord.js"; | ||
| import { Command } from "djs-slash-helper"; | ||
| import { config } from "../../Config.js"; | ||
| import { | ||
| createSuggestion, | ||
| createSuggestionEmbed, | ||
| SUGGESTION_MANAGE_ID, | ||
| SUGGESTION_NO_ID, | ||
| SUGGESTION_VIEW_VOTES_ID, | ||
| SUGGESTION_YES_ID, | ||
| } from "./suggest.js"; | ||
|
|
||
| export const SuggestCommand: Command<ApplicationCommandType.ChatInput> = { | ||
| name: "suggest", | ||
| description: "Create a suggestion", | ||
| type: ApplicationCommandType.ChatInput, | ||
| options: [ | ||
| { | ||
| type: ApplicationCommandOptionType.String, | ||
| name: "suggestion", | ||
| description: "The suggestion", | ||
| required: true, | ||
| }, | ||
| ], | ||
| handle: async (interaction: ChatInputCommandInteraction) => { | ||
| if (!interaction.member || !interaction.inGuild()) { | ||
| await interaction.reply({ | ||
| flags: ["Ephemeral"], | ||
| content: "We are not in a guild?", | ||
| }); | ||
| } | ||
|
|
||
| const member = interaction.member as GuildMember; | ||
|
|
||
| await interaction.deferReply({ | ||
| flags: ["Ephemeral"], | ||
| }); | ||
| // Get the suggestion and optional image | ||
| const suggestionText = interaction.options.get("suggestion") | ||
| ?.value as string; | ||
|
|
||
| const suggestionChannel = await interaction.client.channels.fetch( | ||
| config.suggest.suggestionsChannel, | ||
| ); | ||
|
|
||
| if (!suggestionChannel) { | ||
| await interaction.followUp({ | ||
| content: "There is no Suggestion channel!", | ||
| flags: ["Ephemeral"], | ||
| }); | ||
| return; | ||
| } | ||
| if (!suggestionChannel.isSendable() || !suggestionChannel.isTextBased()) { | ||
| await interaction.followUp({ | ||
| content: | ||
| "The suggestion channel is either not writeable or not a text channel!", | ||
| flags: ["Ephemeral"], | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| const suggestionId = interaction.id; | ||
|
|
||
| const embed = createSuggestionEmbed(suggestionId, member, suggestionText); | ||
|
|
||
| const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents( | ||
| new ButtonBuilder() | ||
| .setCustomId(SUGGESTION_YES_ID) | ||
| .setStyle(ButtonStyle.Success) | ||
| .setEmoji(config.suggest.yesEmojiId), | ||
| new ButtonBuilder() | ||
| .setCustomId(SUGGESTION_NO_ID) | ||
| .setStyle(ButtonStyle.Danger) | ||
| .setEmoji(config.suggest.noEmojiId), | ||
| new ButtonBuilder() | ||
| .setCustomId(SUGGESTION_VIEW_VOTES_ID) | ||
| .setStyle(ButtonStyle.Secondary) | ||
| .setEmoji("👁") | ||
| .setLabel("View Votes"), | ||
| new ButtonBuilder() | ||
| .setStyle(ButtonStyle.Secondary) | ||
| .setCustomId(SUGGESTION_MANAGE_ID) | ||
| .setEmoji("🎛"), | ||
| ); | ||
| const response = await suggestionChannel.send({ | ||
| embeds: [embed], | ||
| components: [buttons], | ||
| }); | ||
|
|
||
| await response.startThread({ | ||
| name: "Suggestion discussion thread", | ||
| reason: `User ${member.displayName} created a suggestion`, | ||
| }); | ||
|
|
||
| await interaction.followUp({ | ||
| content: `Suggestion with the ID \`${suggestionId}\` successfully submitted! See [here](${response.url})`, | ||
| flags: ["Ephemeral"], | ||
| }); | ||
|
|
||
| await createSuggestion( | ||
| BigInt(suggestionId), | ||
| BigInt(member.id), | ||
| BigInt(response.id), | ||
| suggestionText, | ||
| ); | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.