advanced_ruby_command_handler 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8582a5dd17fdc5237ae0e4a1eae97868ec5d5c17f55f35a66edd38128a6d3246
4
- data.tar.gz: 94e2882c42b578f1a05b85731828bbef17a652c2aecbfc87c8ab3861293b3909
3
+ metadata.gz: a11ba24daab81b761181e660e6dbec31f61e66f60e9921ae88ed025ff428dc6f
4
+ data.tar.gz: 63c1cf7eaf789454969ef8e7340573c11bc81c42a10de4381bf06524aaaccd61
5
5
  SHA512:
6
- metadata.gz: 0bb6817906ef0218909f3a440257eef6ea6596d4f45b53f67a108ac26fe8f8e5904376cd25d3b12ee0d24a8bead2c54519fc3760b4b83a2e7fbac0bd4740d129
7
- data.tar.gz: '008acad9ad58e3bf93f1b940fa44ae472e2d3fd0f2857b281a040e68f62e6783d7069940e89a3157408117f6c61decd5c58834946ddd5aa83acb4d0b48178f62'
6
+ metadata.gz: ff38ee1aa4a2d6a1bb6a11ae8b791f626746ca87bf68787e2d3da82ca549c1401de947c8ee952ca45030b098cdba81295e83bd5daae97ff4447a53ab1b95f87f
7
+ data.tar.gz: c450efad33bc9ee1070d3658dca1aa2297f0d69da7da99021ba83c3a865766819a6f52a018251cf1ff4ddd1c95aa0c44ef2d805e29f41d8363d653454600940b
@@ -1,37 +1,12 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: Ruby
9
-
10
- on:
11
- push:
12
- branches: [ main ]
13
- pull_request:
14
- branches: [ main ]
15
-
1
+ name: My workflow
2
+ on: [push, pull_request]
16
3
  jobs:
17
4
  test:
18
-
19
5
  runs-on: ubuntu-latest
20
- strategy:
21
- matrix:
22
- ruby-version: ['2.6', '2.7', '3.0']
23
-
24
6
  steps:
25
7
  - uses: actions/checkout@v2
26
- - name: Set up Ruby
27
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
- # uses: ruby/setup-ruby@v1
30
- uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
8
+ - uses: ruby/setup-ruby@v1
31
9
  with:
32
- ruby-version: ${{ matrix.ruby-version }}
10
+ ruby-version: 2.6 # Not needed with a .ruby-version file
33
11
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
- - name: Install dependencies
35
- run: bundle install
36
- - name: Run tests
37
- run: bundle exec rake
12
+ - run: bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- advanced_ruby_command_handler (2.0.0)
4
+ advanced_ruby_command_handler (2.0.1)
5
5
  discordrb
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  [![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://forthebadge.com)
3
3
 
4
- [![Les Laboratoires Ruby](https://invidget.switchblade.xyz/4P7XcmbDnt)](https://discord.gg/4P7XcmbDnt)
4
+ [Les Laboratoires Ruby](https://discord.gg/4P7XcmbDnt)
5
5
 
6
6
  # AdvancedRubyCommandHandler
7
7
  ## Installation
@@ -29,55 +29,65 @@ Firstly, you have to create a ruby file, where you put the followwing line:
29
29
  require "advanced_ruby_command_handler"
30
30
  ```
31
31
 
32
- Then, initialize the command handler. Specifying the directories and the config file path
32
+ Then, initialize the command handler. Specifying the directories and the modules.
33
33
 
34
34
  ```rb
35
- client = CommandHandler.new(commands_dir: "src/commands", events_dir: "src/events", config_file: "src/private/config.yml")
35
+ command_handler = CommandHandler.new(Hash[
36
+ :commands_dir => "src/commands/",
37
+ :events_dir => "src/events/",
38
+ :commands_module_name => "Commands",
39
+ :events_module_name => "Events"
40
+ ])
41
+ .load_commands
42
+ .load_events
36
43
  ```
37
- Note: if these files dose not exist, the command handler will create them
44
+ Note: if these directories dosen't exist, the command handler will create them
38
45
 
39
46
  And run the bot:
40
47
  ```ruby
41
- client.run
48
+ command_handler.client.run
42
49
  ```
43
50
 
44
51
  ### Events&Commands
45
52
 
46
53
  The command handler have base events as message or ready, but you can create your owns events (in events directory).
47
54
 
48
- Create a file with the name of your event (see https://www.rubydoc.info/github/meew0/discordrb/Discordrb/Events)
55
+ Create a file with the name of your event (see [https://www.rubydoc.info/github/meew0/discordrb/Discordrb/Events](the doc))
49
56
 
50
57
  And use the following template:
51
58
  ```ruby
59
+ # src/events/message.rb
52
60
  # frozen_string_literal: true
53
61
 
54
62
  module Events
55
- def self.<event>(client)
56
- client.<event> do
57
- client.console_logger.info("Event!")
63
+ # self.<event_name>
64
+ def self.message(command_handler)
65
+ Event.new(:message, command_handler.client) do |message|
66
+ Logger.check("Message! : #{message.content}")
58
67
  end
59
- end
68
+ end
60
69
  end
61
70
  ```
62
- Now, when the event will be emitted, the program will puts "Event!"
71
+ Now, when a message is sent, the program will puts "Message! : 'message content'"
63
72
 
64
73
  If you want to add some commands in your bot, you can create sub directories in your command directory.
65
74
  In these directories, you can create ruby files for commands, here's an example:
66
75
 
67
76
  ```ruby
77
+ # src/commands/utils/ping.rb
68
78
  # frozen_string_literal: true
69
79
 
70
- require_relative "advanced_ruby_command_handler"
71
-
72
80
  module Commands
73
- def self.hello
74
- CommandHandler::Command.new({
75
- :name => "hello"
76
- }) do |message, client|
77
- message.respond "Hello Discord!"
81
+ # self.<command_name>
82
+ def self.ping
83
+ Command.new(Hash[
84
+ :name => "ping"
85
+ ]) do |client, message|
86
+ message.respond "Pong!"
78
87
  end
79
88
  end
80
89
  end
90
+
81
91
  ```
82
92
 
83
93
  Now you can create events and commands ! ;)
@@ -5,12 +5,12 @@ require File.expand_path("base", File.dirname(__FILE__))
5
5
 
6
6
  module AdvancedRubyCommandHandler
7
7
  class Database < BaseDatabase
8
- attr_accessor :database, :path
8
+ attr_accessor :client, :path
9
9
 
10
10
  def initialize(path)
11
11
  @path = path
12
- @database = Mongo::Client.new(path)
13
- super(@database)
12
+ @client = Mongo::Client.new(path)
13
+ super(@client)
14
14
  end
15
15
  end
16
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdvancedRubyCommandHandler
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advanced_ruby_command_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - senchuu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-24 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discordrb