Git Product home page Git Product logo

gh-previews's Introduction

gh-previews

A discord bot to preview code from github code links directly in discord

Objective is to match this kind of link: github.com/itsvyle/gh-previews/blob/74f1ef26acfec41574d84b335fce0ee431a424af/README.md#L2

This is useful for code review and sharing code snippets in discord, as it makes asking questions about code snippets easier, without the need for screenshots everywhere.

Usage

Create a .env file in the root directory with the following content:

DISCORD_TOKEN=your_discord_bot_token
GITHUB_PAT=<a github PAT to access private repos, this is optional>

Then, run yarn install and yarn start to start the bot.

You will of course need yarn, node, and a discord bot created with the token obtained

You can also use the dockerfile to build and run the bot in a container; just mount an --env-file with the same content as the .env file, or pass the environment variables directly.

When adding the bot to your server, make sure to give it the following permissions:

  • Send Messages
  • Read messages/channels
  • Read messages history - this is essential as you need to be able to read the message history to reply to a message
  • OPTIONAL: manage messages - this will let the bot delete the embed that shows up in the original embed

Discord developper portal screenshot: image

Example

Copying links

This can be done in github: Screenshot 2024-06-23 113644

This can also be done directly in VSCode: Screenshot 2024-06-23 113911

Display snippets

Once the link is copied, just put it in a discord message, and the bot will answer automatically! image

Roadmap:

  • Add authentication, so that it can access code from private repositories ON REPOS I DONT OWN
  • Add support for knowing who edited the file last, etc.
  • Add support for not having a line number
  • Automatically find files in recent repos when mentioned, and suggest a preview; if the message only contains a mention and is a reply, it uses the content of the previous message

gh-previews's People

Contributors

itsvyle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.