Skip to content

C0D3R Api Documentation

JasirZaeem edited this page Jun 22, 2021 · 5 revisions

The c0d3r Discord bot is currently hosted on our CapRover server, it exposes an express Api that can be used to make it perform actions.

All endpoints require an AUTH token in the Authorization header, you can acquire this from the CapRover server or from engineering.

Instructions to run bot locally are available in the readme.

Details about the bot's design and arcitecture are available in this design doc

The following endpoints are available

  • api/sendchannelmessage

Takes a channel id, and a message and sends it to the given channel.

Example

fetch('https://c0d3r.c0d3.com/api/sendchannelmessage', { 
  method: 'post', 
  headers: new Headers({
    'Authorization': 'Bearer AUTH_TOKEN', 
    'Content-Type': 'application/json'
  }), 
  body: JSON.stringify({
    channelId: 'CHANNEL_ID',
    message: 'YOUR MESSAGE',
  })
});
  • api/senddirectmessage

Takes a user id, and a message and sends a dm to the given user.

Example

fetch('https://c0d3r.c0d3.com/api/senddirectmessage', { 
  method: 'post', 
  headers: new Headers({
    'Authorization': 'Bearer AUTH_TOKEN', 
    'Content-Type': 'application/json'
  }), 
  body: JSON.stringify({
    userId: 'CHANNEL_ID',
    message: 'YOUR MESSAGE',
  })
});
  • api/newsubmission

Send a formatted message to a lesson's channel and a new submission is made to that lesson, requires user's username, the lesson if of the submission and the title of the challenge

Example

fetch('https://c0d3r.c0d3.com/api/newsubmission', { 
  method: 'post', 
  headers: new Headers({
    'Authorization': 'Bearer AUTH_TOKEN', 
    'Content-Type': 'application/json'
  }), 
  body: JSON.stringify({
    username: 'CHANNEL_ID',
    lessonId: 'ID OF THE LESSON',
    challengeTitle: 'TITLE OF THE CHALLENG',
  })
});

image

Clone this wiki locally