Skip to content

Instantly share code, notes, and snippets.

@tak-km
Last active December 5, 2017 13:45
Show Gist options
  • Save tak-km/c32956bad75c48f0916fd4e8c9d91d9d to your computer and use it in GitHub Desktop.
Save tak-km/c32956bad75c48f0916fd4e8c9d91d9d to your computer and use it in GitHub Desktop.
require 'discordrb'
require "csv"
#client_idはbotに設定されているものを入力 prefixはコマンドの呼び出しの時の記号(!play 等の!部分 ?とかでも可)
bot = Discordrb::Commands::CommandBot.new token: '自分のトークン', client_id: 000000000000, prefix: '!'
#スプラトゥーンの武器名が入っているcsvファイルを読み込み
data = CSV.read('buki.csv')
bot.command :random_buki do |event|
server = bot.servers.first[1]
for num in 0..server.channels.length do
if server.channels[num].name == "test_ch" then
users = server.channels[num].users
for num in 0..users.length do
event.respond "#{users[num].name}:#{data[rand(0..data.length)][0]}"
end
end
end
end
bot.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment