changes up the message sending a bit, adds support for pinging

This commit is contained in:
SuperNovaa41 2022-03-11 10:15:29 -05:00
parent 508af3d9d1
commit 9db2a13d3a
4 changed files with 38 additions and 12 deletions

View File

@ -1121,8 +1121,6 @@ gbp.cpp
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
string
-
unordered_map
-
vector
-
algorithm
@ -1149,6 +1147,8 @@ dpp/dispatcher.h
-
dpp/dpp.h
-
dpp/guild.h
-
dpp/intents.h
-
dpp/message.h

View File

@ -22,10 +22,12 @@ std::map<std::string, vecFunc>vecArgs;
*/
std::string commandParse(std::vector<std::string> args)
{
auto i1 = noArgs.find(args[0]);
std::string cmd = args[0];
args.erase(args.begin());
auto i1 = noArgs.find(cmd);
if (i1 != noArgs.end())
return (*i1->second)();
auto i2 = vecArgs.find(args[0]);
auto i2 = vecArgs.find(cmd);
if (i2 != vecArgs.end())
return (*i2->second)(args);
return "Invalid command!";
@ -135,6 +137,24 @@ std::string findNum(std::vector<std::string> args)
return out;
}
/*
std::string notify(std::vector<std::string> args)
{
if (args.size() < 3)
return "Invalid command!";
// !gbp notify SuperNovaa41
// will be the users in put
// we need to append
// !gbp notify SuperNovaa41 message_sender_id
// notify [github name]
// notify stop -> this will search for all notifys with that discord name
}
*/
/**
* ##findName
*

View File

@ -2,6 +2,7 @@
#include <dpp/appcommand.h>
#include <dpp/dispatcher.h>
#include <dpp/dpp.h>
#include <dpp/guild.h>
#include <dpp/intents.h>
#include <dpp/message.h>
#include <dpp/once.h>
@ -70,19 +71,24 @@ void onMessage(dpp::cluster &bot, dpp::message msg)
/* Parse the command */
std::vector<std::string> args = separateArgs(argument);
args.insert(++args.begin(), std::to_string(msg.author.id));
std::string msgContent = commandParse(args);
/* Here we check if we should embed a file, or just send a message */
std::vector<std::string> messageArgs = separateArgs(msgContent);
dpp::message toSend;
if (messageArgs[0] == std::string(FILE_WARNING)) {
toSend = dpp::message(msg.channel_id, "");
toSend.add_file(messageArgs[2], dpp::utility::read_file(messageArgs[1]));
} else
toSend = dpp::message(msg.channel_id, msgContent);
/* Send the message */
bot.message_create(toSend);
std::cout << "test2";
bot.message_create(dpp::message(msg.channel_id, "")
.add_file(messageArgs[2], dpp::utility::read_file(messageArgs[1]))
);
} else {
std::cout << "test";
bot.message_create(dpp::message(msg.channel_id, msgContent)
.set_allowed_mentions(true, false, false, false, { }, { })
);
}
}
int main()