Skip to content

Conversation

@nicx-g
Copy link

@nicx-g nicx-g commented Jun 13, 2023

Summary

Add a screen for project review that connects with Discord messages and the voting screen.

Client

  • Installed axios.
  • Installed discord api types for the Discord service.
  • Created the Projects module.
  • Created the Discord module and API file for server connection.
  • Modified the Vote module to handle socket events.

Server

  • Installed dotenv and added DISCORD_TOKEN to the environment for the bot token.
  • Added .gitignore
  • Restructured services into different files and added the Discord service.
  • Created a router and one for Discord endpoints.
  • Added voting events in the socket.
  • Installed cors to allow calls from localhost.

Images

eb12b3ccf5372fd3dc1f92f31f472972.mp4
942d93e17626e1aff32e92d60767d824.mp4

Endpoints

Get messages

  GET /api/discord/messages?channel_id
Query Type Description
channel_id string Required. Discord channel id

Add reaction

  POST /api/discord/messages/reaction/${id}
Parameter Type Description
id string Required. Discord Message ID

Request Body

{
  emoji: "✅"
  channel_id: "1111515860696313886"
}
Prop Type Description
emoji string Required.
channel_id string Required.

Delete reaction

  DELETE /api/discord/messages/reaction/${id}
Parameter Type Description
id string Required. Discord Message ID

Request Body

{
  emoji: "⌛"
  channel_id: "1111515860696313886"
}
Prop Type Description
emoji string Required.
channel_id string Required.

Get guild info

  GET /api/discord/guilds?guild_id
Query Type Description
guild_id string Required. Discord Guild ID

Get guild channels

  GET /api/discord/guilds/channels?guild_id
Query Type Description
guild_id string Required. Discord Guild ID

@vercel
Copy link

vercel bot commented Jun 13, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @goncy on Vercel.

@goncy first needs to authorize it.

"@react-three/drei": "^9.57.0",
"@react-three/fiber": "^8.11.9",
"@react-three/postprocessing": "^2.7.0",
"axios": "^1.4.0",
Copy link
Owner

Choose a reason for hiding this comment

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

Es necesario? Axios no solo pesa bastante sino que evita que podamos usar el cache del fetch nativo

"@types/three": "^0.149.0",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"discord-api-types": "^0.37.43",
Copy link
Owner

Choose a reason for hiding this comment

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

Imagino es una lib de types, podriamos copiar un par de los tipos que necesitamos al package de types e importarlos?

@@ -0,0 +1,10 @@
import { Provider as SocketProvider } from "@/socket/context";
import ProjectsScreen from "~/modules/projects/screens";
Copy link
Owner

Choose a reason for hiding this comment

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

Los imports de modules deberian ser desde @/projects, una cosa minima es que los modulos son en singular (project en vez de projects)

const api = {
messages: {
fetch: async (channelID: APIChannel["id"]): Promise<APIMessage[]> => {
const url = `http://localhost:6600/api/discord/messages?channel_id=${channelID}`;
Copy link
Owner

Choose a reason for hiding this comment

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

Los fetches, idealmente se hacen desde el lado del server, de esa manera evitas un roundtrip a tu propio server y tener que hardcodear un domain

Copy link
Owner

Choose a reason for hiding this comment

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

En caso de que los fetch sean del lado del cliente se suele crear una carpeta api y adentro un archivo client.ts. Los archivos del client, si van hacia una api route o route handler, fetchean de /api/discord... en vez del path completo, asi es mas facil de abstraerse


return res.data.data;
},
addReaction: async (
Copy link
Owner

Choose a reason for hiding this comment

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

Generalmente aca nesteas el objeto para ir tipo reaction.add, reaction.delete


return res.data;
},
fetchChannels: async (guildID: APIGuild["id"]): Promise<APIChannel[]> => {
Copy link
Owner

Choose a reason for hiding this comment

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

Esto seria fetch y list

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.

2 participants