Skip to content

Commit aceb940

Browse files
committed
Chore: Clean Up
1 parent e39d00d commit aceb940

File tree

13 files changed

+81
-62
lines changed

13 files changed

+81
-62
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ project(bot LANGUAGES CXX)
44

55
set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7-
87
find_package(dpp CONFIG REQUIRED)
98

109
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/config.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

src/commands/close_cmd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ void cmd::closeCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
2828
if (callback2.is_error())
2929
return event.reply(dpp::message("[!] Unable to close post.").set_flags(dpp::m_ephemeral));
3030

31-
dpp::embed embed = dpp::embed()
31+
const dpp::embed embed = dpp::embed()
3232
.set_color(globals::color::defaultColor)
3333
.add_field("Closed post!", "");
3434

35-
dpp::message message(event.command.channel_id, embed);
35+
const dpp::message message(event.command.channel_id, embed);
3636
event.reply(message);
3737
});
3838
});

src/commands/code_cmd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ void cmd::codeCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
55
{
66
const std::string title = "Formatting C++ Code";
77
const std::string content = "Please format your C++ code like this:\n\n\\```cpp\nstd::cout << \"foo bar\";\n\\```";
8-
dpp::embed embed = dpp::embed()
8+
const dpp::embed embed = dpp::embed()
99
.set_color(globals::color::defaultColor)
1010
.set_title(title)
1111
.add_field(content, "");
1212

13-
dpp::message message(event.command.channel_id, embed);
13+
const dpp::message message(event.command.channel_id, embed);
1414
event.reply(message);
1515
}

src/commands/coding_cmd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ void cmd::codingCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
66
static int index;
77
const std::string question = cmd::utils::readFileLine("res/coding.txt", index);
88

9-
dpp::embed embed = dpp::embed()
9+
const dpp::embed embed = dpp::embed()
1010
.set_color(globals::color::defaultColor)
1111
.add_field(question, "");
1212

13-
dpp::message message(event.command.channel_id, embed);
13+
const dpp::message message(event.command.channel_id, embed);
1414
event.reply(message);
1515
}

