diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41c4abf --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.xcworkspace +*.xcuserdatad +.DS_Store \ No newline at end of file diff --git a/mac-example-bot.xcodeproj/project.pbxproj b/mac-example-bot.xcodeproj/project.pbxproj new file mode 100644 index 0000000..56b4535 --- /dev/null +++ b/mac-example-bot.xcodeproj/project.pbxproj @@ -0,0 +1,308 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 21F8B3092B191F0600C32FB8 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F8B3082B191F0600C32FB8 /* main.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 21F8B3032B191F0600C32FB8 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 21F8B3052B191F0600C32FB8 /* mac-example-bot */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "mac-example-bot"; sourceTree = BUILT_PRODUCTS_DIR; }; + 21F8B3082B191F0600C32FB8 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; usesTabs = 1; }; + 21F8B30F2B191F2C00C32FB8 /* mac-example-bot.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "mac-example-bot.entitlements"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 21F8B3022B191F0600C32FB8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 21F8B2FC2B191F0600C32FB8 = { + isa = PBXGroup; + children = ( + 21F8B3072B191F0600C32FB8 /* mac-example-bot */, + 21F8B3062B191F0600C32FB8 /* Products */, + ); + sourceTree = ""; + }; + 21F8B3062B191F0600C32FB8 /* Products */ = { + isa = PBXGroup; + children = ( + 21F8B3052B191F0600C32FB8 /* mac-example-bot */, + ); + name = Products; + sourceTree = ""; + }; + 21F8B3072B191F0600C32FB8 /* mac-example-bot */ = { + isa = PBXGroup; + children = ( + 21F8B30F2B191F2C00C32FB8 /* mac-example-bot.entitlements */, + 21F8B3082B191F0600C32FB8 /* main.cpp */, + ); + path = "mac-example-bot"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 21F8B3042B191F0600C32FB8 /* mac-example-bot */ = { + isa = PBXNativeTarget; + buildConfigurationList = 21F8B30C2B191F0600C32FB8 /* Build configuration list for PBXNativeTarget "mac-example-bot" */; + buildPhases = ( + 21F8B3012B191F0600C32FB8 /* Sources */, + 21F8B3022B191F0600C32FB8 /* Frameworks */, + 21F8B3032B191F0600C32FB8 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "mac-example-bot"; + productName = "mac-example-bot"; + productReference = 21F8B3052B191F0600C32FB8 /* mac-example-bot */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 21F8B2FD2B191F0600C32FB8 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1500; + TargetAttributes = { + 21F8B3042B191F0600C32FB8 = { + CreatedOnToolsVersion = 15.0.1; + }; + }; + }; + buildConfigurationList = 21F8B3002B191F0600C32FB8 /* Build configuration list for PBXProject "mac-example-bot" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 21F8B2FC2B191F0600C32FB8; + productRefGroup = 21F8B3062B191F0600C32FB8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 21F8B3042B191F0600C32FB8 /* mac-example-bot */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 21F8B3012B191F0600C32FB8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 21F8B3092B191F0600C32FB8 /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 21F8B30A2B191F0600C32FB8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 21F8B30B2B191F0600C32FB8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 21F8B30D2B191F0600C32FB8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; + CODE_SIGN_ENTITLEMENTS = "mac-example-bot/mac-example-bot.entitlements"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + FRAMEWORK_SEARCH_PATHS = ""; + HEADER_SEARCH_PATHS = /opt/homebrew/include; + LIBRARY_SEARCH_PATHS = /opt/homebrew/lib; + OTHER_CFLAGS = ""; + OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; + OTHER_LDFLAGS = "-ldpp"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 21F8B30E2B191F0600C32FB8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; + CODE_SIGN_ENTITLEMENTS = "mac-example-bot/mac-example-bot.entitlements"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + FRAMEWORK_SEARCH_PATHS = ""; + HEADER_SEARCH_PATHS = /opt/homebrew/include; + LIBRARY_SEARCH_PATHS = /opt/homebrew/lib; + OTHER_CFLAGS = ""; + OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; + OTHER_LDFLAGS = "-ldpp"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 21F8B3002B191F0600C32FB8 /* Build configuration list for PBXProject "mac-example-bot" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 21F8B30A2B191F0600C32FB8 /* Debug */, + 21F8B30B2B191F0600C32FB8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 21F8B30C2B191F0600C32FB8 /* Build configuration list for PBXNativeTarget "mac-example-bot" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 21F8B30D2B191F0600C32FB8 /* Debug */, + 21F8B30E2B191F0600C32FB8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 21F8B2FD2B191F0600C32FB8 /* Project object */; +} diff --git a/mac-example-bot/mac-example-bot.entitlements b/mac-example-bot/mac-example-bot.entitlements new file mode 100644 index 0000000..8cc185a --- /dev/null +++ b/mac-example-bot/mac-example-bot.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.cs.disable-library-validation + + + diff --git a/mac-example-bot/main.cpp b/mac-example-bot/main.cpp new file mode 100644 index 0000000..28d6518 --- /dev/null +++ b/mac-example-bot/main.cpp @@ -0,0 +1,39 @@ +#include +#include + +/* Be sure to place your token in the line below. + * Follow steps here to get a token: + * https://dpp.dev/creating-a-bot-application.html + * When you invite the bot, be sure to invite it with the + * scopes 'bot' and 'applications.commands', e.g. + * https://discord.com/oauth2/authorize?client_id=940762342495518720&scope=bot+applications.commands&permissions=139586816064 + */ +const std::string BOT_TOKEN = "add your token here"; + +int main() { + /* Create bot cluster */ + dpp::cluster bot(BOT_TOKEN); + + /* Output simple log messages to stdout */ + bot.on_log(dpp::utility::cout_logger()); + + /* Handle slash command */ + bot.on_slashcommand([](const dpp::slashcommand_t& event) { + if (event.command.get_command_name() == "ping") { + event.reply("Pong!"); + } + }); + + /* Register slash command here in on_ready */ + bot.on_ready([&bot](const dpp::ready_t& event) { + /* Wrap command registration in run_once to make sure it doesnt run on every full reconnection */ + if (dpp::run_once()) { + bot.global_command_create(dpp::slashcommand("ping", "Ping pong!", bot.me.id)); + } + }); + + /* Start the bot */ + bot.start(dpp::st_wait); + + return 0; +}