generator-discord 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "generator-discord",
3
3
  "displayName": "Generator-Discord",
4
- "version": "1.0.9",
4
+ "version": "1.1.0",
5
5
  "main": "./app/index.js",
6
6
  "description": "Yeoman generator for Discord.js",
7
7
  "keywords": [
@@ -13,6 +13,7 @@
13
13
  "scripts": {
14
14
  "build": "tsc",
15
15
  "watch": "tsc -w",
16
+ "test": "vitest run",
16
17
  "debug": "npm i -g generator-discord && npx --node-arg=--inspect yo discord"
17
18
  },
18
19
  "files": [
@@ -32,10 +33,13 @@
32
33
  },
33
34
  "homepage": "https://github.com/emilkrebs/Generator-Discord",
34
35
  "dependencies": {
36
+ "@types/yeoman-test": "~4.0.3",
35
37
  "typescript": "^4.7.2",
36
- "yeoman-generator": "^5.6.1"
38
+ "yeoman-generator": "^5.6.1",
39
+ "yeoman-test": "~7.3.0"
37
40
  },
38
41
  "devDependencies": {
39
- "@types/yeoman-generator": "^5.2.10"
42
+ "@types/yeoman-generator": "^5.2.10",
43
+ "vitest": "^0.29.2"
40
44
  }
41
45
  }
package/src/index.ts CHANGED
@@ -53,6 +53,11 @@ export default class DiscordGenerator extends Generator {
53
53
  name: 'New Discord Bot (JavaScript)',
54
54
  value: 'javascript'
55
55
  }
56
+ ,
57
+ {
58
+ name: 'New Discord Bot (Python)',
59
+ value: 'python'
60
+ }
56
61
  ]
57
62
  },
58
63
  {
@@ -0,0 +1,3 @@
1
+ {
2
+ "token":"<%= bot-token %>"
3
+ }
@@ -8,7 +8,6 @@
8
8
  "start": "node ./src/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "colors": "^1.4.0",
12
11
  "discord.js": "^13.8.0"
13
12
  }
14
13
  }
@@ -1,32 +1,26 @@
1
1
  const { Client, Intents } = require('discord.js');
2
- const colors = require('colors');
3
2
  const { token } = require('../config.json');
4
3
 
5
-
4
+ // Create a new client instance with Intents that specify which privileged intents your bot requires
6
5
  const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
7
6
 
8
- // run this code once when your client is ready
7
+
8
+ // Run this code when the client is ready. This event will only trigger one time after logging in
9
9
  client.once('ready', () => {
10
- console.log(getTime() + colors.green('Bot is Ready.'));
11
- console.log(getTime() + colors.green(`Bot is logged in as ${colors.yellow(client.user.tag)}.`));
10
+ console.log(`Bot is logged in as ${client.user.tag}.`);
12
11
  });
13
12
 
14
- // run this code when a new message is created
13
+ // Listen for messages
15
14
  client.on('messageCreate', async message => {
16
15
  const { content } = message;
16
+ // Reply with "Pong!" when someone says "!ping"
17
17
  if (content === "!ping") {
18
- return await message.reply("pong!");
18
+ return await message.reply("Pong!");
19
19
  }
20
20
  });
21
21
 
22
22
 
23
- // get the current time to get useful log messages
24
- function getTime() {
25
- let dateTime = new Date()
26
- return colors.gray(`[${dateTime.getHours()}:${dateTime.getMinutes()}:${dateTime.getSeconds()}] `);
27
- }
28
-
29
- // login with your client's token
23
+ // Login to Discord with your app's token
30
24
  client.login(token);
31
25
 
32
- // for more information check out the official guide: https://discordjs.guide/creating-your-bot
26
+ // For more information about the Discord.js library, visit https://discord.js.org/#/docs/main/stable/general/welcome
@@ -0,0 +1,21 @@
1
+ import discord
2
+ from discord.ext import commands
3
+
4
+ # Define bot prefix and create bot instance
5
+ bot_prefix = "!"
6
+ bot = commands.Bot(command_prefix=bot_prefix)
7
+
8
+ # Define bot events
9
+ @bot.event
10
+ async def on_ready():
11
+ print(f"Logged in as {bot.user.name} ({bot.user.id})")
12
+
13
+ # Define bot commands
14
+ @bot.command()
15
+ async def ping(ctx):
16
+ await ctx.send("Pong!")
17
+
18
+ # Run bot with bot token
19
+ bot.run("<%= bot-token %>")
20
+
21
+ # For more information on how to use discord.py, visit https://discordpy.readthedocs.io/en/latest/
@@ -0,0 +1,3 @@
1
+ {
2
+ "token":"<%= bot-token %>"
3
+ }
@@ -10,7 +10,6 @@
10
10
  "build": "tsc"
11
11
  },
12
12
  "dependencies": {
13
- "colors": "^1.4.0",
14
13
  "discord.js": "^13.8.0",
15
14
  "typescript": "^4.7.2"
16
15
  }
@@ -1,31 +1,27 @@
1
1
  import { Client, Intents } from 'discord.js';
2
- import colors from 'colors';
3
2
  import { token } from '../config.json';
4
3
 
4
+ // Create a new client instance with Intents that specify which privileged intents your bot requires
5
5
  const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
6
6
 
7
- // run this code once when your client is ready
7
+ // Run this code when the client is ready. This event will only trigger one time after logging in
8
8
  client.once('ready', () => {
9
- console.log(getTime() + colors.green('Bot is Ready.'));
10
- console.log(getTime() + colors.green(`Bot is logged in as ${colors.yellow(client.user!.tag)}.`));
9
+ console.log(`Bot is logged in as ${client.user.tag}.`);
11
10
  });
12
11
 
13
- // run this code when a new message is created
12
+
13
+ // Listen for messages
14
14
  client.on('messageCreate', async message => {
15
15
  const { content } = message;
16
+ // Reply with "Pong!" when someone says "!ping"
16
17
  if (content === "!ping") {
17
- await message.reply("pong!");
18
+ await message.reply("Pong!");
18
19
  return;
19
20
  }
20
21
  });
21
22
 
22
- // get the current time to get useful log messages
23
- function getTime() {
24
- let dateTime = new Date()
25
- return colors.gray(`[${dateTime.getHours()}:${dateTime.getMinutes()}:${dateTime.getSeconds()}] `);
26
- }
27
23
 
28
- // login to with your client's token
24
+ // Login to Discord with your app's token
29
25
  client.login(token);
30
26
 
31
- // for more information check out the official guide: https://discordjs.guide/creating-your-bot
27
+ // For more information about the Discord.js library, visit https://discord.js.org/#/docs/main/stable/general/welcome