Sha256: 39c87e0cf634d69092253aec7695006ef08b7641a161fd12414ad403dcbcaacb

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

# frozen_string_literal: true

require "discorb"

client = Discorb::Client.new

localizations = {
  localized: {
    text: {
      en: "Hello, %s!",
      ja: "%sさん、こんにちは!",
    },
  },
}

client.once :standby do
  puts "Logged in as #{client.user}"
end

client.slash(
  {
    default: "greet",
    ja: "挨拶",
  }, {
    default: "Bot greets. Cute OwO",
    ja: "Botが挨拶します。かわいいね",
  }, {
    "name" => {
      name_localizations: {
        ja: "名前",
      },
      description: {
        default: "The name to greet.",
        ja: "挨拶する人の名前。",
      },
      type: :string,
      optional: true,
    },
  }
) do |interaction, name|
  interaction.post(
    format((localizations[:localized][:text][interaction.locale] || localizations[:localized][:text][:en]),
           name || interaction.user.to_s),
    ephemeral: true,
  )
end

client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
discorb-0.20.0 examples/commands/slash.rb
discorb-0.19.0 examples/commands/slash.rb
discorb-0.18.1 examples/commands/slash.rb
discorb-0.18.0 examples/commands/slash.rb