Skip to content

Commit

Permalink
Merge pull request #412 from MaoShizhong/feature/add-optional-user-me…
Browse files Browse the repository at this point in the history
…ntion-to-slash-commands

Slash commands: Add optional user mention option
  • Loading branch information
codyloyd authored Sep 11, 2023
2 parents 73d0919 + 0e20ed9 commit e92ee89
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 34 deletions.
10 changes: 8 additions & 2 deletions new-era-commands/slash/ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ai')
.setDescription('Generative AI and Learning to Code'),
.setDescription('Generative AI and Learning to Code')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const aiEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('Generative AI and Learning Code')
Expand All @@ -26,6 +29,9 @@ module.exports = {
],
);

await interaction.reply({ embeds: [aiEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [aiEmbed],
});
},
};
14 changes: 10 additions & 4 deletions new-era-commands/slash/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ const config = require('../../config');
module.exports = {
data: new SlashCommandBuilder()
.setName('bookmark')
.setDescription('Info about bookmarking messages in the TOP Discord server'),
.setDescription('Info about bookmarking messages in the TOP Discord server')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const bookmarkEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('Bookmark messages in this server')
.setDescription(`
To bookmark a message, react with the bookmark icon 🔖 on the message you wish to save for later.
To bookmark a message, react with the bookmark icon 🔖 on the message you wish to save for later.
<@${config.clientId}> will then deliver the message to your DMs in an embedded format with a link to the original message in the server.
<@${config.clientId}> will then deliver the message to your DMs in an embedded format with a link to the original message in the server.
You can delete a bookmarked message at any time from your DMs by reacting on it with the ❌ emoji.
`);

await interaction.reply({ embeds: [bookmarkEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [bookmarkEmbed],
});
},
};
10 changes: 8 additions & 2 deletions new-era-commands/slash/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('code')
.setDescription('How to share your code'),
.setDescription('How to share your code')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const codeEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('How to share your code')
Expand All @@ -30,6 +33,9 @@ For \`inline code\` use one backtick (no syntax highlighting):
- [Codepen](https://codepen.io/) for basic HTML/CSS/Javascript
`);

await interaction.reply({ embeds: [codeEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [codeEmbed],
});
},
};
14 changes: 10 additions & 4 deletions new-era-commands/slash/contribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('contribute')
.setDescription('Information on how to contribute to TOP on GitHub'),
.setDescription('Information on how to contribute to TOP on GitHub')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const contributingEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('Contributing to The Odin Project Repositories')
Expand All @@ -20,11 +23,11 @@ To contribute to The Odin Project, check out our repositories on GitHub:
Make sure to read the [contributing guide](https://github.com/TheOdinProject/.github/blob/main/CONTRIBUTING.md) before getting started.
To find issues ready to be worked on, go to the \`issues\` tab in each repository. You can also create new issues or propose suggestions there.
To find issues ready to be worked on, go to the \`issues\` tab in each repository. You can also create new issues or propose suggestions there.
**First time contributors**
If you're a first-time contributor, you can look for issues labeled \`good first issue\`.
If you're a first-time contributor, you can look for issues labeled \`good first issue\`.
These are beginner-friendly and perfect for getting started with open source contributions.
**Top-contributors role**
Expand All @@ -34,6 +37,9 @@ You will recognize our TOP-Contributors by their special role which you can lear
We hope to see you on GitHub!
`);

