python-discord / meta

Issue tracker for suggestions and other questions relating to our community
https://pythondiscord.com
31 stars 5 forks source link

Feature: Share code snippet #104

Closed CyberCitizen01 closed 3 years ago

CyberCitizen01 commented 3 years ago

What?

A bot command to embed/share specific lines of code from Github.

Justification

It will be very easy to share code snippets and I think its nice to have code snippets around while explaining code to someone. Besides when asking for help in help channels, if you have your code somewhere say Github, then a single command can negate the need of copy pasting the code and the need of checking if the code you are pasting too long ๐Ÿ˜‚ .

Implementation

For example, to get a code snippet from this Github repository, from this file, containing lines from line 10 to line 14:

!snippet github python-discord/cj8-qualifier/master/qualifier/test_qualifier.py 10-14

(or maybe include complete http link)
returns: @.discord_user Your requested code snippet from https://github.com/python-discord/cj8-qualifier/blob/master/qualifier/test_qualifier.py#L10-L14 is here:

@dataclass
class TableParams:
    rows: List[List[Any]]
    labels: List[Any] = None
    centered: bool = False

May also include support for sharing code snippets from other Github like services and also maybe from hastebin (as generally large files are shared via hastebin, so it would be helpful when discussing about particular lines of code).

Some example commands for different cases to explain further:


P.S. I'm a beginner and have joined the community very recently, so I don't know if this feature already exists. Also, if this feature is to be added ๐Ÿ˜… , a proper tag, and suitable format for arguments (unlike mentioned above, which seems to over-complicate things) would be very nice and convenient to use.

jb3 commented 3 years ago

Feature already exists ๐Ÿ˜„!

Posting a GitHub link with highlighted lines will have the bot relay the selected lines into Discord.