brainiac-discord 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7111ffc72dd19a6df6442ba8634e288c5085f06d696d51941a9fe64f9223a7db
4
- data.tar.gz: 6748908008c71f05cdf84eff403bfdeee5ef30bc950acb327de7e5556bbdfc3d
3
+ metadata.gz: b993813772110a77d5ac815a314c8eb7853083ac9cbd0c3322579e1f1b80ee40
4
+ data.tar.gz: 63d422ec1ffe6e8d3c12b267c5f14061d23651e863e69f891f6d558a7e553010
5
5
  SHA512:
6
- metadata.gz: a01f1a444b3714dce15727b9c6572295f20b77d1891abaac462da1ee49ebcc3cefedcf44a7e18d00e2eeb339c0a3c70d3513a481a4c8524751aa91d3d7fc59f1
7
- data.tar.gz: 72e2b469f446a22464134230c5d16a0c7d2d4ea3fee06adb450e795441b4061f87e9f0346ef8be50be573e9f355f6a15857e944ccc5469f3a40d337644f8fa71
6
+ metadata.gz: 72e8c931e9fb970da65743314407deebb8096f6f6e53263432ccf34fa637eed3e72b814df9de299f55f4ef162bf7bd50192c2c9a96cc077bb96defca272e06da
7
+ data.tar.gz: 476d43b17b45b289e661da974062445f1ff1a660410ab5679fd3a41777fbfaecccc7abe010b1d272cc848dc3610108fd1561b9517c140576ff58d5cff3efa51a
@@ -44,7 +44,8 @@ module Brainiac
44
44
  return
45
45
  end
46
46
 
47
- token ||= prompt_for_token(display_name, entry["open_browser"])
47
+ existing_id = discord_config.dig("user_mappings", display_name)
48
+ token ||= prompt_for_token(display_name, entry["open_browser"], existing_id)
48
49
  return unless token
49
50
 
50
51
  me = request(:get, "/users/@me", token)
@@ -68,15 +69,24 @@ module Brainiac
68
69
 
69
70
  private
70
71
 
71
- def prompt_for_token(display_name, browser)
72
+ # With a user_mappings entry the app already exists (the token was lost
73
+ # or rotated), so send the user straight to its Bot tab instead of
74
+ # "New Application". A bot's user ID is its application ID.
75
+ def prompt_for_token(display_name, browser, existing_id = nil)
72
76
  return nil unless $stdin.tty?
73
77
 
78
+ url = existing_id ? "#{PORTAL_URL}/#{existing_id}/bot" : PORTAL_URL
74
79
  puts ""
75
- puts " [Discord] Opening the developer portal in your browser…" if browser && open_url(PORTAL_URL)
76
- puts " [Discord] Create a bot for #{display_name} (the only manual step):"
77
- puts " 1. #{PORTAL_URL} → New Application → name it \"#{display_name}\""
78
- puts " 2. Bot tab → Reset Token → copy it"
79
- puts " Name, avatar, description and Message Content intent are set automatically."
80
+ puts " [Discord] Opening the developer portal in your browser…" if browser && open_url(url)
81
+ if existing_id
82
+ puts " [Discord] #{display_name} already has a Discord app, but its bot token isn't saved."
83
+ puts " #{url} → Reset Token → copy it"
84
+ else
85
+ puts " [Discord] Create a bot for #{display_name} (the only manual step):"
86
+ puts " 1. #{PORTAL_URL} → New Application → name it \"#{display_name}\""
87
+ puts " 2. Bot tab → Reset Token → copy it"
88
+ puts " Name, avatar, description and Message Content intent are set automatically."
89
+ end
80
90
  print " Bot token (blank to skip): "
81
91
  token = read_secret
82
92
  puts ""
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Discord
6
- VERSION = "0.0.24"
6
+ VERSION = "0.0.25"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainiac-discord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis