Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Get features from BETA #38

Merged
merged 80 commits into from
Jul 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
4c7b1e1
feat: Add join and leave events
vic256 Jul 5, 2022
5bdc7d7
feat: Add join request packet and rule event
vic256 Jul 5, 2022
45dd156
fix: Remove rule accept when guild member is update
vic256 Jul 6, 2022
0dde1b3
refactor: Rename delete by remove
vic256 Jul 6, 2022
c98803f
Merge pull request #26 from mineral-dart/member-events
LeadcodeDev Jul 6, 2022
8fef4cd
feat: add message post generation
LeadcodeDev Jul 8, 2022
7301561
Merge pull request #27 from mineral-dart/add-generate-file-message
LeadcodeDev Jul 8, 2022
f072b89
feat: Remove empty lines from environment file
LeadcodeDev Jul 8, 2022
7706ae8
Merge pull request #28 from mineral-dart/remove-empty-line-environment
LeadcodeDev Jul 8, 2022
98e293b
feat: Implement thumbnail into embeds
LeadcodeDev Jul 8, 2022
e9aeda3
Merge pull request #29 from mineral-dart/add-missing-thumbnail-embed
LeadcodeDev Jul 8, 2022
9a4ba48
feat: Implement logs reporter
LeadcodeDev Jul 8, 2022
909b6fa
Merge pull request #30 from mineral-dart/reporter
LeadcodeDev Jul 8, 2022
f5672da
fix: Reporter condition
LeadcodeDev Jul 8, 2022
74301c5
feat: implements voice state management
vic256 Jul 8, 2022
123e864
feat: implement global voice update event
vic256 Jul 8, 2022
de8cb88
feat: implement custom_id on voice connect
vic256 Jul 8, 2022
ebe09cb
fix: change url and discord return status code
vic256 Jul 10, 2022
3ef8ed4
refactor: change indentation
vic256 Jul 10, 2022
ccae289
fix: change member update url on move
vic256 Jul 10, 2022
ce4cbf2
Merge pull request #31 from mineral-dart/voice-events
LeadcodeDev Jul 10, 2022
a59cb74
feat: add disconnect
vic256 Jul 10, 2022
585195a
feat: add get user method
vic256 Jul 10, 2022
fdf03c5
fix: Use ChannelType instead of int
vic256 Jul 10, 2022
2ce27fe
feat: Infuse environment into events/commands/stores
LeadcodeDev Jul 11, 2022
4216d58
Merge pull request #32 from mineral-dart/voice-events
LeadcodeDev Jul 11, 2022
1b5e87f
Merge branch 'develop' of github.com:mineral-dart/core into develop
LeadcodeDev Jul 11, 2022
d031990
feat: Add getOrFail method
LeadcodeDev Jul 11, 2022
af4d193
feat: Add custom message
LeadcodeDev Jul 11, 2022
694a36c
docs: Write doc
LeadcodeDev Jul 11, 2022
a0b11ca
feat: Add find method
LeadcodeDev Jul 11, 2022
f9a3b8b
feat: Add findOrFail method
LeadcodeDev Jul 11, 2022
bcd26e7
feat: Work in progress
LeadcodeDev Jul 11, 2022
3409b53
feat: Work in progress
LeadcodeDev Jul 11, 2022
7047154
Merge pull request #33 from mineral-dart/add-more-collection-methods
LeadcodeDev Jul 11, 2022
bfe878b
feat: Add leave method
LeadcodeDev Jul 14, 2022
eae8096
feat: Implement send message to dm channel
LeadcodeDev Jul 14, 2022
7cf6a1e
feat: Improve DX
LeadcodeDev Jul 14, 2022
3109ca7
feat: Improve DX
LeadcodeDev Jul 14, 2022
6456e6e
feat: Improve DX
LeadcodeDev Jul 14, 2022
8aacf24
feat: Improve DX
LeadcodeDev Jul 14, 2022
2ed5a4d
Merge pull request #34 from mineral-dart/add-client-methods
LeadcodeDev Jul 14, 2022
0ba8811
refactor: Refactor folder name
LeadcodeDev Jul 14, 2022
962499c
refactor: Refactor folder name
LeadcodeDev Jul 14, 2022
43cf9a1
fix: Missing load commands
LeadcodeDev Jul 14, 2022
907c882
fix: Force lowercase
LeadcodeDev Jul 14, 2022
ae397bc
refactor: Rename BaseChannel → PartialChannel
LeadcodeDev Jul 14, 2022
db289d1
docs: Write User send message
LeadcodeDev Jul 16, 2022
ee992b6
docs: Write User getDisplayAvatarUrl
LeadcodeDev Jul 16, 2022
61daccc
docs: Write Color
LeadcodeDev Jul 16, 2022
96c1777
docs: Write moderation rules
LeadcodeDev Jul 16, 2022
d84e78f
docs: Write webhooks
LeadcodeDev Jul 16, 2022
35d7f85
docs: Write guildMember voices
LeadcodeDev Jul 16, 2022
bc3c8a4
docs: Write mineral_client.dart
LeadcodeDev Jul 16, 2022
0d958bf
docs: Write modal
LeadcodeDev Jul 16, 2022
c26dd00
docs: Write Guild
LeadcodeDev Jul 16, 2022
6366a44
docs: Write GuildMember
LeadcodeDev Jul 16, 2022
9369c56
docs: Write GuildRoleManager
LeadcodeDev Jul 16, 2022
0526f7c
docs: Write MemberRoleManager
LeadcodeDev Jul 16, 2022
0e18d4e
docs: Write CommandInteraction
LeadcodeDev Jul 16, 2022
9acf8d3
docs: Write Interaction
LeadcodeDev Jul 16, 2022
534c125
docs: Write ModalInteraction
LeadcodeDev Jul 16, 2022
189e8ca
docs: Write SelectMenuInteraction
LeadcodeDev Jul 16, 2022
f5107b5
refactor: Move managers
LeadcodeDev Jul 16, 2022
fce51df
refactor: Remove unused method
LeadcodeDev Jul 16, 2022
5e9dafa
docs: Write MessageEmbed
LeadcodeDev Jul 16, 2022
2b02410
refactor: Fix member_role_manager break link
LeadcodeDev Jul 16, 2022
fbc4426
docs: Add highlight title
LeadcodeDev Jul 16, 2022
4f1c210
docs: Add Example case
LeadcodeDev Jul 16, 2022
e56db07
Merge pull request #35 from mineral-dart/write-documentation
LeadcodeDev Jul 16, 2022
4ae5251
feat: Implement edit message
LeadcodeDev Jul 16, 2022
83ac4b3
feat: Work on documentation settings
LeadcodeDev Jul 16, 2022
85ce3bc
docs: Write README
LeadcodeDev Jul 16, 2022
1448a04
chore: Create .pubignore
LeadcodeDev Jul 16, 2022
817f0d1
fix: Work in progress
LeadcodeDev Jul 16, 2022
28a78cc
fix: user is bot
LeadcodeDev Jul 16, 2022
ab33520
fix: replace late by nullable field
vic256 Jul 16, 2022
1970f9f
refactor: Move delete channel method
LeadcodeDev Jul 16, 2022
1dab713
Merge branch 'develop' of github.com:mineral-dart/core into develop
LeadcodeDev Jul 16, 2022
a3dd402
fix: Return null if guild feature don't exist
vic256 Jul 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assets/
48 changes: 14 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
# Mineral
![banner](https://raw.githubusercontent.com/mineral-dart/core/develop/assets/images/banner.png)

For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
Mineral is a robust, powerful and scalable framework designed to let you develop discord bots with the Dart language.

For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->
The Mineral framework currently allows you to use the latest Discord features:
- Slashcommands/Subcommands/Subcommand group
- Modals
- Scheduled events
- Auto-moderation
- Select menus
- Buttons
- Ephemeral messages

TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.
And much more...

## Features
Join our ranks and add your contribution to the best discord framework for Dart 💪

TODO: List what your package can do. Maybe include images, gifs, or videos.

## Getting started

TODO: List prerequisites and provide or point to information on how to
start using the package.

## Usage

TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.

```dart
const like = 'sample';
```

## Additional information

TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.
https://github.com/mineral-dart
Binary file added assets/images/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion bin/mineral.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:args/args.dart';
import 'package:mineral/api.dart';
import 'package:mineral/core.dart';
import 'package:mineral/src/internal/entities/cli_manager.dart';
import 'package:mineral/src/internal/managers/cli_manager.dart';

Future<void> main (List<String> arguments) async {
Kernel kernel = Kernel();
kernel.loadConsole();

final ArgParser parser = ArgParser();

final makeCommandParser = ArgParser();
Expand Down
2 changes: 2 additions & 0 deletions dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dartdoc:
favicon: assets/images/icon.png
10 changes: 4 additions & 6 deletions lib/api.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/// The api is the Map of all the classes, enumerations of the framework
///
/// {@category Api}
library api;

export 'src/api/client/mineral_client.dart' show MineralClient, ClientActivity, ClientStatus, Intent;
Expand All @@ -11,8 +9,7 @@ export 'src/api/user.dart' show User;
export 'src/api/status.dart' show Status, StatusType;
export 'src/api/activity.dart' show Activity;
export 'src/api/guilds/guild_member.dart' show GuildMember;
export 'src/api/guilds/member_role_manager.dart' show MemberRoleManager;
export 'src/api/voice.dart' show Voice;
export 'src/api/managers/member_role_manager.dart' show MemberRoleManager;

export 'src/api/guilds/guild.dart' show Guild;
export 'src/api/moderation_rule.dart' show ModerationEventType, ModerationTriggerType, ModerationPresetType, ModerationActionType, ModerationTriggerMetadata, ModerationActionMetadata, ModerationAction, ModerationRule;
Expand All @@ -27,8 +24,8 @@ export 'src/api/channels/text_based_channel.dart' show TextBasedChannel;
export 'src/api/channels/text_channel.dart' show TextChannel;
export 'src/api/channels/category_channel.dart' show CategoryChannel;

export 'src/api/message.dart' show Message;
export 'src/api/message_embed.dart' show MessageEmbed, Footer, Image, Author, Field;
export 'src/api/messages/message.dart' show Message;
export 'src/api/messages/message_embed.dart' show MessageEmbed, Footer, Image, Thumbnail, Author, Field;
export 'src/api/color.dart' show Color;

export 'src/api/emoji.dart' show Emoji;
Expand All @@ -48,5 +45,6 @@ export 'src/api/interactions/select_menu_interaction.dart' show SelectMenuIntera

export 'src/api/utils.dart';
export 'src/internal/extensions/collection.dart';
export 'src/internal/extensions/string.dart';

typedef Snowflake = String;
41 changes: 30 additions & 11 deletions lib/console.dart
Original file line number Diff line number Diff line change
@@ -1,56 +1,75 @@
/// Console to print formatted and beautifully messages
library console;

import 'package:mineral/core.dart';
import 'package:mineral/src/internal/managers/reporter_manager.dart';

class Console {
static void log ({ required String message, String level = "info"}) {
if(level == "debug") {
static void log ({ required String message, String level = 'info'}) {
if (level == 'debug') {
final Environment environment = ioc.singleton(ioc.services.environment);
final String? logLevel = environment.get('LOG_LEVEL');

if (logLevel != "debug") return;
if (logLevel != 'debug') return;
}

print(message);
}

static debug ({ String prefix = 'debug', required String message }) {
ReporterManager? reporter = ioc.singleton(ioc.services.reporter);

if (reporter != null && reporter.reportLevel == 'debug') {
_report('[ $prefix ] $message');
}

String p = ColorList.white(prefix);
log(message: "[ $p ] $message", level: "debug");
log(message: '[ $p ] $message', level: 'debug');
}

static info ({ String prefix = 'info', required String message }) {
String p = ColorList.blue(prefix);
log(message: "[ $p ] $message", level: "info");
log(message: '[ $p ] $message', level: 'info');
_report('[ $prefix ] $message');
}

static success ({ String prefix = 'success', required String message }) {
String p = ColorList.green(prefix);
log(message: "[ $p ] $message", level: "info");
log(message: '[ $p ] $message', level: 'info');
_report('[ $prefix ] $message');
}

static error ({ String prefix = 'error', required String message }) {
log(message: getErrorMessage(prefix: ColorList.red(prefix), message: message), level: "error");
log(message: getErrorMessage(prefix: ColorList.red(prefix), message: message), level: 'error');
_report('[ $prefix ] $message');
}

static warn ({ String prefix = 'warn', required String message }) {
log(message: getWarnMessage(prefix: ColorList.yellow(prefix), message: message), level: "warn");
log(message: getWarnMessage(prefix: ColorList.yellow(prefix), message: message), level: 'warn');
_report('[ $prefix ] $message');
}

static String getWarnMessage ({ String? prefix = 'warn', required String message }) {
String p = ColorList.yellow(prefix!);
return "[ $p ] $message";
return '[ $p ] $message';
}

static String getErrorMessage ({ String? prefix = 'error', required String message }) {
String p = ColorList.red(prefix!);
return "[ $p ] $message";
return '[ $p ] $message';
}

static _report (String message) {
ReporterManager? reporter = ioc.singleton(ioc.services.reporter);
if (reporter != null) {
reporter.write(message);
}
}
}

class ColorList {
static String black (String text) => '\x1B[30m$text\x1B[0m';
static String red (String text) => '\x1B[31m$text\x1B[0m';
static String red (String text) => '\x1B[186m$text\x1B[0m';
static String green (String text) => '\x1B[32m$text\x1B[0m';
static String yellow (String text) => '\x1B[33m$text\x1B[0m';
static String blue (String text) => '\x1B[34m$text\x1B[0m';
Expand Down
9 changes: 5 additions & 4 deletions lib/core.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// 🧡 The neuralgic heart of the application, this module gathers all the functionalities of the framework.
library core;

export 'src/internal/environment.dart' show Environment;
Expand All @@ -7,7 +8,7 @@ export 'src/internal/ioc.dart' show ioc, Service;

export 'src/constants.dart';
export 'src/internal/http.dart';
export 'src/internal/entities/event_manager.dart' show Event, Events, MineralEvent;
export 'src/internal/entities/command_manager.dart' show Command, MineralCommand, Option, OptionType, OptionChoice, Subcommand, CommandGroup;
export 'src/internal/entities/store_manager.dart' show Store, MineralStore;
export 'src/internal/entities/module_manager.dart' show Module, MineralModule;
export 'src/internal/managers/event_manager.dart' show Event, Events, MineralEvent;
export 'src/internal/managers/command_manager.dart' show Command, MineralCommand, Option, OptionType, OptionChoice, Subcommand, CommandGroup;
export 'src/internal/managers/store_manager.dart' show Store, MineralStore;
export 'src/internal/managers/module_manager.dart' show Module, MineralModule;
1 change: 1 addition & 0 deletions lib/exception.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Core exceptions
library exception;

export 'src/exceptions/token_exception.dart';
Expand Down
14 changes: 1 addition & 13 deletions lib/helper.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Helper class to simplify actions
library helper;

import 'dart:convert';
Expand Down Expand Up @@ -37,17 +38,4 @@ class Helper {

return _permissions;
}

static toPascalCase (String value) {
List<String> words = value.split('_');
return words.map((word) => "${word[0].toUpperCase()}${word.substring(1)}").join('');
}

static toCapitalCase (String value) {
return '${value[0].toUpperCase()}${value.substring(1)}';
}

static String toSnakeCase (String value) {
return value.split(RegExp(r"(?=[A-Z])")).join('_').toLowerCase();
}
}
5 changes: 2 additions & 3 deletions lib/internal.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// The internal library is the collection of all classes needed by the framework to work.
///
/// {@category Internal}
/// @nodoc
library internal;

export 'src/internal/websockets/websockets.dart';
export 'src/internal/websockets/websockets.dart';
1 change: 0 additions & 1 deletion lib/src/api/channels/category_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:convert';
import 'package:http/http.dart';
import 'package:mineral/api.dart';
import 'package:mineral/core.dart';
import 'package:mineral/src/api/channels/channel.dart';
import 'package:mineral/src/api/managers/webhook_manager.dart';

class CategoryChannel extends Channel {
Expand Down
17 changes: 13 additions & 4 deletions lib/src/api/channels/channel.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:http/http.dart';
import 'package:mineral/api.dart';
import 'package:mineral/core.dart';
import 'package:mineral/src/api/channels/partial_channel.dart';
import 'package:mineral/src/api/managers/webhook_manager.dart';

enum ChannelType {
Expand Down Expand Up @@ -36,8 +37,7 @@ Map<ChannelType, Channel Function(dynamic payload)> channels = {
// 'GUILD_FORUM': () => ,
};

class Channel {
Snowflake id;
class Channel extends PartialChannel {
ChannelType type;
Snowflake? guildId;
late Guild? guild;
Expand All @@ -50,7 +50,7 @@ class Channel {
WebhookManager webhooks;

Channel({
required this.id,
required id,
required this.type,
required this.guildId,
required this.position,
Expand All @@ -59,7 +59,7 @@ class Channel {
required this.parentId,
required this.flags,
required this.webhooks,
});
}): super(id: id);

Future<T> setLabel<T extends Channel> (String label) async {
Http http = ioc.singleton(ioc.services.http);
Expand Down Expand Up @@ -95,6 +95,15 @@ class Channel {
return this as T;
}

Future<bool> delete () async {
Http http = ioc.singleton(ioc.services.http);
Response response = await http.destroy(url: "/channels/$id");

guild?.channels.cache.remove(id);

return response.statusCode == 200;
}

@override
String toString () => "<#$id>";
}
38 changes: 38 additions & 0 deletions lib/src/api/channels/dm_channel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:mineral/api.dart';
import 'package:mineral/core.dart';
import 'package:mineral/src/api/channels/partial_channel.dart';
import 'package:mineral/src/api/managers/message_manager.dart';

class DmChannel extends PartialChannel {
Snowflake? lastMessageId;
MessageManager messages;
Map<Snowflake, User> recipients;

DmChannel({
required id,
required this.lastMessageId,
required this.messages,
required this.recipients,
}): super(id: id);

factory DmChannel.from({ required dynamic payload }) {
MineralClient client = ioc.singleton(ioc.services.client);

Map<Snowflake, User> users = {};
if (payload['recipients'] != null) {
for (dynamic element in payload['recipients']) {
User? user = client.users.cache.get(element['id']);
user ??= User.from(element);

users.putIfAbsent(user.id, () => user!);
}
}

return DmChannel(
id: payload['id'],
lastMessageId: payload['last_message_id'],
messages: MessageManager(payload['id'], null),
recipients: users
);
}
}
7 changes: 7 additions & 0 deletions lib/src/api/channels/partial_channel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:mineral/api.dart';

class PartialChannel {
Snowflake id;

PartialChannel({ required this.id });
}
4 changes: 2 additions & 2 deletions lib/src/api/channels/public_thread.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class PublicThread extends Channel {

String? name;
Snowflake? lastMessageId;
DateTime? lastPinTimstamp;
DateTime? lastPinTimestamp;

PublicThread({
required Snowflake id,
Expand Down Expand Up @@ -48,4 +48,4 @@ class PublicThread extends Channel {
webhooks: payload['webhooks'],
);
}
}
}
Loading