#discord-bots

1 messages ยท Page 55 of 1

primal token
#

how so? it seems nice to me, just a bit jitterish is the word?

slate swan
primal token
#

the only annoying thing ive encountered is i cant add custom apps like discord into the favorites panel which is sad, i always need to check the dir and launch the executable

primal token
primal token
#

You can always do <link> so it wont get embeded lol, thanks

slate swan
#

yeah i did the same in the edit cause there's no remove embeds option on phone

sonic flax
#

how would i edit a role name and color from a command

sage otter
#

!d discord.Role.edit

unkempt canyonBOT
#

await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., display_icon=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the role.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this.

All fields are optional.

Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.

Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead...
fresh iron
#

can't discord detect if someone is online through a python file for example and then ban it immediately and by that they get rid of self-bots

rapid jetty
#

?

#

wdym

fresh iron
#

a lot of people use selfbots to do illegal stuff such as spamming

#

advertising

#

and so on

#
clinet.run(token, bot=False)
sage otter
#

that doesnt exist anymore within the library.

fresh iron
#

im asking if discord is able to detect the places a disocrd user can log into an account through

fresh iron
sage otter
#

dpy

fresh iron
#

you can literally make another one

sage otter
#

Im just sayin

worthy mortar
#

Is it possible to create a bot that will notify me if too many users join my server in a certain amount of time?

for example, if more than 3 new members join in less than 1 minute, can i get a notification / temporarily block the users joining?

limber bison
#

how cycle funtion work ?

#

i creating a russion - roullet game so i want first player1 play then second then again player1 till 6 bullets if a player die in beetween game complete

fresh iron
#

that's why bots exist

#

make conditions and use time

limber bison
#

its easy

#

event u can do so many other stuff

worthy mortar
sage otter
#

if you load the players into an iterable . You can call next() on it to cycle through the players. Alternatively, you could just cycle manually by having a list and popping and appending continuously through turns.

limber bison
#

oh

#

let me read your text again

#

still it will didnt work i thing

#

๐Ÿค”

sage otter
#

I havent really used it before because I havent really had a use for it. However, its something I was told could be used in your situation. If I had to give an example that could apply to your situation without using it. It would be along the lines of:

player_list = [player1, player2]
for _ in range(6): # 6 total turns
    selected_player = player_list.pop(0)
    ... # Do whatever here
    player_list.append(selected_player)
#

For sure not a perfect example but

#

its all I got so AMshrug

limber bison
#

@sage otterthis working but if player = iter(["player1" , "player2"] it gives errors

#

ooo sory

#

let me read your text first

sage otter
#

thats for sure a way to do it. Not very efficient tho.

fresh iron
#

why do i get this error when i have installed the lib

#

even tried reinstalling it

pliant gulch
#

E.g the one you install to might be 3.9 while the one your vscode uses is 3.10 for an example

fresh iron
#

it doesn't run anyway as a python file

#

so something is missing

pliant gulch
fresh iron
#

it's not about vscode

pliant gulch
#

What does this mean exactly

pliant gulch
#

Also your linter seems to suggest it's missing as well

#

Which most commonly suggests an issue with Vscode using the wrong interpreter for python

pliant gulch
#

Can you show how you install discord.py and how you run the file?

fresh iron
#

and run it through PS

#

python file.py

limber bison
fresh iron
#

no its not

pliant gulch
limber bison
#

๐Ÿค”

pliant gulch
#

Also show the traceback from python file.py

fresh iron
#

my file name is the name in my rich presence on my profile does it matter because it has a symbol

pliant gulch
#

Okay now show the traceback of python file.py

#

Keep in mind doing pip install discord will install a mirror but that isn't the cause of your issue so ignore that for now

primal token
#

@slate swan sadly i couldnt deploy xubuntu fully it was getting allot of errors and when it did the files were corruptedducky_party

pliant gulch
#

Whats the point of xubuntu if you can just swap Gnome with XFCE

primal token
#

i was thinking about it but idk tbh

pliant gulch
primal token
#

i wasnt quite sure as my xfce session or xubuntu session were both crashing

pliant gulch
#

Just install xfce using your package manager, logout of your ubuntu session and use your login manager to switch desktops

primal token
#

yeah i was thinking about it but im not sure due to my past issue with crashing of sessions and when they didnt crashed the corrupted files would come in play

pliant gulch
#

Are you using bare metal or is this a VM?

#

Also could be an issue with graphic drivers

primal token
#

dualbooting currently, so "bare metal"

primal token
pliant gulch
#

I would suggest reading /var/log and looking for any XFCE entries to try to diagnose it then

primal token
#

ill reinstall xubuntu-desktop and ill see

pliant gulch
#

And why even XFCE

#

Gnome should suffice, and it's easy as hell to rice

#

Not to mention there is also gnome shell extensions such as material shell

#

Which convert Gnome desktop into A tiling window manager

primal token
#

well idk, personally i dont have nothing against gnome and ubuntu the only thing that i dislike is the usage of memory and stutters for some reason maybe because its a fresh instalation i doubt it

pliant gulch
#

If you want a lower memory footprint then gnome isn't a good choice, xfce is lite yea

#

But I would suggest, for the long run a tiling window manager itself

#

For an example, you would make a fresh install, then install, lets say BSPWM or I3 (or I3 gaps)

#

All you do from there is add anything extra, like notifications, bars etc

#

Then boom, you got yourself a super minimal desktop

primal token
#

to spare some back pain, i think ill probably just remove my ubuntu installation and probably use XFCE

silk fulcrum
#

@primal token why is hunter asking me if I know you?

pliant gulch
#

Your gonna remove your distro installation and just use a desktop????

#

Or did you mean gnome and not ubuntu

primal token
#

what

primal token
silk fulcrum
#

@maiden fable him

pliant gulch
# primal token what

i think ill probably just remove my "ubuntu installation" and probably use "XFCE"

primal token
#

well theyre both different distros right?

pliant gulch
#

No

primal token
pliant gulch
#

XFCE is a desktop enviorment

#

It's a package you download to use in your distro for desktops

#

Ubuntu is a distro itself

primal token
#

ah i see, guess im mixing stuff up

#

so gnome is a desktop environment itself i suppose?

pliant gulch
#

Yes ubuntu comes with gnome

#

But iirc you can install a ubuntu iso that omits gnome

silk fulcrum
primal token
#

alright let me install XFCE then

primal token
slate swan
#

hello, how do I make my bot delete a certain message on a certain channel? python

limber bison
#

can i turn off reply to orignal message in buttons ?

silk fulcrum
silk fulcrum
limber bison
#

๐Ÿ˜ณ

silk fulcrum
limber bison
#

damn

slate swan
silk fulcrum
#

uhm, I don't think that is the topic of this channel
try asking somewhere else, where topic looks similar to what you're doing

slate swan
silk fulcrum
#

tbh, no idea

hollow spoke
#

hello

#

Can I ask a question

silk fulcrum
#

just ask

hollow spoke
#

ok

#

How do you write code in Python?
Is how to write (if the result is greater than zero, do the command)

silk fulcrum
#

๐Ÿ—ฟ

#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

hollow spoke
#

you cant help me ?

silk fulcrum
#

uhm, I sent resources how to learn python

#

not enough?

primal token
pliant gulch
#

Alright

hollow spoke
primal token
#

My first thoughts on a ubuntu were pretty good, it didnt broke down 50 times like my windows installation kek

silk fulcrum
hollow spoke
#

ok thanks

carmine pasture
#
    client = commands.Bot(command_prefix = "!")
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
#

whenever i try to run the bot that error shows up

#

it is suggesting that the commands.bot line has a problem

carmine pasture
#

wdym

vocal snow
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

carmine pasture
#

ahhh

slate swan
#
client = commands.Bot(command_prefix = "!", intents=intents)
carmine pasture
#

thanks

#

lemme try that

slate swan
#

try it

carmine pasture
#

does the i need to be capital?

#

cause it looks like it does

potent spear
#

it's a kwarg, so no

#

only the initialization of that variable has to be, since discord.Intents is a class

carmine pasture
#

ah

#
    client = commands.Bot(command_prefix = "!", intents=intents)
NameError: name 'intents' is not defined. Did you mean: 'Intents'?
potent spear
#

error says it all

carmine pasture
#

hmm

potent spear
carmine pasture
#

hang on

#

tysm guys

#

it works now

slate swan
#

๐Ÿคฏ

#

almost like you need to define a variable before trying to use it

carmine pasture
#

lol

slate swan
#

Does anyone know how to make a bot automatically delete it's message?

slate swan
#

!d discord.Message.delete

unkempt canyonBOT
#

await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other peopleโ€™s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
slate swan
#

I'm talking about like the bot's own message

#

So basically for example, I use a command for the bot to send a message, then a couple seconds later the bot deletes the message it sent (not mine)

#

that will delete the message the bot sent

#

Oh okay thanks

slate swan
slate swan
#

oh

#

Just do

await ctx.send('message', delete_after=2.0)
#

alr ill try it

slate swan
#

alr

#

It worked, thank you man I appreciate it :)

