Sha256: 3f958f527c3d42ea90c5b1adf164d31753f4a79aeb0a3c959807ddabafcbf993
Contents?: true
Size: 1.11 KB
Versions: 25
Compression:
Stored size: 1.11 KB
Contents
require "discorb" require "json" client = Discorb::Client.new client.once :ready do puts "Logged in as #{client.user}" end def bookmark_channel(guild) guild.channels.find { |c| c.is_a?(Discorb::TextChannel) && c.name == "bookmarks" } end def build_embed_from_message(message) embed = Discorb::Embed.new embed.description = message.content embed.author = Discorb::Embed::Author.new(message.author.to_s_user, icon: message.author.avatar.url) embed.timestamp = message.timestamp embed.footer = Discorb::Embed::Footer.new("Message ID: #{message.id}") embed end client.message_command("Bookmark", guild_ids: [857373681096327180]) do |interaction, message| unless channel = bookmark_channel(interaction.guild) interaction.post("Bookmark channel not found. Please create one called `bookmarks`.", ephemeral: true) next end channel.post( message.jump_url, embed: build_embed_from_message(message), ).wait interaction.post("Bookmarked!", ephemeral: true) end client.change_presence( Discorb::Activity.new( "Open message context menu to bookmark" ) ) client.run(ENV["DISCORD_BOT_TOKEN"])
Version data entries
25 entries across 25 versions & 1 rubygems