Class: Discorb::GuildTemplate
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- Discorb::GuildTemplate
- Defined in:
- lib/discorb/guild_template.rb
Overview
Represents a guild template.
Defined Under Namespace
Classes: TemplateGuild
Instance Attribute Summary collapse
-
#code -> String
readonly
The code of the template.
-
#created_at -> Time
readonly
The time this template was created.
-
#creator -> Discorb::User
readonly
The user who created this template.
-
#description -> String
readonly
The description of the template.
-
#is_dirty -> Boolean
(also: #dirty?)
readonly
Whether this template is dirty.
-
#name -> String
readonly
The name of the template.
-
#serialized_source_guild -> Discorb::GuildTemplate::TemplateGuild
(also: #content)
readonly
The guild where the template was created.
- #source_guild -> nil, Discorb::Guild readonly
-
#source_guild_id -> Discorb::Guild
readonly
The guild where the template was created.
-
#updated_at -> Time
readonly
The time this template was last updated.
-
#usage_count -> Integer
readonly
The number of times this template has been used.
Instance Method Summary collapse
-
#delete! -> Async::Task<void>
(also: #destroy!)
Delete the template.
-
#edit(name = nil, description = Discorb::Unset) -> Async::Task<void>
(also: #modify)
Edit the template.
-
#update -> Async::Task<void>
Update the template.
Methods inherited from DiscordModel
Instance Attribute Details
#code -> String (readonly)
Returns The code of the template.
9 10 11 |
# File 'lib/discorb/guild_template.rb', line 9 def code @code end |
#created_at -> Time (readonly)
Returns The time this template was created.
19 20 21 |
# File 'lib/discorb/guild_template.rb', line 19 def created_at @created_at end |
#creator -> Discorb::User (readonly)
Returns The user who created this template.
17 18 19 |
# File 'lib/discorb/guild_template.rb', line 17 def creator @creator end |
#description -> String (readonly)
Returns The description of the template.
13 14 15 |
# File 'lib/discorb/guild_template.rb', line 13 def description @description end |
#is_dirty -> Boolean (readonly) Also known as: dirty?
Returns Whether this template is dirty.
28 29 30 |
# File 'lib/discorb/guild_template.rb', line 28 def is_dirty @is_dirty end |
#name -> String (readonly)
Returns The name of the template.
11 12 13 |
# File 'lib/discorb/guild_template.rb', line 11 def name @name end |
#serialized_source_guild -> Discorb::GuildTemplate::TemplateGuild (readonly) Also known as: content
Returns The guild where the template was created.
25 26 27 |
# File 'lib/discorb/guild_template.rb', line 25 def serialized_source_guild @serialized_source_guild end |
#source_guild -> nil, Discorb::Guild (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
|
# File 'lib/discorb/guild_template.rb', line 31
|
#source_guild_id -> Discorb::Guild (readonly)
Returns The guild where the template was created.
23 24 25 |
# File 'lib/discorb/guild_template.rb', line 23 def source_guild_id @source_guild_id end |
#updated_at -> Time (readonly)
Returns The time this template was last updated.
21 22 23 |
# File 'lib/discorb/guild_template.rb', line 21 def updated_at @updated_at end |
#usage_count -> Integer (readonly)
Returns The number of times this template has been used.
15 16 17 |
# File 'lib/discorb/guild_template.rb', line 15 def usage_count @usage_count end |
Instance Method Details
#delete! -> Async::Task<void> Also known as: destroy!
Delete the template.
92 93 94 95 96 |
# File 'lib/discorb/guild_template.rb', line 92 def delete! Async do @client.http.request(Route.new("/guilds/#{@source_guild_id}/templates/#{@code}", "//guilds/:guild_id/templates/:code", :delete)).wait end end |
#edit(name = nil, description = Discorb::Unset) -> Async::Task<void> Also known as: modify
The arguments of this method are defaultly set to Discorb::Unset
. Specify value to set the value, if not don't specify or specify Discorb::Unset
.
Edit the template.
62 63 64 65 66 67 68 69 |
# File 'lib/discorb/guild_template.rb', line 62 def edit(name = nil, description = Discorb::Unset) Async do payload = {} payload[:name] = name if name payload[:description] = description if description != Discorb::Unset @client.http.request(Route.new("/guilds/#{@source_guild_id}/templates/#{@code}", "//guilds/:guild_id/templates/:code", :patch), payload).wait end end |
#update -> Async::Task<void>
Update the template.
79 80 81 82 83 84 |
# File 'lib/discorb/guild_template.rb', line 79 def update Async do _resp, data = @client.http.request(Route.new("/guilds/#{@source_guild_id}/templates/#{@code}", "//guilds/:guild_id/templates/:code", :put)).wait _set_data(data) end end |