await interaction.reply({ embeds: [contributingEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [contributingEmbed],
});
},
};
14 changes: 10 additions & 4 deletions new-era-commands/slash/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('data')
.setDescription("Don't ask to ask!"),
.setDescription("Don't ask to ask!")
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const dataEmbed = new EmbedBuilder()
.setTitle('Don’t ask to ask!')
.setColor('#cc9543')
Expand All @@ -21,12 +24,15 @@ Instead of asking if anyone can help you, ask your question outright with as muc
**Lesson link:**
**Code:** [code sandbox like replit or codepen]
**Issue/Problem:** [screenshots if applicable]
**What I expected:**
**What I've tried:**
**What I expected:**
**What I've tried:**
**https://www.dontasktoask.com/**
`);

await interaction.reply({ embeds: [dataEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [dataEmbed],
});
},
};
10 changes: 8 additions & 2 deletions new-era-commands/slash/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('debug')
.setDescription('Debugging'),
.setDescription('Debugging')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const debugEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('DEBUGGING')
Expand All @@ -24,6 +27,9 @@ module.exports = {
],
);

await interaction.reply({ embeds: [debugEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [debugEmbed],
});
},
};
12 changes: 9 additions & 3 deletions new-era-commands/slash/freelance.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('freelancing')
.setDescription('Things to consider about freelancing'),
.setDescription('Things to consider about freelancing')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const freelanceEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('Freelancing')
.setDescription(`
Here are some things that should be considered before getting into freelancing: https://discord.com/channels/505093832157691914/505093832157691916/928760451213443193
Here are some things that should be considered before getting into freelancing: https://discord.com/channels/505093832157691914/505093832157691916/928760451213443193
`);

await interaction.reply({ embeds: [freelanceEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [freelanceEmbed],
});
},
};
10 changes: 8 additions & 2 deletions new-era-commands/slash/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('notes')
.setDescription('Things to consider about taking notes'),
.setDescription('Things to consider about taking notes')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const freelanceEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('To note, or not to note, that is the question')
.setDescription(`
Please read this [Discord message about what we think you should consider about taking notes](https://discord.com/channels/505093832157691914/505093832157691916/768161823366578176)
`);

await interaction.reply({ embeds: [freelanceEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [freelanceEmbed],
});
},
};
10 changes: 8 additions & 2 deletions new-era-commands/slash/portfolio.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('portfolio')
.setDescription('Information about portfolio-worthy projects'),
.setDescription('Information about portfolio-worthy projects')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const portfolioEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('Strategically Building Your Portfolio')
Expand All @@ -14,6 +17,9 @@ module.exports = {
Read more on which projects are worth your extra time in
[this article about strategically building your portfolio](https://dev.to/theodinproject/strategically-building-your-portfolio-1km4)
`);
await interaction.reply({ embeds: [portfolioEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [portfolioEmbed],
});
},
};
16 changes: 11 additions & 5 deletions new-era-commands/slash/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('question')
.setDescription('Asking Great Questions'),
.setDescription('Asking Great Questions')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const questionEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('Asking Great Questions')
.setDescription(`
Asking context-rich questions makes it easy to receive help, and makes it easy for others to help you quickly! Great engineers ask great questions, and the prompt below is an invitation to improve your skills and set yourself up for success in the workplace.
Asking context-rich questions makes it easy to receive help, and makes it easy for others to help you quickly! Great engineers ask great questions, and the prompt below is an invitation to improve your skills and set yourself up for success in the workplace.
**Project/Exercise:**
**Lesson link:**
**Code:** [code sandbox like replit or codepen]
**Issue/Problem:** [screenshots if applicable]
**What I expected:**
**What I've tried:**
**What I expected:**
**What I've tried:**
For even more context around on how to hone your question-asking skills, give this a read: https://www.theodinproject.com/guides/community/how_to_ask
`);

await interaction.reply({ embeds: [questionEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [questionEmbed],
});
},
};
11 changes: 9 additions & 2 deletions new-era-commands/slash/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('top')
.setDescription('Information about The Odin Project'),
.setDescription('Information about The Odin Project')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const topEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('The Odin Project')
.setDescription(`
For more information about The Odin Project, visit our site:
[Your Career in Web Development Starts Here](https://www.theodinproject.com/)
`);
await interaction.reply({ embeds: [topEmbed] });

await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [topEmbed],
});
},
};
10 changes: 8 additions & 2 deletions new-era-commands/slash/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('windows')
.setDescription('Windows'),
.setDescription('Windows')
.addUserOption((option) => option.setName('user').setDescription('user to ping')),
execute: async (interaction) => {
const userId = interaction.options.getUser('user')?.id;

const windowsEmbed = new EmbedBuilder()
.setColor('#cc9543')
.setTitle('Windows')
.setDescription('**The Odin Project does not support Windows, WSL, or any OS outside of our recommendations**. We are happy to assist with any questions about installing a VM or dual booting Linux. <https://www.theodinproject.com/paths/foundations/courses/foundations/lessons/installation-overview#os-options>')
.setURL('https://www.theodinproject.com/paths/foundations/courses/foundations/lessons/installation-overview#os-options');

await interaction.reply({ embeds: [windowsEmbed] });
await interaction.reply({
content: userId ? `<@${userId}>` : '',
embeds: [windowsEmbed],
});
},
};

0 comments on commit e92ee89

Please sign in to comment.