Module: CommandrbBot::Helper
- Defined in:
- lib/helper.rb
Class Method Summary collapse
- .avatar_embed(color: nil, colour: nil, url: nil, username: nil, time: Time.now.getutc.asctime) ⇒ Object
- .error_embed(error: nil, footer: nil, colour: nil, color: nil, code_error: true) ⇒ Object
Class Method Details
.avatar_embed(color: nil, colour: nil, url: nil, username: nil, time: Time.now.getutc.asctime) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/helper.rb', line 19 def self.(color: nil, colour: nil, url: nil, username: nil, time: Time.now.getutc.asctime) if url.nil? raise 'Invalid arguments for Helper.avatar_embed!' else colour = 0x22ef1f if color.nil? && colour.nil? username = username.nil? ? 'Unknown User' : username Discordrb::Webhooks::Embed.new( colour: colour || color, image: Discordrb::Webhooks::EmbedImage.new(url: url), author: Discordrb::Webhooks::EmbedAuthor.new(name: "Avatar for #{username}", url: url), footer: Discordrb::Webhooks::.new(text: "Avatar correct as of #{time}") ) end end |
.error_embed(error: nil, footer: nil, colour: nil, color: nil, code_error: true) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/helper.rb', line 5 def self.(error: nil, footer: nil, colour: nil, color: nil, code_error: true) if error.nil? || .nil? raise 'Invalid arguments for Helper.error_embed!' else colour = 0x22ef1f if color.nil? && colour.nil? Discordrb::Webhooks::Embed.new( title: '❌ An error has occured!', description: code_error ? "```ruby\n#{error}```" : error, colour: colour || color, footer: Discordrb::Webhooks::.new(text: ) ) end end |