id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
12,300
mongodb/mongoid
lib/mongoid/config.rb
Mongoid.Config.connect_to
def connect_to(name, options = { read: { mode: :primary }}) self.clients = { default: { database: name, hosts: [ "localhost:27017" ], options: options } } end
ruby
def connect_to(name, options = { read: { mode: :primary }}) self.clients = { default: { database: name, hosts: [ "localhost:27017" ], options: options } } end
[ "def", "connect_to", "(", "name", ",", "options", "=", "{", "read", ":", "{", "mode", ":", ":primary", "}", "}", ")", "self", ".", "clients", "=", "{", "default", ":", "{", "database", ":", "name", ",", "hosts", ":", "[", "\"localhost:27017\"", "]", ...
Connect to the provided database name on the default client. @note Use only in development or test environments for convenience. @example Set the database to connect to. config.connect_to("mongoid_test") @param [ String ] name The database name. @since 3.0.0
[ "Connect", "to", "the", "provided", "database", "name", "on", "the", "default", "client", "." ]
56976e32610f4c2450882b0bfe14da099f0703f4
https://github.com/mongodb/mongoid/blob/56976e32610f4c2450882b0bfe14da099f0703f4/lib/mongoid/config.rb#L67-L75
12,301
mongodb/mongoid
lib/mongoid/config.rb
Mongoid.Config.load!
def load!(path, environment = nil) settings = Environment.load_yaml(path, environment) if settings.present? Clients.disconnect Clients.clear load_configuration(settings) end settings end
ruby
def load!(path, environment = nil) settings = Environment.load_yaml(path, environment) if settings.present? Clients.disconnect Clients.clear load_configuration(settings) end settings end
[ "def", "load!", "(", "path", ",", "environment", "=", "nil", ")", "settings", "=", "Environment", ".", "load_yaml", "(", "path", ",", "environment", ")", "if", "settings", ".", "present?", "Clients", ".", "disconnect", "Clients", ".", "clear", "load_configur...
Load the settings from a compliant mongoid.yml file. This can be used for easy setup with frameworks other than Rails. @example Configure Mongoid. Mongoid.load!("/path/to/mongoid.yml") @param [ String ] path The path to the file. @param [ String, Symbol ] environment The environment to load. @since 2.0.1
[ "Load", "the", "settings", "from", "a", "compliant", "mongoid", ".", "yml", "file", ".", "This", "can", "be", "used", "for", "easy", "setup", "with", "frameworks", "other", "than", "Rails", "." ]
56976e32610f4c2450882b0bfe14da099f0703f4
https://github.com/mongodb/mongoid/blob/56976e32610f4c2450882b0bfe14da099f0703f4/lib/mongoid/config.rb#L98-L106
12,302
mongodb/mongoid
lib/mongoid/config.rb
Mongoid.Config.register_model
def register_model(klass) LOCK.synchronize do models.push(klass) unless models.include?(klass) end end
ruby
def register_model(klass) LOCK.synchronize do models.push(klass) unless models.include?(klass) end end
[ "def", "register_model", "(", "klass", ")", "LOCK", ".", "synchronize", "do", "models", ".", "push", "(", "klass", ")", "unless", "models", ".", "include?", "(", "klass", ")", "end", "end" ]
Register a model in the application with Mongoid. @example Register a model. config.register_model(Band) @param [ Class ] klass The model to register. @since 3.1.0
[ "Register", "a", "model", "in", "the", "application", "with", "Mongoid", "." ]
56976e32610f4c2450882b0bfe14da099f0703f4
https://github.com/mongodb/mongoid/blob/56976e32610f4c2450882b0bfe14da099f0703f4/lib/mongoid/config.rb#L129-L133
12,303
mongodb/mongoid
lib/mongoid/config.rb
Mongoid.Config.load_configuration
def load_configuration(settings) configuration = settings.with_indifferent_access self.options = configuration[:options] self.clients = configuration[:clients] set_log_levels end
ruby
def load_configuration(settings) configuration = settings.with_indifferent_access self.options = configuration[:options] self.clients = configuration[:clients] set_log_levels end
[ "def", "load_configuration", "(", "settings", ")", "configuration", "=", "settings", ".", "with_indifferent_access", "self", ".", "options", "=", "configuration", "[", ":options", "]", "self", ".", "clients", "=", "configuration", "[", ":clients", "]", "set_log_le...
From a hash of settings, load all the configuration. @example Load the configuration. config.load_configuration(settings) @param [ Hash ] settings The configuration settings. @since 3.1.0
[ "From", "a", "hash", "of", "settings", "load", "all", "the", "configuration", "." ]
56976e32610f4c2450882b0bfe14da099f0703f4
https://github.com/mongodb/mongoid/blob/56976e32610f4c2450882b0bfe14da099f0703f4/lib/mongoid/config.rb#L143-L148
12,304
mongodb/mongoid
lib/mongoid/config.rb
Mongoid.Config.truncate!
def truncate! Clients.default.database.collections.each do |collection| collection.find.delete_many end and true end
ruby
def truncate! Clients.default.database.collections.each do |collection| collection.find.delete_many end and true end
[ "def", "truncate!", "Clients", ".", "default", ".", "database", ".", "collections", ".", "each", "do", "|", "collection", "|", "collection", ".", "find", ".", "delete_many", "end", "and", "true", "end" ]
Truncate all data in all collections, but not the indexes. @example Truncate all collection data. Mongoid::Config.truncate! @note This will be slower than purge! @return [ true ] true. @since 2.0.2
[ "Truncate", "all", "data", "in", "all", "collections", "but", "not", "the", "indexes", "." ]
56976e32610f4c2450882b0bfe14da099f0703f4
https://github.com/mongodb/mongoid/blob/56976e32610f4c2450882b0bfe14da099f0703f4/lib/mongoid/config.rb#L202-L206
12,305
mongodb/mongoid
lib/mongoid/config.rb
Mongoid.Config.options=
def options=(options) if options options.each_pair do |option, value| Validators::Option.validate(option) send("#{option}=", value) end end end
ruby
def options=(options) if options options.each_pair do |option, value| Validators::Option.validate(option) send("#{option}=", value) end end end
[ "def", "options", "=", "(", "options", ")", "if", "options", "options", ".", "each_pair", "do", "|", "option", ",", "value", "|", "Validators", "::", "Option", ".", "validate", "(", "option", ")", "send", "(", "\"#{option}=\"", ",", "value", ")", "end", ...
Set the configuration options. Will validate each one individually. @example Set the options. config.options = { raise_not_found_error: true } @param [ Hash ] options The configuration options. @since 3.0.0
[ "Set", "the", "configuration", "options", ".", "Will", "validate", "each", "one", "individually", "." ]
56976e32610f4c2450882b0bfe14da099f0703f4
https://github.com/mongodb/mongoid/blob/56976e32610f4c2450882b0bfe14da099f0703f4/lib/mongoid/config.rb#L216-L223
12,306
thoughtbot/clearance
lib/clearance/authorization.rb
Clearance.Authorization.deny_access
def deny_access(flash_message = nil) respond_to do |format| format.any(:js, :json, :xml) { head :unauthorized } format.any { redirect_request(flash_message) } end end
ruby
def deny_access(flash_message = nil) respond_to do |format| format.any(:js, :json, :xml) { head :unauthorized } format.any { redirect_request(flash_message) } end end
[ "def", "deny_access", "(", "flash_message", "=", "nil", ")", "respond_to", "do", "|", "format", "|", "format", ".", "any", "(", ":js", ",", ":json", ",", ":xml", ")", "{", "head", ":unauthorized", "}", "format", ".", "any", "{", "redirect_request", "(", ...
Responds to unauthorized requests in a manner fitting the request format. `js`, `json`, and `xml` requests will receive a 401 with no body. All other formats will be redirected appropriately and can optionally have the flash message set. When redirecting, the originally requested url will be stored in the session...
[ "Responds", "to", "unauthorized", "requests", "in", "a", "manner", "fitting", "the", "request", "format", ".", "js", "json", "and", "xml", "requests", "will", "receive", "a", "401", "with", "no", "body", ".", "All", "other", "formats", "will", "be", "redir...
1623cdeb648f33a55f0eb7be17e8f19a4291e1f2
https://github.com/thoughtbot/clearance/blob/1623cdeb648f33a55f0eb7be17e8f19a4291e1f2/lib/clearance/authorization.rb#L43-L48
12,307
thoughtbot/clearance
lib/clearance/rack_session.rb
Clearance.RackSession.call
def call(env) session = Clearance::Session.new(env) env[:clearance] = session response = @app.call(env) session.add_cookie_to_headers response[1] response end
ruby
def call(env) session = Clearance::Session.new(env) env[:clearance] = session response = @app.call(env) session.add_cookie_to_headers response[1] response end
[ "def", "call", "(", "env", ")", "session", "=", "Clearance", "::", "Session", ".", "new", "(", "env", ")", "env", "[", ":clearance", "]", "=", "session", "response", "=", "@app", ".", "call", "(", "env", ")", "session", ".", "add_cookie_to_headers", "r...
Reads previously existing sessions from a cookie and maintains the cookie on each response.
[ "Reads", "previously", "existing", "sessions", "from", "a", "cookie", "and", "maintains", "the", "cookie", "on", "each", "response", "." ]
1623cdeb648f33a55f0eb7be17e8f19a4291e1f2
https://github.com/thoughtbot/clearance/blob/1623cdeb648f33a55f0eb7be17e8f19a4291e1f2/lib/clearance/rack_session.rb#L20-L26
12,308
meew0/discordrb
lib/discordrb/data/user.rb
Discordrb.User.send_file
def send_file(file, caption = nil, filename: nil, spoiler: nil) pm.send_file(file, caption: caption, filename: filename, spoiler: spoiler) end
ruby
def send_file(file, caption = nil, filename: nil, spoiler: nil) pm.send_file(file, caption: caption, filename: filename, spoiler: spoiler) end
[ "def", "send_file", "(", "file", ",", "caption", "=", "nil", ",", "filename", ":", "nil", ",", "spoiler", ":", "nil", ")", "pm", ".", "send_file", "(", "file", ",", "caption", ":", "caption", ",", "filename", ":", "filename", ",", "spoiler", ":", "sp...
Send the user a file. @param file [File] The file to send to the user @param caption [String] The caption of the file being sent @param filename [String] Overrides the filename of the uploaded file @param spoiler [true, false] Whether or not this file should appear as a spoiler. @return [Message] the message sent ...
[ "Send", "the", "user", "a", "file", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/user.rb#L108-L110
12,309
meew0/discordrb
lib/discordrb/data/user.rb
Discordrb.User.update_presence
def update_presence(data) @status = data['status'].to_sym if data['game'] game = data['game'] @game = game['name'] @stream_url = game['url'] @stream_type = game['type'] else @game = @stream_url = @stream_type = nil end end
ruby
def update_presence(data) @status = data['status'].to_sym if data['game'] game = data['game'] @game = game['name'] @stream_url = game['url'] @stream_type = game['type'] else @game = @stream_url = @stream_type = nil end end
[ "def", "update_presence", "(", "data", ")", "@status", "=", "data", "[", "'status'", "]", ".", "to_sym", "if", "data", "[", "'game'", "]", "game", "=", "data", "[", "'game'", "]", "@game", "=", "game", "[", "'name'", "]", "@stream_url", "=", "game", ...
Set the user's presence data @note for internal use only @!visibility private
[ "Set", "the", "user", "s", "presence", "data" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/user.rb#L122-L134
12,310
meew0/discordrb
lib/discordrb/permissions.rb
Discordrb.PermissionCalculator.permission?
def permission?(action, channel = nil) # If the member is the server owner, it irrevocably has all permissions. return true if owner? # First, check whether the user has Manage Roles defined. # (Coincidentally, Manage Permissions is the same permission as Manage Roles, and a # Manage Perm...
ruby
def permission?(action, channel = nil) # If the member is the server owner, it irrevocably has all permissions. return true if owner? # First, check whether the user has Manage Roles defined. # (Coincidentally, Manage Permissions is the same permission as Manage Roles, and a # Manage Perm...
[ "def", "permission?", "(", "action", ",", "channel", "=", "nil", ")", "# If the member is the server owner, it irrevocably has all permissions.", "return", "true", "if", "owner?", "# First, check whether the user has Manage Roles defined.", "# (Coincidentally, Manage Permissions is the...
Checks whether this user can do the particular action, regardless of whether it has the permission defined, through for example being the server owner or having the Manage Roles permission @param action [Symbol] The permission that should be checked. See also {Permissions::FLAGS} for a list. @param channel [Channel,...
[ "Checks", "whether", "this", "user", "can", "do", "the", "particular", "action", "regardless", "of", "whether", "it", "has", "the", "permission", "defined", "through", "for", "example", "being", "the", "server", "owner", "or", "having", "the", "Manage", "Roles...
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/permissions.rb#L135-L147
12,311
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.category=
def category=(channel) channel = @bot.channel(channel) raise ArgumentError, 'Cannot set parent category to a channel that isn\'t a category' unless channel.category? update_channel_data(parent_id: channel.id) end
ruby
def category=(channel) channel = @bot.channel(channel) raise ArgumentError, 'Cannot set parent category to a channel that isn\'t a category' unless channel.category? update_channel_data(parent_id: channel.id) end
[ "def", "category", "=", "(", "channel", ")", "channel", "=", "@bot", ".", "channel", "(", "channel", ")", "raise", "ArgumentError", ",", "'Cannot set parent category to a channel that isn\\'t a category'", "unless", "channel", ".", "category?", "update_channel_data", "(...
Sets this channels parent category @param channel [Channel, #resolve_id] the target category channel @raise [ArgumentError] if the target channel isn't a category
[ "Sets", "this", "channels", "parent", "category" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L155-L160
12,312
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.sort_after
def sort_after(other = nil, lock_permissions = false) raise TypeError, 'other must be one of Channel, NilClass, or #resolve_id' unless other.is_a?(Channel) || other.nil? || other.respond_to?(:resolve_id) other = @bot.channel(other.resolve_id) if other # Container for the API request payload mo...
ruby
def sort_after(other = nil, lock_permissions = false) raise TypeError, 'other must be one of Channel, NilClass, or #resolve_id' unless other.is_a?(Channel) || other.nil? || other.respond_to?(:resolve_id) other = @bot.channel(other.resolve_id) if other # Container for the API request payload mo...
[ "def", "sort_after", "(", "other", "=", "nil", ",", "lock_permissions", "=", "false", ")", "raise", "TypeError", ",", "'other must be one of Channel, NilClass, or #resolve_id'", "unless", "other", ".", "is_a?", "(", "Channel", ")", "||", "other", ".", "nil?", "||"...
Sorts this channel's position to follow another channel. @param other [Channel, #resolve_id, nil] The channel below which this channel should be sorted. If the given channel is a category, this channel will be sorted at the top of that category. If it is `nil`, the channel will be sorted at the top of the channe...
[ "Sorts", "this", "channel", "s", "position", "to", "follow", "another", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L169-L228
12,313
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.nsfw=
def nsfw=(nsfw) raise ArgumentError, 'nsfw value must be true or false' unless nsfw.is_a?(TrueClass) || nsfw.is_a?(FalseClass) update_channel_data(nsfw: nsfw) end
ruby
def nsfw=(nsfw) raise ArgumentError, 'nsfw value must be true or false' unless nsfw.is_a?(TrueClass) || nsfw.is_a?(FalseClass) update_channel_data(nsfw: nsfw) end
[ "def", "nsfw", "=", "(", "nsfw", ")", "raise", "ArgumentError", ",", "'nsfw value must be true or false'", "unless", "nsfw", ".", "is_a?", "(", "TrueClass", ")", "||", "nsfw", ".", "is_a?", "(", "FalseClass", ")", "update_channel_data", "(", "nsfw", ":", "nsfw...
Sets whether this channel is NSFW @param nsfw [true, false] @raise [ArguementError] if value isn't one of true, false
[ "Sets", "whether", "this", "channel", "is", "NSFW" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L233-L237
12,314
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.send_temporary_message
def send_temporary_message(content, timeout, tts = false, embed = nil) @bot.send_temporary_message(@id, content, timeout, tts, embed) end
ruby
def send_temporary_message(content, timeout, tts = false, embed = nil) @bot.send_temporary_message(@id, content, timeout, tts, embed) end
[ "def", "send_temporary_message", "(", "content", ",", "timeout", ",", "tts", "=", "false", ",", "embed", "=", "nil", ")", "@bot", ".", "send_temporary_message", "(", "@id", ",", "content", ",", "timeout", ",", "tts", ",", "embed", ")", "end" ]
Sends a temporary message to this channel. @param content [String] The content to send. Should not be longer than 2000 characters or it will result in an error. @param timeout [Float] The amount of time in seconds after which the message sent will be deleted. @param tts [true, false] Whether or not this message shou...
[ "Sends", "a", "temporary", "message", "to", "this", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L352-L354
12,315
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.send_embed
def send_embed(message = '', embed = nil) embed ||= Discordrb::Webhooks::Embed.new yield(embed) if block_given? send_message(message, false, embed) end
ruby
def send_embed(message = '', embed = nil) embed ||= Discordrb::Webhooks::Embed.new yield(embed) if block_given? send_message(message, false, embed) end
[ "def", "send_embed", "(", "message", "=", "''", ",", "embed", "=", "nil", ")", "embed", "||=", "Discordrb", "::", "Webhooks", "::", "Embed", ".", "new", "yield", "(", "embed", ")", "if", "block_given?", "send_message", "(", "message", ",", "false", ",", ...
Convenience method to send a message with an embed. @example Send a message with an embed channel.send_embed do |embed| embed.title = 'The Ruby logo' embed.image = Discordrb::Webhooks::EmbedImage.new(url: 'https://www.ruby-lang.org/images/header-ruby-logo.png') end @param message [String] The message ...
[ "Convenience", "method", "to", "send", "a", "message", "with", "an", "embed", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L367-L371
12,316
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.send_file
def send_file(file, caption: nil, tts: false, filename: nil, spoiler: nil) @bot.send_file(@id, file, caption: caption, tts: tts, filename: filename, spoiler: spoiler) end
ruby
def send_file(file, caption: nil, tts: false, filename: nil, spoiler: nil) @bot.send_file(@id, file, caption: caption, tts: tts, filename: filename, spoiler: spoiler) end
[ "def", "send_file", "(", "file", ",", "caption", ":", "nil", ",", "tts", ":", "false", ",", "filename", ":", "nil", ",", "spoiler", ":", "nil", ")", "@bot", ".", "send_file", "(", "@id", ",", "file", ",", "caption", ":", "caption", ",", "tts", ":",...
Sends a file to this channel. If it is an image, it will be embedded. @param file [File] The file to send. There's no clear size limit for this, you'll have to attempt it for yourself (most non-image files are fine, large images may fail to embed) @param caption [string] The caption for the file. @param tts [true, f...
[ "Sends", "a", "file", "to", "this", "channel", ".", "If", "it", "is", "an", "image", "it", "will", "be", "embedded", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L393-L395
12,317
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.delete_overwrite
def delete_overwrite(target, reason = nil) raise 'Tried deleting a overwrite for an invalid target' unless target.is_a?(Member) || target.is_a?(User) || target.is_a?(Role) || target.is_a?(Profile) || target.is_a?(Recipient) || target.respond_to?(:resolve_id) API::Channel.delete_permission(@bot.token, @id, ...
ruby
def delete_overwrite(target, reason = nil) raise 'Tried deleting a overwrite for an invalid target' unless target.is_a?(Member) || target.is_a?(User) || target.is_a?(Role) || target.is_a?(Profile) || target.is_a?(Recipient) || target.respond_to?(:resolve_id) API::Channel.delete_permission(@bot.token, @id, ...
[ "def", "delete_overwrite", "(", "target", ",", "reason", "=", "nil", ")", "raise", "'Tried deleting a overwrite for an invalid target'", "unless", "target", ".", "is_a?", "(", "Member", ")", "||", "target", ".", "is_a?", "(", "User", ")", "||", "target", ".", ...
Deletes a permission overwrite for this channel @param target [Member, User, Role, Profile, Recipient, #resolve_id] What permission overwrite to delete @param reason [String] The reason the for the overwrite deletion.
[ "Deletes", "a", "permission", "overwrite", "for", "this", "channel" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L482-L486
12,318
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.update_from
def update_from(other) @topic = other.topic @name = other.name @position = other.position @topic = other.topic @recipients = other.recipients @bitrate = other.bitrate @user_limit = other.user_limit @permission_overwrites = other.permission_overwrites @nsfw = other.n...
ruby
def update_from(other) @topic = other.topic @name = other.name @position = other.position @topic = other.topic @recipients = other.recipients @bitrate = other.bitrate @user_limit = other.user_limit @permission_overwrites = other.permission_overwrites @nsfw = other.n...
[ "def", "update_from", "(", "other", ")", "@topic", "=", "other", ".", "topic", "@name", "=", "other", ".", "name", "@position", "=", "other", ".", "position", "@topic", "=", "other", ".", "topic", "@recipients", "=", "other", ".", "recipients", "@bitrate",...
Updates the cached data from another channel. @note For internal use only @!visibility private
[ "Updates", "the", "cached", "data", "from", "another", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L491-L503
12,319
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.users
def users if text? @server.online_members(include_idle: true).select { |u| u.can_read_messages? self } elsif voice? @server.voice_states.map { |id, voice_state| @server.member(id) if !voice_state.voice_channel.nil? && voice_state.voice_channel.id == @id }.compact end end
ruby
def users if text? @server.online_members(include_idle: true).select { |u| u.can_read_messages? self } elsif voice? @server.voice_states.map { |id, voice_state| @server.member(id) if !voice_state.voice_channel.nil? && voice_state.voice_channel.id == @id }.compact end end
[ "def", "users", "if", "text?", "@server", ".", "online_members", "(", "include_idle", ":", "true", ")", ".", "select", "{", "|", "u", "|", "u", ".", "can_read_messages?", "self", "}", "elsif", "voice?", "@server", ".", "voice_states", ".", "map", "{", "|...
The list of users currently in this channel. For a voice channel, it will return all the members currently in that channel. For a text channel, it will return all online members that have permission to read it. @return [Array<Member>] the users in this channel
[ "The", "list", "of", "users", "currently", "in", "this", "channel", ".", "For", "a", "voice", "channel", "it", "will", "return", "all", "the", "members", "currently", "in", "that", "channel", ".", "For", "a", "text", "channel", "it", "will", "return", "a...
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L508-L514
12,320
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.history
def history(amount, before_id = nil, after_id = nil, around_id = nil) logs = API::Channel.messages(@bot.token, @id, amount, before_id, after_id, around_id) JSON.parse(logs).map { |message| Message.new(message, @bot) } end
ruby
def history(amount, before_id = nil, after_id = nil, around_id = nil) logs = API::Channel.messages(@bot.token, @id, amount, before_id, after_id, around_id) JSON.parse(logs).map { |message| Message.new(message, @bot) } end
[ "def", "history", "(", "amount", ",", "before_id", "=", "nil", ",", "after_id", "=", "nil", ",", "around_id", "=", "nil", ")", "logs", "=", "API", "::", "Channel", ".", "messages", "(", "@bot", ".", "token", ",", "@id", ",", "amount", ",", "before_id...
Retrieves some of this channel's message history. @param amount [Integer] How many messages to retrieve. This must be less than or equal to 100, if it is higher than 100 it will be treated as 100 on Discord's side. @param before_id [Integer] The ID of the most recent message the retrieval should start at, or nil i...
[ "Retrieves", "some", "of", "this", "channel", "s", "message", "history", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L529-L532
12,321
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.history_ids
def history_ids(amount, before_id = nil, after_id = nil, around_id = nil) logs = API::Channel.messages(@bot.token, @id, amount, before_id, after_id, around_id) JSON.parse(logs).map { |message| message['id'].to_i } end
ruby
def history_ids(amount, before_id = nil, after_id = nil, around_id = nil) logs = API::Channel.messages(@bot.token, @id, amount, before_id, after_id, around_id) JSON.parse(logs).map { |message| message['id'].to_i } end
[ "def", "history_ids", "(", "amount", ",", "before_id", "=", "nil", ",", "after_id", "=", "nil", ",", "around_id", "=", "nil", ")", "logs", "=", "API", "::", "Channel", ".", "messages", "(", "@bot", ".", "token", ",", "@id", ",", "amount", ",", "befor...
Retrieves message history, but only message IDs for use with prune. @note For internal use only @!visibility private
[ "Retrieves", "message", "history", "but", "only", "message", "IDs", "for", "use", "with", "prune", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L537-L540
12,322
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.load_message
def load_message(message_id) response = API::Channel.message(@bot.token, @id, message_id) Message.new(JSON.parse(response), @bot) rescue RestClient::ResourceNotFound nil end
ruby
def load_message(message_id) response = API::Channel.message(@bot.token, @id, message_id) Message.new(JSON.parse(response), @bot) rescue RestClient::ResourceNotFound nil end
[ "def", "load_message", "(", "message_id", ")", "response", "=", "API", "::", "Channel", ".", "message", "(", "@bot", ".", "token", ",", "@id", ",", "message_id", ")", "Message", ".", "new", "(", "JSON", ".", "parse", "(", "response", ")", ",", "@bot", ...
Returns a single message from this channel's history by ID. @param message_id [Integer] The ID of the message to retrieve. @return [Message, nil] the retrieved message, or `nil` if it couldn't be found.
[ "Returns", "a", "single", "message", "from", "this", "channel", "s", "history", "by", "ID", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L545-L550
12,323
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.pins
def pins msgs = API::Channel.pinned_messages(@bot.token, @id) JSON.parse(msgs).map { |msg| Message.new(msg, @bot) } end
ruby
def pins msgs = API::Channel.pinned_messages(@bot.token, @id) JSON.parse(msgs).map { |msg| Message.new(msg, @bot) } end
[ "def", "pins", "msgs", "=", "API", "::", "Channel", ".", "pinned_messages", "(", "@bot", ".", "token", ",", "@id", ")", "JSON", ".", "parse", "(", "msgs", ")", ".", "map", "{", "|", "msg", "|", "Message", ".", "new", "(", "msg", ",", "@bot", ")",...
Requests all pinned messages in a channel. @return [Array<Message>] the received messages.
[ "Requests", "all", "pinned", "messages", "in", "a", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L556-L559
12,324
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.prune
def prune(amount, strict = false, &block) raise ArgumentError, 'Can only delete between 1 and 100 messages!' unless amount.between?(1, 100) messages = if block_given? history(amount).select(&block).map(&:id) else history_ids(amount) end case messages.size ...
ruby
def prune(amount, strict = false, &block) raise ArgumentError, 'Can only delete between 1 and 100 messages!' unless amount.between?(1, 100) messages = if block_given? history(amount).select(&block).map(&:id) else history_ids(amount) end case messages.size ...
[ "def", "prune", "(", "amount", ",", "strict", "=", "false", ",", "&", "block", ")", "raise", "ArgumentError", ",", "'Can only delete between 1 and 100 messages!'", "unless", "amount", ".", "between?", "(", "1", ",", "100", ")", "messages", "=", "if", "block_gi...
Delete the last N messages on this channel. @param amount [Integer] The amount of message history to consider for pruning. Must be a value between 2 and 100 (Discord limitation) @param strict [true, false] Whether an error should be raised when a message is reached that is too old to be bulk deleted. If this is fa...
[ "Delete", "the", "last", "N", "messages", "on", "this", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L570-L589
12,325
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.delete_messages
def delete_messages(messages, strict = false) raise ArgumentError, 'Can only delete between 2 and 100 messages!' unless messages.count.between?(2, 100) messages.map!(&:resolve_id) bulk_delete(messages, strict) end
ruby
def delete_messages(messages, strict = false) raise ArgumentError, 'Can only delete between 2 and 100 messages!' unless messages.count.between?(2, 100) messages.map!(&:resolve_id) bulk_delete(messages, strict) end
[ "def", "delete_messages", "(", "messages", ",", "strict", "=", "false", ")", "raise", "ArgumentError", ",", "'Can only delete between 2 and 100 messages!'", "unless", "messages", ".", "count", ".", "between?", "(", "2", ",", "100", ")", "messages", ".", "map!", ...
Deletes a collection of messages @param messages [Array<Message, Integer, #resolve_id>] the messages (or message IDs) to delete. Total must be an amount between 2 and 100 (Discord limitation) @param strict [true, false] Whether an error should be raised when a message is reached that is too old to be bulk deleted....
[ "Deletes", "a", "collection", "of", "messages" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L597-L602
12,326
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.make_invite
def make_invite(max_age = 0, max_uses = 0, temporary = false, unique = false, reason = nil) response = API::Channel.create_invite(@bot.token, @id, max_age, max_uses, temporary, unique, reason) Invite.new(JSON.parse(response), @bot) end
ruby
def make_invite(max_age = 0, max_uses = 0, temporary = false, unique = false, reason = nil) response = API::Channel.create_invite(@bot.token, @id, max_age, max_uses, temporary, unique, reason) Invite.new(JSON.parse(response), @bot) end
[ "def", "make_invite", "(", "max_age", "=", "0", ",", "max_uses", "=", "0", ",", "temporary", "=", "false", ",", "unique", "=", "false", ",", "reason", "=", "nil", ")", "response", "=", "API", "::", "Channel", ".", "create_invite", "(", "@bot", ".", "...
Creates a new invite to this channel. @param max_age [Integer] How many seconds this invite should last. @param max_uses [Integer] How many times this invite should be able to be used. @param temporary [true, false] Whether membership should be temporary (kicked after going offline). @param unique [true, false] If ...
[ "Creates", "a", "new", "invite", "to", "this", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L633-L636
12,327
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.create_group
def create_group(user_ids) raise 'Attempted to create group channel on a non-pm channel!' unless pm? response = API::Channel.create_group(@bot.token, @id, user_ids.shift) channel = Channel.new(JSON.parse(response), @bot) channel.add_group_users(user_ids) end
ruby
def create_group(user_ids) raise 'Attempted to create group channel on a non-pm channel!' unless pm? response = API::Channel.create_group(@bot.token, @id, user_ids.shift) channel = Channel.new(JSON.parse(response), @bot) channel.add_group_users(user_ids) end
[ "def", "create_group", "(", "user_ids", ")", "raise", "'Attempted to create group channel on a non-pm channel!'", "unless", "pm?", "response", "=", "API", "::", "Channel", ".", "create_group", "(", "@bot", ".", "token", ",", "@id", ",", "user_ids", ".", "shift", "...
Creates a Group channel @param user_ids [Array<Integer>] Array of user IDs to add to the new group channel (Excluding the recipient of the PM channel). @return [Channel] the created channel.
[ "Creates", "a", "Group", "channel" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L653-L659
12,328
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.add_group_users
def add_group_users(user_ids) raise 'Attempted to add a user to a non-group channel!' unless group? user_ids = [user_ids] unless user_ids.is_a? Array user_ids.each do |user_id| API::Channel.add_group_user(@bot.token, @id, user_id.resolve_id) end self end
ruby
def add_group_users(user_ids) raise 'Attempted to add a user to a non-group channel!' unless group? user_ids = [user_ids] unless user_ids.is_a? Array user_ids.each do |user_id| API::Channel.add_group_user(@bot.token, @id, user_id.resolve_id) end self end
[ "def", "add_group_users", "(", "user_ids", ")", "raise", "'Attempted to add a user to a non-group channel!'", "unless", "group?", "user_ids", "=", "[", "user_ids", "]", "unless", "user_ids", ".", "is_a?", "Array", "user_ids", ".", "each", "do", "|", "user_id", "|", ...
Adds a user to a group channel. @param user_ids [Array<#resolve_id>, #resolve_id] User ID or array of user IDs to add to the group channel. @return [Channel] the group channel.
[ "Adds", "a", "user", "to", "a", "group", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L664-L672
12,329
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.remove_group_users
def remove_group_users(user_ids) raise 'Attempted to remove a user from a non-group channel!' unless group? user_ids = [user_ids] unless user_ids.is_a? Array user_ids.each do |user_id| API::Channel.remove_group_user(@bot.token, @id, user_id.resolve_id) end self end
ruby
def remove_group_users(user_ids) raise 'Attempted to remove a user from a non-group channel!' unless group? user_ids = [user_ids] unless user_ids.is_a? Array user_ids.each do |user_id| API::Channel.remove_group_user(@bot.token, @id, user_id.resolve_id) end self end
[ "def", "remove_group_users", "(", "user_ids", ")", "raise", "'Attempted to remove a user from a non-group channel!'", "unless", "group?", "user_ids", "=", "[", "user_ids", "]", "unless", "user_ids", ".", "is_a?", "Array", "user_ids", ".", "each", "do", "|", "user_id",...
Removes a user from a group channel. @param user_ids [Array<#resolve_id>, #resolve_id] User ID or array of user IDs to remove from the group channel. @return [Channel] the group channel.
[ "Removes", "a", "user", "from", "a", "group", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L679-L687
12,330
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.webhooks
def webhooks raise 'Tried to request webhooks from a non-server channel' unless server webhooks = JSON.parse(API::Channel.webhooks(@bot.token, @id)) webhooks.map { |webhook_data| Webhook.new(webhook_data, @bot) } end
ruby
def webhooks raise 'Tried to request webhooks from a non-server channel' unless server webhooks = JSON.parse(API::Channel.webhooks(@bot.token, @id)) webhooks.map { |webhook_data| Webhook.new(webhook_data, @bot) } end
[ "def", "webhooks", "raise", "'Tried to request webhooks from a non-server channel'", "unless", "server", "webhooks", "=", "JSON", ".", "parse", "(", "API", "::", "Channel", ".", "webhooks", "(", "@bot", ".", "token", ",", "@id", ")", ")", "webhooks", ".", "map",...
Requests a list of Webhooks on the channel. @return [Array<Webhook>] webhooks on the channel.
[ "Requests", "a", "list", "of", "Webhooks", "on", "the", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L702-L707
12,331
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.invites
def invites raise 'Tried to request invites from a non-server channel' unless server invites = JSON.parse(API::Channel.invites(@bot.token, @id)) invites.map { |invite_data| Invite.new(invite_data, @bot) } end
ruby
def invites raise 'Tried to request invites from a non-server channel' unless server invites = JSON.parse(API::Channel.invites(@bot.token, @id)) invites.map { |invite_data| Invite.new(invite_data, @bot) } end
[ "def", "invites", "raise", "'Tried to request invites from a non-server channel'", "unless", "server", "invites", "=", "JSON", ".", "parse", "(", "API", "::", "Channel", ".", "invites", "(", "@bot", ".", "token", ",", "@id", ")", ")", "invites", ".", "map", "{...
Requests a list of Invites to the channel. @return [Array<Invite>] invites to the channel.
[ "Requests", "a", "list", "of", "Invites", "to", "the", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L711-L716
12,332
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.add_recipient
def add_recipient(recipient) raise 'Tried to add recipient to a non-group channel' unless group? raise ArgumentError, 'Tried to add a non-recipient to a group' unless recipient.is_a?(Recipient) @recipients << recipient end
ruby
def add_recipient(recipient) raise 'Tried to add recipient to a non-group channel' unless group? raise ArgumentError, 'Tried to add a non-recipient to a group' unless recipient.is_a?(Recipient) @recipients << recipient end
[ "def", "add_recipient", "(", "recipient", ")", "raise", "'Tried to add recipient to a non-group channel'", "unless", "group?", "raise", "ArgumentError", ",", "'Tried to add a non-recipient to a group'", "unless", "recipient", ".", "is_a?", "(", "Recipient", ")", "@recipients"...
Adds a recipient to a group channel. @param recipient [Recipient] the recipient to add to the group @raise [ArgumentError] if tried to add a non-recipient @note For internal use only @!visibility private
[ "Adds", "a", "recipient", "to", "a", "group", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L728-L733
12,333
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.remove_recipient
def remove_recipient(recipient) raise 'Tried to remove recipient from a non-group channel' unless group? raise ArgumentError, 'Tried to remove a non-recipient from a group' unless recipient.is_a?(Recipient) @recipients.delete(recipient) end
ruby
def remove_recipient(recipient) raise 'Tried to remove recipient from a non-group channel' unless group? raise ArgumentError, 'Tried to remove a non-recipient from a group' unless recipient.is_a?(Recipient) @recipients.delete(recipient) end
[ "def", "remove_recipient", "(", "recipient", ")", "raise", "'Tried to remove recipient from a non-group channel'", "unless", "group?", "raise", "ArgumentError", ",", "'Tried to remove a non-recipient from a group'", "unless", "recipient", ".", "is_a?", "(", "Recipient", ")", ...
Removes a recipient from a group channel. @param recipient [Recipient] the recipient to remove from the group @raise [ArgumentError] if tried to remove a non-recipient @note For internal use only @!visibility private
[ "Removes", "a", "recipient", "from", "a", "group", "channel", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L740-L745
12,334
meew0/discordrb
lib/discordrb/data/channel.rb
Discordrb.Channel.bulk_delete
def bulk_delete(ids, strict = false) min_snowflake = IDObject.synthesise(Time.now - TWO_WEEKS) ids.reject! do |e| next unless e < min_snowflake message = "Attempted to bulk_delete message #{e} which is too old (min = #{min_snowflake})" raise ArgumentError, message if strict ...
ruby
def bulk_delete(ids, strict = false) min_snowflake = IDObject.synthesise(Time.now - TWO_WEEKS) ids.reject! do |e| next unless e < min_snowflake message = "Attempted to bulk_delete message #{e} which is too old (min = #{min_snowflake})" raise ArgumentError, message if strict ...
[ "def", "bulk_delete", "(", "ids", ",", "strict", "=", "false", ")", "min_snowflake", "=", "IDObject", ".", "synthesise", "(", "Time", ".", "now", "-", "TWO_WEEKS", ")", "ids", ".", "reject!", "do", "|", "e", "|", "next", "unless", "e", "<", "min_snowfl...
Deletes a list of messages on this channel using bulk delete.
[ "Deletes", "a", "list", "of", "messages", "on", "this", "channel", "using", "bulk", "delete", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/channel.rb#L770-L785
12,335
meew0/discordrb
lib/discordrb/container.rb
Discordrb.EventContainer.include_events
def include_events(container) handlers = container.instance_variable_get '@event_handlers' return unless handlers @event_handlers ||= {} @event_handlers.merge!(handlers) { |_, old, new| old + new } end
ruby
def include_events(container) handlers = container.instance_variable_get '@event_handlers' return unless handlers @event_handlers ||= {} @event_handlers.merge!(handlers) { |_, old, new| old + new } end
[ "def", "include_events", "(", "container", ")", "handlers", "=", "container", ".", "instance_variable_get", "'@event_handlers'", "return", "unless", "handlers", "@event_handlers", "||=", "{", "}", "@event_handlers", ".", "merge!", "(", "handlers", ")", "{", "|", "...
Adds all event handlers from another container into this one. Existing event handlers will be overwritten. @param container [Module] A module that `extend`s {EventContainer} from which the handlers will be added.
[ "Adds", "all", "event", "handlers", "from", "another", "container", "into", "this", "one", ".", "Existing", "event", "handlers", "will", "be", "overwritten", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/container.rb#L526-L532
12,336
meew0/discordrb
lib/discordrb/data/webhook.rb
Discordrb.Webhook.update
def update(data) # Only pass a value for avatar if the key is defined as sending nil will delete the data[:avatar] = avatarise(data[:avatar]) if data.key?(:avatar) data[:channel_id] = data[:channel].resolve_id data.delete(:channel) update_webhook(data) end
ruby
def update(data) # Only pass a value for avatar if the key is defined as sending nil will delete the data[:avatar] = avatarise(data[:avatar]) if data.key?(:avatar) data[:channel_id] = data[:channel].resolve_id data.delete(:channel) update_webhook(data) end
[ "def", "update", "(", "data", ")", "# Only pass a value for avatar if the key is defined as sending nil will delete the", "data", "[", ":avatar", "]", "=", "avatarise", "(", "data", "[", ":avatar", "]", ")", "if", "data", ".", "key?", "(", ":avatar", ")", "data", ...
Updates the webhook if you need to edit more than 1 attribute. @param data [Hash] the data to update. @option data [String, #read, nil] :avatar The new avatar, in base64-encoded JPG format, or nil to delete the avatar. @option data [Channel, String, Integer, #resolve_id] :channel The channel the webhook should use. ...
[ "Updates", "the", "webhook", "if", "you", "need", "to", "edit", "more", "than", "1", "attribute", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/webhook.rb#L77-L83
12,337
meew0/discordrb
lib/discordrb/data/webhook.rb
Discordrb.Webhook.delete
def delete(reason = nil) if token? API::Webhook.token_delete_webhook(@token, @id, reason) else API::Webhook.delete_webhook(@bot.token, @id, reason) end end
ruby
def delete(reason = nil) if token? API::Webhook.token_delete_webhook(@token, @id, reason) else API::Webhook.delete_webhook(@bot.token, @id, reason) end end
[ "def", "delete", "(", "reason", "=", "nil", ")", "if", "token?", "API", "::", "Webhook", ".", "token_delete_webhook", "(", "@token", ",", "@id", ",", "reason", ")", "else", "API", "::", "Webhook", ".", "delete_webhook", "(", "@bot", ".", "token", ",", ...
Deletes the webhook. @param reason [String] The reason the invite is being deleted.
[ "Deletes", "the", "webhook", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/webhook.rb#L87-L93
12,338
meew0/discordrb
lib/discordrb/webhooks/embeds.rb
Discordrb::Webhooks.Embed.colour=
def colour=(value) if value.nil? @colour = nil elsif value.is_a? Integer raise ArgumentError, 'Embed colour must be 24-bit!' if value >= 16_777_216 @colour = value elsif value.is_a? String self.colour = value.delete('#').to_i(16) elsif value.is_a? Array r...
ruby
def colour=(value) if value.nil? @colour = nil elsif value.is_a? Integer raise ArgumentError, 'Embed colour must be 24-bit!' if value >= 16_777_216 @colour = value elsif value.is_a? String self.colour = value.delete('#').to_i(16) elsif value.is_a? Array r...
[ "def", "colour", "=", "(", "value", ")", "if", "value", ".", "nil?", "@colour", "=", "nil", "elsif", "value", ".", "is_a?", "Integer", "raise", "ArgumentError", ",", "'Embed colour must be 24-bit!'", "if", "value", ">=", "16_777_216", "@colour", "=", "value", ...
Sets the colour of the bar to the side of the embed to something new. @param value [Integer, String, {Integer, Integer, Integer}, #to_i, nil] The colour in decimal, hexadecimal, R/G/B decimal, or nil to clear the embeds colour form.
[ "Sets", "the", "colour", "of", "the", "bar", "to", "the", "side", "of", "the", "embed", "to", "something", "new", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/webhooks/embeds.rb#L42-L58
12,339
meew0/discordrb
lib/discordrb/webhooks/embeds.rb
Discordrb::Webhooks.Embed.add_field
def add_field(name: nil, value: nil, inline: nil) self << EmbedField.new(name: name, value: value, inline: inline) end
ruby
def add_field(name: nil, value: nil, inline: nil) self << EmbedField.new(name: name, value: value, inline: inline) end
[ "def", "add_field", "(", "name", ":", "nil", ",", "value", ":", "nil", ",", "inline", ":", "nil", ")", "self", "<<", "EmbedField", ".", "new", "(", "name", ":", "name", ",", "value", ":", "value", ",", "inline", ":", "inline", ")", "end" ]
Convenience method to add a field to the embed without having to create one manually. @see EmbedField @example Add a field to an embed, conveniently embed.add_field(name: 'A field', value: "The field's content") @param name [String] The field's name @param value [String] The field's value @param inline [true, f...
[ "Convenience", "method", "to", "add", "a", "field", "to", "the", "embed", "without", "having", "to", "create", "one", "manually", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/webhooks/embeds.rb#L98-L100
12,340
meew0/discordrb
lib/discordrb/light/light_bot.rb
Discordrb::Light.LightBot.profile
def profile response = Discordrb::API::User.profile(@token) LightProfile.new(JSON.parse(response), self) end
ruby
def profile response = Discordrb::API::User.profile(@token) LightProfile.new(JSON.parse(response), self) end
[ "def", "profile", "response", "=", "Discordrb", "::", "API", "::", "User", ".", "profile", "(", "@token", ")", "LightProfile", ".", "new", "(", "JSON", ".", "parse", "(", "response", ")", ",", "self", ")", "end" ]
Create a new LightBot. This does no networking yet, all networking is done by the methods on this class. @param token [String] The token that should be used to authenticate to Discord. Can be an OAuth token or a regular user account token. @return [LightProfile] the details of the user this bot is connected to.
[ "Create", "a", "new", "LightBot", ".", "This", "does", "no", "networking", "yet", "all", "networking", "is", "done", "by", "the", "methods", "on", "this", "class", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/light/light_bot.rb#L33-L36
12,341
meew0/discordrb
lib/discordrb/light/light_bot.rb
Discordrb::Light.LightBot.connections
def connections response = Discordrb::API::User.connections(@token) JSON.parse(response).map { |e| Connection.new(e, self) } end
ruby
def connections response = Discordrb::API::User.connections(@token) JSON.parse(response).map { |e| Connection.new(e, self) } end
[ "def", "connections", "response", "=", "Discordrb", "::", "API", "::", "User", ".", "connections", "(", "@token", ")", "JSON", ".", "parse", "(", "response", ")", ".", "map", "{", "|", "e", "|", "Connection", ".", "new", "(", "e", ",", "self", ")", ...
Gets the connections associated with this account. @return [Array<Connection>] this account's connections.
[ "Gets", "the", "connections", "associated", "with", "this", "account", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/light/light_bot.rb#L53-L56
12,342
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.find_emoji
def find_emoji(name) LOGGER.out("Resolving emoji #{name}") emoji.find { |element| element.name == name } end
ruby
def find_emoji(name) LOGGER.out("Resolving emoji #{name}") emoji.find { |element| element.name == name } end
[ "def", "find_emoji", "(", "name", ")", "LOGGER", ".", "out", "(", "\"Resolving emoji #{name}\"", ")", "emoji", ".", "find", "{", "|", "element", "|", "element", ".", "name", "==", "name", "}", "end" ]
Finds an emoji by its name. @param name [String] The emoji name that should be resolved. @return [GlobalEmoji, nil] the emoji identified by the name, or `nil` if it couldn't be found.
[ "Finds", "an", "emoji", "by", "its", "name", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L189-L192
12,343
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.bot_application
def bot_application return unless @type == :bot response = API.oauth_application(token) Application.new(JSON.parse(response), self) end
ruby
def bot_application return unless @type == :bot response = API.oauth_application(token) Application.new(JSON.parse(response), self) end
[ "def", "bot_application", "return", "unless", "@type", "==", ":bot", "response", "=", "API", ".", "oauth_application", "(", "token", ")", "Application", ".", "new", "(", "JSON", ".", "parse", "(", "response", ")", ",", "self", ")", "end" ]
The bot's OAuth application. @return [Application, nil] The bot's application info. Returns `nil` if bot is not a bot account.
[ "The", "bot", "s", "OAuth", "application", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L206-L211
12,344
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.accept_invite
def accept_invite(invite) resolved = invite(invite).code API::Invite.accept(token, resolved) end
ruby
def accept_invite(invite) resolved = invite(invite).code API::Invite.accept(token, resolved) end
[ "def", "accept_invite", "(", "invite", ")", "resolved", "=", "invite", "(", "invite", ")", ".", "code", "API", "::", "Invite", ".", "accept", "(", "token", ",", "resolved", ")", "end" ]
Makes the bot join an invite to a server. @param invite [String, Invite] The invite to join. For possible formats see {#resolve_invite_code}.
[ "Makes", "the", "bot", "join", "an", "invite", "to", "a", "server", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L272-L275
12,345
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.send_message
def send_message(channel, content, tts = false, embed = nil) channel = channel.resolve_id debug("Sending message to #{channel} with content '#{content}'") response = API::Channel.create_message(token, channel, content, tts, embed ? embed.to_hash : nil) Message.new(JSON.parse(response), self) ...
ruby
def send_message(channel, content, tts = false, embed = nil) channel = channel.resolve_id debug("Sending message to #{channel} with content '#{content}'") response = API::Channel.create_message(token, channel, content, tts, embed ? embed.to_hash : nil) Message.new(JSON.parse(response), self) ...
[ "def", "send_message", "(", "channel", ",", "content", ",", "tts", "=", "false", ",", "embed", "=", "nil", ")", "channel", "=", "channel", ".", "resolve_id", "debug", "(", "\"Sending message to #{channel} with content '#{content}'\"", ")", "response", "=", "API", ...
Sends a text message to a channel given its ID and the message's content. @param channel [Channel, Integer, #resolve_id] The channel to send something to. @param content [String] The text that should be sent as a message. It is limited to 2000 characters (Discord imposed). @param tts [true, false] Whether or not thi...
[ "Sends", "a", "text", "message", "to", "a", "channel", "given", "its", "ID", "and", "the", "message", "s", "content", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L366-L372
12,346
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.send_temporary_message
def send_temporary_message(channel, content, timeout, tts = false, embed = nil) Thread.new do Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg" message = send_message(channel, content, tts, embed) sleep(timeout) message.delete end nil end
ruby
def send_temporary_message(channel, content, timeout, tts = false, embed = nil) Thread.new do Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg" message = send_message(channel, content, tts, embed) sleep(timeout) message.delete end nil end
[ "def", "send_temporary_message", "(", "channel", ",", "content", ",", "timeout", ",", "tts", "=", "false", ",", "embed", "=", "nil", ")", "Thread", ".", "new", "do", "Thread", ".", "current", "[", ":discordrb_name", "]", "=", "\"#{@current_thread}-temp-msg\"",...
Sends a text message to a channel given its ID and the message's content, then deletes it after the specified timeout in seconds. @param channel [Channel, Integer, #resolve_id] The channel to send something to. @param content [String] The text that should be sent as a message. It is limited to 2000 characters (Disco...
[ "Sends", "a", "text", "message", "to", "a", "channel", "given", "its", "ID", "and", "the", "message", "s", "content", "then", "deletes", "it", "after", "the", "specified", "timeout", "in", "seconds", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L381-L391
12,347
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.send_file
def send_file(channel, file, caption: nil, tts: false, filename: nil, spoiler: nil) if file.respond_to?(:read) if spoiler filename ||= File.basename(file.path) filename = 'SPOILER_' + filename unless filename.start_with? 'SPOILER_' end # https://github.com/rest-client/r...
ruby
def send_file(channel, file, caption: nil, tts: false, filename: nil, spoiler: nil) if file.respond_to?(:read) if spoiler filename ||= File.basename(file.path) filename = 'SPOILER_' + filename unless filename.start_with? 'SPOILER_' end # https://github.com/rest-client/r...
[ "def", "send_file", "(", "channel", ",", "file", ",", "caption", ":", "nil", ",", "tts", ":", "false", ",", "filename", ":", "nil", ",", "spoiler", ":", "nil", ")", "if", "file", ".", "respond_to?", "(", ":read", ")", "if", "spoiler", "filename", "||...
Sends a file to a channel. If it is an image, it will automatically be embedded. @note This executes in a blocking way, so if you're sending long files, be wary of delays. @param channel [Channel, Integer, #resolve_id] The channel to send something to. @param file [File] The file that should be sent. @param caption...
[ "Sends", "a", "file", "to", "a", "channel", ".", "If", "it", "is", "an", "image", "it", "will", "automatically", "be", "embedded", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L403-L416
12,348
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.create_server
def create_server(name, region = :'eu-central') response = API::Server.create(token, name, region) id = JSON.parse(response)['id'].to_i sleep 0.1 until @servers[id] server = @servers[id] debug "Successfully created server #{server.id} with name #{server.name}" server end
ruby
def create_server(name, region = :'eu-central') response = API::Server.create(token, name, region) id = JSON.parse(response)['id'].to_i sleep 0.1 until @servers[id] server = @servers[id] debug "Successfully created server #{server.id} with name #{server.name}" server end
[ "def", "create_server", "(", "name", ",", "region", "=", ":'", "'", ")", "response", "=", "API", "::", "Server", ".", "create", "(", "token", ",", "name", ",", "region", ")", "id", "=", "JSON", ".", "parse", "(", "response", ")", "[", "'id'", "]", ...
Creates a server on Discord with a specified name and a region. @note Discord's API doesn't directly return the server when creating it, so this method waits until the data has been received via the websocket. This may make the execution take a while. @param name [String] The name the new server should have. Doesn...
[ "Creates", "a", "server", "on", "Discord", "with", "a", "specified", "name", "and", "a", "region", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L424-L431
12,349
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_oauth_application
def update_oauth_application(name, redirect_uris, description = '', icon = nil) API.update_oauth_application(@token, name, redirect_uris, description, icon) end
ruby
def update_oauth_application(name, redirect_uris, description = '', icon = nil) API.update_oauth_application(@token, name, redirect_uris, description, icon) end
[ "def", "update_oauth_application", "(", "name", ",", "redirect_uris", ",", "description", "=", "''", ",", "icon", "=", "nil", ")", "API", ".", "update_oauth_application", "(", "@token", ",", "name", ",", "redirect_uris", ",", "description", ",", "icon", ")", ...
Changes information about your OAuth application @param name [String] What your application should be called. @param redirect_uris [Array<String>] URIs that Discord should redirect your users to after authorizing. @param description [String] A string that describes what your application does. @param icon [String, n...
[ "Changes", "information", "about", "your", "OAuth", "application" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L449-L451
12,350
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.parse_mentions
def parse_mentions(mentions, server = nil) array_to_return = [] # While possible mentions may be in message while mentions.include?('<') && mentions.include?('>') # Removing all content before the next possible mention mentions = mentions.split('<', 2)[1] # Locate the first val...
ruby
def parse_mentions(mentions, server = nil) array_to_return = [] # While possible mentions may be in message while mentions.include?('<') && mentions.include?('>') # Removing all content before the next possible mention mentions = mentions.split('<', 2)[1] # Locate the first val...
[ "def", "parse_mentions", "(", "mentions", ",", "server", "=", "nil", ")", "array_to_return", "=", "[", "]", "# While possible mentions may be in message", "while", "mentions", ".", "include?", "(", "'<'", ")", "&&", "mentions", ".", "include?", "(", "'>'", ")", ...
Gets the users, channels, roles and emoji from a string. @param mentions [String] The mentions, which should look like `<@12314873129>`, `<#123456789>`, `<@&123456789>` or `<:name:126328:>`. @param server [Server, nil] The server of the associated mentions. (recommended for role parsing, to speed things up) @return ...
[ "Gets", "the", "users", "channels", "roles", "and", "emoji", "from", "a", "string", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L457-L485
12,351
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_status
def update_status(status, activity, url, since = 0, afk = false, activity_type = 0) gateway_check @activity = activity @status = status @streamurl = url type = url ? 1 : activity_type activity_obj = activity || url ? { 'name' => activity, 'url' => url, 'type' => type } : nil ...
ruby
def update_status(status, activity, url, since = 0, afk = false, activity_type = 0) gateway_check @activity = activity @status = status @streamurl = url type = url ? 1 : activity_type activity_obj = activity || url ? { 'name' => activity, 'url' => url, 'type' => type } : nil ...
[ "def", "update_status", "(", "status", ",", "activity", ",", "url", ",", "since", "=", "0", ",", "afk", "=", "false", ",", "activity_type", "=", "0", ")", "gateway_check", "@activity", "=", "activity", "@status", "=", "status", "@streamurl", "=", "url", ...
Updates presence status. @param status [String] The status the bot should show up as. Can be `online`, `dnd`, `idle`, or `invisible` @param activity [String, nil] The name of the activity to be played/watched/listened to/stream name on the stream. @param url [String, nil] The Twitch URL to display as a stream. nil f...
[ "Updates", "presence", "status", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L503-L516
12,352
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.add_await!
def add_await!(type, attributes = {}) raise "You can't await an AwaitEvent!" if type == Discordrb::Events::AwaitEvent timeout = attributes[:timeout] raise ArgumentError, 'Timeout must be a number > 0' if timeout&.is_a?(Numeric) && !timeout&.positive? mutex = Mutex.new cv = ConditionVaria...
ruby
def add_await!(type, attributes = {}) raise "You can't await an AwaitEvent!" if type == Discordrb::Events::AwaitEvent timeout = attributes[:timeout] raise ArgumentError, 'Timeout must be a number > 0' if timeout&.is_a?(Numeric) && !timeout&.positive? mutex = Mutex.new cv = ConditionVaria...
[ "def", "add_await!", "(", "type", ",", "attributes", "=", "{", "}", ")", "raise", "\"You can't await an AwaitEvent!\"", "if", "type", "==", "Discordrb", "::", "Events", "::", "AwaitEvent", "timeout", "=", "attributes", "[", ":timeout", "]", "raise", "ArgumentErr...
Awaits an event, blocking the current thread until a response is received. @param type [Class] The event class that should be listened for. @option attributes [Numeric] :timeout the amount of time to wait for a response before returning `nil`. Waits forever if omitted. @return [Event, nil] The event object that was ...
[ "Awaits", "an", "event", "blocking", "the", "current", "thread", "until", "a", "response", "is", "received", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L619-L650
12,353
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.prune_empty_groups
def prune_empty_groups @channels.each_value do |channel| channel.leave_group if channel.group? && channel.recipients.empty? end end
ruby
def prune_empty_groups @channels.each_value do |channel| channel.leave_group if channel.group? && channel.recipients.empty? end end
[ "def", "prune_empty_groups", "@channels", ".", "each_value", "do", "|", "channel", "|", "channel", ".", "leave_group", "if", "channel", ".", "group?", "&&", "channel", ".", "recipients", ".", "empty?", "end", "end" ]
Makes the bot leave any groups with no recipients remaining
[ "Makes", "the", "bot", "leave", "any", "groups", "with", "no", "recipients", "remaining" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L694-L698
12,354
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_voice_state
def update_voice_state(data) @session_id = data['session_id'] server_id = data['guild_id'].to_i server = server(server_id) return unless server user_id = data['user_id'].to_i old_voice_state = server.voice_states[user_id] old_channel_id = old_voice_state.voice_channel.id if o...
ruby
def update_voice_state(data) @session_id = data['session_id'] server_id = data['guild_id'].to_i server = server(server_id) return unless server user_id = data['user_id'].to_i old_voice_state = server.voice_states[user_id] old_channel_id = old_voice_state.voice_channel.id if o...
[ "def", "update_voice_state", "(", "data", ")", "@session_id", "=", "data", "[", "'session_id'", "]", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "server", "(", "server_id", ")", "return", "unless", "server", "user_id", "=", ...
Internal handler for VOICE_STATE_UPDATE
[ "Internal", "handler", "for", "VOICE_STATE_UPDATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L763-L777
12,355
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_voice_server
def update_voice_server(data) server_id = data['guild_id'].to_i channel = @should_connect_to_voice[server_id] debug("Voice server update received! chan: #{channel.inspect}") return unless channel @should_connect_to_voice.delete(server_id) debug('Updating voice server!') toke...
ruby
def update_voice_server(data) server_id = data['guild_id'].to_i channel = @should_connect_to_voice[server_id] debug("Voice server update received! chan: #{channel.inspect}") return unless channel @should_connect_to_voice.delete(server_id) debug('Updating voice server!') toke...
[ "def", "update_voice_server", "(", "data", ")", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "channel", "=", "@should_connect_to_voice", "[", "server_id", "]", "debug", "(", "\"Voice server update received! chan: #{channel.inspect}\"", ")", "return", ...
Internal handler for VOICE_SERVER_UPDATE
[ "Internal", "handler", "for", "VOICE_SERVER_UPDATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L780-L800
12,356
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.create_channel
def create_channel(data) channel = Channel.new(data, self) server = channel.server # Handle normal and private channels separately if server server.add_channel(channel) @channels[channel.id] = channel elsif channel.pm? @pm_channels[channel.recipient.id] = channel ...
ruby
def create_channel(data) channel = Channel.new(data, self) server = channel.server # Handle normal and private channels separately if server server.add_channel(channel) @channels[channel.id] = channel elsif channel.pm? @pm_channels[channel.recipient.id] = channel ...
[ "def", "create_channel", "(", "data", ")", "channel", "=", "Channel", ".", "new", "(", "data", ",", "self", ")", "server", "=", "channel", ".", "server", "# Handle normal and private channels separately", "if", "server", "server", ".", "add_channel", "(", "chann...
Internal handler for CHANNEL_CREATE
[ "Internal", "handler", "for", "CHANNEL_CREATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L803-L816
12,357
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_channel
def update_channel(data) channel = Channel.new(data, self) old_channel = @channels[channel.id] return unless old_channel old_channel.update_from(channel) end
ruby
def update_channel(data) channel = Channel.new(data, self) old_channel = @channels[channel.id] return unless old_channel old_channel.update_from(channel) end
[ "def", "update_channel", "(", "data", ")", "channel", "=", "Channel", ".", "new", "(", "data", ",", "self", ")", "old_channel", "=", "@channels", "[", "channel", ".", "id", "]", "return", "unless", "old_channel", "old_channel", ".", "update_from", "(", "ch...
Internal handler for CHANNEL_UPDATE
[ "Internal", "handler", "for", "CHANNEL_UPDATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L819-L825
12,358
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.delete_channel
def delete_channel(data) channel = Channel.new(data, self) server = channel.server # Handle normal and private channels separately if server @channels.delete(channel.id) server.delete_channel(channel.id) elsif channel.pm? @pm_channels.delete(channel.recipient.id) ...
ruby
def delete_channel(data) channel = Channel.new(data, self) server = channel.server # Handle normal and private channels separately if server @channels.delete(channel.id) server.delete_channel(channel.id) elsif channel.pm? @pm_channels.delete(channel.recipient.id) ...
[ "def", "delete_channel", "(", "data", ")", "channel", "=", "Channel", ".", "new", "(", "data", ",", "self", ")", "server", "=", "channel", ".", "server", "# Handle normal and private channels separately", "if", "server", "@channels", ".", "delete", "(", "channel...
Internal handler for CHANNEL_DELETE
[ "Internal", "handler", "for", "CHANNEL_DELETE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L828-L841
12,359
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.add_recipient
def add_recipient(data) channel_id = data['channel_id'].to_i channel = self.channel(channel_id) recipient_user = ensure_user(data['user']) recipient = Recipient.new(recipient_user, channel, self) channel.add_recipient(recipient) end
ruby
def add_recipient(data) channel_id = data['channel_id'].to_i channel = self.channel(channel_id) recipient_user = ensure_user(data['user']) recipient = Recipient.new(recipient_user, channel, self) channel.add_recipient(recipient) end
[ "def", "add_recipient", "(", "data", ")", "channel_id", "=", "data", "[", "'channel_id'", "]", ".", "to_i", "channel", "=", "self", ".", "channel", "(", "channel_id", ")", "recipient_user", "=", "ensure_user", "(", "data", "[", "'user'", "]", ")", "recipie...
Internal handler for CHANNEL_RECIPIENT_ADD
[ "Internal", "handler", "for", "CHANNEL_RECIPIENT_ADD" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L844-L851
12,360
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.add_guild_member
def add_guild_member(data) server_id = data['guild_id'].to_i server = self.server(server_id) member = Member.new(data, server, self) server.add_member(member) end
ruby
def add_guild_member(data) server_id = data['guild_id'].to_i server = self.server(server_id) member = Member.new(data, server, self) server.add_member(member) end
[ "def", "add_guild_member", "(", "data", ")", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "self", ".", "server", "(", "server_id", ")", "member", "=", "Member", ".", "new", "(", "data", ",", "server", ",", "self", ")", ...
Internal handler for GUILD_MEMBER_ADD
[ "Internal", "handler", "for", "GUILD_MEMBER_ADD" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L864-L870
12,361
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_guild_member
def update_guild_member(data) server_id = data['guild_id'].to_i server = self.server(server_id) member = server.member(data['user']['id'].to_i) member.update_roles(data['roles']) member.update_nick(data['nick']) end
ruby
def update_guild_member(data) server_id = data['guild_id'].to_i server = self.server(server_id) member = server.member(data['user']['id'].to_i) member.update_roles(data['roles']) member.update_nick(data['nick']) end
[ "def", "update_guild_member", "(", "data", ")", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "self", ".", "server", "(", "server_id", ")", "member", "=", "server", ".", "member", "(", "data", "[", "'user'", "]", "[", "'...
Internal handler for GUILD_MEMBER_UPDATE
[ "Internal", "handler", "for", "GUILD_MEMBER_UPDATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L873-L880
12,362
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.delete_guild_member
def delete_guild_member(data) server_id = data['guild_id'].to_i server = self.server(server_id) user_id = data['user']['id'].to_i server.delete_member(user_id) rescue Discordrb::Errors::NoPermission Discordrb::LOGGER.warn("delete_guild_member attempted to access a server for which the...
ruby
def delete_guild_member(data) server_id = data['guild_id'].to_i server = self.server(server_id) user_id = data['user']['id'].to_i server.delete_member(user_id) rescue Discordrb::Errors::NoPermission Discordrb::LOGGER.warn("delete_guild_member attempted to access a server for which the...
[ "def", "delete_guild_member", "(", "data", ")", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "self", ".", "server", "(", "server_id", ")", "user_id", "=", "data", "[", "'user'", "]", "[", "'id'", "]", ".", "to_i", "serv...
Internal handler for GUILD_MEMBER_DELETE
[ "Internal", "handler", "for", "GUILD_MEMBER_DELETE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L883-L891
12,363
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_guild_role
def update_guild_role(data) role_data = data['role'] server_id = data['guild_id'].to_i server = @servers[server_id] new_role = Role.new(role_data, self, server) role_id = role_data['id'].to_i old_role = server.roles.find { |r| r.id == role_id } old_role.update_from(new_role) ...
ruby
def update_guild_role(data) role_data = data['role'] server_id = data['guild_id'].to_i server = @servers[server_id] new_role = Role.new(role_data, self, server) role_id = role_data['id'].to_i old_role = server.roles.find { |r| r.id == role_id } old_role.update_from(new_role) ...
[ "def", "update_guild_role", "(", "data", ")", "role_data", "=", "data", "[", "'role'", "]", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "@servers", "[", "server_id", "]", "new_role", "=", "Role", ".", "new", "(", "role_d...
Internal handler for GUILD_ROLE_UPDATE
[ "Internal", "handler", "for", "GUILD_ROLE_UPDATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L910-L918
12,364
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.create_guild_role
def create_guild_role(data) role_data = data['role'] server_id = data['guild_id'].to_i server = @servers[server_id] new_role = Role.new(role_data, self, server) existing_role = server.role(new_role.id) if existing_role existing_role.update_from(new_role) else se...
ruby
def create_guild_role(data) role_data = data['role'] server_id = data['guild_id'].to_i server = @servers[server_id] new_role = Role.new(role_data, self, server) existing_role = server.role(new_role.id) if existing_role existing_role.update_from(new_role) else se...
[ "def", "create_guild_role", "(", "data", ")", "role_data", "=", "data", "[", "'role'", "]", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "@servers", "[", "server_id", "]", "new_role", "=", "Role", ".", "new", "(", "role_d...
Internal handler for GUILD_ROLE_CREATE
[ "Internal", "handler", "for", "GUILD_ROLE_CREATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L921-L932
12,365
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.delete_guild_role
def delete_guild_role(data) role_id = data['role_id'].to_i server_id = data['guild_id'].to_i server = @servers[server_id] server.delete_role(role_id) end
ruby
def delete_guild_role(data) role_id = data['role_id'].to_i server_id = data['guild_id'].to_i server = @servers[server_id] server.delete_role(role_id) end
[ "def", "delete_guild_role", "(", "data", ")", "role_id", "=", "data", "[", "'role_id'", "]", ".", "to_i", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "@servers", "[", "server_id", "]", "server", ".", "delete_role", "(", ...
Internal handler for GUILD_ROLE_DELETE
[ "Internal", "handler", "for", "GUILD_ROLE_DELETE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L935-L940
12,366
meew0/discordrb
lib/discordrb/bot.rb
Discordrb.Bot.update_guild_emoji
def update_guild_emoji(data) server_id = data['guild_id'].to_i server = @servers[server_id] server.update_emoji_data(data) end
ruby
def update_guild_emoji(data) server_id = data['guild_id'].to_i server = @servers[server_id] server.update_emoji_data(data) end
[ "def", "update_guild_emoji", "(", "data", ")", "server_id", "=", "data", "[", "'guild_id'", "]", ".", "to_i", "server", "=", "@servers", "[", "server_id", "]", "server", ".", "update_emoji_data", "(", "data", ")", "end" ]
Internal handler for GUILD_EMOJIS_UPDATE
[ "Internal", "handler", "for", "GUILD_EMOJIS_UPDATE" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/bot.rb#L943-L947
12,367
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.voice_regions
def voice_regions return @voice_regions unless @voice_regions.empty? regions = JSON.parse API.voice_regions(token) regions.each do |data| @voice_regions[data['id']] = VoiceRegion.new(data) end @voice_regions end
ruby
def voice_regions return @voice_regions unless @voice_regions.empty? regions = JSON.parse API.voice_regions(token) regions.each do |data| @voice_regions[data['id']] = VoiceRegion.new(data) end @voice_regions end
[ "def", "voice_regions", "return", "@voice_regions", "unless", "@voice_regions", ".", "empty?", "regions", "=", "JSON", ".", "parse", "API", ".", "voice_regions", "(", "token", ")", "regions", ".", "each", "do", "|", "data", "|", "@voice_regions", "[", "data", ...
Returns or caches the available voice regions
[ "Returns", "or", "caches", "the", "available", "voice", "regions" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L29-L38
12,368
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.channel
def channel(id, server = nil) id = id.resolve_id raise Discordrb::Errors::NoPermission if @restricted_channels.include? id debug("Obtaining data for channel with id #{id}") return @channels[id] if @channels[id] begin begin response = API::Channel.resolve(token, id) ...
ruby
def channel(id, server = nil) id = id.resolve_id raise Discordrb::Errors::NoPermission if @restricted_channels.include? id debug("Obtaining data for channel with id #{id}") return @channels[id] if @channels[id] begin begin response = API::Channel.resolve(token, id) ...
[ "def", "channel", "(", "id", ",", "server", "=", "nil", ")", "id", "=", "id", ".", "resolve_id", "raise", "Discordrb", "::", "Errors", "::", "NoPermission", "if", "@restricted_channels", ".", "include?", "id", "debug", "(", "\"Obtaining data for channel with id ...
Gets a channel given its ID. This queries the internal channel cache, and if the channel doesn't exist in there, it will get the data from Discord. @param id [Integer] The channel ID for which to search for. @param server [Server] The server for which to search the channel for. If this isn't specified, it will be ...
[ "Gets", "a", "channel", "given", "its", "ID", ".", "This", "queries", "the", "internal", "channel", "cache", "and", "if", "the", "channel", "doesn", "t", "exist", "in", "there", "it", "will", "get", "the", "data", "from", "Discord", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L46-L67
12,369
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.user
def user(id) id = id.resolve_id return @users[id] if @users[id] LOGGER.out("Resolving user #{id}") begin response = API::User.resolve(token, id) rescue RestClient::ResourceNotFound return nil end user = User.new(JSON.parse(response), self) @users[id] = us...
ruby
def user(id) id = id.resolve_id return @users[id] if @users[id] LOGGER.out("Resolving user #{id}") begin response = API::User.resolve(token, id) rescue RestClient::ResourceNotFound return nil end user = User.new(JSON.parse(response), self) @users[id] = us...
[ "def", "user", "(", "id", ")", "id", "=", "id", ".", "resolve_id", "return", "@users", "[", "id", "]", "if", "@users", "[", "id", "]", "LOGGER", ".", "out", "(", "\"Resolving user #{id}\"", ")", "begin", "response", "=", "API", "::", "User", ".", "re...
Gets a user by its ID. @note This can only resolve users known by the bot (i.e. that share a server with the bot). @param id [Integer] The user ID that should be resolved. @return [User, nil] The user identified by the ID, or `nil` if it couldn't be found.
[ "Gets", "a", "user", "by", "its", "ID", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L75-L87
12,370
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.server
def server(id) id = id.resolve_id return @servers[id] if @servers[id] LOGGER.out("Resolving server #{id}") begin response = API::Server.resolve(token, id) rescue Discordrb::Errors::NoPermission return nil end server = Server.new(JSON.parse(response), self) ...
ruby
def server(id) id = id.resolve_id return @servers[id] if @servers[id] LOGGER.out("Resolving server #{id}") begin response = API::Server.resolve(token, id) rescue Discordrb::Errors::NoPermission return nil end server = Server.new(JSON.parse(response), self) ...
[ "def", "server", "(", "id", ")", "id", "=", "id", ".", "resolve_id", "return", "@servers", "[", "id", "]", "if", "@servers", "[", "id", "]", "LOGGER", ".", "out", "(", "\"Resolving server #{id}\"", ")", "begin", "response", "=", "API", "::", "Server", ...
Gets a server by its ID. @note This can only resolve servers the bot is currently in. @param id [Integer] The server ID that should be resolved. @return [Server, nil] The server identified by the ID, or `nil` if it couldn't be found.
[ "Gets", "a", "server", "by", "its", "ID", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L93-L105
12,371
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.member
def member(server_or_id, user_id) server_id = server_or_id.resolve_id user_id = user_id.resolve_id server = server_or_id.is_a?(Server) ? server_or_id : self.server(server_id) return server.member(user_id) if server.member_cached?(user_id) LOGGER.out("Resolving member #{server_id} on ser...
ruby
def member(server_or_id, user_id) server_id = server_or_id.resolve_id user_id = user_id.resolve_id server = server_or_id.is_a?(Server) ? server_or_id : self.server(server_id) return server.member(user_id) if server.member_cached?(user_id) LOGGER.out("Resolving member #{server_id} on ser...
[ "def", "member", "(", "server_or_id", ",", "user_id", ")", "server_id", "=", "server_or_id", ".", "resolve_id", "user_id", "=", "user_id", ".", "resolve_id", "server", "=", "server_or_id", ".", "is_a?", "(", "Server", ")", "?", "server_or_id", ":", "self", "...
Gets a member by both IDs, or `Server` and user ID. @param server_or_id [Server, Integer] The `Server` or server ID for which a member should be resolved @param user_id [Integer] The ID of the user that should be resolved @return [Member, nil] The member identified by the IDs, or `nil` if none could be found
[ "Gets", "a", "member", "by", "both", "IDs", "or", "Server", "and", "user", "ID", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L111-L127
12,372
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.ensure_user
def ensure_user(data) if @users.include?(data['id'].to_i) @users[data['id'].to_i] else @users[data['id'].to_i] = User.new(data, self) end end
ruby
def ensure_user(data) if @users.include?(data['id'].to_i) @users[data['id'].to_i] else @users[data['id'].to_i] = User.new(data, self) end end
[ "def", "ensure_user", "(", "data", ")", "if", "@users", ".", "include?", "(", "data", "[", "'id'", "]", ".", "to_i", ")", "@users", "[", "data", "[", "'id'", "]", ".", "to_i", "]", "else", "@users", "[", "data", "[", "'id'", "]", ".", "to_i", "]"...
Ensures a given user object is cached and if not, cache it from the given data hash. @param data [Hash] A data hash representing a user. @return [User] the user represented by the data hash.
[ "Ensures", "a", "given", "user", "object", "is", "cached", "and", "if", "not", "cache", "it", "from", "the", "given", "data", "hash", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L149-L155
12,373
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.ensure_server
def ensure_server(data) if @servers.include?(data['id'].to_i) @servers[data['id'].to_i] else @servers[data['id'].to_i] = Server.new(data, self) end end
ruby
def ensure_server(data) if @servers.include?(data['id'].to_i) @servers[data['id'].to_i] else @servers[data['id'].to_i] = Server.new(data, self) end end
[ "def", "ensure_server", "(", "data", ")", "if", "@servers", ".", "include?", "(", "data", "[", "'id'", "]", ".", "to_i", ")", "@servers", "[", "data", "[", "'id'", "]", ".", "to_i", "]", "else", "@servers", "[", "data", "[", "'id'", "]", ".", "to_i...
Ensures a given server object is cached and if not, cache it from the given data hash. @param data [Hash] A data hash representing a server. @return [Server] the server represented by the data hash.
[ "Ensures", "a", "given", "server", "object", "is", "cached", "and", "if", "not", "cache", "it", "from", "the", "given", "data", "hash", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L160-L166
12,374
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.ensure_channel
def ensure_channel(data, server = nil) if @channels.include?(data['id'].to_i) @channels[data['id'].to_i] else @channels[data['id'].to_i] = Channel.new(data, self, server) end end
ruby
def ensure_channel(data, server = nil) if @channels.include?(data['id'].to_i) @channels[data['id'].to_i] else @channels[data['id'].to_i] = Channel.new(data, self, server) end end
[ "def", "ensure_channel", "(", "data", ",", "server", "=", "nil", ")", "if", "@channels", ".", "include?", "(", "data", "[", "'id'", "]", ".", "to_i", ")", "@channels", "[", "data", "[", "'id'", "]", ".", "to_i", "]", "else", "@channels", "[", "data",...
Ensures a given channel object is cached and if not, cache it from the given data hash. @param data [Hash] A data hash representing a channel. @param server [Server, nil] The server the channel is on, if known. @return [Channel] the channel represented by the data hash.
[ "Ensures", "a", "given", "channel", "object", "is", "cached", "and", "if", "not", "cache", "it", "from", "the", "given", "data", "hash", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L172-L178
12,375
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.invite
def invite(invite) code = resolve_invite_code(invite) Invite.new(JSON.parse(API::Invite.resolve(token, code)), self) end
ruby
def invite(invite) code = resolve_invite_code(invite) Invite.new(JSON.parse(API::Invite.resolve(token, code)), self) end
[ "def", "invite", "(", "invite", ")", "code", "=", "resolve_invite_code", "(", "invite", ")", "Invite", ".", "new", "(", "JSON", ".", "parse", "(", "API", "::", "Invite", ".", "resolve", "(", "token", ",", "code", ")", ")", ",", "self", ")", "end" ]
Gets information about an invite. @param invite [String, Invite] The invite to join. For possible formats see {#resolve_invite_code}. @return [Invite] The invite with information about the given invite URL.
[ "Gets", "information", "about", "an", "invite", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L204-L207
12,376
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.find_channel
def find_channel(channel_name, server_name = nil, type: nil) results = [] if /<#(?<id>\d+)>?/ =~ channel_name # Check for channel mentions separately return [channel(id)] end @servers.values.each do |server| server.channels.each do |channel| results << channel...
ruby
def find_channel(channel_name, server_name = nil, type: nil) results = [] if /<#(?<id>\d+)>?/ =~ channel_name # Check for channel mentions separately return [channel(id)] end @servers.values.each do |server| server.channels.each do |channel| results << channel...
[ "def", "find_channel", "(", "channel_name", ",", "server_name", "=", "nil", ",", "type", ":", "nil", ")", "results", "=", "[", "]", "if", "/", "\\d", "/", "=~", "channel_name", "# Check for channel mentions separately", "return", "[", "channel", "(", "id", "...
Finds a channel given its name and optionally the name of the server it is in. @param channel_name [String] The channel to search for. @param server_name [String] The server to search for, or `nil` if only the channel should be searched for. @param type [Integer, nil] The type of channel to search for (0: text, 1: p...
[ "Finds", "a", "channel", "given", "its", "name", "and", "optionally", "the", "name", "of", "the", "server", "it", "is", "in", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L215-L230
12,377
meew0/discordrb
lib/discordrb/cache.rb
Discordrb.Cache.find_user
def find_user(username, discrim = nil) users = @users.values.find_all { |e| e.username == username } return users.find { |u| u.discrim == discrim } if discrim users end
ruby
def find_user(username, discrim = nil) users = @users.values.find_all { |e| e.username == username } return users.find { |u| u.discrim == discrim } if discrim users end
[ "def", "find_user", "(", "username", ",", "discrim", "=", "nil", ")", "users", "=", "@users", ".", "values", ".", "find_all", "{", "|", "e", "|", "e", ".", "username", "==", "username", "}", "return", "users", ".", "find", "{", "|", "u", "|", "u", ...
Finds a user given its username or username & discriminator. @overload find_user(username) Find all cached users with a certain username. @param username [String] The username to look for. @return [Array<User>] The array of users that were found. May be empty if none were found. @overload find_user(username,...
[ "Finds", "a", "user", "given", "its", "username", "or", "username", "&", "discriminator", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/cache.rb#L249-L254
12,378
meew0/discordrb
lib/discordrb/data/message.rb
Discordrb.Message.edit
def edit(new_content, new_embed = nil) response = API::Channel.edit_message(@bot.token, @channel.id, @id, new_content, [], new_embed ? new_embed.to_hash : nil) Message.new(JSON.parse(response), @bot) end
ruby
def edit(new_content, new_embed = nil) response = API::Channel.edit_message(@bot.token, @channel.id, @id, new_content, [], new_embed ? new_embed.to_hash : nil) Message.new(JSON.parse(response), @bot) end
[ "def", "edit", "(", "new_content", ",", "new_embed", "=", "nil", ")", "response", "=", "API", "::", "Channel", ".", "edit_message", "(", "@bot", ".", "token", ",", "@channel", ".", "id", ",", "@id", ",", "new_content", ",", "[", "]", ",", "new_embed", ...
Edits this message to have the specified content instead. You can only edit your own messages. @param new_content [String] the new content the message should have. @param new_embed [Hash, Discordrb::Webhooks::Embed, nil] The new embed the message should have. If `nil` the message will be changed to have no embed. @...
[ "Edits", "this", "message", "to", "have", "the", "specified", "content", "instead", ".", "You", "can", "only", "edit", "your", "own", "messages", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/message.rb#L155-L158
12,379
meew0/discordrb
lib/discordrb/data/message.rb
Discordrb.Message.create_reaction
def create_reaction(reaction) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) API::Channel.create_reaction(@bot.token, @channel.id, @id, reaction) nil end
ruby
def create_reaction(reaction) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) API::Channel.create_reaction(@bot.token, @channel.id, @id, reaction) nil end
[ "def", "create_reaction", "(", "reaction", ")", "reaction", "=", "reaction", ".", "to_reaction", "if", "reaction", ".", "respond_to?", "(", ":to_reaction", ")", "API", "::", "Channel", ".", "create_reaction", "(", "@bot", ".", "token", ",", "@channel", ".", ...
Reacts to a message. @param reaction [String, #to_reaction] the unicode emoji or {Emoji}
[ "Reacts", "to", "a", "message", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/message.rb#L243-L247
12,380
meew0/discordrb
lib/discordrb/data/message.rb
Discordrb.Message.reacted_with
def reacted_with(reaction, limit: 100) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) paginator = Paginator.new(limit, :down) do |last_page| after_id = last_page.last.id if last_page last_page = JSON.parse(API::Channel.get_reactions(@bot.token, @channel.id, @id, reacti...
ruby
def reacted_with(reaction, limit: 100) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) paginator = Paginator.new(limit, :down) do |last_page| after_id = last_page.last.id if last_page last_page = JSON.parse(API::Channel.get_reactions(@bot.token, @channel.id, @id, reacti...
[ "def", "reacted_with", "(", "reaction", ",", "limit", ":", "100", ")", "reaction", "=", "reaction", ".", "to_reaction", "if", "reaction", ".", "respond_to?", "(", ":to_reaction", ")", "paginator", "=", "Paginator", ".", "new", "(", "limit", ",", ":down", "...
Returns the list of users who reacted with a certain reaction. @param reaction [String, #to_reaction] the unicode emoji or {Emoji} @param limit [Integer] the limit of how many users to retrieve. `nil` will return all users @example Get all the users that reacted with a thumbsup. thumbs_up_reactions = message.reac...
[ "Returns", "the", "list", "of", "users", "who", "reacted", "with", "a", "certain", "reaction", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/message.rb#L257-L265
12,381
meew0/discordrb
lib/discordrb/data/message.rb
Discordrb.Message.delete_reaction
def delete_reaction(user, reaction) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) API::Channel.delete_user_reaction(@bot.token, @channel.id, @id, reaction, user.resolve_id) end
ruby
def delete_reaction(user, reaction) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) API::Channel.delete_user_reaction(@bot.token, @channel.id, @id, reaction, user.resolve_id) end
[ "def", "delete_reaction", "(", "user", ",", "reaction", ")", "reaction", "=", "reaction", ".", "to_reaction", "if", "reaction", ".", "respond_to?", "(", ":to_reaction", ")", "API", "::", "Channel", ".", "delete_user_reaction", "(", "@bot", ".", "token", ",", ...
Deletes a reaction made by a user on this message. @param user [User, #resolve_id] the user who used this reaction @param reaction [String, #to_reaction] the reaction to remove
[ "Deletes", "a", "reaction", "made", "by", "a", "user", "on", "this", "message", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/message.rb#L270-L273
12,382
meew0/discordrb
lib/discordrb/data/message.rb
Discordrb.Message.delete_own_reaction
def delete_own_reaction(reaction) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) API::Channel.delete_own_reaction(@bot.token, @channel.id, @id, reaction) end
ruby
def delete_own_reaction(reaction) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) API::Channel.delete_own_reaction(@bot.token, @channel.id, @id, reaction) end
[ "def", "delete_own_reaction", "(", "reaction", ")", "reaction", "=", "reaction", ".", "to_reaction", "if", "reaction", ".", "respond_to?", "(", ":to_reaction", ")", "API", "::", "Channel", ".", "delete_own_reaction", "(", "@bot", ".", "token", ",", "@channel", ...
Deletes this client's reaction on this message. @param reaction [String, #to_reaction] the reaction to remove
[ "Deletes", "this", "client", "s", "reaction", "on", "this", "message", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/message.rb#L277-L280
12,383
meew0/discordrb
lib/discordrb/data/audit_logs.rb
Discordrb.AuditLogs.process_users
def process_users(users) users.each do |element| user = User.new(element, @bot) @users[user.id] = user end end
ruby
def process_users(users) users.each do |element| user = User.new(element, @bot) @users[user.id] = user end end
[ "def", "process_users", "(", "users", ")", "users", ".", "each", "do", "|", "element", "|", "user", "=", "User", ".", "new", "(", "element", ",", "@bot", ")", "@users", "[", "user", ".", "id", "]", "=", "user", "end", "end" ]
Process user objects given by the request @note For internal use only @!visibility private
[ "Process", "user", "objects", "given", "by", "the", "request" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/audit_logs.rb#L268-L273
12,384
meew0/discordrb
lib/discordrb/data/audit_logs.rb
Discordrb.AuditLogs.process_webhooks
def process_webhooks(webhooks) webhooks.each do |element| webhook = Webhook.new(element, @bot) @webhooks[webhook.id] = webhook end end
ruby
def process_webhooks(webhooks) webhooks.each do |element| webhook = Webhook.new(element, @bot) @webhooks[webhook.id] = webhook end end
[ "def", "process_webhooks", "(", "webhooks", ")", "webhooks", ".", "each", "do", "|", "element", "|", "webhook", "=", "Webhook", ".", "new", "(", "element", ",", "@bot", ")", "@webhooks", "[", "webhook", ".", "id", "]", "=", "webhook", "end", "end" ]
Process webhook objects given by the request @note For internal use only @!visibility private
[ "Process", "webhook", "objects", "given", "by", "the", "request" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/audit_logs.rb#L278-L283
12,385
meew0/discordrb
lib/discordrb/commands/parser.rb
Discordrb::Commands.CommandChain.execute
def execute(event) old_chain = @chain @bot.debug 'Executing bare chain' result = execute_bare(event) @chain_args ||= [] @bot.debug "Found chain args #{@chain_args}, preliminary result #{result}" @chain_args.each do |arg| case arg.first when 'repeat' new_r...
ruby
def execute(event) old_chain = @chain @bot.debug 'Executing bare chain' result = execute_bare(event) @chain_args ||= [] @bot.debug "Found chain args #{@chain_args}, preliminary result #{result}" @chain_args.each do |arg| case arg.first when 'repeat' new_r...
[ "def", "execute", "(", "event", ")", "old_chain", "=", "@chain", "@bot", ".", "debug", "'Executing bare chain'", "result", "=", "execute_bare", "(", "event", ")", "@chain_args", "||=", "[", "]", "@bot", ".", "debug", "\"Found chain args #{@chain_args}, preliminary r...
Divides the command chain into chain arguments and command chain, then executes them both. @param event [CommandEvent] The event to execute the command with. @return [String] the result of the command chain execution.
[ "Divides", "the", "command", "chain", "into", "chain", "arguments", "and", "command", "chain", "then", "executes", "them", "both", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/commands/parser.rb#L278-L304
12,386
meew0/discordrb
lib/discordrb/data/role.rb
Discordrb.Role.update_from
def update_from(other) @permissions = other.permissions @name = other.name @hoist = other.hoist @colour = other.colour @position = other.position @managed = other.managed end
ruby
def update_from(other) @permissions = other.permissions @name = other.name @hoist = other.hoist @colour = other.colour @position = other.position @managed = other.managed end
[ "def", "update_from", "(", "other", ")", "@permissions", "=", "other", ".", "permissions", "@name", "=", "other", ".", "name", "@hoist", "=", "other", ".", "hoist", "@colour", "=", "other", ".", "colour", "@position", "=", "other", ".", "position", "@manag...
Updates the data cache from another Role object @note For internal use only @!visibility private
[ "Updates", "the", "data", "cache", "from", "another", "Role", "object" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/role.rb#L88-L95
12,387
meew0/discordrb
lib/discordrb/data/role.rb
Discordrb.Role.update_data
def update_data(new_data) @name = new_data[:name] || new_data['name'] || @name @hoist = new_data['hoist'] unless new_data['hoist'].nil? @hoist = new_data[:hoist] unless new_data[:hoist].nil? @colour = new_data[:colour] || (new_data['color'] ? ColourRGB.new(new_data['color']) : @colour) end
ruby
def update_data(new_data) @name = new_data[:name] || new_data['name'] || @name @hoist = new_data['hoist'] unless new_data['hoist'].nil? @hoist = new_data[:hoist] unless new_data[:hoist].nil? @colour = new_data[:colour] || (new_data['color'] ? ColourRGB.new(new_data['color']) : @colour) end
[ "def", "update_data", "(", "new_data", ")", "@name", "=", "new_data", "[", ":name", "]", "||", "new_data", "[", "'name'", "]", "||", "@name", "@hoist", "=", "new_data", "[", "'hoist'", "]", "unless", "new_data", "[", "'hoist'", "]", ".", "nil?", "@hoist"...
Updates the data cache from a hash containing data @note For internal use only @!visibility private
[ "Updates", "the", "data", "cache", "from", "a", "hash", "containing", "data" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/role.rb#L100-L105
12,388
meew0/discordrb
lib/discordrb/data/role.rb
Discordrb.Role.packed=
def packed=(packed, update_perms = true) update_role_data(permissions: packed) @permissions.bits = packed if update_perms end
ruby
def packed=(packed, update_perms = true) update_role_data(permissions: packed) @permissions.bits = packed if update_perms end
[ "def", "packed", "=", "(", "packed", ",", "update_perms", "=", "true", ")", "update_role_data", "(", "permissions", ":", "packed", ")", "@permissions", ".", "bits", "=", "packed", "if", "update_perms", "end" ]
Changes this role's permissions to a fixed bitfield. This allows setting multiple permissions at once with just one API call. Information on how this bitfield is structured can be found at https://discordapp.com/developers/docs/topics/permissions. @example Remove all permissions from a role role.packed = 0 @pa...
[ "Changes", "this", "role", "s", "permissions", "to", "a", "fixed", "bitfield", ".", "This", "allows", "setting", "multiple", "permissions", "at", "once", "with", "just", "one", "API", "call", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/role.rb#L143-L146
12,389
meew0/discordrb
lib/discordrb/data/role.rb
Discordrb.Role.sort_above
def sort_above(other = nil) other = @server.role(other.resolve_id) if other roles = @server.roles.sort_by(&:position) roles.delete_at(@position) index = other ? roles.index { |role| role.id == other.id } + 1 : 1 roles.insert(index, self) updated_roles = roles.map.with_index { |role...
ruby
def sort_above(other = nil) other = @server.role(other.resolve_id) if other roles = @server.roles.sort_by(&:position) roles.delete_at(@position) index = other ? roles.index { |role| role.id == other.id } + 1 : 1 roles.insert(index, self) updated_roles = roles.map.with_index { |role...
[ "def", "sort_above", "(", "other", "=", "nil", ")", "other", "=", "@server", ".", "role", "(", "other", ".", "resolve_id", ")", "if", "other", "roles", "=", "@server", ".", "roles", ".", "sort_by", "(", ":position", ")", "roles", ".", "delete_at", "(",...
Moves this role above another role in the list. @param other [Role, #resolve_id, nil] The role above which this role should be moved. If it is `nil`, the role will be moved above the @everyone role. @return [Integer] the new position of this role
[ "Moves", "this", "role", "above", "another", "role", "in", "the", "list", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/role.rb#L152-L163
12,390
meew0/discordrb
lib/discordrb/data/member.rb
Discordrb.Member.set_roles
def set_roles(role, reason = nil) role_ids = role_id_array(role) API::Server.update_member(@bot.token, @server.id, @user.id, roles: role_ids, reason: reason) end
ruby
def set_roles(role, reason = nil) role_ids = role_id_array(role) API::Server.update_member(@bot.token, @server.id, @user.id, roles: role_ids, reason: reason) end
[ "def", "set_roles", "(", "role", ",", "reason", "=", "nil", ")", "role_ids", "=", "role_id_array", "(", "role", ")", "API", "::", "Server", ".", "update_member", "(", "@bot", ".", "token", ",", "@server", ".", "id", ",", "@user", ".", "id", ",", "rol...
Bulk sets a member's roles. @param role [Role, Array<Role>] The role(s) to set. @param reason [String] The reason the user's roles are being changed.
[ "Bulk", "sets", "a", "member", "s", "roles", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/member.rb#L94-L97
12,391
meew0/discordrb
lib/discordrb/data/member.rb
Discordrb.Member.modify_roles
def modify_roles(add, remove, reason = nil) add_role_ids = role_id_array(add) remove_role_ids = role_id_array(remove) old_role_ids = @roles.map(&:id) new_role_ids = (old_role_ids - remove_role_ids + add_role_ids).uniq API::Server.update_member(@bot.token, @server.id, @user.id, roles: new_...
ruby
def modify_roles(add, remove, reason = nil) add_role_ids = role_id_array(add) remove_role_ids = role_id_array(remove) old_role_ids = @roles.map(&:id) new_role_ids = (old_role_ids - remove_role_ids + add_role_ids).uniq API::Server.update_member(@bot.token, @server.id, @user.id, roles: new_...
[ "def", "modify_roles", "(", "add", ",", "remove", ",", "reason", "=", "nil", ")", "add_role_ids", "=", "role_id_array", "(", "add", ")", "remove_role_ids", "=", "role_id_array", "(", "remove", ")", "old_role_ids", "=", "@roles", ".", "map", "(", ":id", ")"...
Adds and removes roles from a member. @param add [Role, Array<Role>] The role(s) to add. @param remove [Role, Array<Role>] The role(s) to remove. @param reason [String] The reason the user's roles are being changed. @example Remove the 'Member' role from a user, and add the 'Muted' role to them. to_add = server....
[ "Adds", "and", "removes", "roles", "from", "a", "member", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/member.rb#L107-L114
12,392
meew0/discordrb
lib/discordrb/data/member.rb
Discordrb.Member.add_role
def add_role(role, reason = nil) role_ids = role_id_array(role) if role_ids.count == 1 API::Server.add_member_role(@bot.token, @server.id, @user.id, role_ids[0], reason) else old_role_ids = @roles.map(&:id) new_role_ids = (old_role_ids + role_ids).uniq API::Server.upda...
ruby
def add_role(role, reason = nil) role_ids = role_id_array(role) if role_ids.count == 1 API::Server.add_member_role(@bot.token, @server.id, @user.id, role_ids[0], reason) else old_role_ids = @roles.map(&:id) new_role_ids = (old_role_ids + role_ids).uniq API::Server.upda...
[ "def", "add_role", "(", "role", ",", "reason", "=", "nil", ")", "role_ids", "=", "role_id_array", "(", "role", ")", "if", "role_ids", ".", "count", "==", "1", "API", "::", "Server", ".", "add_member_role", "(", "@bot", ".", "token", ",", "@server", "."...
Adds one or more roles to this member. @param role [Role, Array<Role, #resolve_id>, #resolve_id] The role(s) to add. @param reason [String] The reason the user's roles are being changed.
[ "Adds", "one", "or", "more", "roles", "to", "this", "member", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/member.rb#L119-L129
12,393
meew0/discordrb
lib/discordrb/data/member.rb
Discordrb.Member.remove_role
def remove_role(role, reason = nil) role_ids = role_id_array(role) if role_ids.count == 1 API::Server.remove_member_role(@bot.token, @server.id, @user.id, role_ids[0], reason) else old_role_ids = @roles.map(&:id) new_role_ids = old_role_ids.reject { |i| role_ids.include?(i) } ...
ruby
def remove_role(role, reason = nil) role_ids = role_id_array(role) if role_ids.count == 1 API::Server.remove_member_role(@bot.token, @server.id, @user.id, role_ids[0], reason) else old_role_ids = @roles.map(&:id) new_role_ids = old_role_ids.reject { |i| role_ids.include?(i) } ...
[ "def", "remove_role", "(", "role", ",", "reason", "=", "nil", ")", "role_ids", "=", "role_id_array", "(", "role", ")", "if", "role_ids", ".", "count", "==", "1", "API", "::", "Server", ".", "remove_member_role", "(", "@bot", ".", "token", ",", "@server",...
Removes one or more roles from this member. @param role [Role, Array<Role>] The role(s) to remove. @param reason [String] The reason the user's roles are being changed.
[ "Removes", "one", "or", "more", "roles", "from", "this", "member", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/member.rb#L134-L144
12,394
meew0/discordrb
lib/discordrb/data/member.rb
Discordrb.Member.set_nick
def set_nick(nick, reason = nil) # Discord uses the empty string to signify 'no nickname' so we convert nil into that nick ||= '' if @user.current_bot? API::User.change_own_nickname(@bot.token, @server.id, nick, reason) else API::Server.update_member(@bot.token, @server.id, @use...
ruby
def set_nick(nick, reason = nil) # Discord uses the empty string to signify 'no nickname' so we convert nil into that nick ||= '' if @user.current_bot? API::User.change_own_nickname(@bot.token, @server.id, nick, reason) else API::Server.update_member(@bot.token, @server.id, @use...
[ "def", "set_nick", "(", "nick", ",", "reason", "=", "nil", ")", "# Discord uses the empty string to signify 'no nickname' so we convert nil into that", "nick", "||=", "''", "if", "@user", ".", "current_bot?", "API", "::", "User", ".", "change_own_nickname", "(", "@bot",...
Sets or resets this member's nickname. Requires the Change Nickname permission for the bot itself and Manage Nicknames for other users. @param nick [String, nil] The string to set the nickname to, or nil if it should be reset. @param reason [String] The reason the user's nickname is being changed.
[ "Sets", "or", "resets", "this", "member", "s", "nickname", ".", "Requires", "the", "Change", "Nickname", "permission", "for", "the", "bot", "itself", "and", "Manage", "Nicknames", "for", "other", "users", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/member.rb#L207-L216
12,395
meew0/discordrb
lib/discordrb/data/member.rb
Discordrb.Member.update_roles
def update_roles(role_ids) @roles = [] role_ids.each do |id| # It is posible for members to have roles that do not exist # on the server any longer. See https://github.com/meew0/discordrb/issues/371 role = @server.role(id) @roles << role if role end end
ruby
def update_roles(role_ids) @roles = [] role_ids.each do |id| # It is posible for members to have roles that do not exist # on the server any longer. See https://github.com/meew0/discordrb/issues/371 role = @server.role(id) @roles << role if role end end
[ "def", "update_roles", "(", "role_ids", ")", "@roles", "=", "[", "]", "role_ids", ".", "each", "do", "|", "id", "|", "# It is posible for members to have roles that do not exist", "# on the server any longer. See https://github.com/meew0/discordrb/issues/371", "role", "=", "@...
Update this member's roles @note For internal use only. @!visibility private
[ "Update", "this", "member", "s", "roles" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/data/member.rb#L228-L236
12,396
meew0/discordrb
lib/discordrb/commands/command_bot.rb
Discordrb::Commands.CommandBot.execute_command
def execute_command(name, event, arguments, chained = false, check_permissions = true) debug("Executing command #{name} with arguments #{arguments}") return unless @commands command = @commands[name] command = command.aliased_command if command.is_a?(CommandAlias) return unless !check_per...
ruby
def execute_command(name, event, arguments, chained = false, check_permissions = true) debug("Executing command #{name} with arguments #{arguments}") return unless @commands command = @commands[name] command = command.aliased_command if command.is_a?(CommandAlias) return unless !check_per...
[ "def", "execute_command", "(", "name", ",", "event", ",", "arguments", ",", "chained", "=", "false", ",", "check_permissions", "=", "true", ")", "debug", "(", "\"Executing command #{name} with arguments #{arguments}\"", ")", "return", "unless", "@commands", "command",...
Executes a particular command on the bot. Mostly useful for internal stuff, but one can never know. @param name [Symbol] The command to execute. @param event [CommandEvent] The event to pass to the command. @param arguments [Array<String>] The arguments to pass to the command. @param chained [true, false] Whether o...
[ "Executes", "a", "particular", "command", "on", "the", "bot", ".", "Mostly", "useful", "for", "internal", "stuff", "but", "one", "can", "never", "know", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/commands/command_bot.rb#L208-L240
12,397
meew0/discordrb
lib/discordrb/commands/command_bot.rb
Discordrb::Commands.CommandBot.simple_execute
def simple_execute(chain, event) return nil if chain.empty? args = chain.split(' ') execute_command(args[0].to_sym, event, args[1..-1]) end
ruby
def simple_execute(chain, event) return nil if chain.empty? args = chain.split(' ') execute_command(args[0].to_sym, event, args[1..-1]) end
[ "def", "simple_execute", "(", "chain", ",", "event", ")", "return", "nil", "if", "chain", ".", "empty?", "args", "=", "chain", ".", "split", "(", "' '", ")", "execute_command", "(", "args", "[", "0", "]", ".", "to_sym", ",", "event", ",", "args", "["...
Executes a command in a simple manner, without command chains or permissions. @param chain [String] The command with its arguments separated by spaces. @param event [CommandEvent] The event to pass to the command. @return [String, nil] the command's result, if there is any.
[ "Executes", "a", "command", "in", "a", "simple", "manner", "without", "command", "chains", "or", "permissions", "." ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/commands/command_bot.rb#L327-L332
12,398
meew0/discordrb
lib/discordrb/commands/command_bot.rb
Discordrb::Commands.CommandBot.permission?
def permission?(user, level, server) determined_level = if user.webhook? || server.nil? 0 else user.roles.reduce(0) do |memo, role| [@permissions[:roles][role.id] || 0, memo].max ...
ruby
def permission?(user, level, server) determined_level = if user.webhook? || server.nil? 0 else user.roles.reduce(0) do |memo, role| [@permissions[:roles][role.id] || 0, memo].max ...
[ "def", "permission?", "(", "user", ",", "level", ",", "server", ")", "determined_level", "=", "if", "user", ".", "webhook?", "||", "server", ".", "nil?", "0", "else", "user", ".", "roles", ".", "reduce", "(", "0", ")", "do", "|", "memo", ",", "role",...
Check if a user has permission to do something @param user [User] The user to check @param level [Integer] The minimum permission level the user should have (inclusive) @param server [Server] The server on which to check @return [true, false] whether or not the user has the given permission
[ "Check", "if", "a", "user", "has", "permission", "to", "do", "something" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/commands/command_bot.rb#L353-L363
12,399
meew0/discordrb
lib/discordrb/commands/command_bot.rb
Discordrb::Commands.CommandBot.create_message
def create_message(data) message = Discordrb::Message.new(data, self) return message if message.from_bot? && !@should_parse_self return message if message.webhook? && !@attributes[:webhook_commands] unless message.author Discordrb::LOGGER.warn("Received a message (#{message.inspect}) wi...
ruby
def create_message(data) message = Discordrb::Message.new(data, self) return message if message.from_bot? && !@should_parse_self return message if message.webhook? && !@attributes[:webhook_commands] unless message.author Discordrb::LOGGER.warn("Received a message (#{message.inspect}) wi...
[ "def", "create_message", "(", "data", ")", "message", "=", "Discordrb", "::", "Message", ".", "new", "(", "data", ",", "self", ")", "return", "message", "if", "message", ".", "from_bot?", "&&", "!", "@should_parse_self", "return", "message", "if", "message",...
Internal handler for MESSAGE_CREATE that is overwritten to allow for command handling
[ "Internal", "handler", "for", "MESSAGE_CREATE", "that", "is", "overwritten", "to", "allow", "for", "command", "handling" ]
764298a1ff0be69a1853b510d736f21c2b91a2fe
https://github.com/meew0/discordrb/blob/764298a1ff0be69a1853b510d736f21c2b91a2fe/lib/discordrb/commands/command_bot.rb#L393-L423