Start of nyxx.interactions

This commit is contained in:
HarryET 2020-12-20 16:09:44 +00:00 committed by Szymon Uglis
parent 206aaeb454
commit 005bc2c863
No known key found for this signature in database
GPG key ID: 112376C5BEE91FE2
13 changed files with 340 additions and 0 deletions

View file

@ -0,0 +1,3 @@
## 1.0.0
- Initial version, created by Stagehand

View file

@ -0,0 +1,88 @@
<div align="center">
<br />
<p> <img width="600" src="https://l7ssha.github.io/nyxx0.png" />
<br />
[![Build Status](https://travis-ci.org/l7ssha/nyxx.svg?branch=master)](https://travis-ci.org/l7ssha/nyxx)
[![Pub](https://img.shields.io/pub/v/nyxx.svg)](https://pub.dartlang.org/packages/nyxx)
[![documentation](https://img.shields.io/badge/Documentation-nyxx-yellow.svg)](https://www.dartdocs.org/documentation/nyxx/latest/)
Simple, robust framework for creating discord bots for Dart language.
<hr />
</div>
### Features
- **Commands framework included** <br>
A fast way to create a bot with command support. Implementing the framework is simple - and everything is done automatically.
- **Cross Platform** <br>
Nyxx works on the command line, in the browser, and on mobile devices.
- **Fine Control** <br>
Nyxx allows you to control every outgoing HTTP request or WebSocket message.
- **Complete** <br>
Nyxx supports nearly all Discord API endpoints.
## Quick example
Basic usage:
```dart
void main() {
var bot = Nyxx("TOKEN");
bot.onMessageReceived.listen((event) {
if (event.message.content == "!ping") {
event.message.channel.send(content: "Pong!");
}
});
}
```
Commands:
```dart
void main() {
final bot = Nyxx("TOKEN");
Commander(bot, prefix: "!!!")
..registerCommand("ping", (context, message) => context.reply(content: "Pong!"));
}
```
## More examples
Nyxx examples can be found [here](https://github.com/l7ssha/nyxx/tree/development/nyxx/example).
Commander examples can be found [here](https://github.com/l7ssha/nyxx/tree/development/nyxx.commander/example)
### Example bots
- [Running on Dart](https://github.com/l7ssha/running_on_dart)
## Documentation, help and examples
**Dartdoc documentation is hosted on [pub](https://www.dartdocs.org/documentation/nyxx/latest/).
This wiki just fills gap in docs with more descriptive guides and tutorials.**
#### [Discord API docs](https://discordapp.com/developers/docs/intro)
Discord API documentation features rich descriptions about all topics that nyxx covers.
#### [Discord API Guild](https://discord.gg/discord-api)
The unofficial guild for Discord Bot developers. To get help with nyxx check `#dart_nyxx` channel.
#### [Dartdocs](https://www.dartdocs.org/documentation/nyxx/latest/)
The dartdocs page will always have the documentation for the latest release.
#### [Dev docs](https://nyxx.l7ssha.xyz)
You can read about upcoming changes in the library on my website.
#### [Wiki](https://github.com/l7ssha/nyxx/wiki)
Wiki documentation are designed to match the latest Nyxx release.
## Contributing to Nyxx
Read [contributing document](https://github.com/l7ssha/nyxx/blob/development/CONTRIBUTING.md)
## Credits
* [Hackzzila's](https://github.com/Hackzzila) for [nyx](https://github.com/Hackzzila/nyx).

View file

@ -0,0 +1,110 @@
analyzer:
enable-experiment:
- non-nullable
strong-mode:
implicit-casts: false
exclude:
- example/**
linter:
rules:
- avoid_empty_else
- comment_references
- control_flow_in_finally
- empty_statements
- hash_and_equals
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- avoid_slow_async_io
- cancel_subscriptions
- test_types_in_equals
- throw_in_finally
- valid_regexps
- always_declare_return_types
- annotate_overrides
- avoid_init_to_null
- avoid_return_types_on_setters
- await_only_futures
- camel_case_types
- constant_identifier_names
- empty_constructor_bodies
- library_names
- library_prefixes
- non_constant_identifier_names
- only_throw_errors
- package_api_docs
- package_prefixed_library_names
- prefer_is_not_empty
- slash_for_doc_comments
- type_init_formals
- unnecessary_getters_setters
- package_names
- unnecessary_await_in_return
- use_function_type_syntax_for_parameters
- avoid_returning_null_for_future
- no_duplicate_case_values
- unnecessary_statements
- always_require_non_null_named_parameters
- always_put_required_named_parameters_first
- avoid_catches_without_on_clauses
- avoid_function_literals_in_foreach_calls
- avoid_redundant_argument_values
- avoid_returning_null
- avoid_returning_null_for_void
- avoid_returning_this
- camel_case_extensions
- curly_braces_in_flow_control_structures
- directives_ordering
- empty_catches
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- missing_whitespace_between_adjacent_strings
- no_runtimeType_toString
- null_closures
- omit_local_variable_types
- one_member_abstracts
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_double_quotes
- prefer_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
- prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_if_elements_to_conditional_expressions
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_int_literals
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- provide_deprecation_message
- prefer_typing_uninitialized_variables
- public_member_api_docs
- unawaited_futures
- unnecessary_brace_in_string_interps
- unnecessary_lambdas
- unnecessary_null_in_if_null_operators
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_string_escapes
- use_rethrow_when_possible
- use_string_buffers
- void_checks
- use_to_and_as_if_applicable
- sort_pub_dependencies
- prefer_is_not_operator
- prefer_iterable_whereType
- prefer_mixin
- prefer_null_aware_operators
- prefer_spread_collections

View file

@ -0,0 +1,12 @@
library nyxx_interactions;
import "package:nyxx/nyxx.dart";
part "src/ExtendNyxx.dart";
part "src/Interactions.dart";
part "src/events/InteractionEvent.dart";
part "src/models/CommandInteractionData.dart";
part "src/models/CommandInteractionOption.dart";
part "src/models/CommandInteractionOptionType.dart";
part "src/models/Interaction.dart";
part "src/models/InteractionType.dart";

View file

@ -0,0 +1,3 @@
part of nyxx_interactions;
extension on Nyxx {}

View file

@ -0,0 +1,9 @@
part of nyxx_interactions;
/// Interaction extension for Nyxx. Allows use of: Slash Commands.
class Interactions {
///
Interactions(Nyxx client, [bool force = false]) {
client.shardManager.rawEvent.listen((event) {});
}
}

View file

@ -0,0 +1,3 @@
part of nyxx_interactions;
class InteractionEvent {}

View file

@ -0,0 +1,11 @@
part of nyxx_interactions;
class CommandInteractionData {
final Snowflake id;
final String name;
final List<CommandInteractionOption>? options;
CommandInteractionData._new(this.id, this.name, this.options);
}

View file

@ -0,0 +1,8 @@
part of nyxx_interactions;
class CommandInteractionOption {
final String name;
final CommandInteractionOptionType? value;
final List<CommandInteractionOption>? options;
CommandInteractionOption._new(this.name, this.value, this.options);
}

View file

@ -0,0 +1,12 @@
part of nyxx_interactions;
enum CommandInteractionOptionType {
SUB_COMMAND,
SUB_COMMAND_GROUP,
STRING,
INTEGER,
BOOLEAN,
USER,
CHANNEL,
ROLE
}

View file

@ -0,0 +1,50 @@
part of nyxx_interactions;
class Interaction extends SnowflakeEntity implements Disposable {
/// Reference to bot instance
final Nyxx client;
late final InteractionType type;
late final CommandInteractionData? data;
late final Snowflake guild_id;
late final Snowflake channel_id;
late final User author;
late final String token;
late final int version;
Interaction._new(
this.client,
Map<String, dynamic> raw,
) : super(Snowflake(raw["id"])) {
switch (raw["type"] as int) {
case 1:
{
this.type = InteractionType.Ping;
break;
}
case 2:
{
this.type = InteractionType.ApplicationCommand;
break;
}
default:
{
this.type = InteractionType.Unknown;
break;
}
}
this.guild_id = Snowflake(raw["guild_id"]);
this.channel_id = Snowflake(raw["channel_id"]);
this.author =
}
@override
Future<void> dispose() => Future.value(null);
}

View file

@ -0,0 +1,7 @@
part of nyxx_interactions;
enum InteractionType {
Ping,
ApplicationCommand,
Unknown
}

View file

@ -0,0 +1,24 @@
name: nyxx_interactions
version: 0.0.0-dev.1
description: Interactions for Nyxx library
homepage: https://github.com/l7ssha/nyxx
repository: https://github.com/l7ssha/nyxx
documentation: https://github.com/l7ssha/nyxx/wiki
issue_tracker: https://github.com/l7ssha/nyxx/issue
environment:
sdk: '>=2.12.0-51.0.dev <3.0.0'
dependencies:
nyxx: "^1.1.0-dev.1"
http: "^0.13.0-nullsafety-dev"
dependency_overrides:
http:
git:
url: git://github.com/dart-lang/http.git
http_parser:
git:
url: git://github.com/dart-lang/http_parser.git
nyxx:
path: "../nyxx"