Interactions subpackage for nyxx_library

Overview

nyxx_interactions

pub documentation documentation documentation documentation

Simple, robust framework for creating discord bots for Dart language.


Features

  • Slash commands support
    Supports and provides easy API for creating and handling slash commands
  • Commands framework included
    A fast way to create a bot with command support. Implementing the framework is simple - and everything is done automatically.
  • Cross Platform
    Nyxx works on the command line, in the browser, and on mobile devices.
  • Fine Control
    Nyxx allows you to control every outgoing HTTP request or WebSocket message.
  • Complete
    Nyxx supports nearly all Discord API endpoints.

Quick example

Basic usage:

void main() {
  final bot = Nyxx("TOKEN", GatewayIntents.allUnprivileged);

  bot.onMessageReceived.listen((event) {
    if (event.message.content == "!ping") {
      event.message.channel.sendMessage(MessageBuilder.content("Pong!"));
    }
  });
}

Slash commands:

void main() {
  final bot = Nyxx("<%TOKEN%>", GatewayIntents.allUnprivileged);
  final interactions = Interactions(bot);

  interactions
    ..registerHandler("test", "This is test comamnd", [], handler: (event) async {
      await event.reply(MessageBuilder.content("This is example message result"));
    });
}

Commands:

void main() {
  final bot = Nyxx("TOKEN", GatewayIntents.allUnprivileged);

  Commander(bot, prefix: "!!!")
    ..registerCommand("ping", (context, message) => context.reply(MessageBuilder.content("Pong!")));
}

More examples

Nyxx examples can be found here.

Commander examples can be found here

Slash commands (interactions) examples can be found here

Example bots

Documentation, help and examples

Dartdoc documentation is hosted on pub. This wiki just fills gap in docs with more descriptive guides and tutorials.

Discord API docs

Discord API documentation features rich descriptions about all topics that nyxx covers.

Discord API Guild

The unofficial guild for Discord Bot developers. To get help with nyxx check #dart_nyxx channel.

Dartdocs

The dartdocs page will always have the documentation for the latest release.

Dev docs

You can read about upcoming changes in the library on my website.

Wiki

Wiki documentation are designed to match the latest Nyxx release.

Contributing to Nyxx

Read contributing document

Credits

Comments
  • [Bug report] Guild commands not deleted if unregistered

    [Bug report] Guild commands not deleted if unregistered

    Describe the bug

    Registering no guild command builders should result in all commands for that guild being deleted when Interactions.sync() is called. However, this is not the case and no guild commands are deleted for that guild.

    This is also the case with Interactions.syncOnReady().

    To reproduce

    1. Register a command builder for a specific guild
    2. Call Interactions.sync()
    3. Stop the bot
    4. Restart the bot, do not register the command builder and call Interactions.sync()
    5. Command is still registered for that guild but should have been deleted

    Expected behaviour

    After registering no commands for a specific guild, Interactions.sync() should delete all command for that guild.

    Desktop

    • OS: Artix Linux 5.15.5-artix1-1
    • Dart: 2.14.4
    • nyxx_interactions: 2.9.0, appears to also be present in 3.0.0-dev-0 but have not tested.

    Additional context

    This for loop will not call bulkOverrideGuildCommands() for any guilds with no commands registered as they will not be a partition. This means that commands for any guild will be left untouched if no command builders are registered for it, causing the issue.

    bug 
    opened by abitofevrything 6
  • feat: Add support for new select menus components

    feat: Add support for new select menus components

    Description

    Implements new options for select menus.

    Resolves #61

    Connected issues & potential other potential problems

    • https://github.com/nyxx-discord/nyxx/pull/380

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    Checklist:

    • [x] Ran dart analyze or make analyze and fixed all issues
    • [x] Ran dart format --set-exit-if-changed -l 160 ./lib or make format and fixed all issues
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] I have checked my changes haven't lowered code coverage
    enhancement 
    opened by Rapougnac 4
  • buttons_and_dropdowns example does not run:

    buttons_and_dropdowns example does not run: "Cannot sent message when MessageBuilder doesn't have set either content, embed or files"

    I can't manage to make the ComponentMessageBuilder send anything. Whenever I run the buttons_and_dropdowns example, with a valid token of course, the interaction fails and the following error gets logged: [SHOUT] [Client] Got Error: Message: [Invalid argument(s): Cannot sent message when MessageBuilder doesn't have set either content, embed or files]. Stacktrace: Instance of '_StringStackTrace' The same happens every time I send or respond with a ComponentMessageBuilder instead of a normal MessageBuilder.

    I haven't dug into the code much since I'm not very good at that, but it seems like the problem is that ComponentMessageBuilder doesn't set either content, embeds or files anywhere, and doesn't override canBeUsedAsNewMessage.

    Environment info

    • OS: Artix Linux 5.15.10
    • Dart 2.16.0-134.0.dev
    • Nyxx version: both on 3.0.1 and 3.2.1, nyxx_interactions on 3.1.0
    bug 
    opened by Four-Griffins 4
  • Create a followup message with ephemeral

    Create a followup message with ephemeral

    Create a followup message with ephemeral. https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message thanks for the hard work <3.

    enhancement 
    opened by lucascardo12 4
  • BUGFIX fix interaction handling mapping for global slash command

    BUGFIX fix interaction handling mapping for global slash command

    Description

    BUGFIX Global Slash Command Interaction Handlers were not being mapped to correctly. This would result in the interaction not being processed at all if the related slash command wasn't created for a specific guild.

    Connected issues & potential other potential problems

    Type of change

    • [x] Bug fix (non-breaking change which fixes an issue)

    Checklist:

    • [ ] Ran dart analyze or make analyze and fixed all issues
    • [x] Ran dart format --set-exit-if-changed -l 160 ./lib or make format and fixed all issues
    • [x] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] I have checked my changes haven't lowered code coverage
    opened by NDSo 2
  • Allow handlers on different nesting layers, closes nyxx#233

    Allow handlers on different nesting layers, closes nyxx#233

    Description

    Previously handlers could not be registered for both subcommands and sub-subcommands because of the way preventing root handlers on slash commands with subcommands was implemented. This PR reworks that system to allow both subcommands and sub-subcommands to have handlers, while still preventing slash commands with subcommands having roor handlers.

    Also added .gitignore since it was missing, it is the same as nyxx.

    Type of change

    Please delete options that are not relevant.

    • [x] Bug fix (non-breaking change which fixes an issue)

    Checklist:

    • [x] Ran dartanalyzer --options analysis_options.yaml .
    • [x] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    bug 
    opened by abitofevrything 2
  • Implements slash commands mentions

    Implements slash commands mentions

    Description

    Add slash commands mention. Fixes #59

    Connected issues & potential other potential problems

    -/-

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    Checklist:

    • [x] Ran dart analyze or make analyze and fixed all issues
    • [x] Ran dart format --set-exit-if-changed -l 160 ./lib or make format and fixed all issues
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] I have added tests that prove my fix is effective or that my feature works
    • [ ] I have checked my changes haven't lowered code coverage
    opened by Rapougnac 1
  • feature: Locales

    feature: Locales

    Description

    Fixes: #19 Support slash commands locales. Transform IInteractions.create() into a factory. (Don't know if I was right)

    Connected issues & potential other potential problems

    None.

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    Checklist:

    • [x] Ran dart analyze or make analyze and fixed all issues
    • [x] Ran dart format --set-exit-if-changed -l 160 ./lib or make format and fixed all issues
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] I have added tests that prove my fix is effective or that my feature works
    • [ ] I have checked my changes haven't lowered code coverage
    enhancement 
    opened by Rapougnac 1
  • Refactor sync() method in IInteractions to be visible and fully functional

    Refactor sync() method in IInteractions to be visible and fully functional

    Is your feature request related to a problem? Please describe.

    Currently only the syncOnReady() method is exposed in IInteractions. This means that any projects that need to wait for the client to be ready, do some processing and then sync slash commands cannot do so.

    Describe the solution you'd like

    Expose the sync() method in IInteractions.

    Describe alternatives you've considered

    It is possible to directly import package:nyxx_interactions/src/interactions.dart however this is against dart style guides and package guidelines.

    opened by abitofevrything 1
  • Check autocomplete implementation

    Check autocomplete implementation

    Ref: https://github.com/discord/discord-api-docs/pull/3996

    Our autocomplete implementation needs to be checked against official docs if everything is up to spec

    enhancement 
    opened by l7ssha 1
  • Add Indonesian locale

    Add Indonesian locale

    Description

    Add Indonesian locale

    Connected issues & potential other potential problems

    -/-

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    Checklist:

    • [x] Ran dart analyze or make analyze and fixed all issues
    • [x] Ran dart format --set-exit-if-changed -l 160 ./lib or make format and fixed all issues
    • [x] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] I have checked my changes haven't lowered code coverage
    enhancement 
    opened by Rapougnac 0
Releases(nyxx_interactions-4.5.0)
Owner
nyxx - discord api for dart
Wrapper around Discord API for Dart
nyxx - discord api for dart
‎‎‎‎‎Create a serverless Discord bot in pure dart using Discord Interactions webhooks

Create a serverless Discord bot in pure dart using Discord Interactions webhooks Features Feature Status Manage Application Commands Full support (uni

null 4 Sep 28, 2022
A fun Snowfall/Rainfall Project with Interactions

snowfall Snowfall Project Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is yo

Paras Jain 8 Oct 31, 2022
Code for Flutter Talk from Flutter Vikings 2022: Custom User Interactions in Flutter

Custom User Interactions - Flutter Vikings 2022 A companion app for the Flutter Vikings 2022 talk - Custom User Interactions with Shortcuts, Intents,

Justin McCandless 9 Sep 16, 2022