{"id":24387966,"url":"https://github.com/xliel/discord-fivem-api","last_synced_at":"2025-10-15T14:38:09.661Z","repository":{"id":37394608,"uuid":"307665531","full_name":"xliel/discord-fivem-api","owner":"xliel","description":"A Node.js package to interact with FiveM servers, allowing you to retrieve server data, player information, and resources. Ideal for Discord bot integration or standalone Node.js applications.","archived":false,"fork":false,"pushed_at":"2024-09-11T22:03:40.000Z","size":46,"stargazers_count":20,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-06T23:50:01.447Z","etag":null,"topics":["discord","discord-fivem","discord-fivem-bot","discord-js","discordapp","fivem","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/discord-fivem-api","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xliel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-27T10:37:43.000Z","updated_at":"2025-08-31T12:37:52.000Z","dependencies_parsed_at":"2024-06-19T20:03:27.584Z","dependency_job_id":"52c6c965-af81-446c-bbec-9af90025bba6","html_url":"https://github.com/xliel/discord-fivem-api","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"e5ef62c4688180be8225b49eaa264539f4fc1cf0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xliel/discord-fivem-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xliel%2Fdiscord-fivem-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xliel%2Fdiscord-fivem-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xliel%2Fdiscord-fivem-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xliel%2Fdiscord-fivem-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xliel","download_url":"https://codeload.github.com/xliel/discord-fivem-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xliel%2Fdiscord-fivem-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279085573,"owners_count":26100017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","discord-fivem","discord-fivem-bot","discord-js","discordapp","fivem","nodejs"],"created_at":"2025-01-19T13:22:03.141Z","updated_at":"2025-10-15T14:38:09.630Z","avatar_url":"https://github.com/xliel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Installation\n\nInstall the `discord-fivem-api` package using either npm or yarn:\n\n```bash\n$ npm install discord-fivem-api\n# or\n$ yarn add discord-fivem-api\n```\n\n## Usage\n\nFirst, import the `DiscordFivemApi` class:\n\n```javascript\nconst DiscordFivemApi = require('discord-fivem-api');\n```\n\nNext, create a new instance of the class with the desired configuration options:\n\n```javascript\nconst options = {\n  address: 'localhost', // IP or hostname of the FiveM server\n  port: 30120,          // Port number (default: 30120)\n  useStructure: true,   // Whether to use the custom `Player` and `Server` structures (default: true)\n  interval: 5000,       // Interval in ms between server updates (default: 2500)\n};\n\nconst api = new DiscordFivemApi(options, true); // 'true' initializes the API immediately\n```\n\nConfiguration Options\nThe `options` object supports the following properties:\n- `address` (required): The IP address or hostname of the FiveM server.\n- `port` (optional, default: `30120`): The port number of the FiveM server.\n- `useStructure`: (optional, default: `true`): Whether to use the custom `Player` and `Server` classes from the structures directory.\n- `interval`: (optional, default: `2500`): The interval (in milliseconds) between server data updates.\n\nThe second argument (`init`) specifies whether to initialize the API immediately (`true`) or not (`false`, default).\n\n\n### Methods\nOnce the `DiscordFivemApi` instance is created, you can use its methods to retrieve server information:\n\n```javascript\napi.getStatus()\n  .then((status) =\u003e console.log(`Server status: ${status}`))\n  .catch((err) =\u003e console.error(err));\n\napi.getServerData()\n  .then((serverData) =\u003e console.log(serverData))\n  .catch((err) =\u003e console.error(err));\n\napi.getServerPlayers()\n  .then((players) =\u003e console.log(players))\n  .catch((err) =\u003e console.error(err));\n\napi.getPlayersOnline()\n  .then((count) =\u003e console.log(`Players online: ${count}`))\n  .catch((err) =\u003e console.error(err));\n\napi.getMaxPlayers()\n  .then((maxPlayers) =\u003e console.log(`Max players: ${maxPlayers}`))\n  .catch((err) =\u003e console.error(err));\n```\n\n### Method Details\n\n- `\u003cApi\u003e.getStatus()` Returns a promise that resolves to 'online' or 'offline'.\n\n- `\u003cApi\u003e.getServerData()` Returns a promise that resolves to an object containing server information. If useStructure is true, it returns an instance of the Server class.\n\n- `\u003cApi\u003e.getServerPlayers()` Returns a promise that resolves to an array of player objects. If useStructure is true, each object is an instance of the Player class.\n\n- `\u003cApi\u003e.getPlayersOnline()` Returns a promise that resolves to the number of players currently online.\n\n- `\u003cApi\u003e.getMaxPlayers()` Returns a promise that resolves to the server's maximum player capacity.\n\n### Events\n```javascript\napi.on('ready', () =\u003e console.log('API initialized'));\napi.on('readyPlayers', (players) =\u003e console.log(`Players: ${players.length}`));\napi.on('readyResources', (resources) =\u003e console.log(`Resources: ${resources.length}`));\napi.on('playerJoin', (player) =\u003e console.log(`${player.name} joined the server`));\napi.on('playerLeave', (player) =\u003e console.log(`${player.name} left the server`));\napi.on('resourceAdd', (resource) =\u003e console.log(`Resource added: ${resource}`));\napi.on('resourceRemove', (resource) =\u003e console.log(`Resource removed: ${resource}`));\n```\n\n### Event Details\n\n- `ready`: Emitted when the API is initialized.\n- `readyPlayers`: Emitted when player data is available.\n- `readyResources`: Emitted when resource data is available.\n- `playerJoin`: Emitted when a player joins the server.\n- `playerLeave`: Emitted when a player leaves the server.\n- `resourceAdd`: Emitted when a new resource is added to the server.\n- `resourceRemove`: Emitted when a resource is removed from the server.\n\n## License\n\nThis package is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxliel%2Fdiscord-fivem-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxliel%2Fdiscord-fivem-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxliel%2Fdiscord-fivem-api/lists"}