Skip to content

Commit 14d5cc2

Browse files
authored
Made with ❤️ and everything in English
1 parent cdcfd1a commit 14d5cc2

40 files changed

+619
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === 'react') {
3+
message.react('👍').then(() => {
4+
message.react('👎');
5+
});
6+
}
7+
});
8+
9+
client.on('messageReactionAdd', (reaction, user) => {
10+
if (reaction.emoji.name === '👍') {
11+
reaction.message.channel.send(`${user.username} liked the message.`);
12+
}
13+
});
14+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!typing') {
3+
message.channel.sendTyping();
4+
setTimeout(() => {
5+
message.reply('I am typing!');
6+
}, 1000); // Delay for 1 second
7+
}
8+
});
9+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!checkrole') {
3+
const member = message.member;
4+
const roleName = 'YourRoleName'; // Replace with the role you want to check
5+
6+
if (member.roles.cache.some((role) => role.name === roleName)) {
7+
message.reply(`You have the ${roleName} role.`);
8+
} else {
9+
message.reply(`You do not have the ${roleName} role.`);
10+
}
11+
}
12+
});
13+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { Client, Intents, MessageActionRow, MessageButton } = require('discord.js');
2+
3+
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
4+
5+
client.on('ready', () => {
6+
console.log(`Logged in as ${client.user.tag}`);
7+
});
8+
9+
client.on('messageCreate', async (message) => {
10+
if (message.content === '!button') {
11+
const row = new MessageActionRow().addComponents(
12+
new MessageButton()
13+
.setCustomId('button')
14+
.setLabel('Click Me!')
15+
.setStyle('PRIMARY')
16+
);
17+
18+
await message.channel.send({ content: 'Click the button below:', components: [row] });
19+
}
20+
});
21+
22+
client.on('interactionCreate', async (interaction) => {
23+
if (!interaction.isButton()) return;
24+
25+
if (interaction.customId === 'button') {
26+
await interaction.reply('Button clicked!');
27+
}
28+
});
29+
30+
client.login('YOUR_BOT_TOKEN');
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { Client, Intents } = require('discord.js');
2+
3+
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
4+
5+
client.once('ready', () => {
6+
console.log(`Logged in as ${client.user.tag}`);
7+
});
8+
9+
client.login('YOUR_BOT_TOKEN');
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { Client, Intents, MessageActionRow, MessageSelectMenuBuilder } = require('discord.js');
2+
3+
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
4+
5+
client.on('messageCreate', async (message) => {
6+
if (message.content === '!selectmenu') {
7+
const row = new MessageActionRow().addComponents(
8+
new MessageSelectMenuBuilder()
9+
.setCustomId('select')
10+
.setPlaceholder('Select an option')
11+
.addOption({
12+
label: 'Option 1',
13+
value: 'option1',
14+
})
15+
.addOption({
16+
label: 'Option 2',
17+
value: 'option2',
18+
})
19+
);
20+
21+
await message.channel.send({ content: 'Please select an option:', components: [row] });
22+
}
23+
});
24+
25+
client.on('interactionCreate', async (interaction) => {
26+
if (!interaction.isSelectMenu()) return;
27+
28+
const selectedValue = interaction.values[0];
29+
30+
if (selectedValue === 'option1') {
31+
await interaction.reply('You selected Option 1.');
32+
} else if (selectedValue === 'option2') {
33+
await interaction.reply('You selected Option 2.');
34+
}
35+
});
36+
37+
client.login('YOUR_BOT_TOKEN');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!clear') {
3+
const channel = message.channel;
4+
channel.bulkDelete(5); // Delete the last 5 messages, adjust the number as needed.
5+
}
6+
});
7+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!userinfo') {
3+
const user = message.author;
4+
const userInfo = `Username: ${user.username}\nID: ${user.id}\nTag: ${user.tag}`;
5+
message.channel.send(userInfo);
6+
}
7+
});
8+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const cooldowns = new Map();
2+
3+
client.on('messageCreate', (message) => {
4+
if (message.content === '!cooldown') {
5+
const { author } = message;
6+
if (!cooldowns.has(author.id)) {
7+
// Set a 10-second cooldown for this command
8+
cooldowns.set(author.id, Date.now() + 10000);
9+
10+
// Your command logic here
11+
message.reply('This command has a 10-second cooldown.');
12+
13+
setTimeout(() => {
14+
cooldowns.delete(author.id);
15+
}, 10000);
16+
} else {
17+
const timeLeft = (cooldowns.get(author.id) - Date.now()) / 1000;
18+
message.reply(`Please wait ${timeLeft.toFixed(1)} more seconds before using this command.`);
19+
}
20+
}
21+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!error') {
3+
// Simulate an error (for testing purposes)
4+
throw new Error('This is a test error.');
5+
}
6+
});
7+
8+
// Handling errors globally
9+
client.on('error', (error) => {
10+
console.error('An error occurred:', error);
11+
});
12+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const prefix = '!';
2+
3+
client.on('messageCreate', (message) => {
4+
if (!message.content.startsWith(prefix) || message.author.bot) return;
5+
6+
const args = message.content.slice(prefix.length).trim().split(/ +/);
7+
const command = args.shift().toLowerCase();
8+
9+
if (command === 'ping') {
10+
message.reply('Pong!');
11+
} else if (command === 'hello') {
12+
message.channel.send('Hello!');
13+
}
14+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content.startsWith('!say')) {
3+
const args = message.content.slice(5).trim().split(/ +/);
4+
const text = args.join(' ');
5+
6+
message.channel.send(text);
7+
}
8+
});
9+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
client.on('guildCreate', (guild) => {
2+
console.log(`Added to server: ${guild.name}`);
3+
});
4+
5+
client.on('guildDelete', (guild) => {
6+
console.log(`Removed from server: ${guild.name}`);
7+
});
8+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { Client, Intents, MessageActionRow, MessageButton } = require('discord.js');
2+
3+
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
4+
5+
client.on('ready', () => {
6+
console.log(`Logged in as ${client.user.tag}`);
7+
});
8+
9+
client.on('messageCreate', async (message) => {
10+
if (message.content === '!buttons') {
11+
const row = new MessageActionRow()
12+
.addComponents(
13+
new MessageButton()
14+
.setCustomId('button1')
15+
.setLabel('Button 1')
16+
.setStyle('PRIMARY'),
17+
new MessageButton()
18+
.setCustomId('button2')
19+
.setLabel('Button 2')
20+
.setStyle('SECONDARY')
21+
);
22+
23+
await message.channel.send({ content: 'Click the buttons below:', components: [row] });
24+
}
25+
});
26+
27+
client.on('interactionCreate', async (interaction) => {
28+
if (!interaction.isButton()) return;
29+
30+
if (interaction.customId === 'button1') {
31+
await interaction.reply('Button 1 clicked!');
32+
} else if (interaction.customId === 'button2') {
33+
await interaction.reply('Button 2 clicked!');
34+
}
35+
});
36+
37+
client.login('YOUR_BOT_TOKEN');
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Create multiple select menus in the same row
2+
const row = new MessageActionRow().addComponents(
3+
new MessageSelectMenuBuilder()
4+
.setCustomId('select1')
5+
.setPlaceholder('Select option 1')
6+
.addOption({
7+
label: 'Option A',
8+
value: 'optionA',
9+
})
10+
.addOption({
11+
label: 'Option B',
12+
value: 'optionB',
13+
}),
14+
15+
new MessageSelectMenuBuilder()
16+
.setCustomId('select2')
17+
.setPlaceholder('Select option 2')
18+
.addOption({
19+
label: 'Option X',
20+
value: 'optionX',
21+
})
22+
.addOption({
23+
label: 'Option Y',
24+
value: 'optionY',
25+
})
26+
);
27+
28+
// Handle interactions for multiple select menus
29+
client.on('interactionCreate', async (interaction) => {
30+
if (!interaction.isSelectMenu()) return;
31+
32+
const selectedValue = interaction.values[0];
33+
34+
switch (interaction.customId) {
35+
case 'select1':
36+
if (selectedValue === 'optionA') {
37+
await interaction.reply('You selected Option A from select menu 1.');
38+
} else if (selectedValue === 'optionB') {
39+
await interaction.reply('You selected Option B from select menu 1.');
40+
}
41+
break;
42+
43+
case 'select2':
44+
if (selectedValue === 'optionX') {
45+
await interaction.reply('You selected Option X from select menu 2.');
46+
} else if (selectedValue === 'optionY') {
47+
await interaction.reply('You selected Option Y from select menu 2.');
48+
}
49+
break;
50+
}
51+
});
52+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
client.on('guildMemberAdd', (member) => {
2+
const welcomeChannel = member.guild.channels.cache.find((channel) => channel.name === 'welcome');
3+
if (welcomeChannel) {
4+
welcomeChannel.send(`Welcome to the server, ${member.user.tag}!`);
5+
}
6+
});
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === 'react') {
3+
message.react('👍');
4+
message.react('👎');
5+
}
6+
});
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!ping') {
3+
message.reply('Pong!');
4+
}
5+
});
6+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!dm') {
3+
const user = message.author;
4+
user.send('This is a direct message!');
5+
}
6+
});
7+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { MessageEmbed } = require('discord.js');
2+
3+
client.on('messageCreate', (message) => {
4+
if (message.content === '!embed') {
5+
const embed = new MessageEmbed()
6+
.setTitle('Embed Title')
7+
.setDescription('This is an example embed.')
8+
.setColor('#3498db');
9+
10+
message.reply({ embeds: [embed] });
11+
}
12+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!sendfile') {
3+
const attachment = new MessageAttachment('path-to-your-file.png');
4+
message.channel.send({ files: [attachment] });
5+
}
6+
});
7+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
client.on('messageCreate', (message) => {
2+
if (message.content === '!sendtouser') {
3+
const userId = 'USER_ID'; // Replace with the user's ID
4+
const user = client.users.cache.get(userId);
5+
6+
if (user) {
7+
user.send('This is a message sent directly to a user!');
8+
} else {
9+
message.reply('User not found.');
10+
}
11+
}
12+
});
13+

0 commit comments

Comments
 (0)