#๐Ÿ”’ Run not working

109 messages ยท Page 1 of 1 (latest)

dense gorge
#

When i try to run a file in vsc it does absolutly nothing

crude portalBOT
#

@dense gorge

Python help channel opened

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.

mossy robin
hollow trout
#

also your code perhaps

hollow trout
#

save your file

cerulean rock
# dense gorge

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

dense gorge
#

alr

hollow trout
#

if you do not save a file, then the shown content is only what is loaded in your editor, not what the file contains

dense gorge
#

still does nothing

hollow trout
#

show screenshot again

dense gorge
hollow trout
#

why do you have Output open?

#

that's for extensions and such

#

go to terminal

dense gorge
#

i don't know it just show me that

cerulean rock
# dense gorge

Trust your work space and use terminal instead of Output.

hollow trout
#

can you check if you have Code Runner installed on vscode? if so, uninstall it

dense gorge
hollow trout
#

did you just open it or did you run the file?

dense gorge
#

i openned qnd then runned

hollow trout
#

ran it how? play button in top right?

#

also can you keep showing the full screen please

cerulean rock
# dense gorge

Click the drop menu next to the play button and click run in dedicated terminal.

dense gorge
#

The triangle

#

i just did and still nothing

cerulean rock
hollow trout
dense gorge
hollow trout
#

Can we circle back to this?

dense gorge
#

what's workspace

dense gorge
hollow trout
#

in extensions

#

on the left

dense gorge
hollow trout
#

ah

#

so yeah click the configure your settings

dense gorge
#

here ?

cerulean rock
# dense gorge

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.
dense gorge
#

yo what

#

so i need to change to trusted windows ?

cerulean rock
# dense gorge

You need to change your current vscode Window to be trusted. Click Manage Workspace Trust. and select Trust.

dense gorge
#

now it works thanks

cerulean rock
dense gorge
#

Yeah i am enable and now it works thank you so much

#

Can i ask you another question ?

cerulean rock
dense gorge
#

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

cerulean rock
dense gorge
#

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

cerulean rock
#

Like a discord bot?

dense gorge
#

yeah

cerulean rock
#

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?

dense gorge
#

what

#

like if i setted up with discord developer portal ?

cerulean rock
dense gorge
#

yeah i have that token

#

the thing i need is to give my bot the perms of respond to my messages

cerulean rock
dense gorge
#

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

cerulean rock
crude portalBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

#

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.
dense gorge
#

i can't send it

cerulean rock
#

Read the messge.

cerulean rock
#

!intents

crude portalBOT
#
Using intents in discord.py

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.

dense gorge
#

thanks

#

It works but idk why my codei s not working lol

cerulean rock
dense gorge
#

ok

cerulean rock
# dense gorge 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')
dense gorge
#

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'

cerulean rock
#

I see what you did wrong but do you?

dense gorge
#

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

cerulean rock
#

Its normal if you make errors.

#

Show screenshot of the error.

dense gorge
#

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.

cerulean rock
cerulean rock
dense gorge
#

alr lemme try to fix that

#

wait i don't find the option that's not normal

#

Is that on OAuth ?

cerulean rock
dense gorge
#

i did thanks

#

thanks for helping me with all that

cerulean rock
dense gorge
#

yeah

cerulean rock
#

To close this help post.

dense gorge
#

alright brother again thanks for all that help ๐Ÿ™‚

#

!close

crude portalBOT
#
Python help channel closed

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.