Giter Club home page Giter Club logo

discord-screenshot's Introduction

discord-screenshot

License Chat

You can also read this in Portuguese.

discord-screenshot is a resource for FiveM that captures the screen of a player and uploads it to a discord webhook.

Showcase

Installation

  1. Make sure your artifacts (windows or linux) are up to date.
  2. Extract the latest zip file at releases (discord-screenshot-x-x-x.zip) in your resources folder.
  3. Add ensure screenshot-basic and ensure discord-screenshot in your server.cfg.
  4. Adjust the configuration of the resource in the settings.json.

Configuration

  • webhookUrl - The url of your discord's webhook.
  • framework - The framework you are using (vrp or none).
  • commandName - The command name.
  • commandPermission - The permission to use the command.
  • hiddenIdentifiers - A list of the identifiers that won't be shown in the embed (e.g. ip).
  • screenshotOptions
    • encoding - The file format (png, jpg or webp)
    • quality - The image quality from 0.0 to 1.0.

Default usage

Note: If you pass -1 as target, the screen of all the players will be captured.

Standalone

/screenshot <player or identifier>

Can be used via the server console or by anyone with the ace permission request.screenshot.

vRP

/screenshot <user_id>

Can be used via the server console or by anyone with the permission request.screenshot.

Exports

Server

requestClientScreenshotUploadToDiscord

Captures the screen of the player and sends it to the configured discord's webhook.

Parameters:

  • player: string | number
  • webhookMessageData?: WebhookMessageData
  • timeoutMs?: number
  • callback?: (error?: string) => void

Example:

exports["discord-screenshot"]:requestClientScreenshotUploadToDiscord(
    GetPlayers()[1],
    {
        username = "A cat",
        avatar_url = "https://cdn2.thecatapi.com/images/IboDUkK8K.jpg",
        content = "Meow!",
        embeds = {
            {
                color = 16771584,
                author = {
                    name = "Wow!",
                    icon_url = "https://cdn.discordapp.com/embed/avatars/0.png"
                },
                title = "I can send anything."
            }
        }
    },
    30000,
    function(error)
        if error then
            return print("^1ERROR: " .. error)
        end
        print("Sent screenshot successfully")
    end
)

requestCustomClientScreenshotUploadToDiscord

Captures the screen of the player and sends it to the specified discord's webhook.

Parameters:

  • player: string | number
  • webhookUrl: string
  • options?: object
    • encoding: 'png' | 'jpg' | 'webp'
    • quality: number
  • webhookMessageData?: WebhookMessageData
  • timeoutMs?: number
  • callback?: (error?: string) => void

Example:

exports["discord-screenshot"]:requestCustomClientScreenshotUploadToDiscord(
    GetPlayers()[1],
    "https://ptb.discord.com/api/webhooks/767824413780607097/WLjd77Y0CUvqXmhLCYzqkiZ-BrTpcGfNiZ7hXcJRgQxrU0YR8sy566MgMHgqRx8IZ9iu",
    {
        encoding = "png",
        quality = 1
    },
    {
        username = "A cat",
        avatar_url = "https://cdn2.thecatapi.com/images/IboDUkK8K.jpg",
        content = "Meow!",
        embeds = {
            {
                color = 16771584,
                author = {
                    name = "Wow!",
                    icon_url = "https://cdn.discordapp.com/embed/avatars/0.png"
                },
                title = "I can send anything."
            }
        }
    },
    30000,
    function(error)
        if error then
            return print("^1ERROR: " .. error)
        end
        print("Sent screenshot successfully")
    end
)

Dependencies

discord-screenshot's People

Contributors

jaimeadf avatar redrumrp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discord-screenshot's Issues

Deprecated code

As far as I know this doesn't cause any issues, just a warning about a deprecated function being used;

`(node:8628) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

(node:8628) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.`

I get this same warning twice when triggering screenshots.

[Improvement] Move Webhook Server sided

As is common practice on the internet, we should never trust a client.

In that respect, it would be more secure moving the webhookUrl out of the settings.json and into server.js

Not really an issue

This isn't really an issue. Moreso a question. I was wondering if there was a way to use your API to have the screenshot displayed inside of the embed instead of outside of it. I know it's possible, but you need to put a placeholder name in the embed that the attached file has as its name.

I can maybe help you try to add this if needed.

Best Regards,
Badger (on FiveM forums)

Screenshots me instead if player id i choose

Hey, this is an amzing script, i love it, just one issue, it screenshots the person why types /screenshot (1 or 2 or 3 or 4 or etc..) if anyone does /screenshot -1 it does everyone perfectly fine, any fix let me know thank you

error

(node:3908) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use FXServer --trace-deprecation ... to show where the warning was created)

Changing message

Will it be possible to change the message format sended to discord ?
Actually it's showing all players indentifiers, but for exemple i would like to remove the display of the IP. Could it be possible ?

Problem when trying to take screenshot

So I am trying to use it in the gcphone that I have but when I try to take a screenshot I get this error but the sending images with screenshot-basic works fine I am using a PHP file that sends the photos to a folder but I can't figure it out
image
this is the error this is the code
image
and this is when I am trying to trigger it with the command
image

screenshot-basic now uses POST headers.

Both the project-error version of screenshot-basic and CitizenFX are now using headers. Might want to update that. Or even just provide compatibility with project-error's fork of screenshot-basic

I've never done anything in typescript before but might have a go at doing a pull request. Deixa ver como corre...

An error occurred: Timeout

Hey so my discord-screenshot just stop working randomly i have no clue why, im getting "An error occurred: Timeout" in the discord

Untitled

DeprecationWarning

Happens the first time you take a screenshot.

(node:824) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use FXServer --trace-deprecation ... to show where the warning was created)

Screenshot question

Hi,

I love the screenshot but I've got a question. Is there any possibility that the screenshot's show the currently open menu in screen?

For example, if they have a shop menu open, in the current config it doesn't show that just the screen of the player with no menu information.

Thanks,

GAthlon

.

.

Script Error: Attempt to call a string value (local 'callback')

Hi,

Whenever I make /screenshot or /screenshot 1 in-game, I get the following error message in both client and server console:

SCRIPT ERROR: [string "-- Proxy interface system, used to add/call f..."]:39: attempt to call a string value (local 'callback')
>  (@discord-screenshot/dist/server.js:13)
> k.call (@discord-screenshot/dist/server.js:13)

Using Dunko's vRP Version (1.0)

No Such Export

image
I have been getting the following error after the most recent update. The resource is running and I can use the screenshot -1 command to trigger screenshots from all players so I'm not sure why the export has stopped working.

DeprecationWarning

(node:2052) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Screenshot Missing UI

When a screenshot is taken and send into discord, it looks like it has removed all the UI elements that are open on the user's screen.

My screenshot: image

Provided screenshot:
image

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.