Skip to content

Commit ffe983b

Browse files
mbn-codeebcq
andauthored
Add project command to suggest coding project ideas (#17)
* Add project command to suggest coding project ideas * Fix CMakeLists.txt * Refactor msgs --------- Co-authored-by: fellalli <fellalli@web.de>
1 parent 077deab commit ffe983b

File tree

6 files changed

+128
-1
lines changed

6 files changed

+128
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ add_executable(bot
2424
src/commands/close_cmd.cpp
2525
src/commands/ticket_cmd.cpp
2626
src/commands/code_cmd.cpp
27+
src/commands/project_cmd.cpp
2728

2829
# utils
2930
src/utils/suggestion/suggestion.cpp

src/commands/commands.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ namespace cmd
4343
*/
4444
void codeCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
4545

46+
/**
47+
* @brief Replies with a coding project idea
48+
* @param bot
49+
* @param slashcommand event
50+
*/
51+
void projectCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
52+
4653
namespace utils
4754
{
4855
/**

src/commands/project_cmd.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "commands.h"
2+
#include "../globals/globals.h"
3+
4+
void cmd::projectCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
5+
{
6+
static int index;
7+
const std::string project = cmd::utils::readFileLine("res/project.txt", index);
8+
9+
dpp::embed embed = dpp::embed()
10+
.set_color(globals::color::defaultColor)
11+
.add_field(project, "");
12+
13+
dpp::message message(event.command.channel_id, embed);
14+
event.reply(message);
15+
}

src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ std::list<cmdStruct> cmdList = {
1212
{ "coding", "Get a coding question", cmd::codingCommand },
1313
{ "close", "Close a ticket or forum post", cmd::closeCommand },
1414
{ "ticket", "Open a ticket", cmd::ticketCommand },
15-
{ "code", "Formatting code on Discord", cmd::codeCommand }
15+
{ "code", "Formatting code on Discord", cmd::codeCommand },
16+
{ "project", "Get a project idea", cmd::projectCommand }
1617
};
1718

1819
int main()

src/res/coding.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,32 @@ How do you get the current time?
2929
How do you get a random number?
3030
How do you open a file?
3131
Is C++ memory safe?
32+
What is the difference between a pointer and a reference?
33+
How do you initialize a std::map?
34+
What is the purpose of the namespace keyword?
35+
What is a lambda function in C++?
36+
How do you use a std::set?
37+
What is the difference between struct and class in C++?
38+
What does the override keyword do?
39+
How can you handle exceptions in C++?
40+
What is the role of the explicit keyword?
41+
What does the keyword inline mean?
42+
What is the difference between typedef and using?
43+
How do you iterate over a std::vector?
44+
How does a for-each loop work in C++?
45+
What is the difference between malloc and new?
46+
What is the difference between free and delete?
47+
What is a virtual destructor, and why is it needed?
48+
How does polymorphism work in C++?
49+
How do you implement a pure virtual function?
50+
What is an abstract class?
51+
What is a friend function?
52+
What is the difference between std::list and std::vector?
53+
How do you declare a constant pointer?
54+
How do you copy a std::string?
55+
What is the difference between std::endl and '\n'?
56+
How can you sort a std::vector?
57+
How does the static keyword affect a class member?
58+
How can you create a multi-dimensional array in C++?
59+
How do you initialize a std::pair?
60+
What is the purpose of the decltype keyword?

src/res/project.txt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Print "Hello, World!" to the screen.
2+
Display numbers 1 to 10.
3+
Print a square of * symbols.
4+
Calculate the sum of numbers 1 to 10.
5+
Create a simple GUI (e.g. with text and buttons).
6+
Print your name 5 times.
7+
Print even numbers from 2 to 20.
8+
Create a simple countdown from 10 to 1.
9+
Print the alphabet (A to Z).
10+
Print a triangle of * symbols.
11+
Calculate the factorial of a number.
12+
Check if a number is even or odd.
13+
Display the multiplication table for a number.
14+
Find the greatest common divisor (GCD) of two numbers.
15+
Check if a number is a palindrome.
16+
Calculate the nth Fibonacci number.
17+
Convert Celsius to Fahrenheit.
18+
Count the number of vowels in a string.
19+
Reverse a string.
20+
Find the largest number in an array.
21+
Create a program that adds two matrices.
22+
Sort an array using bubble sort.
23+
Check if a number is a prime number.
24+
Create a basic calculator (add, subtract, multiply, divide).
25+
Generate a random number between 1 and 100.
26+
Check if a word is an anagram of another word.
27+
Simulate rolling a pair of dice.
28+
Print the first n prime numbers.
29+
Draw a rectangle of * symbols.
30+
Find the sum of digits in a number.
31+
Calculate the area of a circle given its radius.
32+
Create a program that generates a username from a name.
33+
Implement a basic guessing game.
34+
Print the elements of a 2D array.
35+
Create a stopwatch timer.
36+
Count the occurrences of a character in a string.
37+
Print Pascal’s triangle.
38+
Calculate the power of a number (a^b).
39+
Create a program to simulate a coin toss.
40+
Sort an array using insertion sort.
41+
Convert a binary number to decimal.
42+
Implement a simple to-do list.
43+
Check if a year is a leap year.
44+
Print the sum of a series, e.g., 1 + 1/2 + 1/3 + ... + 1/n.
45+
Implement a simple login system.
46+
Convert a decimal number to binary.
47+
Display a pattern like a diamond using *.
48+
Find the second largest number in an array.
49+
Check if a string is a palindrome.
50+
Implement a Caesar cipher for text encryption.
51+
Find the sum of an array.
52+
Create a program to simulate a simple game of Rock, Paper, Scissors.
53+
Calculate compound interest.
54+
Create a simple inventory management system.
55+
Print the border of a square with *.
56+
Display the current system date and time.
57+
Print a spiral pattern of numbers.
58+
Calculate the average of numbers in an array.
59+
Find the maximum and minimum of numbers in an array.
60+
Implement a program to check for armstrong numbers.
61+
Create a Tic-Tac-Toe game for two players.
62+
Count the words in a sentence.
63+
Implement a simple stopwatch.
64+
Print the ASCII values of characters in a string.
65+
Create a program to find all divisors of a number.
66+
Convert a number from hexadecimal to decimal.
67+
Generate the multiplication table for 1 to 10.
68+
Find the LCM of two numbers.
69+
Check if a string contains only digits.
70+
Implement a number guessing game.
71+
Create a hangman game with a predefined word.
72+
Count the occurrences of each word in a sentence.
73+
Generate all permutations of a string.
74+
Implement a basic text-based menu system.

0 commit comments

Comments
 (0)