#

Np

#

I didn't know exactly what you wanted at the start my bad

#

No worries man

fresh iron
#
@client.command()
async def battle(ctx, *, member: discord.Member):
    n1 = message_author
    n2 = member
    i1 = 100
    i2 = 100
    while i1 < 101:
        ctx.send(f"{n1}'s health is: {i1}")
        i1 = i1 - random.choice(range(-2, 35))
        time.sleep(0.6)
        ctx.send("--------------------------")
        ctx.send(f"{n2}'s health is: {i2}")
        i2 = i2 - random.choice(range(-2, 35))
        time.sleep(0.6)
        ctx.send("--------------------------")
        if i1 <= 0 and i1 < i2:
            ctx.send(f"{n1}'s health is: 0 DEAD")
            break
        elif i2 <= 0 and i2 < i1:
            ctx.send(f"{n2}'s health is: 0 DEAD")
            break
#

what do i use instead of message author

#

if i wanted to grab the user that uses the command

slate swan
#

What's going on?```py
Traceback (most recent call last):
File "/home/runner/StarLight-Services/venv/lib/python3.8/site-packages/discord/ui/view.py", line 375, in _scheduled_task
await item.callback(interaction)
File "/home/runner/StarLight-Services/cogs/services.py", line 78, in ticket
view = ticket_creation(select.values[0], member)
File "/home/runner/StarLight-Services/cogs/services.py", line 26, in init
super().init(
File "/home/runner/StarLight-Services/venv/lib/python3.8/site-packages/discord/ui/modal.py", line 57, in init
self._weights = _ModalWeights(self._children)
File "/home/runner/StarLight-Services/venv/lib/python3.8/site-packages/discord/ui/modal.py", line 263, in init
self.add_item(item)
File "/home/runner/StarLight-Services/venv/lib/python3.8/site-packages/discord/ui/modal.py", line 280, in add_item
index = self.find_open_space(item)
File "/home/runner/StarLight-Services/venv/lib/python3.8/site-packages/discord/ui/modal.py", line 270, in find_open_space
raise ValueError("could not find open space for item")
ValueError: could not find open space for item

silk fulcrum
slate swan
# silk fulcrum code
class ticket_creation(discord.ui.Modal):
    def __init__(self, ttype, member):
        super().__init__(
            (*[discord.ui.InputText(style = discord.InputTextStyle.long, label = i[0], placeholder = i[1], min_length = 2) for i in questions[ttype]]),
            title = "Ticket Creation")
        self.timeout = None
        self.ttype = ttype
        self.member = member
    async def callback(self, interaction: discord.Interaction):
#

How many inputtext fields may a modal have?

silk fulcrum
#

and you are passing (*[discord.ui.InputText(style = discord.InputTextStyle.long, label = i[0], placeholder = i[1], min_length = 2) for i in questions[ttype]]

#

which doesnt even seem valid syntax

#

looks like you forgot close one )

#

oh no you didnt

#

sorry

slate swan
#

The children isn't a kwarg, just args.

#

class discord.ui.Modal(*children, title, custom_id=None, timeout=None)

silk fulcrum
#

only takes kwargs

silk fulcrum
slate swan
#

You bet

silk fulcrum
#

actually pycord :(

#

very sad

#

no idea what is that

slate swan
#

Not really, but do you know max children a modal can have?

silk fulcrum
#

and i never used pycord

#

unlimited?

#

gonna check on dev portal then

#

yeah it has limit @slate swan

#

it's 5

slate swan
#

Yeah, thanks, that's the problem!

buoyant quail
#

Which event comes on member timeout?
Can't find that

mighty kindle
#
AttributeError: 'Bot' object has no attribute 'memcached'```
#

I dont know how to add memcached to Bot class

buoyant quail
#

bot.memcached = ...

mighty kindle
#

yes but what

buoyant quail
#

anything you want

mighty kindle
#

!d memcached

#

!d memcached

buoyant quail
mighty kindle
#

;-;

silk fulcrum
#

dpy Bot has no memcached, if you wanna use it, just subclass the Bot and do self.memcached = MyCoolMemCached

mighty kindle
#

still same error

#

i installed everything, even ubuntu memcached

#

my bot has no main file

#

how can I use memcached with dpy

#

since i always get error

vocal snow
#

What is memcached

fresh iron
#

whats wrong with this command

prisma orchid
limber bison
#

is this a valid view ?

slate swan
#

Wait nvm

#

I'm blind

limber bison
silk fulcrum
vale wing
limber bison
vocal snow
silk fulcrum
#

and follow pep8 pls

limber bison
vocal snow
#

Send the code i will run black on it for you

limber bison
limber bison
silk fulcrum
#

you cant use self in classvars

vocal snow
#

Why is player a classvar !

vale wing
#

Because that's genius

silk fulcrum
#

and why would you need to make it a list

vale wing
#

The self outside of methods

silk fulcrum
vale wing
#

Nah this dude is

loud junco
limber bison
vale wing
loud junco
#

.append()?

limber bison
#

i mean add

loud junco
#

๐Ÿ’€

silk fulcrum
#

not players

loud junco
#

ctx.message.author will return name

silk fulcrum
loud junco
#

๐Ÿ˜ƒ

silk fulcrum
#

1 - ctx.author is same

loud junco
#

ye true

limber bison
#

damn

silk fulcrum
#

2 - it returns Member / User object

limber bison
silk fulcrum
#

not name

loud junco
limber bison
silk fulcrum
#

str(Member / User) = smth like mecool#3456

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
#

I want to follow an user by an command

#

owh oof

silk fulcrum
#

an user by an command

vale wing
#

Follow?

slate swan
vale wing
#

Use twitch API

silk fulcrum
vale wing
#

With aiohttp

slate swan
vale wing
slate swan
#

Lemme DM you

robust fulcrum
#

Guys how can I use โฎ๏ธ emoji in button emoji?

silk fulcrum
#

\โฎ๏ธ

robust fulcrum
silk fulcrum
#

what error

robust fulcrum
edgy maple
#

I keep getting TypeError: expected token to be a str, received <class 'NoneType'> instead when trying to run my bot in vsc, I made sure I set the token env variable and everything but it still doesn't want to work even with putting the whole token in. Anyone has any ideas on what it might be?

fresh iron
#

is this written correctly

#

whats the error

silk fulcrum
#

you either dont have it in env or have it with other name

silk fulcrum
fresh iron
#

do you think people would leak their tokens while asking for help here

silk fulcrum
#

it's just message

#

on_message(message)

fresh iron
#

so it should be client.send_message

silk fulcrum
robust fulcrum
silk fulcrum
#

what's your second component?

robust fulcrum
#

What?

silk fulcrum
#

counting in programming starts with 0

fresh iron
robust fulcrum
# silk fulcrum `counting in programming starts with 0`
class Help(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=180)
        self.page = 1

    @discord.ui.button(label=None,style=discord.ButtonStyle.blurple,row=0,emoji=":left:")
    async def left(self,interaction:discord.Interaction,button:discord.ui.Button):
        self.page = self.page-1
        if self.page < 1:
            self.page = 1
        await interaction.response.edit_message(content=f"page {self.page}", view=self)

    @discord.ui.button(label=None,style=discord.ButtonStyle.blurple,row=0,emoji=":track_previous:")
    async def md(self,interaction:discord.Interaction,button:discord.ui.Button):
        await interaction.response.edit_message(content=None,view=self)

    @discord.ui.button(label=None,style=discord.ButtonStyle.blurple,row=0,emoji=":right:")
    async def right(self,interaction:discord.Interaction,button:discord.ui.Button):
        self.page = self.page+1
        if self.page > 8:
            self.page = 8
        await interaction.response.edit_message(content=f"page {self.page}", view=self)
fresh iron
#

how do i make it respond to certian messages without a command then

silk fulcrum
#

\โฎ๏ธ

#

hm

#

idk

unkempt canyonBOT
#

Hey @limber bison!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

silk fulcrum
limber bison
brazen raft
edgy maple
#

in a .env file and then i loaded it into main

vale wing
#

Could you show your files hierarchy

edgy maple
cerulean shale
#

Aiohttp clientsession or Requests? Which is better for APIs? I personally have been using aiohttp clientsession but yesterday i shifted to vsc from replit and for some reason I cant have so many clientsessions ๐Ÿ’€

#

Ayyyyyy master

vale wing
# edgy maple

If your file isn't named exactly .env you should parse filename as argument to load_dotenv(). Like this

dotenv.load_dotenv("token.env")```
cerulean shale
#

๐Ÿ™

silk fulcrum
cerulean shale
edgy maple
brazen raft
#

You should open one session and save it in the bot as a bot variable

vale wing
cerulean shale
brazen raft
#

I don't see why not

silk fulcrum
#

what is the problem?

cerulean shale
#

Just asking ๐Ÿฅฒ

brazen raft
#

You can

cerulean shale
#

Ight i will try it then

silk fulcrum
#

insert token here

cerulean shale
#

๐Ÿ’€

#

Remove the parenthesis ig

vale wing
#

^

#

It should look like this

TOKEN=some.nice.token.idk```
edgy maple
#

the parenthesis is just to show it here but in the code its just the token

vale wing
#

Try removing the spaces around =

cerulean shale
#

Yes yes

edgy maple
#

still the same

vale wing
#

Also I see you renamed it to .env, have you removed an argument from load_dotenv?

edgy maple
#

its still this

shrewd apex
#

is this pycharm or vsc?

edgy maple
#

vsc

vale wing
#

Is this function executed before you getenv

edgy maple
#

yeah

vale wing
#

Try printing entire os.environ after loading

brazen raft
#

Or, os.environ.get("TOKEN")

lone lichen
#

dotenv.load_dotenv(โ€œ.envโ€)
os.getenv(โ€œTOKENโ€)

edgy maple
#

when I printed the token it said None

brazen raft
lone lichen
vale wing
brazen raft
lone lichen
#

!d os.environ

unkempt canyonBOT
#

os.environ```
A [mapping](https://docs.python.org/3/glossary.html#term-mapping) object where keys and values are strings that represent the process environment. For example, `environ['HOME']` is the pathname of your home directory (on some platforms), and is equivalent to `getenv("HOME")` in C.

This mapping is captured the first time the [`os`](https://docs.python.org/3/library/os.html#module-os "os: Miscellaneous operating system interfaces.") module is imported, typically during Python startup as part of processing `site.py`. Changes to the environment made after this time are not reflected in [`os.environ`](https://docs.python.org/3/library/os.html#os.environ "os.environ"), except for changes made by modifying [`os.environ`](https://docs.python.org/3/library/os.html#os.environ "os.environ") directly.

This mapping may be used to modify the environment as well as query the environment. [`putenv()`](https://docs.python.org/3/library/os.html#os.putenv "os.putenv") will be called automatically when the mapping is modified.
vale wing
#

!e py d = {"a": 10} d.get("a")

unkempt canyonBOT
#

@vale wing :warning: Your 3.11 eval job has completed with return code 0.

[No output]
lone lichen
#

!d os.getenv

unkempt canyonBOT
#

os.getenv(key, default=None)```
Return the value of the environment variable *key* if it exists, or *default* if it doesnโ€™t. *key*, *default* and the result are str. Note that since [`getenv()`](https://docs.python.org/3/library/os.html#os.getenv "os.getenv") uses [`os.environ`](https://docs.python.org/3/library/os.html#os.environ "os.environ"), the mapping of [`getenv()`](https://docs.python.org/3/library/os.html#os.getenv "os.getenv") is similarly also captured on import, and the function may not reflect future environment changes.

On Unix, keys and values are decoded with [`sys.getfilesystemencoding()`](https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding "sys.getfilesystemencoding") and `'surrogateescape'` error handler. Use [`os.getenvb()`](https://docs.python.org/3/library/os.html#os.getenvb "os.getenvb") if you would like to use a different encoding.

[Availability](https://docs.python.org/3/library/intro.html#availability): most flavors of Unix, Windows.
edgy maple
#

received None in terminal

slate swan
#

you need to load the env file too

edgy maple
#

I did

brazen raft
#

What did you use to load the .env file

vale wing
#

!e py d = {"a": 10} d.get("b")

unkempt canyonBOT
#

@vale wing :warning: Your 3.11 eval job has completed with return code 0.

[No output]
vale wing
#

Wut

#

!d dict.get

unkempt canyonBOT
#

get(key[, default])```
Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](https://docs.python.org/3/library/exceptions.html#KeyError "KeyError").
edgy maple
vale wing
slate swan
#

whats the filename of the env file?

vale wing
#

Why was I sure it raises the error

edgy maple
#

.env

lone lichen
brazen raft
edgy maple
brazen raft
#

Did you install it using py -m pip install python-dotenv

edgy maple
#

yeah i have it installed

lone lichen
#

U did load_dotenv(โ€œ.envโ€)?

brazen raft
#

The package name on PyPi is python-dotenv

#

Which is important

slate swan
#

is it in the same directory as the file you run?

edgy maple
#

it is in the same directory and I did install it correctly

edgy maple
lone lichen
vale wing
#

!pypi python-dotenv

unkempt canyonBOT
slate swan
vale wing
#

@edgy maple try this

import dotenv

values = dotenv.dotenv_values(".env")
print(values)```
edgy maple
#

OrderedDict()

fresh iron
#

why does this command not work anymore

#

it doesn't send any errors

lone lichen
slate swan
brazen raft
#

That might just be word warping

slate swan
#

yeah, then on_message event could be the issue

fresh iron
brazen raft
#

Or you have insufficient intents

lone lichen
brazen raft
#

Also you don't have to save https://open.spotify.com/track/ in each of the strings, you can put it in the sent string and save the track IDs with the song IDs in the list instead

fresh iron
# slate swan the closing quotes are in next line for some strings.. is that because of your I...
@client.command()
async def abba(ctx):
    abbasongs = ["https://open.spotify.com/track/2245x0g1ft0HC7sf79zbYN?si=a70500225cec458f ", "https://open.spotify.com/track/2TxCwUlqaOH3TIyJqGgR91?si=2deaa976e19e409f", "https://open.spotify.com/track/5pMmWfuL0FTGshYt7HVJ8P?si=3b499efd06f24e61", "https://open.spotify.com/track/1rMfDvE2C8ne8UZj847rKM?si=05ca598895564711", "https://open.spotify.com/track/0J2p4KYdr6Mg4ET6JPlbe1?si=bb96cae9955d4e3f", "https://open.spotify.com/track/762B4bOcXF7I2Y8UlKTyTy?si=f7c8b5ac3e0942a7", "https://open.spotify.com/track/29FNeqjOV2kPWGS55qhtGB?si=f3dc8d19271d4f5a", "https://open.spotify.com/track/2w6JXokk0F8i241Y8C0Mn6?si=1e9a3104a7474f6d", "https://open.spotify.com/track/1PtJclc46wTk367PlsU6Uj?si=58cce7e83cb84897", "https://open.spotify.com/track/08GOw3NsrJ0LsCCeyqzt3b?si=312019ebf1fb4033", "https://open.spotify.com/track/6zgtBUEkAfilJ2YEOvNexR?si=39cd2237592844dc", "https://open.spotify.com/track/1zZLRpTzRTqPQ7G7uxYI9Y?si=64e6197df7134cc2", "https://open.spotify.com/track/6TvxPS4fj4LUdjw2es4g21?si=793cdb07cd874d79", "https://open.spotify.com/track/2TxCwUlqaOH3TIyJqGgR91?si=01d194a029a748d5"]
    song = random.choice(abbasongs)
    await ctx.send(f"Here's some great :a: :b: :b: :a: song for ya \n {song}")
slate swan
brazen raft
#

Where it is doesn't matter

#

What its body includes does matter

fresh iron
#

what

cerulean shale
#

Is windows 10 slow or is it just me?

brazen raft
#

That is an off-topic question

fresh iron
worn onyx
#

[Button(label="ok", style= "3", emoji= "๐Ÿ˜", custom_id= "button1"), Button(label="lol", style= "4", emoji= "๐Ÿ˜", custom_id="button1"), Button)] ]) whats wrong is this ^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

brazen raft
#

You need to have intents.message_content = True going by this example

fresh iron
cerulean shale
brazen raft
cerulean shale
#

Yes

fresh iron
brazen raft
fresh iron
#

i already have it

brazen raft
#

You should name discord.ext.commands.Bot instances bot or something, so it's not misleading, because discord.Client is a thing

#

Just saying

fresh iron
#

then i have few @clientcommand and one on message event

brazen raft
fresh iron
#

of course

brazen raft
#

What's the body of your on_message event

silk fulcrum
#

why are u hiding Ramsey

brazen raft
#

At the end of it you need to put await client.process_commands(message)

silk fulcrum
#

listen() is also a thing

brazen raft
#

What do you mean

silk fulcrum
#

@bot.listen()

brazen raft
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").

Example...
silk fulcrum
brazen raft
#

Yeah

worn onyx
#

@silk fulcrum [Button(label="ok", style= "3", emoji= "๐Ÿ˜", custom_id= "button1"), Button(label="lol", style= "4", emoji= "๐Ÿ˜", custom_id="button2")] ]) interaction = await client.wait_for("button_click", check = lambda i: i.custom_id == "button1") await interaction.send(content = "Button clicked", ephmeral=True) whats wrong in this ^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['

silk fulcrum
#

sheeh loks terrible

#
[
    Button(
        label="ok", style= "3", emoji= "๐Ÿ˜", custom_id= "button1"
    ),
    Button(
        label="lol", style= "4", emoji= "๐Ÿ˜", custom_id="button2"
    )
]
      ])```
#

now see the problem?

#

sometimes you gotta do this to figure out what is problem with brackets

worn onyx
#

what to do

cerulean shale
silk fulcrum
#

do you see the problem now?

worn onyx
cerulean shale
#

why are there these ]) brackets at the end?

#

@worn onyx

#

sed lyf always getting ignored

cerulean shale
#

what is this? new to vsc ;-;

#

@silk fulcrum ๐Ÿ™

silk fulcrum
#

i simplified your code

#

problem is obvious now

silk fulcrum
cerulean shale
#

i am trying to run my code by clicking on the run button

#

thats when i am getting that thing

worn onyx
cerulean shale
silk fulcrum
silk fulcrum
#

if you changed something

#

if not - go find the problem

cerulean shale
silk fulcrum
#

you've already been told what is it

silk fulcrum
cerulean shale
#

nope

#

everything is normal

silk fulcrum
#

try running in console

cerulean shale
#

ight

silk fulcrum
#

bruh my touchpad is dead

cerulean shale
cerulean shale
fresh iron
#

how to detect if a message contains a specific word within a sentence whether it's lower or upper case

slate swan
#

why do you even use code runner, just use your terminal

slate swan
#

!e print("SomE TexT".lower())

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

some text
slate swan
#

and check if the lower string is in that string

fresh iron
#

ik that

#

how to detect if a message contains a specific word within a sentence

silk fulcrum
#

lol

slate swan
#

"word" in "sentence" ?

silk fulcrum
unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

False
cold oyster
#

hi

glad cradle
#

has anyone here ever used Cython for their Bot?

tight dagger
fresh iron
slate swan
tight dagger
#

it will work

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

True
cold oyster
glad cradle
fresh iron
#

client.listen instead of on_message?

silk fulcrum
cold oyster
#

dk wat dat is

tight dagger
glad cradle
slate swan
# fresh iron what

if you don't know how to use in statement, consider learning more python

tight dagger
#
@client.listen()
async def(...)
...
tight dagger
silk fulcrum
#

!pip cython

unkempt canyonBOT
#

The Cython compiler for writing C extensions for the Python language.

glad cradle
slate swan
glad cradle
slate swan
#

90% of the code, which will be coming from discord.py's source code will not be cython compatible, so forget about speed

glad cradle
#

especially for things related to the voice client

cold oyster
#

how do i make it so that when i use a command, it will get my id and dump it in a json file?

glad cradle
glad cradle
cold oyster
slate swan
slate swan
fresh iron
silk fulcrum
fresh iron
silk fulcrum
fresh iron
#

thank you master

#

cute cat btw

silk fulcrum
cold oyster
slate swan
grim oar
#

Okmi

silk fulcrum
cerulean shale
#

@silk fulcrum can i dm you master? ๐Ÿฅบ

cerulean shale
slate swan
#

I can't get the error on unwarn

silk fulcrum
slate swan
vocal snow
slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

grim oar
#

Why are you here go back to college

slate swan
#

it doesn't unwarn and shows "string indices must be integers"

tight dagger
cerulean shale
#

um guys so i recently shifted to vsc from replit and am getting error with aiohttp.ClientSession apis, so it says it doesnt have any setup_hook and so i did this, dont even know whether this is right or wrong tbh

silk fulcrum
#

did what?

cerulean shale
#
class Estelle(commands.Bot):

    def __init__(self):
        intents = discord.Intents.default()
        intents.members = True
        intents.message_content = True

        super().__init__(
            command_prefix="?",
            description="My Cool Bot!!!",
            intents=intents,
            strip_after_prefix=True,
            case_insensitive=True
        )

    async def setup_hook(self):
      self.session = aiohttp.ClientSession()

      for cog in cogs:
        await self.load_extension(cog)
slate swan
#

please someone

cerulean shale
#

๐Ÿฅฒ

slate swan
silk fulcrum
cerulean shale
#

as in

silk fulcrum
cerulean shale
#

ight sensei

silk fulcrum
#

at the very bottom

cerulean shale
#

you mean this?

async def setup(bot):
  await bot.add_cog(Chatbot(bot))
silk fulcrum
#

yes

#

all your cogs must have this

#

at the end

cerulean shale
#

but its already there for all the cogs ๐Ÿคก

silk fulcrum
#

but your error says opposite

#

make sure you saved the file

cerulean shale
#

oh ok

#

F

#
async def main():
    bot = Estelle()
    await bot.start()
      
@bot.event
async def on_ready():
  await bot.change_presence(status=discord.Status.online, activity=discord.Game('?help if you are lost '))
  print("Bot is running.")
``` it is saying that bot is not defined....
silk fulcrum
#

bot is not defined, 100% percent

supple thorn
silk fulcrum
#

it's only defined inside your main function

#

you can make on_ready right inside of the bot btw

supple thorn
#

Hi master

#

Wait are you the same master

silk fulcrum
#

like that ```py
class MyBot(commands.Bot):
def init(self):
super().init(...)

async def on_ready(self):
    ...``` @cerulean shale
#

and btw dont change presence in on_ready

#

its bad

cerulean shale
#

oh-

silk fulcrum
#

you can do that directly in bot constructor

cerulean shale
#

but i have other commands too

#
@bot.command()
async def load(ctx, extension):
  await bot.load_extension(f"cogs.{extension}")
  await ctx.send('Loaded Cog!')


@bot.command()
async def unload(ctx, extension):
  await bot.unload_extension(f"cogs.{extension}")
  await ctx.send('Unloaded Cog!')


@bot.command()
async def reload(ctx, extension):
  await bot.reload_extension(f"cogs.{extension}")
  await ctx.send('Reloaded Cog!')  

@bot.event
async def on_command_error(ctx, error):

    if isinstance(error, commands.MissingPermissions):
        await ctx.send(f"{ctx.message.author.mention} :x: You don't meet all the requirements to use this command.")

    elif isinstance(error, commands.CommandOnCooldown):
      #{:.nf}, n places the decimals
      msg = '**Still on cooldown**, pls try again in **{:.0f}s**'.format(error.retry_after)
      await ctx.send(msg)

    elif isinstance(error, commands.MissingRequiredArgument) or isinstance(error, commands.BadArgument):
        helper = str(ctx.invoked_subcommand) if ctx.invoked_subcommand else str(ctx.command)
        await ctx.send(f'{ctx.author.name} The correct way of using that commands is: ')
        await ctx.send_help(helper)

    elif isinstance(error, commands.CommandNotFound):
      await ctx.send("No command under that name is found.")
      

    else:
      print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
      traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
silk fulcrum
#

these ones seem to be good to put in Owner cog

cerulean shale
#

cool sensei

silk fulcrum
#

on_command_error can be put inside the Bot subclassing or in the cog too

#

as @commands.Cog.listener()

cerulean shale
#

ight master

slate swan
#

no one wants to help me..

silk fulcrum
#

what's the problem? @slate swan

slate swan
silk fulcrum
#

error?

slate swan
#

string indices must be integers

slate swan
slate swan
silk fulcrum
#

do you have an error handler?

slate swan
#

??

#

I'm on PyCharm

silk fulcrum
#

error handler

#

in the bot code

#

!d discord.on_error

unkempt canyonBOT
#

discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is logged to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.

The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.10)").

Note

`on_error` will only be dispatched to [`Client.event()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.event "discord.Client.event").

It will not be received by [`Client.wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for "discord.Client.wait_for"), or, if used, [Bots](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#ext-commands-api-bot) listeners such as [`listen()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen") or [`listener()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog.listener "discord.ext.commands.Cog.listener").

Changed in version 2.0: The traceback is now logged rather than printed.
silk fulcrum
#

or on_command_error

slate swan
#

nah

silk fulcrum
#

hm

slate swan
#

no errors only that

silk fulcrum
#

I think this except triggers and you only do print(p)

slate swan
#

it sends that in chat

#

there was a problem with resetting users warns

#

it doesn't reset warns

silk fulcrum
#

print(exception) only prints the description of exception

slate swan
#

so how do I fix the thing

cold sonnet
silk fulcrum
#

there is something like traceback.print_exc(), but you can just do raise e

#

instead of print(e)

silk fulcrum
slate swan
#

how do I fixxxxxxxxxxxxx

silk fulcrum
cold sonnet
#

didn't handle errors

silk fulcrum
slate swan
#

where do I put that

silk fulcrum
#

raise e instead of print(e)

#

in your except

slate swan
#

do I remove except Exception as e: print(e) await ctx.send(f"There was a problem with resetting {user_short}'s warns in {guild_name}") return and change it to that?

silk fulcrum
#

should show full traceback

slate swan
#

@silk fulcrum ..

silk fulcrum
#

why the heck did you do traceback.print_exc()

slate swan
#

you told me bruh

silk fulcrum
#

it most likely exists but you'd need to import traceback for that

cerulean shale
#

how to run code in terminal btw? ๐Ÿฅฒ

silk fulcrum
cerulean shale
slate swan
silk fulcrum
cerulean shale
#

ight

slate swan
silk fulcrum
#

or python main.py

silk fulcrum
#

raise is not a function

slate swan
#

WHAT SHOULD I DO THEN

silk fulcrum
#

raise e

silk fulcrum
slate swan
#

bruh how do I do that then

slate swan
slate swan
silk fulcrum
#

don't you see the difference?

#

raise(e) = what you said

slate swan
silk fulcrum
#

raise e = what I said

slate swan
#

alr I did that

#

now lets see

silk fulcrum
#

sarth is always right

slate swan
#

now it shows an error

silk fulcrum
#

and what is the error

slate swan
#
[2022-08-25 14:49:25] [INFO    ] discord.client: logging in using static token
[2022-08-25 14:49:29] [INFO    ] discord.gateway: Shard ID None has connected to Gateway (Session ID: 9bfa18d8839c9edc1c7ea328ce0e0550).
Dragon Bot is ready to fly in Discord Life
{'users': [{'name': 'Pengu', 'reasons': ['a', 'test']}]}
[2022-08-25 14:49:45] [ERROR   ] discord.ext.commands.bot: Ignoring exception in command unwarn
Traceback (most recent call last):
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\venv\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\main.py", line 373, in unwarn
    raise e
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\main.py", line 364, in unwarn
    if obj["name"] == user_short:
TypeError: string indices must be integers

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

Traceback (most recent call last):
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\venv\lib\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\venv\lib\site-packages\discord\ext\commands\core.py", line 986, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\venv\lib\site-packages\discord\ext\commands\core.py", line 199, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: string indices must be integers```
#

obj is a string

#

??

#

how do I fix the thing

silk fulcrum
#

think with brain?

#

if obj is a string, how can you do obj["name"]

cerulean shale
#

@silk fulcrum how to close a session? is that the issue or is it something else?

silk fulcrum
#

then you look at what your my_list is

slate swan
#

oh I found

silk fulcrum
slate swan
#

so what do I change it to so that it worked?

slate swan
silk fulcrum
#

you can do py async def close(self): await session.close() await super().close()

#

inside the Bot subclass

cerulean shale
#

ight got it

silk fulcrum
slate swan
#

@silk fulcrum ..

#

that still won't close the connection:p

silk fulcrum
#

@slate swan do you know what enumerate means?

cerulean shale
silk fulcrum
cerulean shale
#

runtime error

silk fulcrum
slate swan
silk fulcrum
slate swan
silk fulcrum
silk fulcrum
#

why self.session.close() is not enough?

#

I have no problems with it

cerulean shale
cerulean shale
slate swan
unkempt canyonBOT
#
Not in my house!

No documentation found for the requested symbol.

cerulean shale
silk fulcrum
slate swan
#

@silk fulcrum please just tell me how to fix it, it gives headache

silk fulcrum
slate swan
#

and what's the session variable there?

slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

name mangling
silk fulcrum
slate swan
slate swan
#

look lemme explain

cerulean shale
#
import discord
import asyncio
import aiohttp

from discord.ext import commands

cogs = (
    'cogs.chatbot',
    'cogs.events',
    'cogs.fun',
    'cogs.minigames',
    'cogs.misc',
    'cogs.mod',
    'cogs.nsfw',
    'cogs.reactions',
    'cogs.search',
    'cogs.owner'
)

class Estelle(commands.Bot):

    def __init__(self):
        intents = discord.Intents.default()
        intents.members = True
        intents.message_content = True

        super().__init__(
            command_prefix="?",
            description="My Cool Bot!!!",
            intents=intents,
            strip_after_prefix=True,
            case_insensitive=True
        )

    async def setup_hook(self):
      self.session = aiohttp.ClientSession()

      for cog in cogs:
        await self.load_extension(cog)

    async def close(self):
      await session.close()
      await super().close()

    async def on_ready(self):
      await bot.change_presence(status=discord.Status.online, activity=discord.Game('?help if you are lost '))
      print("Bot is running.")

    async def start(self):
      await super().start("token")


async def main():
    bot = Estelle()
    await bot.start()


asyncio.run(main()) 
``` this is the code on main.py btw
silk fulcrum
#

I made a mistake

slate swan
#

2?warn @slate swan and reason in here, it adds the warning to reports.json file and then warnings display the warnings but 2?unwarn should remove all warnings of the current user from reports.json

#

@silk fulcrum

cerulean shale
silk fulcrum
slate swan
slate swan
#

I said this like 3 times

silk fulcrum
slate swan
#

hopefully your friend is not someone with a "how to create a warn system in discord.py" tutorial guy

cerulean shale
#

problem solved-

slate swan
cerulean shale
slate swan
#

look I just need this code to remove users warnings from reports.json when you do 2?unwarn user

cerulean shale
#

just wait for him to come online bruh

slate swan
silk fulcrum
cerulean shale
silk fulcrum
#

or learn python

slate swan
silk fulcrum
#

how to read what the code does

slate swan
silk fulcrum
#

you should be able to read other code

cerulean shale
#

btw um how to fix this, what does this even mean, something with the last asyncio.run(main()) right

silk fulcrum
#

not only writing your own

slate swan
#

you can't do that bruh

#

you literally said you don't understand it either

cerulean shale
#

bruh whats the issue, tell again

silk fulcrum
cerulean shale
#

dont just shout on others cause they are also trying to help you UNDERSTAND not DOING YOUR WORK FOR YOU

slate swan
#

then how am I supposed to know bruh?

cerulean shale
slate swan
cerulean shale
#

why even make it if you dont know how?

silk fulcrum
slate swan
#

I'll rewrite ;/

silk fulcrum
cerulean shale
slate swan
silk fulcrum
silk fulcrum
#

@cerulean shale show the code that gives an error and the full traceback

#

that is probably the full traceback

#

but i dont see code

#

you may ask me why do I need the code again if you sent it like 5 mins ago

cerulean shale
#
import discord
import http
import aiohttp
from discord.utils import get
from discord.ext import commands
from aiohttp import ClientSession

from main import Estelle 

class Chatbot(commands.Cog):

  def __init__(self, bot):
    self.bot = bot

  @commands.Cog.listener()
  async def on_message(self, message):
    cmdChannel = self.bot.get_channel(1008668481484500992)
    inp = message.content
    
    if message.author == self.bot.user:
      return
    
    elif message.channel.id != cmdChannel.id:
      return
    
    else:
      await message.channel.typing()
      async with aiohttp.ClientSession() as cs:
        async with cs.get(f'https://api.popcat.xyz/chatbot?msg={inp}&owner=Ricky&botname=Estelle') as r:
          res = await r.json()
    
    await message.reply(f"{res['response']}")


async def setup(bot: Estelle):
  await bot.add_cog(Chatbot(bot))
``` this is the code in chatbot.py
silk fulcrum
#

because some smart people change something to some shit because "this gave an error and i tried like that"

cerulean shale
silk fulcrum
cerulean shale
glad cradle
#

lmao

cerulean shale
#

this is the complete error its giving

silk fulcrum
#

uhhh

#

im stupid

slate swan
#

just use bot.run()

silk fulcrum
#

you''d need to launch your bot in other file

glad cradle
#

when you're inside an async function you can't use asyncio.run(..) (this doesn't even make sense) just await your coroutine

silk fulcrum
#

otherwise it will launch itself again when you import it

#

there is not problem with starting via asyncio.run()

#

the problem is with typehinting

slate swan
#

typehinting has nothing to do with it :p

#

you can typehint a list as a discord.Client and the interpreter won't give a shit

silk fulcrum
#

he imports his bot instance from the bot file

#

and that runs the bot file again

#

so it tries to launch bot again

slate swan
#

why tho lmao

silk fulcrum
#

that could lead to repeating commands if that was bot.run

silk fulcrum
#

that's what I do there

#

import the instance to typehint

#

i should just remove that

#

I just use launch.py to launch the bot, that's why my habit with importing the bot got me

slate swan
#
import typing

if typing.TYPE_CHECKING:
   from main import YourClass

class YourCog(commands.Cog): ...

def setup(bot: "YourClass"):
    bot.add_cog(YourCog())
silk fulcrum
#

oh type_checking is actually usable here

slate swan
#

setup should be asynchronous i forgor

silk fulcrum
#

yeah

#

2.0

cerulean shale
#

;-;

silk fulcrum
#

gonna edit my example

limber bison
#

did i use self.msg in right way ?

#

in error hendling

silk fulcrum
limber bison
silk fulcrum
#

you do self.msg = msg

#

but what is msg there

limber bison
#

yha

#

its a msg boject

#

object

silk fulcrum
#

i dont see where is it defined

limber bison
#

last 8th line

#

@silk fulcrum

silk fulcrum
#

dont get ya

paper sluice
#

msg is not defined in that scope

limber bison
cerulean shale
#

@silk fulcrum ok so whats the issue again ๐Ÿฅฒ

limber bison
#

got point

#

let me fix it

slate swan
silk fulcrum
slate swan
#

I am outside rn

cerulean shale
#

ooooooh

slate swan
#

Oh ok

cerulean shale
silk fulcrum
#

actually no idea why

paper sluice
slate swan
#

does anyone have unwarn system?

paper sluice
#

TYPE_CHECKING is False so that condition will not be true

cerulean shale
cerulean shale
#

tried to yoink code from friend but since it aint working, asking others for their code?

#

trying making it on your own and ask for help if you get any errors

paper sluice
slate swan
#

and I'm asking for a code cuz there are lots of other errors for example on modmail that I have to fix so that didn't waste time

glad cradle
silk fulcrum
slate swan
#

modmail used to work but idk now

#

that's you

#

and this is me and I have no regrets

cerulean shale
#

ayo master it works now btw, should do few changes and i will be completely shifted to vsc

paper sluice
cerulean shale
paper sluice
#

TYPE_CHECKING is always False

cerulean shale
#

work*

slate swan
#

ik

glad cradle
# paper sluice TYPE_CHECKING is always False

the docs says

A special constant that is assumed to be True by 3rd party static type checkers. It is False at runtime.
if TYPE_CHECKING:
    ...

doesn't this mean if TYPE_CHECKING is True: import...? (I'm just trying to understand)

paper sluice
glad cradle
paper sluice
#

if you have a circular import then yes

swift pumice
#

hi guys

#
async def responsetime(ctx):
    variable_list = [
        '0000,4',
        '3',
        '0,1',
        '00000000000000000000000000000000000000000000000,1',
    ]

    embed = nextcord.Embed(
        colour=0xc81f9f,
        title="Rating",
        description=f"it took {random.choice(variable_list)} seconds to respond to you"
    )
    await ctx.send(embed=embed)``` how can i add a rarity for 0,1?
silk fulcrum
#

hi

#

wdym rarity?

#

a chance?

swift pumice
#

yes

silk fulcrum
#

!d random.choices

unkempt canyonBOT
#

random.choices(population, weights=None, *, cum_weights=None, k=1)```
Return a *k* sized list of elements chosen from the *population* with replacement. If the *population* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").

If a *weights* sequence is specified, selections are made according to the relative weights. Alternatively, if a *cum\_weights* sequence is given, the selections are made according to the cumulative weights (perhaps computed using [`itertools.accumulate()`](https://docs.python.org/3/library/itertools.html#itertools.accumulate "itertools.accumulate")). For example, the relative weights `[10, 5, 30, 5]` are equivalent to the cumulative weights `[10, 15, 45, 50]`. Internally, the relative weights are converted to cumulative weights before making selections, so supplying the cumulative weights saves work.
swift pumice
#

like that its more uncommon that 0,1 comes

shrewd apex
#

can the on_member_remove be used for bans and kicks or it's some other event?

silk fulcrum
#

has weights

swift pumice
shrewd apex
#

sounds good

silk fulcrum
shrewd apex
#

cumulative weights

swift pumice
#

ok

shrewd apex
#

like they add up to prev weights

swift pumice
#

thanks

cerulean shale
#

yo, pillow and pil are completely same or do they have any differences? ik that pillow is pil fork btw

slate swan
#

PIL is no longer maintained iirc

cerulean shale
#

well are they completely same? or are there any differences?

slate swan
maiden fable
fresh iron
#

why the bot's response for some commands is doubled

maiden fable
#

!pypi PIL

unkempt canyonBOT
fresh iron
#

repeated twice

maiden fable
#

Oh, nvm
I always get confused ffs

slate swan
#

Pil is such a hard library to install I stg

fresh iron
#

like this

cerulean shale
slate swan
slate swan
maiden fable
# slate swan tf

Do u not know? They have to compile it themselves to install it :DDD

slate swan
#

Ong

slate swan
slate swan
slate swan
#

Use HIM

#

easy_pil users: ๐Ÿ—ฟ

#

harvs imaging module troll_fresh_and_so_clean

maiden fable
maiden fable
unkempt canyonBOT
slate swan
#

i mean i won't be surprised

#

WHAT!!!

fresh iron
#

not sure how to fix that without deleting the event

slate swan
maiden fable
#

Change the decorator

slate swan
#

Or make it listen

maiden fable
#

From event to listen()

slate swan
#

how about check message_content intents

fresh iron
#

it's listen

slate swan
#

disnake does that iirc

slate swan
#

!d discord.ext.commands.when_mentioned

unkempt canyonBOT
#

discord.ext.commands.when_mentioned(bot, msg, /)```
A callable that implements a command prefix equivalent to being mentioned.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

>   Changed in version 2.0: `bot` and `msg` parameters are now positional-only.
> 
>
slate swan
#

Why would you throw a warning without a mention prefix

#

Why in python it try and except and not throw and catch

#

because whats the point of making commands that won't work ๐Ÿคก

cerulean shale
#

from PIL import Image, ImageFont, ImageDraw, ImageOps this won't work? ;-;

slate swan
cerulean shale
slate swan
slate swan
slate swan
cerulean shale
#

@slate swan i installed it

slate swan
#

uh is that an IDE or runtime warning?

#

if you're using VSCODE restart it

#

Use pycharm

cerulean shale
# cerulean shale

this is cmd, i used terminal to installed it and it did but it wasnt working so i used cmd too

slate swan
#

Venv ๐Ÿ˜

cerulean shale
# slate swan Use pycharm

i am literally shifting to vsc from replit, been working on that shi- for 2 days now and you want me to shift to pycharm? ๐Ÿคก

slate swan
cerulean shale
slate swan
#

Pycharm is so easy to learn

cerulean shale
slate swan
cerulean shale
#

not you

slate swan
cerulean shale
#

cause i used replit, i feel like a clown

slate swan
slate swan
#

My vscode doesnโ€™t work

cerulean shale
slate swan
#

It just asks me to install python

cerulean shale
#

then? ๐Ÿ˜ญ

slate swan
#

Idk

#

Pillow just chill like that

#

Iโ€™m outside

#

Talking in the python discord

cerulean shale
#

f

slate swan
#

Tf??? Grass???? Python developer??? With grass???? Omg???? This crazy????

#

@frank lake

frank lake
#

@slate swan ?

slate swan
#

Bro where tf u at Iโ€™ve been sat here for an hour

frank lake
#

What are u tralking about ?

slate swan
#

Bruh we were supposed to meet up dawg

#

Why tf you ditching

#

For the Fortnite cosplay

cerulean shale
#

you will probably get banned if you this kinda convo in here ๐Ÿคทโ€โ™‚๏ธ

slate swan
#

Iโ€™ve been banned 2 times

#

Iโ€™m not scared to be banned again

frank lake
#

I don't know him

slate swan
#

I donโ€™t like your stranger kink

frank lake
#

weird ppl got blocked