Upgrade to Pro — share decks privately, control downloads, hide ads and more …

はじめてのDiscordBot

 はじめてのDiscordBot

More Decks by 株式会社ビットキー / Bitkey Inc.

Other Decks in Technology

Transcript

  1. ͸͡ΊͯͷDiscord Bot

  2. Outline 1. ࣗݾ঺հ 2. ͳͥDiscord Bot͕ඞཁͳͷ͔ 3. Discord Bot Λಈ͔ͯ͠ΈΔ

    4. Discord Bot ΛVCʹࢀՃͤ͞Δ 5. ·ͱΊ 2 2
  3. 1. ࣗݾ঺հ • ໊લ ◦ ͼ΍͖͋ (BYAK) • ձࣾ ◦

    גࣜձࣾϏοτΩʔ • ࢓ࣄ ◦ Go ͰόοΫΤϯυͷ։ൃ ◦ React+Firebase Ͱϑϩϯτͷ։ൃ ◦ C++ ͰϑΝʔϜ΢ΣΞͷςετ΍σόοά • झຯ ◦ ϘʔυήʔϜ ◦ VϥΠόʔͷਪ͠׆ 3
  4. ͳͥDiscord Bot͕ඞཁͳͷ͔ 4 4

  5. 2. DiscordͱίϛϡχςΟ ίϛϡχςΟαʔόʔͱͯ͠ͷ Discord • ίϛϡχςΟʹ͸ɺίϛϡχςΟಛ༗ͷϧʔϧͱͦΕʹ൐͏ӡ༻࡞ۀ͕ੜ ·Ε͕ͪ ◦ ྫ: αʔόʔʹࢀՃͨ͠ਓ΁ͷΦϯϘʔσΟϯά

    ▪ ࣗݾ঺հɺϩʔϧͷద༻ ◦ ྫ: ϒϩʔυΩϟετ഑৴ͷࡍͷςΩετͷಡΈ্͛ 5
  6. 2. DiscordͱίϛϡχςΟ ίϛϡχςΟαʔόʔͱͯ͠ͷ Discord • ίϛϡχςΟʹ͸ɺίϛϡχςΟಛ༗ͷϧʔϧͱͦΕʹ൐͏ӡ༻࡞ۀ ͕ੜ·Ε͕ͪ ◦ ྫ: αʔόʔʹࢀՃͨ͠ਓ΁ͷΦϯϘʔσΟϯά

    ▪ ࣗݾ঺հɺϩʔϧͷద༻ ◦ ྫ: ϒϩʔυΩϟετ഑৴ͷࡍͷςΩετͷಡΈ্͛ 6 ࣗಈԽ͠Α͏ɹˠɹDiscord ͷ BotػೳΛ࢖͑͹Ͱ͖ͦ͏
  7. 2. DiscordͱίϛϡχςΟ ࠓ೔આ໌͢Δ಺༰ 1. Discord Bot Λىಈ͠ɺαʔόʔͰϝοηʔδΛ΍ΓͱΓ͢Δ 2. Bot ΛϘΠενϟοτʹࢀՃͤ͞ɺԻ੠σʔλΛ࠶ੜ͢Δ

    7
  8. Discord Bot Λಈ͔ͯ͠ΈΔ 8 8

  9. 3. Discord Bot Λಈ͔ͯ͠ΈΔ ͜ 9

  10. 3. Discord Bot Λಈ͔ͯ͠ΈΔ ͜ 10

  11. 3. Discord Bot Λಈ͔ͯ͠ΈΔ ͜ 11

  12. 3. Discord Bot Λಈ͔ͯ͠ΈΔ ͜ 12

  13. 3. Discord Bot Λಈ͔ͯ͠ΈΔ • Πϕϯτͱϋϯυϥ ◦ discord ͸͍͔ͭ͘Πϕϯτ͕ఆٛ͞Ε͍ͯͯɺదٓൃՐ͢Δͷ ͰɺΠϕϯτʹԠͨ͡ϋϯυϥΛొ࿥͢Δ͜ͱͰɺͦͷΠϕϯτ͕

    ൃੜͨ͠λΠϛϯάͰ bot ʹॲཧΛ࣮ߦͤ͞Δ͜ͱ͕Ͱ͖·͢ɻ ▪ ྫ: Ready: Bot͕αʔόʔʹ઀ଓ͠·ͨ͠ ▪ ྫ: Message Create: ϝοηʔδ͕ૹΒΕ·ͨ͠ ◦ discordgo Ͱ͸ discord ͷΠϕϯτ໊ʹରԠͨ͠ struct ͕ఆٛ͞Ε ͍ͯͯɺϋϯυϥͷୈ̎Ҿ਺ʹ౉͖ͬͯ·͢ɻ 13
  14. 3. Discord Bot Λಈ͔ͯ͠ΈΔ 14

  15. 3. Discord Bot Λಈ͔ͯ͠ΈΔ 15

  16. 3. Discord Bot Λಈ͔ͯ͠ΈΔ 16

  17. 3. Discord Bot Λಈ͔ͯ͠ΈΔ 17

  18. Bot ΛVCʹࢀՃͤ͞Δ 18 18

  19. Α͋͘ΔΠϯλʔϑΣʔε “!!” ࢝·ΓͳͲͰίϚϯυΛ൑அ͠ɺ ίϚϯυͷૹ৴ऀͷ͍ΔVCʹࢀՃͨ͠Γɺ ίϚϯυʹΑͬͯޮՌԻΛྲྀͨ͠Γ͢Δػೳ͕͋Γ·͢ 4. Bot ΛVCʹࢀՃͤ͞Δ 19

  20. 20 4. Bot ΛVCʹࢀՃͤ͞Δ

  21. 21 4. Bot ΛVCʹࢀՃͤ͞Δ

  22. 22 4. Bot ΛVCʹࢀՃͤ͞Δ

  23. 23 4. Bot ΛVCʹࢀՃͤ͞Δ

  24. 24 4. Bot ΛVCʹࢀՃͤ͞Δ

  25. 25 4. Bot ΛVCʹࢀՃͤ͞Δ

  26. 26 4. Bot ΛVCʹࢀՃͤ͞Δ

  27. ·ͱΊ 27 27

  28. 28 5. ·ͱΊ • ·ͱΊ ◦ discordgo, dgvoice Λ࢖͏͜ͱͰ؆୯ʹBotΛ࣮૷Ͱ͖Δ ◦

    Discord্Ͱਓ͕ߦ͏ૢ࡞͸BotʹҠৡͰ͖Δ ◦ ͜͜Ͱઆ໌͠ͳ͔ͬͨΠϕϯτ΍ૢ࡞ʹ͍ͭͯ͸ެࣜυΩϡϝϯτΛࢀ র͠ɺରԠͨ͠ discordgo ͷAPIΛௐ΂Δͱྑ͍ɻ ▪ discordgo ͸ Discord API ͷ௿ϨϕϧϚοϐϯάΛ໨తͱͨ͠ϥΠϒ ϥϦͷͳͷͰɺެࣜυΩϡϝϯτ͕ͦͷ··౰ͯ͸·Δ͜ͱ͕ଟ͍ ▪ discordgo/examples ΋ࢀߟʹͳΔ ▪ Ͳ͏ͯ͠΋Θ͔Βͳ͚Ε͹ Discord Gophers ΁
  29. 29 5. ·ͱΊ ͜ͷࢿྉͷݩʹͳͬͨDiscord Bot͸ͪ͜Β https://github.com/byakheee/my-discord-bot