├── package.json ├── src └── main.js └── .gitignore /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-bot-node", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "dotenv": "^16.4.5" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // Initialize dotenv 2 | require("dotenv").config(); 3 | 4 | // Discord.js versions ^13.0 require us to explicitly define client intents 5 | const { Client, GatewayIntentBits } = require("discord.js"); 6 | const client = new Client({ 7 | intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages], 8 | }); 9 | 10 | client.on("messageCreate", (message) => { 11 | console.log(`👍 works as expected`); 12 | }); 13 | client.on("interactionCreate", (interaction) => { 14 | console.log(`👍 works as expected`); 15 | }); 16 | 17 | // Log In our bot 18 | // client.login(process.env.CLIENT_TOKEN); 19 | 20 | // client.login(TOKEN); 21 | 22 | // 运行Bot 23 | console.log(process.env.TOKEN) 24 | client.login(process.env.TOKEN); // 替换为您的Discord令牌 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Display 2 | FileType 3 | Initial 4 | Others 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | .clinic 11 | # Runtime data 12 | pids 13 | *.pid 14 | *.seed 15 | *.pid.lock 16 | sale/ 17 | lude/ 18 | guiyan/ 19 | guiyan/* 20 | project/guiyan 21 | # Directory for instrumented libs generated by jscoverage/JSCover 22 | lib-cov 23 | 24 | # Coverage directory used by tools like istanbul 25 | coverage 26 | 27 | # nyc test coverage 28 | .nyc_output 29 | 30 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 31 | .grunt 32 | 33 | # Bower dependency directory (https://bower.io/) 34 | bower_components 35 | 36 | # node-waf configuration 37 | .lock-wscript 38 | 39 | # Compiled binary addons (https://nodejs.org/api/addons.html) 40 | build/Release 41 | 42 | # Dependency directories 43 | node_modules/ 44 | jspm_packages/ 45 | 46 | # Typescript v1 declaration files 47 | typings/ 48 | 49 | # Optional npm cache directory 50 | .npm 51 | 52 | # Optional eslint cache 53 | .eslintcache 54 | 55 | # Optional REPL history 56 | .node_repl_history 57 | 58 | # Output of 'npm pack' 59 | *.tgz 60 | 61 | # Yarn Integrity file 62 | .yarn-integrity 63 | 64 | # dotenv environment variables file 65 | .env 66 | .vscode 67 | temp/ 68 | --------------------------------------------------------------------------------