src/commands/commands.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,50 @@ namespace cmd
1010
{
1111
/**
1212
* @brief Replies with a question in the chat to change the topic
13-
* @param bot
14-
* @param slashcommand event
13+
* @param bot cluster
14+
* @param event slash command event
1515
*/
1616
void topicCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
1717

1818
/**
1919
* @brief Replies with a C++ related coding question
20-
* @param bot
21-
* @param slashcommand event
20+
* @param bot cluster
21+
* @param event slash command event
2222
*/
2323
void codingCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
2424

2525
/**
2626
* @brief Closes a forum post
27-
* @param bot
28-
* @param slashcommand event
27+
* @param bot cluster
28+
* @param event slash command event
2929
*/
3030
void closeCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
3131

3232
/**
3333
* @brief Opens a ticket
34-
* @param bot
35-
* @param slashcommand event
34+
* @param bot cluster
35+
* @param event slash command event
3636
*/
3737
void ticketCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
3838

3939
/**
4040
* @brief Instruction: Formatting C++ Code on Discord
41-
* @param bot
42-
* @param slashcommand event
41+
* @param bot cluster
42+
* @param event slash command event
4343
*/
4444
void codeCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
4545

4646
/**
47-
* @brief Replies with a coding project idea
48-
* @param bot
49-
* @param slashcommand event
47+
* @brief Replies with a coding project idea
48+
* @param bot cluster
49+
* @param event slash command event
5050
*/
5151
void projectCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
5252

5353
/**
54-
* @brief Replies with the rules
55-
* @param bot
56-
* @param slashcommand event
54+
* @brief Replies with the rules
55+
* @param bot cluster
56+
* @param event slash command event
5757
*/
5858
void ruleCommand(dpp::cluster& bot, const dpp::slashcommand_t& event);
5959

src/commands/project_cmd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void cmd::projectCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
4848
const std::string projectDescription = project["description"];
4949
const std::string projectHint = project.contains("hint") ? project["hint"] : "No hint available.";
5050

51-
dpp::embed embed = dpp::embed()
51+
const dpp::embed embed = dpp::embed()
5252
.set_color(globals::color::defaultColor)
5353
.add_field("Project Idea", projectTitle)
5454
.add_field("Description", projectDescription);
@@ -68,7 +68,7 @@ void cmd::projectCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
6868

6969
event.reply(message);
7070

71-
bot.on_button_click([&bot, &data](const dpp::button_click_t& event) {
71+
bot.on_button_click([&bot](const dpp::button_click_t& event) {
7272
// Ignore if button id does not start with hint_button_
7373
if (event.custom_id.rfind("hint_button_", 0) != 0)
7474
return;

src/commands/rule_cmd.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
void cmd::ruleCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
1111
{
12-
std::vector<std::string> rules = {
12+
const std::vector<std::string> rules = {
1313
"Follow Discord's Terms of Service: Adhere to Discord's Terms of Service (ToS) and Community Guidelines.",
1414
"Be respectful: Treat others with kindness, respect, and patience. Avoid harassment, personal attacks, or any form of offensive behavior.",
1515
"Stay on topic: Keep discussions focused on C++ coding and related topics. Avoid excessive off-topic conversations that may disrupt the flow of the server.",
@@ -22,7 +22,7 @@ void cmd::ruleCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
2222
"Do not copy and paste answers from ChatGPT or similar AI tools."
2323
};
2424

25-
dpp::command_interaction cmdData = event.command.get_command_interaction();
25+
const dpp::command_interaction cmdData = event.command.get_command_interaction();
2626
if (cmdData.options.empty())
2727
return event.reply(dpp::message("Please follow our <#" + globals::channel::rulesId.str() + ">."));
2828

@@ -36,10 +36,10 @@ void cmd::ruleCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
3636
if ((index < 1 || index > rules.size()))
3737
return event.reply(dpp::message("Rule number " + std::to_string(index) + " does not exist. Visit <#" + globals::channel::rulesId.str() + "> to see all available rules.").set_flags(dpp::m_ephemeral));
3838

39-
const std::string rule = rules.at(index-1);
39+
const std::string& rule = rules.at(index-1);
4040
const dpp::embed embed = dpp::embed()
4141
.set_color(globals::color::defaultColor)
4242
.add_field("Rule " + std::to_string(index), rule);
43-
dpp::message message(event.command.channel_id, embed);
43+
const dpp::message message(event.command.channel_id, embed);
4444
event.reply(message);
4545
}

src/commands/ticket_cmd.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
void cmd::ticketCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
55
{
6+
dpp::message message(event.command.channel_id, "Creating ticket...");
7+
event.reply(message.set_flags(dpp::m_ephemeral));
8+
69
const dpp::channel ticketChannel = dpp::channel()
710
.set_name(event.command.get_issuing_user().username)
811
.set_type(dpp::CHANNEL_TEXT)
@@ -14,13 +17,15 @@ void cmd::ticketCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
1417
bot.channel_create(ticketChannel, [&bot, event](const dpp::confirmation_callback_t& callback) {
1518
if (!callback.is_error())
1619
{
17-
dpp::channel ticketChannel = std::get<dpp::channel>(callback.value);
18-
19-
dpp::message pingMessage = dpp::message(ticketChannel.id, event.command.get_issuing_user().get_mention() + " opened this ticket.");
20+
const auto ticketChannel = std::get<dpp::channel>(callback.value);
21+
const auto pingMessage = dpp::message(ticketChannel.id, event.command.get_issuing_user().get_mention() + " opened this ticket.");
2022
bot.message_create(pingMessage);
2123

22-
dpp::message message(event.command.channel_id, "Ticket " + ticketChannel.get_mention() + " created!");
23-
event.reply(message.set_flags(dpp::m_ephemeral));
24+
event.edit_response("Ticket " + ticketChannel.get_mention() + " created!");
25+
}
26+
else
27+
{
28+
event.edit_response("Failed to create ticket channel!");
2429
}
2530
});
2631
}

src/commands/topic_cmd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ void cmd::topicCommand(dpp::cluster& bot, const dpp::slashcommand_t& event)
66
static int index;
77
const std::string topic = cmd::utils::readFileLine("res/topic.txt", index);
88

9-
dpp::embed embed = dpp::embed()
9+
const dpp::embed embed = dpp::embed()
1010
.set_color(globals::color::defaultColor)
1111
.add_field(topic, "");
1212

13-
dpp::message message(event.command.channel_id, embed);
13+
const dpp::message message(event.command.channel_id, embed);
1414
event.reply(message);
1515
}

src/commands/utils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ std::string cmd::utils::readFileLine(const std::string& path, int &index)
1313
for (int i = 0; std::getline(file, line) && i < index; i++);
1414

1515
// validate next line
16-
std::string next;
17-
if (!getline(file, next) || line.length() == 0)
16+
if (std::string next; !getline(file, next) || line.length() == 0)
1817
index = 0;
1918
else
2019
index++;

0 commit comments

Comments
 (0)