#๐ Run not working
109 messages ยท Page 1 of 1 (latest)
@dense gorge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
send a screenshot of your screen after trying to run it
also your code perhaps
save your file
Looks like you need to save the file to write the changes. (indicated by the white circle next to the file name).
do Ctrl + S
alr
if you do not save a file, then the shown content is only what is loaded in your editor, not what the file contains
still does nothing
show screenshot again
i don't know it just show me that
Trust your work space and use terminal instead of Output.
can you check if you have Code Runner installed on vscode? if so, uninstall it
did you just open it or did you run the file?
i openned qnd then runned
ran it how? play button in top right?
also can you keep showing the full screen please
Click the drop menu next to the play button and click run in dedicated terminal.
Did you trust your workspace?
that shouldn't make a difference
wym
Can we circle back to this?
what's workspace
how to do that
here ?
This screenshot shows that you are in restricted mode you need to change it to a trusted window. Having the window in restricted mode can cause issues for extensions.
Extensions
The VS Code extensions ecosystem is incredibly rich and diverse. People have created extensions to help with just about any programming task or editor customization. Some extensions provide full programming language support (IntelliSense, debugging, code analysis), and others let you play music or have virtual pets.
Most extensions run code on your behalf and could potentially do harm. Some extensions have settings that could cause them to act maliciously if configured to run an unexpected executable. For this reason, extensions that have not explicitly opted into Workspace Trust are disabled by default in Restricted Mode.
You need to change your current vscode Window to be trusted. Click Manage Workspace Trust. and select Trust.
now it works thanks
You are able to run code fine now?
Yeah i am enable and now it works thank you so much
Can i ask you another question ?
Sure.
I am making a bot but i need to give the bot perms to write commands how do i do that
sorry if those are dumb question i am really new
What do you mean by write commands. What is the context?
like i for example i want my bot when i do !hello he says hello like he respond so he has the perm to write
Is this discord related?
Like a discord bot?
yeah
Well you are going to have to learn python basics. However read along the discord.py docs
https://discordpy.readthedocs.io/en/stable/
There are examples you use there.
Have you set up a bot details/token via the discord developer portal?
Think of it like this. You need to register your bot first with discord. They give you a token that you can use to sign into that bot.
yeah i have that token
the thing i need is to give my bot the perms of respond to my messages
You just need the message content intent
import discord
import requests
from discord.ext import commands
bot = commands.Bot(command_prefix="/")
Like before this i have to put a command that sais something like message = true or smth like that
!code What is your whole code you got relating to your bot. Remove the token when you send it to us.
Hey @dense gorge!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
Read the messge.
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
Read through the examples on the docs.
https://discordpy.readthedocs.io/en/stable/intro.html
https://discordpy.readthedocs.io/en/stable/quickstart.html
ok
Have a look at this example from the docs.
# This example requires the 'message_content' intent.
import discord
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run('your token here')
it keeps saying the same error
File "c:\Users\db\Documents\new url shortenner.py", line 13, in <module>
bot = commands.Bot(command_prefix="!")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.init() missing 1 required keyword-only argument: 'intents'
Read this message again and see what you are missing
I see what you did wrong but do you?
yeah i see
my vsc is so glitched
Now it says i have an error in the line 687
but my code only has 38 lines
Thats cause its an error in the import modules. You did something wrong that broke a pile down the line.
Its normal if you make errors.
Show screenshot of the error.
alr
the error is to long ima just tape it
Traceback (most recent call last):
File "c:\Users\db\Documents\new url shortenner.py", line 38, in <module>
bot.run("")
File "C:\Users\db\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 869, in run
asyncio.run(runner())
File "C:\Users\db\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\db\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\db\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\db\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 858, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\db\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 787, in start
await self.connect(reconnect=reconnect)
File "C:\Users\db\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 711, 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.
You haven't enabled message content in the developer portal
Read the second paragraph of this.
alr lemme try to fix that
wait i don't find the option that's not normal
Is that on OAuth ?
Its in bot
Is the bot working for you now?
yeah
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.