Giter VIP home page Giter VIP logo

chatgpt-bot-for-discord's Introduction

ChatGPT を利用した Discord Bot

技術記事書きました

必要なトークン、API Keyの取得

このボットの実行には以下のトークンが必要です.

  • Discord botのToken
  • OpenAIのAPIキー

Secrets.tomlにトークンをセットしてください。

DISCORD_TOKEN="xxxxxxx"
CHATGPT_TOKEN="xxxxxxx"

OpenAIのAPIキー取得方法

OpenAI API keysへアクセスしてCreate new secret keyをクリックしてAPIキー発行します。 Usage limitsで使用量の上限を設定しておくことを推奨します。

Discord botの作成とトークン取得

  1. Discord Developer Portalへアクセスし、New Applicationをクリックし、アプリケーションを作成します
  2. 作成したアプリケーションからBotのページに移動して、Add Botをクリックし、Botを作成します。
  3. TOKENの下にあるCopyをクリックして、Tokenを取得します

Botの設定と導入

設定

  1. 初期設定ではPUBLIC BOTがONになっているので、OFFにします
  2. MESSAGE CONTENT INTENTをONにして、メッセージを取得できるようにします

image

サーバーへの導入

  1. OAuth2 > URL URL Generator へアクセスします
  2. SCOPESのBotにチェックを入れます
  3. BOT PERMISSIONSのSend Messages,Read Message Historyにチェックを入れます

image

  1. ページの一番下にある、GENERATED URLをコピーしてブラウザに貼り付けます
  2. 案内に従いBotをサーバーへ導入します

Botを動かす

📦 shuttleのセットアップ

  1. shuttleのインストール

    cargo binstall cargo-shuttle
  2. shuttleへログイン

    cargo shuttle login
  3. shuttleのapi keyの取得 ログインしたのちapi keyが付与されたのコマンドをコピーして実行し、認証を行います image

    cargo shuttle login --api-key <your_api_key>
  4. プロジェクト作成を行います

    Cargo.tomlnameの項目を任意の文字列に書き換えます。 shuttleで既に使われているnameと重複した場合、a project with the same name already existsと表示されます。 https://github.com/yukyu30/chatgpt-bot-for-discord/blob/83ca21adbd79033e1449efca26f0b49265ef8c71/Cargo.toml#L1-L2

    デフォルトでは30分アクセスがないとスリープモードになるため、--idle-minutes 0のオプションをつけます

    cargo shuttle project new  --idle-minutes 0

🤖 開発環境での実行

cargo shuttle run

🚀 デプロイ

cargo shuttle deploy

以下のような表示がされたらデプロイ成功です👏

Service Name:  <project name>
Deployment ID:  xxxxxxxxx-1234-6789-1234-xxxxxxxxxx
Status:        running
Last Updated:  2023-03-11T10:08:18Z
URI:           <app_url>

Botを止める

cargo shuttle stop

参考

shuttle Docs

免責事項

本プログラムに起因するトラブル・損害・損失につきましても、 当方は一切責任を負いません。

chatgpt-bot-for-discord's People

Contributors

k9i-0 avatar yukyu30 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.