main
Brett 2024-02-23 14:37:23 -05:00
parent c251ef0c34
commit 5d5c293406
1 changed files with 21 additions and 10 deletions

View File

@ -7,7 +7,9 @@
int main(int argc, const char** argv) int main(int argc, const char** argv)
{ {
blt::arg_parse parser; blt::arg_parse parser;
parser.addArgument(blt::arg_builder("-t", "--token").setDefault("uWU").setAction(blt::arg_action_t::STORE).setHelp("The discord bot token").setRequired().build()); parser.addArgument(
blt::arg_builder("-t", "--token").setDefault("uWU").setAction(blt::arg_action_t::STORE).setHelp("The discord bot token").setRequired()
.build());
// for (int i = 0; i < argc; i++) // for (int i = 0; i < argc; i++)
// BLT_TRACE(argv[i]); // BLT_TRACE(argv[i]);
@ -16,7 +18,7 @@ int main(int argc, const char** argv)
BLT_TRACE(args.get<std::string>("--token")); BLT_TRACE(args.get<std::string>("--token"));
BLT_TRACE(argv[argc - 1]); BLT_TRACE(argv[argc - 1]);
dpp::cluster bot(argv[argc-1]); dpp::cluster bot(argv[argc - 1], dpp::i_default_intents | dpp::i_message_content | dpp::i_all_intents);
bot.on_slashcommand([](auto event) { bot.on_slashcommand([](auto event) {
if (event.command.get_command_name() == "ping") if (event.command.get_command_name() == "ping")
@ -28,18 +30,27 @@ int main(int argc, const char** argv)
bot.on_ready([&bot](auto event) { bot.on_ready([&bot](auto event) {
if (dpp::run_once<struct register_bot_commands>()) if (dpp::run_once<struct register_bot_commands>())
{ {
bot.global_command_create( bot.global_command_create(dpp::slashcommand("ping", "Ping pong!", bot.me.id));
dpp::slashcommand("ping", "Ping pong!", bot.me.id)
);
} }
}); });
bot.on_message_create([&bot](auto event) { bot.on_message_create([&bot](const dpp::message_create_t& event) {
if (event.msg.id == bot.me.id)
return;
BLT_TRACE("(%s)> %s", event.msg.author.username.c_str(), event.msg.content.c_str()); BLT_TRACE("(%s)> %s", event.msg.author.username.c_str(), event.msg.content.c_str());
if (event.msg.author.username == "") for (const dpp::attachment& attach : event.msg.attachments)
{ {
BLT_INFO("\tAttachment: %s", attach.url.c_str());
} }
for (const dpp::embed& embed : event.msg.embeds)
{
BLT_INFO("\tEmbedding: %s", embed.url.c_str());
}
//BLT_TRACE_STREAM << event.msg.channel_id.str() << " " << event.msg.channel_id.str() << " " << "\n";
// if (blt::string::toLowerCase(event.msg.author.username) != "autismbot" && blt::string::toLowerCase(event.msg.author.username) != "jewhack")
// {
// //event.reply("Test response " + event.msg.author.global_name);
// }
}); });
bot.start(dpp::st_wait); bot.start(dpp::st_wait);