{"id":15013883,"url":"https://github.com/draym/discord-puppet","last_synced_at":"2025-04-12T05:47:10.623Z","repository":{"id":116487501,"uuid":"609788182","full_name":"Draym/discord-puppet","owner":"Draym","description":"Discord client for server side applications, includes Midjourney AI client.","archived":false,"fork":false,"pushed_at":"2023-10-03T08:20:04.000Z","size":100,"stargazers_count":43,"open_issues_count":2,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-14T04:02:04.206Z","etag":null,"topics":["discord","midjourney","puppet","puppeteer"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@d-lab/discord-puppet","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Draym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-03-05T08:32:57.000Z","updated_at":"2024-09-28T12:28:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddd31336-0333-4baf-9e7b-e73a2c52031b","html_url":"https://github.com/Draym/discord-puppet","commit_stats":{"total_commits":39,"total_committers":2,"mean_commits":19.5,"dds":"0.17948717948717952","last_synced_commit":"57f6165017ea7780169098c3e3c96d2f1521d431"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fdiscord-puppet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fdiscord-puppet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fdiscord-puppet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Draym%2Fdiscord-puppet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Draym","download_url":"https://codeload.github.com/Draym/discord-puppet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219848897,"owners_count":16556331,"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","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","midjourney","puppet","puppeteer"],"created_at":"2024-09-24T19:44:53.693Z","updated_at":"2024-10-14T04:02:10.042Z","avatar_url":"https://github.com/Draym.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `Discord Puppet` ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge\u0026logo=node.js\u0026logoColor=white)![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge\u0026logo=typescript\u0026logoColor=white) [![npm version](https://badge.fury.io/js/@d-lab%2Fdiscord-puppet.svg)](https://badge.fury.io/js/@d-lab%2Fdiscord-puppet)\n\nNode client that simulates a Discord user in a headless browser. Use Discord functionalities including BOT interaction on the server-side. Include a Midjourney client which you can use to generate images using the `/imagine` command of Midjourney.\n\n[available on NPM](https://www.npmjs.com/package/@d-lab/discord-puppet)\n\n## Installation\n\n```bash\nnpm i @d-lab/discord-puppet \n```\n\nDiscord Puppet is using Puppeteer to simulate a Discord user in a headless browser.\nIf you want to run it on a headless browser, you may have to install addition depencies based on your OS.\n\nFor Debian UI-less: [check tavinus GIST](https://gist.github.com/tavinus/7effd4b3dac87cb4366e3767679a192f)\n\n```bash\nsudo apt install libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgbm1 libasound2 libpangocairo-1.0-0 libxss1 libgtk-3-0\n```\n\n## Discord Puppet base SDK\n\nYou will find different basic actions for Discord under the Puppet class. You can use it to create your own puppet, such as the Midjourney Puppet\ndescribed below.\n\n#### Example\n\n```ts\nimport {Puppet, options} from \"@d-lab/discord-puppet\"\n\nconst config: Option = options(\n    process.env.DISCORD_USERNAME,\n    process.env.DISCORD_PASSWORD\n)\n/** Setup Puppet config and pluggins */\nconst puppet = new Puppet(config)\n\n/** Start Puppet opens a browser and a new Tab, handle Login then redirect to specified server or default one*/\nawait puppet.start()\n\nawait puppet.clickServer(\"My Server\")\nawait puppet.clickChannel(\"my-channel\")\nawait puppet.sendMessage(\"Hello world!\")\n\n/** close headless browser */\nawait puppet.shutdown()\n```\n\n### I18N support\nDiscord use different label in the code based on your language settings. You can specify the language you want to use in the config constructor.\nFor now only English and French are set up, but no worries there are only 3 labels to translate.\n\n```ts\nimport {Puppet, buildOptions, Language, LanguagePack} from \"@d-lab/discord-puppet\"\n\nconst frLanguage: LanguagePack = new LanguagePack(\"fr\", {\n  \"servers\": \"Serveurs\",\n  \"channels\": \"Salons\",\n  \"close\": \"Fermer\"\n})\n\nconst config: Option = buildOptions({\n  username: process.env.DISCORD_USERNAME,\n  password: process.env.DISCORD_PASSWORD,\n  language: frLanguage\n  //language: Language.EN\n})\n/** Setup Puppet config and pluggins */\nconst puppet = new Puppet(config)\n```\n\n## MidJourney Puppet\n\nThis library has been initially built to create a puppet for the MidJourney AI Art generation. This service is only available on Discord as a bot for\nnow.\nUsing this puppet you can easily generate AI art using the puppet.imagine() method on the server side.\n\n#### Prerequisite\n\nThis Puppet is using the MidJourney Bot, you will need to add it to your server. You can find the bot on\nthe [MidJourney Website](https://www.midjourney.com/).\n\n- Join MidJourney Discord\n- If your discord user never used MidJourney before\n    - run any command on MidJourney bot (such as imagine)\n    - accept their Terms of Service\n    - your user is set up!\n- Create a new Personal Server on Discord: for example 'My\n  Art' [steps](https://media.discordapp.net/attachments/1074234231175262248/1082211527790178384/image.png?width=1440\u0026height=642)\n- Add the bot to your personal server from MidJourney\n  server [steps](https://media.discordapp.net/attachments/1074234231175262248/1082210468476764241/image.png?width=922\u0026height=663)\n- Add a new channel: for example 'all-art'\n- You're good to go!\n\n#### Example\n\n```ts\nimport {MidjourneyPuppet, options} from \"@d-lab/discord-puppet\"\n\nconst config: Option = options(\n    process.env.DISCORD_USERNAME,\n    process.env.DISCORD_PASSWORD\n)\nconst puppet = new MidjourneyPuppet(config)\nawait puppet.start()\nawait puppet.clickServer(\"My Art\")\nawait puppet.clickChannel(\"all-art\")\n\n/** Get your MidJourney account status */\nconst msg1 = await puppet.info()\nconsole.log(\"MJY account: \", msg1)\n\n/** Ask MidJourney to generate an image */\n// you can specify an optional callback that will receive the url of the image being generated on the fly\n// you will receive multiple URLs every time MidJourney is updating the not-finished-image\n// it can be usefull if you want to show the loading image to the user\nfunction loading(url: string) {\n    console.log(\"Loading ~ \", url)\n}\n\nconst msg2 = await puppet.imagine(`Your Imagine prompt (check MidJourney prompt guides)`, loading)\nconsole.log(\"MJY image: \", msg2)\n```\n\n## Test Locally\n\nYou can use the example script located in ./bin to try out this library.\n\nFirst clone this repository on your local machine.\n\n```bash\nclone https://github.com/Draym/discord-puppet.git\ncd discord-puppet\n```\n\nThen install the dependencies\n\n```bash\nnpm i\n```\n\nThen create a .env file with your Discord credentials. You can check the file .env.example to see the mandatory fields.\n\nThen run the example script\n\n```bash\nts-node ./bin/midjourney-cmds.ts\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraym%2Fdiscord-puppet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdraym%2Fdiscord-puppet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraym%2Fdiscord-puppet/lists"}