Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically upload files in help channels to a bin service #21

Open
GodderE2D opened this issue Oct 4, 2023 · 5 comments
Open

Automatically upload files in help channels to a bin service #21

GodderE2D opened this issue Oct 4, 2023 · 5 comments
Labels
💡 idea New feature or request

Comments

@GodderE2D
Copy link

As mentioned in the /tag query: bin command, users should upload large code snippets to a bin service instead of uploading them as files. Some reasons include:

  • They cannot be viewed within the client on mobile (must open in browser or download)
  • Trying to expand it will lead to the same issue, it will just be a big codeblock again but hideable
  • Trying to view full-screen and referring back to other messages in chat is a hassle
  • You cannot Ctrl + F to quickly find a keyword
  • You can upload the code to a bin service yourself but that can become a hassle, especially on mobile
  • You can always tell the user to upload it to a bin service themselves, but they're d.js members so you never know

Possible Solution

Upon detecting a message in a help channel with a .txt/.js/.ts file, upload the contents of the file to a bin service. Then, silently reply to the message with the link to the bin.

As for which bin service to use, I think sourcebin is the most popular but I can't find if they have a public API or not. Pastebin is a close contender.

Concept

image
@GodderE2D GodderE2D changed the title Automatically convert files uploaded in help channels to a bin service Automatically upload files in help channels to a bin service Oct 4, 2023
@almostSouji almostSouji transferred this issue from discordjs/discord-utils-bot Oct 5, 2023
@almostSouji almostSouji added the 💡 idea New feature or request label Oct 5, 2023
@jaw0r3k
Copy link
Contributor

jaw0r3k commented Oct 5, 2023

I'd like it, but as a context menu command to not clutter the chat

@almostSouji
Copy link
Member

You must be human. Accounts registered or maintained by "bots" or other automated methods are not permitted.
~https://sourceb.in/terms

@sdanialraza
Copy link

What about https://srcshare.io/? They also have an API: https://api.wornoffkeys.com/v1/srcshare

@GodderE2D
Copy link
Author

What about https://srcshare.io/? They also have an API: https://api.wornoffkeys.com/v1/srcshare

That link's broken for me.

// 20231009211137
// https://api.wornoffkeys.com/v1/srcshare

{
  "errorType": "Runtime.UnhandledPromiseRejection",
  "errorMessage": "CastError: Cast to ObjectId failed for value \"\" (type string) at path \"_id\" for model \"srcshare-code\"",
  "trace": [
    "Runtime.UnhandledPromiseRejection: CastError: Cast to ObjectId failed for value \"\" (type string) at path \"_id\" for model \"srcshare-code\"",
    "    at process.<anonymous> (file:///var/runtime/index.mjs:1250:17)",
    "    at process.emit (node:events:513:28)",
    "    at emit (node:internal/process/promises:140:20)",
    "    at processPromiseRejections (node:internal/process/promises:274:27)",
    "    at processTicksAndRejections (node:internal/process/task_queues:97:32)"
  ]
}

@sdanialraza
Copy link

sdanialraza commented Oct 10, 2023

That link's broken for me.

Yeah, not sure what that's about but I've used it, I just made a fetch request, something like this:

fetch("https://api.wornoffkeys.com/v1/srcshare", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    tabs: [
      {
        name: "Code",
        content: `${code}`,
      },
      {
        name: "Error",
        content: `${error}`,
      },
    ],
    language: `${language}`,
    title: `${title}`,
    description: `${description}`,
  }),
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 idea New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants