discorb 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +5 -1
- data/docs/cli/init.md +15 -1
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/exe/init.rb +58 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4197e97af48fc47c1062d0327ccc048cb8317701be673a2bce035b108f7cade
|
4
|
+
data.tar.gz: 7c48b69868636ca4722e3ec2aee50bb6148174c1cfdcf0b31a2d227110aefa76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7215a8dc3b0c3502f1948838aac8c08cc0ae0ac4c7c874dcc695c48fc5ead628f36718f08e7e2854aa46f191e9f0c851ff23a6f96aa82edaa3c7d7c912ff490b
|
7
|
+
data.tar.gz: 7ade9dcd2e56efb2513928a021d0f557d827a230b02f2c23ee6691cc9decc919f2e51b19e9e95fab13f535e8cc112cc8f3a29ac36e3a2144651a625e60ea0e25
|
data/Changelog.md
CHANGED
@@ -186,4 +186,8 @@ end
|
|
186
186
|
- Add: Add `Member#guild_permissions` as alias of `Member#permissions`
|
187
187
|
- Add: Add default role to `Member#roles`
|
188
188
|
- Fix: Fix error in `Integration#_set_data`
|
189
|
-
- Change: Reverse `Member#roles`
|
189
|
+
- Change: Reverse `Member#roles`
|
190
|
+
|
191
|
+
## 0.7.3
|
192
|
+
|
193
|
+
- Add: Improve `discorb init`
|
data/docs/cli/init.md
CHANGED
@@ -32,6 +32,18 @@ If true, the command will initialize git and commit the initial files with commi
|
|
32
32
|
Use `git commit --amend -m "..."` to change the commit message.
|
33
33
|
Default to false.
|
34
34
|
|
35
|
+
### `--[no-]desc`
|
36
|
+
|
37
|
+
Whether to create a description file.
|
38
|
+
If true, the command will create a `.env.sample` and `README.md` file.
|
39
|
+
Default to false.
|
40
|
+
|
41
|
+
### `-n` `--name`
|
42
|
+
|
43
|
+
The name of the project.
|
44
|
+
It will be used in the `README.md` file.
|
45
|
+
Default to the directory name.
|
46
|
+
|
35
47
|
### `-t`, `--token`
|
36
48
|
|
37
49
|
The name of token environment variable.
|
@@ -49,7 +61,9 @@ The following files will be created:
|
|
49
61
|
| File | Description |
|
50
62
|
| ---- | ----------- |
|
51
63
|
| `.env` | Environment variables. |
|
64
|
+
| `main.rb` | Main script. |
|
52
65
|
| `.gitignore` | Git ignore file. Won't be created if `--git` is false. |
|
53
66
|
| `Gemfile` | Gemfile. Won't be created if `--bundle` is false. |
|
54
67
|
| `Gemfile.lock` | Gemfile lock file. Won't be created if `--bundle` is false. |
|
55
|
-
| `
|
68
|
+
| `README.md` | Readme file. Won't be created if `--desc` is false. |
|
69
|
+
| `.env.sample` | Sample environment variables. Won't be created if `--desc` is false. |
|
data/lib/discorb/common.rb
CHANGED
@@ -4,7 +4,7 @@ module Discorb
|
|
4
4
|
# @return [String] The API base URL.
|
5
5
|
API_BASE_URL = "https://discord.com/api/v9"
|
6
6
|
# @return [String] The version of discorb.
|
7
|
-
VERSION = "0.7.
|
7
|
+
VERSION = "0.7.3"
|
8
8
|
# @return [String] The user agent for the bot.
|
9
9
|
USER_AGENT = "DiscordBot (https://github.com/discorb-lib/discorb #{VERSION}) Ruby/#{RUBY_VERSION}"
|
10
10
|
|
data/lib/discorb/exe/init.rb
CHANGED
@@ -96,11 +96,46 @@ FILES = {
|
|
96
96
|
gem "discorb", "~> #{Discorb::VERSION}"
|
97
97
|
gem "dotenv", "~> 2.7"
|
98
98
|
RUBY
|
99
|
+
".env.sample" => <<~BASH,
|
100
|
+
%<token>s=
|
101
|
+
BASH
|
102
|
+
"README.md" => <<~MARKDOWN,
|
103
|
+
# %<name>s
|
104
|
+
|
105
|
+
Welcome to your bot: %<name>s!
|
106
|
+
|
107
|
+
TODO: Write your bot's description here.
|
108
|
+
|
109
|
+
## Usage
|
110
|
+
|
111
|
+
TODO: Write your bot's usage here.
|
112
|
+
|
113
|
+
## Features
|
114
|
+
|
115
|
+
TODO: Write your bot's features here.
|
116
|
+
|
117
|
+
## How to host
|
118
|
+
|
119
|
+
1. Clone the repository.
|
120
|
+
2. Run `bundle install`.
|
121
|
+
3. Get your bot's token from the Discord developer portal.
|
122
|
+
4. Copy `.env.sample` to `.env` and fill in the token.
|
123
|
+
5. Run `bundle exec discorb run`.
|
124
|
+
|
125
|
+
TODO: Write your own customizations here.
|
126
|
+
|
127
|
+
## License
|
128
|
+
|
129
|
+
TODO: Write your bot's license here.
|
130
|
+
See https://choosealicense.com/ for more information.
|
131
|
+
https://rubygems.org/gems/license-cli may be useful.
|
132
|
+
|
133
|
+
MARKDOWN
|
99
134
|
}
|
100
135
|
|
101
136
|
# @!visibility private
|
102
137
|
def create_file(name)
|
103
|
-
File.write($path + "/#{name}", format(FILES[name], token: $values[:token]), mode: "wb")
|
138
|
+
File.write($path + "/#{name}", format(FILES[name], token: $values[:token], name: $values[:name]), mode: "wb")
|
104
139
|
end
|
105
140
|
|
106
141
|
# @!visibility private
|
@@ -132,6 +167,14 @@ def git_init
|
|
132
167
|
" to change commit message of initial commit.\n"
|
133
168
|
end
|
134
169
|
|
170
|
+
# @!visibility private
|
171
|
+
def make_descs
|
172
|
+
iputs "Making descriptions..."
|
173
|
+
create_file(".env.sample")
|
174
|
+
create_file("README.md")
|
175
|
+
sputs "Made descriptions.\n"
|
176
|
+
end
|
177
|
+
|
135
178
|
opt = OptionParser.new <<~BANNER
|
136
179
|
A tool to make a new project.
|
137
180
|
|
@@ -145,6 +188,8 @@ $values = {
|
|
145
188
|
git: false,
|
146
189
|
force: false,
|
147
190
|
token: "TOKEN",
|
191
|
+
descs: false,
|
192
|
+
name: nil,
|
148
193
|
}
|
149
194
|
|
150
195
|
opt.on("--[no-]bundle", "Whether to use bundle. Default to true.") do |v|
|
@@ -155,10 +200,18 @@ opt.on("--[no-]git", "Whether to initialize git. Default to false.") do |v|
|
|
155
200
|
$values[:git] = v
|
156
201
|
end
|
157
202
|
|
203
|
+
opt.on("--[no-]descs", "Whether to put some file for description. Default to false.") do |v|
|
204
|
+
$values[:descs] = v
|
205
|
+
end
|
206
|
+
|
158
207
|
opt.on("-t NAME", "--token NAME", "The name of token environment variable. Default to TOKEN.") do |v|
|
159
208
|
$values[:token] = v
|
160
209
|
end
|
161
210
|
|
211
|
+
opt.on("-n NAME", "--name NAME", "The name of your project. Default to the directory name.") do |v|
|
212
|
+
$values[:name] = v
|
213
|
+
end
|
214
|
+
|
162
215
|
opt.on("-f", "--force", "Whether to force use directory. Default to false.") do |v|
|
163
216
|
$values[:force] = v
|
164
217
|
end
|
@@ -187,10 +240,14 @@ if (dir = ARGV[0])
|
|
187
240
|
Dir.chdir($path)
|
188
241
|
end
|
189
242
|
|
243
|
+
$values[:name] ||= Dir.pwd.split("/").last
|
244
|
+
|
190
245
|
bundle_init if $values[:bundle]
|
191
246
|
|
192
247
|
make_files
|
193
248
|
|
194
249
|
git_init if $values[:git]
|
195
250
|
|
251
|
+
make_descs if $values[:descs]
|
252
|
+
|
196
253
|
sputs "\nSuccessfully made a new project at \e[32m#{$path}\e[92m."
|