#importing disnake into vs code

1 messages · Page 1 of 1 (latest)

dire path
#

Do you have pip installed?

#

if you open command prompt and type pip you can see if you have it

#

if you do, you can install Disnake to PATH (will be available in all projects) by writting pip install disnake

If you only want to install disnake for this specific project you should look into venv's but unfortunately I won't be much help there.

Then inside of VS Code, inside of a python file, you can write import disnake

#

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

#

in CMD

#

then do

#

python get-pip.py

#

this should work on windows?

#

oh

#

try doing pip

#

i see

#

so you installed it but now you need to get it into your PATH

#

your current pip install is located at C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts

#

you can type that into files

#

ok

#

one sec

#

open properties

dense moth
#

Pip should have been installed to PATH with Python when you used the windows installer.

dire path
#

I told him to check pip

#

apparently it said not found

#

anyways

#

actually search up control panel instead

#

when it opens, search for PATH

#

no, sorry, I mislead you to the wrong program. Open up the control panel this time and search for PATH

#

then click this

#

then double click on PATH

#

ok

#

then hit new

#

and then put

#

C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts\whatever the name of pip is

#

the thing you installed

#

you need to put the address of where it's stored on your computer

#

idk what the actual name of the file is

#

so just go to C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts\ in files and look for something called pip, then copy the address

#

ya

#

probably just pip

#

open this in your files

#

C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts

#

and then look for pip

#

should just need to copy the address to pip

#

so

#

you would put C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts\the exact name of the pip file

#

you can just extend the address I sent above

#

C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts\

#

after the last \

#

just put the name of the pip file

#

that you want to use

#

after it should work

#

I just checked. On my PC I actually just added C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts to path and I think that includes all files within it

#

you can test it by doing pip in cmd

#

if it shows you all the commands

#

then you have it

#

dang

#

one sec

#

did you hit ok

#

when you put the address in

#

are you sure you don't have curl

#

in CMD do curl --help

#

yea

#

you should be able to do

#

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

#

oh

#

python get-pip.py

#

do that

#

what is python called on your computer

#

py?

#

on mine it's python

#

its saying the command python was not found

#

so is python named something else?

#

try py get-pip.py

#

ok

#

go back to the screen where we edit the environment variables

#

yes

#

then search path

#

when you click this make sure you look for System Variables

#

there will be 2 lists

#

one for your local user

#

and one for your system variables

#

inside of system variables should be PATH in all caps

#

double click that

#

then hit new

#

C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts

#

and hit OK

#

oh rip lol

#

send picture

#

lol

#

here

#

ok thats fine ig

#

just double click that

#

then hit new

#

and put: C:\Users\andre\AppData\Local\Programs\Python\Python310\Scripts

#

then hit ok

#

oh

#

then hit the other ok

#

then hit apply

#

like when you get back to this screen after hitting ok twice

#

you hit the apply at the bottom right

#

then it should work

#

also you can delete that other one we did earlier

#

ok maybe you don't need too

#

just hit ok

#

yay

#

do pip --version

#

nice

#

you have pip now

#

so

dire path
#

ok

#

then you are good

#

inside of vs code

#

in a python file

#

you should be able to write import disnake

#

weird

#

wait

#

is it written like that?

#

it should be lowercase

#

import disnake

#

weird

#

last thing I can say is

#

inside of vs code

#

at the top bar

#

go to terminal>new terminal

#

or Ctrl+Shift+`

#
import disnake
from disnake.ext import commands
import pytube

class myCog(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.slash_command(name="test")
    async def test(
        self,
        inter: disnake.ApplicationCommandInteraction,
        test_a: str,
        test_b: commands.option_enum(["hello", "youtube"]),
    ):
        print(test_a, test_b)

def setup(bot: commands.Bot):
    bot.add_cog(myCog(bot))
#

this is the general format I use

#

it's a little more advanced as it uses a cog, but it's the only boilerplate code I could share with you from my PC

#

I just treat cogs like they are categories

#

so if I was making slash commands for moderation, my cog would probably be called moderation

#

now, one important think to remember when using cogs.

#

You actually have to load the cogs

#

make one file called bot.py

#
from disnake.ext import commands
import config

class main(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix=commands.when_mentioned,
            intents=config.intents,
            help_command=None,  # type: ignore
            sync_commands_debug=True,
            sync_permissions=True,
            test_guilds=config.testGuilds,
            strict_localization=True,
        )

    async def on_ready(self):
        print(f"\n"
              f"The bot is ready.\n"
              f"User: {self.user}\n"
              f"ID: {self.user.id}\n")
#

put this

#

ok

#

wait

#

you should just be able to kill terminal

#

in vs code

#

I imagine you are running the script in VS code?

#

ok in the future

#

use F5

#

to run code

#

i don't have that on my computer

#

i just use cogs