Skip to content

feat: complete webhook and add auto assign commands - #260

Merged
h1divp merged 12 commits into
devfrom
feat/discord-bot-auto-assign-roles
Jan 19, 2026
Merged

feat: complete webhook and add auto assign commands#260
h1divp merged 12 commits into
devfrom
feat/discord-bot-auto-assign-roles

Conversation

@SobaSkee

Copy link
Copy Markdown
Collaborator

Description

  • Created a webhook for the discord bot that accepts as parameters: user_id, role_name, guild_id
  • Created a discord bot command called assign_hacker_roles that queries database for all users with event_role == attending and then iterates over discord server to add a specified role to users without that role
  • Added another utility command to remove a specified role from all users in the server in case the role above messes things up

Linked Jira Ticket

Type of Change

Checklist

  • My code follows the project's style guidelines
  • I have commented on complex parts of the code
  • I have updated documentation if necessary
  • I have updated or added tests to cover my changes
  • I have updated the OpenAPI YAML or other API schema files if applicable

Additional Notes

Comment thread apps/discord-bot/cogs/general.py Outdated
)
@app_commands.describe(
event_id="UUID of event",
hacker_role="Discord role to assign to hackers"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change hacker_role to role

Comment thread apps/discord-bot/utils/role_assignment.py
Comment thread apps/discord-bot/.env.example Outdated
DISCORD_TOKEN= No newline at end of file
DISCORD_TOKEN=
API_KEY=
GEMINI_API_KEY=

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean cmon man this shouldnt be part of our codebase at all...
if you use AI please make sure to clean stuff up before making commits

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the gemini api key? thats for the thread summarizations

@h1divp h1divp Dec 27, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. .env.example is used to show environment variables needed for the project to run during development. Gemini should not be required for stuff to run or to develop. You can keep it in your own env file for your own needs, I just don't think there's a need to show it as a required parameter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy hell I was not thinking... Apologies

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy hell I was not thinking... Apologies

Comment thread apps/api/internal/services/discord.go Outdated
}
}

func (s *DiscordService) GetUserEventRoleByDiscordID(ctx context.Context, discordID string) (*uuid.UUID, *sqlc.EventRoleType, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to use a function called GetUserEventRoleByDiscordIDAndEventId, and when you make the api request it should be from a route like GET /events/{eventId}/discord/{discordId}
event_roles are associated with a specific event, so that needs to be included in the query. Users can be part of multiple events, namely if they attend multiple swamphacks hackathons

SELECT event_id, role
FROM event_roles
WHERE user_id = $1
ORDER BY assigned_at DESC

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this gets only the event_role from the oldest event that a user has joined. you should be passing in an event_role with the user_id to get this. see other comment

@AlexanderWangY

Copy link
Copy Markdown
Member

Hi please resolve conflicts :)

-- name: DeleteAccount :exec
DELETE FROM auth.accounts
WHERE provider_id = $1 AND account_id = $2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this and its repo function isn't being used anywhere it should be removed, but since we are low on time im okay with doing that in a refactor later


r.Get("/", api.Handlers.Event.GetEventByID)
r.Get("/role", api.Handlers.Event.GetEventRole)
r.Get("/discord/{discordId}", api.Handlers.Discord.GetUserEventRoleByDiscordIDAndEventId)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a later refactor, we should probably move this to GET /discord/account/{discordId}/ under the Discord Routes section

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably add the gemini token back in, my bad for not thinking :)

Comment thread apps/api/api Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete pls

if response.status == 200:
data = await response.json()
event_role = data.get("role")
discord_role_name = "Hacker"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably add these to env but hardcoding is fine for now

@h1divp h1divp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just make sure to delete the 39mb api/api binary file and you're good to merge

@h1divp h1divp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlc issue needs to be fixed, delete large bin file, then merge is OK

@h1divp
h1divp merged commit b15e47a into dev Jan 19, 2026
2 checks passed
@hieunguyent12
hieunguyent12 deleted the feat/discord-bot-auto-assign-roles branch March 15, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants