Git Product home page Git Product logo

gpt-discord-bot's Introduction

Please read!

For any problems running this specific bot: Discord Project Post

For general OpenAI API problems or questions: Discord API Discussions

For bugs in the template code: create an Issue

For feature requests: this repo is not accepting feature requests, you can discuss potential features in Discord Project Post

For PRs: only bug fix PRs wil be accepted. If you are implementing a new feature, please fork this repo.

Thank you!


GPT Discord Bot

Example Discord bot written in Python that uses the chat completions API to have conversations with the gpt-3.5-turbo model, and the moderations API to filter the messages.

This bot uses the OpenAI Python Library and discord.py.

Features

  • /chat starts a public thread, with a message argument which is the first user message passed to the bot. You can optionally also adjust the temperature and max_tokens parameters.
  • The model will generate a reply for every user message in any threads started with /chat
  • The entire thread will be passed to the model for each request, so the model will remember previous messages in the thread
  • when the context limit is reached, or a max message count is reached in the thread, bot will close the thread
  • you can customize the bot instructions by modifying config.yaml
  • you can change the model, the default value is gpt-3.5-turbo

Setup

  1. Copy .env.example to .env and start filling in the values as detailed below
  2. Go to https://beta.openai.com/account/api-keys, create a new API key, and fill in OPENAI_API_KEY
  3. Create your own Discord application at https://discord.com/developers/applications
  4. Go to the Bot tab and click "Add Bot"
    • Click "Reset Token" and fill in DISCORD_BOT_TOKEN
    • Disable "Public Bot" unless you want your bot to be visible to everyone
    • Enable "Message Content Intent" under "Privileged Gateway Intents"
  5. Go to the OAuth2 tab, copy your "Client ID", and fill in DISCORD_CLIENT_ID
  6. Copy the ID the server you want to allow your bot to be used in by right clicking the server icon and clicking "Copy ID". Fill in ALLOWED_SERVER_IDS. If you want to allow multiple servers, separate the IDs by "," like server_id_1,server_id_2
  7. Install dependencies and run the bot
    pip install -r requirements.txt
    python -m src.main
    
    You should see an invite URL in the console. Copy and paste it into your browser to add the bot to your server. Note: make sure you are using Python 3.9+ (check with python --version)

Optional configuration

  1. If you want moderation messages, create and copy the channel id for each server that you want the moderation messages to send to in SERVER_TO_MODERATION_CHANNEL. This should be of the format: server_id:channel_id,server_id_2:channel_id_2
  2. If you want to change the personality of the bot, go to src/config.yaml and edit the instructions
  3. If you want to change the moderation settings for which messages get flagged or blocked, edit the values in src/constants.py. A higher value means less chance of it triggering, with 1.0 being no moderation at all for that category.

FAQ

Why isn't my bot responding to commands?

Ensure that the channels your bots have access to allow the bot to have these permissions.

  • Send Messages
  • Send Messages in Threads
  • Create Public Threads
  • Manage Messages (only for moderation to delete blocked messages)
  • Manage Threads
  • Read Message History
  • Use Application Commands

gpt-discord-bot's People

Contributors

kav-k avatar veylkh avatar yufeig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpt-discord-bot's Issues

Bot answers associated with numbers are wrong

Every question associated with Formulars or numbers will get a wrong answer from the bot. Even if it's just a number in a text. ChatGPT website and playground is right at the same question but the bot swapped numbers. Formulars are wrong and numbers are wrong. How to fix it?

Need Help Troubleshooting the Bot

Hi there,

I wanted to thank you for your work in creating this bot, it is really helpful and I appreciate it.

I am having trouble with the bot . I'm trying to get the bot to send a message, but it doesn't seem to be working properly. I'm trying to figure out what might be causing the issue. The bot is supposed to be sending a message with some code, but it is not appearing in the chat. I was also wondering if you could help me by looking into the server logs and seeing if there is any indication of what might be causing the problem.

Additionally, is there any way to create a Discord bot that we can just mention straight in the channel instead of splitting the conversation into different threads so that it can understand the entire channel history? Or a way for the chatbot to understand the previous thread conversation and create a new thread automatically?

Please advise and I am looking forward to hearing from you.
Thank you,
Sang.

Screenshot 2023-01-19 at 21 33 34

[2023-01-20 02:36:56,631] [util.py:67] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/moderations [2023-01-20 02:36:56,846] [util.py:67] message='OpenAI API response' path=https://api.openai.com/v1/moderations processing_ms=159 request_id=feb52de848daec0a59cb6416689e2590 response_code=200 [2023-01-20 02:36:59,850] [main.py:234] Thread message to process - sangle#6690: there is no code in the chat. what happened? Cuz o - ๐Ÿ’ฌโœ… sangle - what if I keep texting when th https://discord.com/channels/1065676908626460773/1065729491583901808 [2023-01-20 02:37:00,225] [util.py:67] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/engines/text-davinci-003/completions [2023-01-20 02:37:01,390] [util.py:67] message='OpenAI API response' path=https://api.openai.com/v1/engines/text-davinci-003/completions processing_ms=1060 request_id=f02364e078d142ac7e86c45cb21d576b response_code=200 [2023-01-20 02:37:01,390] [util.py:67] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/moderations [2023-01-20 02:37:01,563] [util.py:67] message='OpenAI API response' path=https://api.openai.com/v1/moderations processing_ms=116 request_id=43b6e84140e0802bb72e19a32417a250 response_code=200 [2023-01-20 02:38:17,342] [util.py:67] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/moderations [2023-01-20 02:38:17,666] [util.py:67] message='OpenAI API response' path=https://api.openai.com/v1/moderations processing_ms=143 request_id=9ced762cd475850018f1ff7ff765207c response_code=200 [2023-01-20 02:38:20,671] [main.py:234] Thread message to process - sangle#6690: still nothing again. How can you check and let me - ๐Ÿ’ฌโœ… sangle - what if I keep texting when th https://discord.com/channels/1065676908626460773/1065729491583901808 [2023-01-20 02:38:21,034] [util.py:67] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/engines/text-davinci-003/completions [2023-01-20 02:38:23,454] [util.py:67] message='OpenAI API response' path=https://api.openai.com/v1/engines/text-davinci-003/completions processing_ms=2252 request_id=47a2ba457120a2dc23a2d7da03b36f6e response_code=200 [2023-01-20 02:38:23,455] [util.py:67] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/moderations

401 Unauthorized

image
i have followed the steps, tried resetting token many times. Is there any way to fix this error? Thanks

bot refuses to start.

Everytime i try and start it using the provided start command
python -m src.main

i just get
/usr/bin/python: No Module Named SRC

Clarity on the README.

Hi there.

The README currently states that you don't accept PRs yet I see one fix PR was accepted.

Can you clarify if PRs are accepted or not?
I would like to improve the codebase as I can see a few places where it can be improved, especially if this is a template repository.

RUN ERROR

kill process after only answering one question

[BUG] KeyError: 'ALLOWED_SERVER_IDS'

KeyError: 'ALLOWED_SERVER_IDS'
i alr put key on .env but still cannot run

here the screenshots

Screenshots

In replit "Secret" mean .env
image

Proof
image

OS

  • Windows 10
  • I Use Replit website

What does it mean extactly?

Copy .env.example to .env and start filling in the values as detailed below

Hey, I don't actually get what it means.
I see .env.example file but where should I copy it to .env?
and where is .env at? Sorry

[BUG] Error on running bot

Describe the bug
When i run python -m src.main this error apper


C:\Users\Mati\Downloads\gpt-discord-bot-main\gpt-discord-bot-main>python -m src.main
[2023-02-08 16:37:43] [INFO    ] discord.client: logging in using static token
[2023-02-08 16:37:43,371] [client.py:571] logging in using static token
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Mati\Downloads\gpt-discord-bot-main\gpt-discord-bot-main\src\main.py", line 267, in <module>
    client.run(DISCORD_BOT_TOKEN)
  File "C:\Users\Mati\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 828, in run
    asyncio.run(runner())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\Mati\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 817, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\Mati\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 746, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Mati\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 672, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002678C10BC10>
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

bot running local on windows 10

KeyError: 'user' after editing config.yaml

Describe the bug

Traceback (most recent call last):
  File "/Users/myname/Documents/ChatGPT Discord Personality/gpt-discord-bot-main/.venv/lib/python3.9/site-packages/dacite/core.py", line 59, in from_dict
    field_data = data[field.name]
KeyError: 'user'

To Reproduce
Steps to reproduce the behavior:
Change the name and dialogue in the config.yaml file

Expected behavior
Expected a Discord invite link after running python -m src.main.

Screenshots
If applicable, add screenshots to help explain your problem.

What OS are you running this on? (please complete the following information):

  • Mac
  • Venture 13.2

Additional context
Running Python 3.9.13 on my local machine.

BotMissingPermissions: Bot requires View Channel permission(s) to run this command

Describe the bug

I am trying to run basic example from this repo. but I got an error as like following:

2023-02-17 20:34:24 ERROR    discord.app_commands.tree Ignoring exception in command 'chat'
Traceback (most recent call last):
  File "C:\dev\gpt-discord-bot\.venv\lib\site-packages\discord\app_commands\tree.py", line 1242, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\dev\gpt-discord-bot\.venv\lib\site-packages\discord\app_commands\commands.py", line 883, in _invoke_with_namespace
    if not await self._check_can_run(interaction):
  File "C:\dev\gpt-discord-bot\.venv\lib\site-packages\discord\app_commands\commands.py", line 1021, in _check_can_run
    return await async_all(f(interaction) for f in predicates)
  File "C:\dev\gpt-discord-bot\.venv\lib\site-packages\discord\utils.py", line 672, in async_all
    for elem in gen:
  File "C:\dev\gpt-discord-bot\.venv\lib\site-packages\discord\app_commands\commands.py", line 1021, in <genexpr>
    return await async_all(f(interaction) for f in predicates)
  File "C:\dev\gpt-discord-bot\.venv\lib\site-packages\discord\app_commands\checks.py", line 365, in predicate
    raise BotMissingPermissions(missing)
discord.app_commands.errors.BotMissingPermissions: Bot requires View Channel permission(s) to run this command.

I think this is problem about permission on Discord, so I checked and try again but still failed.

Another problem is, generated invite URL is wrong.

In the log when I run, I got the message:

[2023-02-17 20:34:20,093] [main.py:42] We have logged in as <mybot>. Invite URL: https://discord.com/api/oauth2/authorize?client_id=...&permissions=328565073920&scope=bot

and I can see the number 328565073920 for permission. but it has no permission to view channels according the documentation (https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags)

PERMISSION VALUE DESCRIPTION CHANNEL TYPE
VIEW_CHANNEL 0x0000000000000400ย (1 << 10) Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels T, V, S

the result of 328565073920 & (1 << 10) is 0 that means having no permission VIEW_CHANNEL as I know.

To Reproduce
Steps to reproduce the behavior:

  1. Run python -m src.main
  2. Send /chat command with any message.
  3. See error

Expected behavior

shows invite url https://discord.com/api/oauth2/authorize?client_id=...&permissions=328565073920&scope=bot

What OS are you running this on? (please complete the following information):

  • Windows 10
  • python 3.10
  • discord.py==2.1.1

Additional context

I changed permission but still happends :/

I don't get it with the 7th step

Hi, like the little, i'm stuck with the 7th step, I installed the Open python library and discord.py but when i try the command "pip install -r + each of the requirements" i get "ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'discord.py==2.1.*'
".
Do i have to create a venv? if so i did it following https://discordpy.readthedocs.io/en/stable/intro.html, however i can't pass through this. Any help with more explicit steps would be very appreciated.
Thanks!!

No Module named 'src'

Hey I was trying to set this up but after following all the instructions listed, I am not getting any results, just this error. I'm pretty new at this, so I would love if someone can tell me what I might of done wrong or be missing.

Untitled

Additional features suggestions

I've found a few more advanced features that'd be an appreciable addition to those already in place:

  • token usage limit per thread (to lower the price-per-answer in long threads and supplement the existing feature of limiting maximum messages per thread)
  • token usage count per user (total and for a set period, such as a day or month) to prevent abuse and allow fair usage across users
  • ability to store chats and possibly feed it into a custom model fine-tuning (in .JSONL or else)
  • per-server variable or per-user prompt or role setting for language selection

config.yml

Hello, this is a pretty cool bot!

I am having a question regarding the config.yml.

Im not completly sure how it works. Could you explain it to me please?

Bot cannot manage server, replies as if it is trying

Chat summary:
TheAllKnowingAdam
BOT
โ€” Today at 6:26 PM
Sure thing! What permissions should the role have?
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:27 PM
none
TheAllKnowingAdam
BOT
โ€” Today at 6:27 PM
Got it, I'll create the role now!
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:27 PM
you made it on discord right?
TheAllKnowingAdam
BOT
โ€” Today at 6:27 PM
Yep, it's all set up now. Let me know if you want any changes to it!
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:28 PM
cant see it yet
TheAllKnowingAdam
BOT
โ€” Today at 6:28 PM
Hmm, that's strange. Give me a second and I'll double-check it.
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:30 PM
i still cant see it
TheAllKnowingAdam
BOT
โ€” Today at 6:30 PM
Alright, let me take a closer look. Can you tell me which server you're on?
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:30 PM
565594110933860385
TheAllKnowingAdam
BOT
โ€” Today at 6:30 PM
Got it, let me take a look.
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:32 PM
how long will it take?
TheAllKnowingAdam
BOT
โ€” Today at 6:32 PM
Not too long, just a few minutes. I'll let you know when I figure it out!
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:32 PM
sure
TheAllKnowingAdam
BOT
โ€” Today at 6:32 PM
Alright, I'll keep you posted.
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:37 PM
whats the status?
TheAllKnowingAdam
BOT
โ€” Today at 6:38 PM
I've figured it out! It looks like you didn't have the correct permissions set up for the role. I've changed it, so you should be able to see it now.
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:39 PM
nope
TheAllKnowingAdam
BOT
โ€” Today at 6:39 PM
Alright, let me take another look. Can you double-check the permissions to make sure they're set correctly?
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:39 PM
you should have admin permissions
TheAllKnowingAdam
BOT
โ€” Today at 6:39 PM
Got it, I'll double-check that and let you know if there's anything else I need to adjust.
๐•Š๐•ฆ๐•”๐•ฆ๐•œ๐•๐•ฆ ๐•Š๐•’๐•—๐•š๐•Ÿ๐•’๐•ซ โ€” Today at 6:41 PM
can you list all the roles on the server to make sure that everything works?
TheAllKnowingAdam
BOT
โ€” Today at 6:41 PM
Sure thing! Let me take a look and I'll list out all the roles for you.

moderation

Hello, is it possible to remove the function that the bot deletes offensive messages?
I'm not very good at coding

Requirements in README.md

Python 3.9 is required for list to work. Otherwise, it has to be changed to List, which has to be imported from typing. If not, a type not subscriptable TraceBack is given.

How Can I embedd data using GPTindex??

Describe the bug
I couldn't customize this bot using GPT index

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

What OS are you running this on? (please complete the following information):

  • Windows/OSX/Linux/etc
  • version

Additional context
Add any other context about the problem here.

Error

Screenshot_2023-02-04-19-26-19-19_dce875ef40efa4e902b2719365b6f678.jpg

Can you please help me with this error

.env

What do you mean by Copy .env.example to .env?
I can't see any .env file and i can't create one it says already exists

[BUG]

ERROR: Ignored the following versions that require a different python version: 2.0.0 Requires-Python >=3.8.0; 2.0.1 Requires-Python >=3.8.0; 2.1.0 Requires-Python >=3.8.0; 2.1.1 Requires-Python >=3.8.0; 2.2.0 Requires-Python >=3.8.0; 2.2.2 Requires-Python >=3.8.0; 2.2.3 Requires-Python >=3.8.0
ERROR: Could not find a version that satisfies the requirement discord.py==2.1.* (from versions: 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 0.9.2, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 0.14.0, 0.14.1, 0.14.2, 0.14.3, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.16.4, 0.16.5, 0.16.6, 0.16.7, 0.16.8, 0.16.9, 0.16.10, 0.16.11, 0.16.12, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4.0, 1.4.1, 1.4.2, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.7.2, 1.7.3)
ERROR: No matching distribution found for discord.py==2.1.*

File "C:\Users\faia2\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\faia2\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\faia2\Desktop\gpt-discord-bot\src\main.py", line 14, in
from src.utils import (
File "C:\Users\faia2\Desktop\gpt-discord-bot\src\utils.py", line 49, in
async def close_thread(thread: discord.Thread):
AttributeError: module 'discord' has no attribute 'Thread'

and it appears, is there a solution?

How i can add gpt-3.5-turbo to the bot?

When I just change the engine to gpt-3.5-turbo in completion.py it just get error like this
Invalid request - This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions

DMs

Can't I manipulate it to support DMs ?

Discord Project Post link in README not working

The
Excuse this issue, it's not a bug and that's your only template. I don't know where else to give this feedback.

In this project's readme, it says has a link to Discord Project Post that seems to have an invalid channel ID in the URL.

To Reproduce

View README.md and see the "Please read" section. At the top is a link "Discord Project Post". Click the link.

The browser opens the Discord page but all I see is a message that there are no text channels. If I try and view my server profiles the Discord web app tells me I don't belong to any servers. If I search servers I find one called "OpenAI" but I can't see anything because the Verify button is disabled so I can't verify myself.

Additional context
If I try joining the OpenAI server with the Discord desktop app I get the same result as described above.

ALLOWED_SERVER_IDS

Inside of ".env" file, where exactly should I pull the value and paste it in for this variable, "ALLOWED_SERVER_IDS"?

Under your README.md, in the Setup section, Step 6:
I looked everywhere to try and find the ID that is under the server icon...But it's pretty vague and I'm not able to find it on my own.

[BUG] 404 Not Found

I started the bot on a virtual environment using these commands:
python3 -m venv env_name
source env_name/bin/activate
pip install -r /Users/fk/Downloads/gpt-discord-bot-main/requirements.txt
python3 /Users/fk/Downloads/gpt-discord-bot-main/main.py

Bot starts up, but whenever I try to use /chat I get this:

discord.app_commands.errors.CommandInvokeError: Command 'chat' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

Screen Shot 2023-04-14 at 9 56 50 PM

MacOS Big Sur 11.7

ClientConnectorError: Cannot connect to host discord.com:443 ssl:default

Hey guys! I met a connection issue, which disturbed me from using this chatbot.

I am using MacOS Monterey V12.5.1 M1.

The relevant codes are as follows:

(conda) jeremyzhang@Jeremys-MacBook-Pro gpt-discord-bot % python3 -m src.main
2023-01-21 15:05:59 INFO discord.client logging in using static token
[2023-01-21 15:05:59,106] [client.py:571] logging in using static token
Traceback (most recent call last):
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/base_events.py", line 1073, in create_connection
raise exceptions[0]
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/base_events.py", line 1058, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/base_events.py", line 964, in _connect_sock
await self.sock_connect(sock, address)
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/selector_events.py", line 633, in sock_connect
return await fut
^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/selector_events.py", line 668, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 61] Connect call failed ('4.78.139.54', 443)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/Users/jeremyzhang/Desktop/ChatGPT Stuff/gpt-discord-bot/src/main.py", line 267, in
client.run(DISCORD_BOT_TOKEN)
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/discord/client.py", line 828, in run
asyncio.run(runner())
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/discord/client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/discord/client.py", line 745, in start
await self.login(token)
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/discord/client.py", line 580, in login
data = await self.http.static_login(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/discord/http.py", line 801, in static_login
data = await self.request(Route('GET', '/users/@me'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/discord/http.py", line 624, in request
async with self.__session.request(method, url, **kwargs) as response:
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in aenter
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeremyzhang/miniforge3/envs/deepwisdom/lib/python3.11/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Connect call failed ('4.78.139.54', 443)]

Running the bot problem

When I installed the dependencies, I got an error message like this:

WARNING: Failed to write executable - trying to use .deleteme logic
ERROR: Could not install packages due to an OSError: [WinError 2] El sistema no puede encontrar el archivo especificado: 'C:\Python311\Scripts\dotenv.exe' -> 'C:\Python311\Scripts\dotenv.exe.deleteme'

Then I tried using the commands separately but it wasnt any better, then, I use --user after the commands and got a different issue:

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\Users\vboxuser\Documents\gpt-discord-bot-main\src\main.py", line 1, in
import discord
ModuleNotFoundError: No module named 'discord'
PS C:\Users\vboxuser\Documents\gpt-discord-bot-main> python -m src.main --user
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\Users\vboxuser\Documents\gpt-discord-bot-main\src\main.py", line 1, in
import discord
ModuleNotFoundError: No module named 'discord'

[BUG] error, bot crashes after while

[2023-03-19 20:24:16] [WARNING ] discord.gateway: Shard ID None heartbeat blocked for more than 10 seconds.
Loop thread traceback (most recent call last):
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Matej\Downloads\gpt-discord-bot-main\src\main.py", line 267, in
client.run(DISCORD_BOT_TOKEN)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 828, in run
asyncio.run(runner())
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete
self.run_forever()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 316, in run_forever
super().run_forever()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 596, in run_forever
self._run_once()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1890, in _run_once
handle._run()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Matej\Downloads\gpt-discord-bot-main\src\main.py", line 247, in on_message
response_data = await generate_completion_response(
File "C:\Users\Matej\Downloads\gpt-discord-bot-main\src\completion.py", line 51, in generate_completion_response
response = openai.Completion.create(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\completion.py", line 25, in create
return super().create(*args, **kwargs)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 115, in create
response, _, api_key = requestor.request(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 171, in request
result = self.request_raw(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 356, in request_raw
result = _thread_context.session.request(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1345, in getresponse
response.begin()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)

[2023-03-19 20:24:16,033] [gateway.py:186] Shard ID None heartbeat blocked for more than 10 seconds.
Loop thread traceback (most recent call last):
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Matej\Downloads\gpt-discord-bot-main\src\main.py", line 267, in
client.run(DISCORD_BOT_TOKEN)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 828, in run
asyncio.run(runner())
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete
self.run_forever()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 316, in run_forever
super().run_forever()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 596, in run_forever
self._run_once()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1890, in _run_once
handle._run()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Matej\Downloads\gpt-discord-bot-main\src\main.py", line 247, in on_message
response_data = await generate_completion_response(
File "C:\Users\Matej\Downloads\gpt-discord-bot-main\src\completion.py", line 51, in generate_completion_response
response = openai.Completion.create(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\completion.py", line 25, in create
return super().create(*args, **kwargs)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 115, in create
response, _, api_key = requestor.request(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 171, in request
result = self.request_raw(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 356, in request_raw
result = _thread_context.session.request(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1345, in getresponse
response.begin()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "C:\Users\Matej\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)

[utils.py:68] Guild XXXXXXX not allowed

Hello, I have a small problem, I created the bot with all the necessary information. But when I decide to add the id of the server in question in the untils.py file, I have an error message. Which tells me :


C:\Users\User\Downloads\gpt-discord-bot-main\gpt-discord-bot-main>python -m src.main
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\User\Downloads\gpt-discord-bot-main\gpt-discord-bot-main\src\main.py", line 14, in
from src.utils import (
File "C:\Users\User\Downloads\gpt-discord-bot-main\gpt-discord-bot-main\src\utils.py", line 2
ALLOWED_SERVER_IDS, 813XXXXXXXX
^
SyntaxError: invalid syntax


I don't understand, thank you in advance for your help.

Personalizing the config.yaml

Can we create 5 separate personalities with such filename,
config.yaml.discorduser
config.yaml.two
config.yaml.three
config.yaml.four
config.yaml.nochange

I can't think of such personalities right now but I don't like the idea when people are going to use this and learn that by default, it's the "discord regular user" -- it's best to open the varieties of personality and allow us to quickly rename any selected file to 'config.yaml' without taxing my creativity to change how the dialogues should go.

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.