changes up the message sending a bit, adds support for pinging
This commit is contained in:
parent
508af3d9d1
commit
9db2a13d3a
@ -1121,8 +1121,6 @@ gbp.cpp
|
|||||||
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
|
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
|
||||||
string
|
string
|
||||||
-
|
-
|
||||||
unordered_map
|
|
||||||
-
|
|
||||||
vector
|
vector
|
||||||
-
|
-
|
||||||
algorithm
|
algorithm
|
||||||
@ -1149,6 +1147,8 @@ dpp/dispatcher.h
|
|||||||
-
|
-
|
||||||
dpp/dpp.h
|
dpp/dpp.h
|
||||||
-
|
-
|
||||||
|
dpp/guild.h
|
||||||
|
-
|
||||||
dpp/intents.h
|
dpp/intents.h
|
||||||
-
|
-
|
||||||
dpp/message.h
|
dpp/message.h
|
||||||
|
Binary file not shown.
@ -22,10 +22,12 @@ std::map<std::string, vecFunc>vecArgs;
|
|||||||
*/
|
*/
|
||||||
std::string commandParse(std::vector<std::string> args)
|
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())
|
if (i1 != noArgs.end())
|
||||||
return (*i1->second)();
|
return (*i1->second)();
|
||||||
auto i2 = vecArgs.find(args[0]);
|
auto i2 = vecArgs.find(cmd);
|
||||||
if (i2 != vecArgs.end())
|
if (i2 != vecArgs.end())
|
||||||
return (*i2->second)(args);
|
return (*i2->second)(args);
|
||||||
return "Invalid command!";
|
return "Invalid command!";
|
||||||
@ -135,6 +137,24 @@ std::string findNum(std::vector<std::string> args)
|
|||||||
return out;
|
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
|
* ##findName
|
||||||
*
|
*
|
||||||
|
22
src/main.cpp
22
src/main.cpp
@ -2,6 +2,7 @@
|
|||||||
#include <dpp/appcommand.h>
|
#include <dpp/appcommand.h>
|
||||||
#include <dpp/dispatcher.h>
|
#include <dpp/dispatcher.h>
|
||||||
#include <dpp/dpp.h>
|
#include <dpp/dpp.h>
|
||||||
|
#include <dpp/guild.h>
|
||||||
#include <dpp/intents.h>
|
#include <dpp/intents.h>
|
||||||
#include <dpp/message.h>
|
#include <dpp/message.h>
|
||||||
#include <dpp/once.h>
|
#include <dpp/once.h>
|
||||||
@ -70,19 +71,24 @@ void onMessage(dpp::cluster &bot, dpp::message msg)
|
|||||||
|
|
||||||
/* Parse the command */
|
/* Parse the command */
|
||||||
std::vector<std::string> args = separateArgs(argument);
|
std::vector<std::string> args = separateArgs(argument);
|
||||||
|
|
||||||
|
|
||||||
|
args.insert(++args.begin(), std::to_string(msg.author.id));
|
||||||
std::string msgContent = commandParse(args);
|
std::string msgContent = commandParse(args);
|
||||||
|
|
||||||
/* Here we check if we should embed a file, or just send a message */
|
/* Here we check if we should embed a file, or just send a message */
|
||||||
std::vector<std::string> messageArgs = separateArgs(msgContent);
|
std::vector<std::string> messageArgs = separateArgs(msgContent);
|
||||||
dpp::message toSend;
|
|
||||||
if (messageArgs[0] == std::string(FILE_WARNING)) {
|
if (messageArgs[0] == std::string(FILE_WARNING)) {
|
||||||
toSend = dpp::message(msg.channel_id, "");
|
std::cout << "test2";
|
||||||
toSend.add_file(messageArgs[2], dpp::utility::read_file(messageArgs[1]));
|
bot.message_create(dpp::message(msg.channel_id, "")
|
||||||
} else
|
.add_file(messageArgs[2], dpp::utility::read_file(messageArgs[1]))
|
||||||
toSend = dpp::message(msg.channel_id, msgContent);
|
);
|
||||||
|
} else {
|
||||||
/* Send the message */
|
std::cout << "test";
|
||||||
bot.message_create(toSend);
|
bot.message_create(dpp::message(msg.channel_id, msgContent)
|
||||||
|
.set_allowed_mentions(true, false, false, false, { }, { })
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user