#discord-bots

1 messages · Page 65 of 1

shrewd apex
#

(self, interaction, button)

slate swan
#

I just have this error

    extensions = bot.cfg.get('core.InitialExtensions')
    for extension in extensions:
        bot.load_extension(f'cogs.{extension}')
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension(f'cogs.{extension}')
#

how can i fix it?

shrewd apex
#

await it

#

also u can await only in an async function

#

ie u can await that only in async def

slate swan
#

@shrewd apex how can I make it so that when the button is clicked , information is written when the user has registered and when he has logged on to the server ??

shrewd apex
#

wdym log in to a server

#

and register what

slate swan
cerulean shale
maiden fable
#

Kota Factory ft. Sarthak

slate swan
cerulean shale
#

With buttons

shrewd apex
#

so u want when a user clicks a button it send an embed? with user info?

#

just use the interaction.user object

slate swan
shrewd apex
#

!d discord.Interaction.user

unkempt canyonBOT
shrewd apex
shrewd apex
cerulean shale
#

@shrewd apex what's the difference between user and memeber btw?

shrewd apex
cerulean shale
#

Oh-

#

Cool

shrewd apex
#

skadoosh~

cerulean shale
#

🤯

cerulean shale
#

Kung fu panda 4

shrewd apex
#

nice

#

3rd was op

slate swan
#

@shrewd apex I've already used it and then I didn't succeed, now everything works...

cerulean shale
shrewd apex
#

mhm

cerulean shale
#

imagine talking about movies in a python related channel

shrewd apex
#

it's discord bot channel so it's fine

cerulean shale
#

Every part has its own epic scenes tho

shrewd apex
#

🏃 before mods arrive

vale wing
#

In this channel we often talk about meaning of life, creation of the universe and the eternal fight between good and evil

cerulean shale
#

In part 2, him reflecting the explosives 💀

vale wing
#

Also I 🤓

slate swan
#

@shrewd apex And is it possible to make it so that everything is written in numbers, that is, 2.11.2012 ?

shrewd apex
#

1st one was just him literally throwing his weight around

cerulean shale
vale wing
#

Double datetime

shrewd apex
#

!d datetime.datetime.strftime

unkempt canyonBOT
#

datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
cerulean shale
shrewd apex
#

👌

vale wing
#

Am I op

#

Silence means agreement

#

🙏

shrewd apex
#

... sure

shrewd apex
cerulean shale
slate swan
#

@shrewd apex ERROR

Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 59, in voicetime
    created_at = interaction.user.created_at.datetime.datetime.strftime("%a %b \n %B %Y")
AttributeError: 'datetime.datetime' object has no attribute 'datetime'```
shrewd apex
#

💀

cerulean shale
#

intense music starts playing in the background

radiant parrot
#

How would I make it so when a user sends a message in a certain channel, the bot fowards that message to another channel and deletes the message the user sent from the first channel>

slate swan
#

@shrewd apexthank you of course for your help. But my God, who writes documentation for python, which individual is brainless, describes everything so terribly

cerulean shale
shrewd apex
#

sorry for not responding but busy

#

not at home so

slate swan
cerulean shale
#

People can have different opinions

slate swan
#

@cerulean shale it just seems to me that in order to understand this documentation, you need to learn not python, but the Orc language.

cerulean shale
cerulean shale
slate swan
#

did guild.create_webhook get removed

shrewd apex
#

check the docs

#

it should be there tho i remeber making an event for it in my logger yesterday

pliant gulch
slate swan
#

it was

pliant gulch
#

You can only create a webhook from a channel

#

It's impossible to do Guild.create_webhook

#

And if you don't believe me you can check the official API as well as all versions of discord.py documentation

#

It doesn't exist, and never has

slate swan
#

mb guild.channel.create_webhook

#

that existed

pliant gulch
#

Guild.channel does not exist

shrewd apex
#

!d discord.TextChannel.create_webhook

unkempt canyonBOT
#

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

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
shrewd apex
#

no guild.create_webhook

maiden fable
#

webhooks are associated with channels, not guilds

slate swan
#

alr mb

#

How to make user information written in the format 02.11.2016 ?

#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
slate swan
#

and it will give you when they joined in that format

#

😝

slate swan
#

huh

slate swan
# slate swan huh
    @discord.ui.button(style= discord.ButtonStyle.grey, emoji = '2️⃣')
    async def lvl(self, button, interaction):
        joined_at = interaction.user.utils.format_dt(interaction.user.joined_at, style="d")
        await interaction.response.send_message(
                embed = discord.Embed(description= f'Присоединился: {joined_at}', colour=0xF1C40F),
                delete_after=60
            )```
#

ur trying to get the date the interaction joined lmao

#

which wont work

#

user: discord.Member=None

#

if u want the user put this in ur args^

#

and ur defining joined at

#

u dont need to do that

slate swan
# slate swan ur trying to get the date the interaction joined lmao
Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 67, in lvl
    joined_at = interaction.user.utils.format_dt(user.joined_at, style="d")
AttributeError: 'Member' object has no attribute 'utils'```
ERROR
#

ye because ur doing user.utils

#
@discord.ui.button(style= discord.ButtonStyle.grey, emoji = '2️⃣')
    async def lvl(self, button, interaction, user: discord.Member=None):
        await interaction.response.send_message(
                embed = discord.Embed(description= f'Присоединился: {utils.format_dt(user.joined_at, style="D")}', colour=0xF1C40F),
                delete_after=60
            )```
#

try this

slate swan
# slate swan ```py @discord.ui.button(style= discord.ButtonStyle.grey, emoji = '2️⃣') asy...
Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 68, in lvl
    embed = discord.Embed(description= f'Присоединился: {utils.format_dt(user.joined_at, style="D")}', colour=0xF1C40F),
NameError: name 'utils' is not defined```
#

import utils ffs

shrewd apex
#

discord.utils

slate swan
#

from discord import utils prayge

slate swan
shrewd apex
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
slate swan
shrewd apex
#

🙏

slate swan
# slate swan ```py @discord.ui.button(style= discord.ButtonStyle.grey, emoji = '2️⃣') asy...
Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 65, in lvl
    embed = discord.Embed(description= f'Присоединился: {utils.format_dt(user.joined_at, style="D")}', colour=0xF1C40F),
AttributeError: 'NoneType' object has no attribute 'joined_at'```
#

get rid of the =None

#

id=None> row=None> -
I don't even have this in my code.

torn spear
#

How to use pagination with buttons for a help command?

slate swan
#

@slate swan@shrewd apex@slate swan Thanks for the help

#

what did I do

#

np

#

oh I thought that was sarcastic lmao

#

he mightve meant asher

#

indeed prayge

slate swan
#

lmao

cerulean shale
slate swan
#

ew

shrewd apex
torn spear
#

Okay thanks

shrewd apex
#

!pypi reactionmenu if u just want a readymade paginator

unkempt canyonBOT
#

A library to create a discord.py 2.0+ paginator. Supports pagination with buttons, reactions, and category selection using selects.

slate swan
#

@slate swan I had a lead of both

cerulean shale
slate swan
#

??

cerulean shale
#

Nvm ig

cerulean shale
#

🥲

slate swan
cerulean shale
#

@slate swan what do you plan on nuking 💀

slate swan
#

SH

#

???

cerulean shale
slate swan
#

NOTHING

cerulean shale
#

caught in 4k?

slate swan
#

5k

primal token
cerulean shale
#

calling 911

slate swan
#

no please!

cerulean shale
#

gonna get paid

#

@slate swan i am the one who's smug rn 😏

slate swan
#

meh

primal token
#

!ot

unkempt canyonBOT
cerulean shale
#

🚪 🏃

slate swan
#

okimii

cerulean shale
#

You yoinked that code?

#

Well your arg is number but you are using msg, and since msg ain't defined, it won't work

#

Copied the code?

primal token
#

you ment interaction.user.id?

cerulean shale
#

I am asking YOU dude anyways

primal token
#

yes?

slate swan
cerulean shale
#

😔

primal token
slate swan
#

Yeah sure

primal token
#

was that supposed to be sarcastic?

slate swan
#

Yes

primal token
#

i figured

slate swan
#

How do you print hello world with base64 @primal token

cerulean shale
#

🎉

primal token
slate swan
#

Code

#

It

#

I need to see how you’d do it

primal token
#

you want do what? compare codebases or sm

slate swan
#

No

#

Compare wit Okimii code

primal token
#

mines probably better kek

shrewd apex
#

🔥

meager chasm
#

hi can someone help me test something? i think its a bug with the python bot

#

if you do !user_info it gives you wrong info

meager chasm
meager chasm
shrewd apex
#

sure

sick birch
unkempt canyonBOT
#
Robin (Robin J#2415)

hypesquad_brilliance

User information

Created: <t:1523220614:R>
Profile: @sick birch
ID: 432643355634171905

Member information

Joined: <t:1624113052:R>
Roles: <@&815701647526330398>, <@&787816728474288181>, <@&267630620367257601>, <@&764802720779337729>, <@&463658397560995840>, <@&897568414044938310>, <@&988801794668908655>

Activity

Messages: 31,254
Activity blocks: 5,131

Infractions

Total: 0
Active: 0

sick birch
#

Looks right

meager chasm
#

hmm but it is not showing correct info for noid : |

primal token
#

the hell are you trying to do with my info?

shrewd apex
shrewd apex
primal token
#

kek

shrewd apex
sick birch
#

!user_info @primal token

unkempt canyonBOT
#

You may not use this command on users other than yourself.

sick birch
#

bruh

primal token
#

kek

shrewd apex
#

Robin flex perms failed

#

or maybe it's just the command i think

meager chasm
#

yes comand is broaken

maiden fable
#

Lmao

meager chasm
sick birch
#

Oh

#

That’s intentional

shrewd apex
#

ic privacy 🙏

primal token
#

Paranoid🙈

shrewd apex
cerulean shale
#

fck u
-Endysis

glad cradle
meager chasm
cerulean shale
#

💀

primal token
shrewd apex
#

by fooling them onto ur bed pBlush

cerulean shale
#

📸

pliant gulch
#

Kind of gets rid of the need for that argument at all unless your a moderator

shrewd apex
#

hmm

dreamy walrus
#

Hi there so I am trying to do button and this keeps happening
cannot import name 'Locale' from 'discord.enums'

Could someone help please I am trying to put a button on a message then if someone clicks it (no limit on how long after the button was created) it will respond

shrewd apex
#

wdym trying to do button💀

#

u mean a persistent view?

dreamy walrus
meager chasm
dreamy walrus
#

And when I click it

pliant gulch
meager chasm
#

ohh do the modrator take bribe

dreamy walrus
meager chasm
#

why i cannot reaction here

sick birch
meager chasm
#

o no D:

#

why like that

#

can i pay fr reaction

sick birch
sick birch
meager chasm
#

: (

sick birch
#

Why? It’s not like reactions enhances your experience in any meaningful way

dreamy walrus
#

Hi there I keep getting this error
ImportError: cannot import name 'Locale' from 'discord.enums'

When I go to import

from discord.ui import  View, Button
shrewd apex
#

u only cherish stuff once it's lost 😔

sick birch
primal token
# slate swan Compare wit Okimii code

!e

eval.__call__("".join.__call__(chr.__call__(int.__call__(a, base=2)) for a in "01110000 01110010 01101001 01101110 01110100 00101000 01011111 01011111 01101001 01101101 01110000 01101111 01110010 01110100 01011111 01011111 00101000 00100111 01100010 01100001 01110011 01100101 00110110 00110100 00100111 00101001 00101110 01100010 00110110 00110100 01100100 01100101 01100011 01101111 01100100 01100101 00101000 00100111 01010011 01000111 01010110 01110011 01100010 01000111 00111000 01100111 01010110 00110010 00111001 01111001 01100010 01000111 01010001 00111101 00100111 00101110 01100101 01101110 01100011 01101111 01100100 01100101 00101000 00100111 01100001 01110011 01100011 01101001 01101001 00100111 00101001 00101001 00101110 01100100 01100101 01100011 01101111 01100100 01100101 00101000 00100111 01100001 01110011 01100011 01101001 01101001 00100111 00101001 00101001".split.__call__()))
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello World
primal token
#

good luck reading it

shrewd apex
#

kek i think PPL want it precisely coz it's rare in this channel flex and all ig i do too ngl

shrewd apex
primal token
#

and yeah it gets encoded in base64 its just everything is in base 2

#

i am one with the computer

dreamy walrus
shrewd apex
#

there is no on_button and all now

shrewd apex
#

prolly some fork u used

dreamy walrus
#

All I am doing is from discord.ui import View, Button and it comes up with an error

shrewd apex
#

do u have 2.0 installed

dreamy walrus
#

Ummm

#

How do you install 2.0?

#

All I did was update it

#

pip install git+https://github.com/Rapptz/discord.py is this it

wicked atlas
#

2.0 has been released, so you can do it from pypi

shrewd apex
wicked atlas
#

Right?

dreamy walrus
#
pip3 install --upgrade discord
Requirement already satisfied: discord.py>=2.0.0 in c:\users\orang\appdata\local\programs\python\python39\lib\site-packages (from discord) (2.0.1)
wicked atlas
#

Do you have another library that uses the package name discord installed, like pycord or disnake?

dreamy walrus
pliant gulch
#

You definitely have some third party library clashing with the main one

#

This is what happens when you upload a package that monkey patches another

primal token
wicked atlas
#

This is also why venvs are useful

slate swan
#

🥺🥺

primal token
#

because im the same skill level which i doubt as okimii it doesnt mean im him lmao

slate swan
#

Idk bro everyone thinks your Okimii

cold sonnet
#

okimii had chinese fairytale guy pfp too

slate swan
dreamy walrus
# dreamy walrus

Ok so I deleted all the discord but the error is comming from the discord folder
As shown in the picture

slate swan
#

They are Japanese

primal token
slate swan
primal token
#

who said i dont?ducky_party

slate swan
#

Idk

#

No one

#

I’m jus sayin

primal token
#

ok

wicked atlas
dreamy walrus
wicked atlas
#

👍

winged dock
#
while True:
                if num=='2':
                  letters=3
                  user = "http://tiktok.com/@" + ('').join(random.choices(string.ascii_letters + string.digits,k=letters))
                  f = open('names.txt', "a+")
                  f.write(f'{user}\n')
                  f.close()
                  #start of 3l and 3c part
                  if num=="2":
                    f = open('names.txt', "a+")
                    f.write(f'{user}\n')
                    f.close()
                    time.sleep(0.2)
                    print(Red+bold+f'[Taken!] {Red+bold+user}/')
                    if random.randint(0,10000) < 36:
                      print(Green+Green+bold+f'[Available] {Green+bold+user}/')
#

code doesnt even run sadly

#

Idk why

#

Impossible from what i know.

sick birch
#

Plugins already exist for it

primal token
sick birch
#

Or if you want to do it yourself you can make a minecraft plugin using JDA or similar

#

Oh then it's going to be difficult

#

Sure but you might want to up the interval

#

At least a few minutes

#

there are apis

#

A google search for "minecraft server status API" will turn up many results

#

So you don't flood the server with requests

maiden fable
#

In short, so that you don't sorta DDOS it

sick birch
#

You're basically carrying out a DoS attack

maiden fable
#

That is why ratelimits are in place

primal token
maiden fable
#

Mb

#

5 sec should be fine imho

primal token
#

if youre spamming a host with requests thats basically is a DOS attack depending on the motive

sick birch
#

I'd do a minute just to be safe

primal token
maiden fable
#

Ngl, since its only 1 request per 5 sec, he should probably be fine
But I remember seeing a module somewhere which has some events regarding people joining, leaving and so on, tho i don't remember where

sick birch
#

It has detailed documentation

#

What does the documentation say?

#

Well that's the first thing you should do

maiden fable
#

Nice!

winged dock
primal token
winged dock
#

Yes

maiden fable
#

bot.pool is None

primal token
sick birch
#

You know what I'm gonna say... what does the documentation say?

#

I doubt that, let me take a look

#

Ah, see?

#

Documentation is the first place you should go to

#

... the documentation has an example for you

maiden fable
#

I wish every module and API had docs this great

sick birch
#

it's not the greatest but it'll do

swift pumice
#

how can i do something like this in nextcord? i mean that there are fields requiered

maiden fable
#

Better than those API's where u gotta try and test the different results

sick birch
#

The one underneath that

#

Gives you a comprehensive example response payload

#

By using the players key

#

Everything you need is inside the documentation

slate swan
#

MyBot doesn’t have that attr

paper sluice
#

you did

print(type(bot.pool))
bot.pool = pool

what do you expect?

slate swan
#

Hey ryuga mind checking dms rlq?

paper sluice
#

sure

#

you are trying to use bot.pool before assigning it.

slate swan
#

Why not try it?

#

Line 105-111 don’t need to be f strings btw

pliant gulch
#

bot.pool is wrong it should be self.pool in order to bind the pool to the instance

#

Also you shouldn't be constructing pools inside of on_ready

#

That sort of thing should only be done once during life-time

#

You are misunderstanding how classes work

#

Later once you have an INSTANCE of MyBot set as bot, then bot.pool will work yes

#

But since you are in a method of MyBot you have to access the instance VIA self

#

So inside of the class, change it to self.pool and outside of the class it'll work fine using bot.pool if bot is MyBot()

primal moth
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 98, in on_message
    await client.process_commands(message)
AttributeError: 'Bot' object has no attribute 'process_commands'

Getting this error using the pycord dictionary

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

client = discord.Bot(intents=intents)
#

Intents are enabled on the bot

swift pumice
#

which ide is that

primal moth
#

looks like the same file editor thats on my friends vps panel

pliant gulch
#

You need to change it there yes, but also inside of on_ready

#

Again it's inside of a method...

#

What do you think?

primal moth
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 98, in on_message
    await client.process_commands(message)
AttributeError: 'Bot' object has no attribute 'process_commands'```
 
Getting this error using the pycord dictionary
```py
intents = discord.Intents.default()
intents.members = True

client = discord.Bot(intents=intents)

Intents are enabled on the bot

pliant gulch
#

Then change it, why ask me? I've already told you to change it inside of on_ready

#

👏

devout iris
#

hia

devout iris
pliant gulch
#

Yes... I mean it looks like it is working does it not?

devout iris
#

what should i import for slash command?

pliant gulch
#

Other than the AttributeError but that's due to the fact your running acquire before the loop is even defined, E.g running acquire before READY is dispatched

#

So the error did not dissapear lol

pliant gulch
# pliant gulch fyi

Again refer to my message above as to why it errored... And refer to this one to fix it

#

If you don't do it inside of on_ready it won't require the bot to be fully ready before the pool can be acquired

#

E.g set it inside of setup_hook etc

#

And I cba to give anymore help rn cause I'm busy so I'll let you figure that out

slate swan
#

how to make a click handler in select menu ? Does it look like a click handler in just buttons or not ?

dreamy walrus
#

Hi there so I have created a button but I want to have an event for when it is clicked. As right now if the bot restarts the button will not work

slate swan
dreamy walrus
#

I think so

#

basically I want an event when you click it and if has a certain event_id then it responds

devout iris
#

I made a slash commands bot, should i get invite url as bot or application.commands ??

#

Which one ?

devout iris
#

Alrighty, tysm

slate swan
#

how to make a click handler in select menu ?

wispy spade
devout iris
#
import discord
import discord.commands


class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents= discord.Intents.default())
        self.synced = False
    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync(guild = discord.Object(id = 693190295520673924, guilds = [773260643872145428])
            self.synced = True
        print(f"{self.user} olarak giriş yapıldı!")


client = aclient()
tree = commands.CommandTree(client)


@tree.command(name = "test", description = "deniyoruz işte karşim", guild = discord.Object(id = 693190295520673924))
async def self(interaction: discord.Interaction, name : str):
    await interaction.response.send_message(f"Merhaba {name}, bu slash komutlarının ilk komutu ve test mesajıdır")

#
PS C:\Users\Administrator\Desktop\fly-bot-slash> & C:/Users/Administrator/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Administrator/Desktop/fly-bot-slash/main.py
  File "c:\Users\Administrator\Desktop\fly-bot-slash\main.py", line 13
    self.synced = True
    ^
SyntaxError: invalid syntax
PS C:\Users\Administrator\Desktop\fly-bot-slash>
slate swan
#
    await bot.change_presence(activity=discord.ActivityType.competing(name=f"{prefix}help"))
TypeError: '_EnumValue_ActivityType' object is not callable```

what is the competing status for this?
#

nevermind, i got it!

meager cape
#

anyone know how i can recreate this with my bot?

#

this was my attempt

rapid shadow
sick birch
rapid shadow
meager cape
#

i got this do you guys how i can make the 0 go next to the words

e.g: completed: 0

tidal hawk
#

You can't

meager cape
tidal hawk
#

with fields, no

meager cape
#

what do i need to make to it

tidal hawk
#

use embed description

meager cape
meager cape
tidal hawk
#

member/user.mention

#

and set_thumbnail(user avatar)

#

check doc

meager cape
#

how do i make a line break between each description

#

lemme send a ss should make more sense

#

i have it like this which is good but how do i keep adding descriptions now

tidal hawk
#

Just add content to the same description with \n as linebreak

slate swan
#

Hello, I'm looking for creators of pokemon bots so that if they could help me with a pokemon bot with their codes or helping please

meager cape
tidal hawk
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
tidal hawk
#

from that object u can access these infos

meager cape
tidal hawk
#

xd

#

y can do it

meager cape
#

yeah sorry im new to python and everything lol

tidal hawk
#

clue, ctrl +f " Member"

meager cape
#

still learning i do appreaciate ur help tho

slate swan
slate swan
#

to get information and stuff

tidal hawk
#

discord.Member

#

and look up what things you can use from other User

meager cape
#

@tidal hawk this?

tidal hawk
#

correct place

meager cape
#

👍

tidal hawk
#

and what kinds of things are you looking for? You want to have users profilepicture and mention him?

meager cape
#

when they use the command it want to appear like this

tidal hawk
#

well now look at that section

primal token
meager cape
#

i got the descirption done i just need the name and picture now

primal token
#

why?

slate swan
#

also, is there a way to set an arg to automatically .lower()? @primal token

#

I can't think rn but it's prolly really easy

primal token
#

well you can just convert it uppon getting it

slate swan
#

I mean like when you define the arg

primal token
#

how would you access the argument uppon defining it?

slate swan
#

nevermind

slate swan
#
async def sasdasd(ctx, something) -> None:

make something automatically .lower()

primal token
slate swan
#

ioh

primal token
#

since strings are immutable you would need to overwrite the variable with the result given with str.lower

slate swan
#

that's how I'm doing it rn

#

I thought there was some otherway

primal token
#

afaik nope

tawdry tendon
#

Just a weird question, if you have a tuple, then you delete it would it still print out the tuple

slate swan
#

How can I put custom emojis on the bot, that is, leave a text from that bot

primal token
tawdry tendon
#

Like

primal token
#

just know that mutable pointers come in play

tawdry tendon
#

I make a tuple, print it out, delete the tuple, and run it again

primal token
tawdry tendon
#

Ah ok, thanks

primal token
#

do remember that python uses a GC which if the object has no references the data gets freed making the object not accessible avoiding segfaults

tawdry tendon
#

Ok thanks for the info

primal token
tawdry tendon
#

I really do not understand lambdas and filters

#

And for lambdas can’t you just use definition instead

#

Like def

pliant gulch
#

No because a lambda is an expression, and a statement def is a statement

torn sail
pliant gulch
#

You can't use def everywhere

primal token
#

no but sometimes its better to have an anonymous function over declaring one

pliant gulch
#

Hence lambdas

primal token
#

its better having an expression than having context managed keywords

tawdry tendon
#

I can’t understand lambdas and filters

pliant gulch
#

lambda = expression & function with no name

#

func def = statement & named function

tawdry tendon
#

Ok

#

Don’t know how to use it too

torn sail
pliant gulch
#
foo(def bar(foo: str))
``` vs ```py
foo(lambda foo: ...)
``` see the diff
pliant gulch
#

One errors and the other doesn't

#

Expression vs statement here

tawdry tendon
#

Ye the first one gets an error obviously because that isn’t the correct syntax

#

Actually it is

#

I think

#

I’m kinda an idiot so ye

primal token
#

you cant declare a function inside of a function call

#

since def is a soft keyword

tawdry tendon
#

What’s a soft keyword…

primal token
#

andy ment its different passing a function and a lambda object

#

since one is a statement while the other is an expression

pliant gulch
#

def is not a soft keyword

#

def is just a keyword

tawdry tendon
#

Can you show me an example of a lambda and a def that would output the same thing

pliant gulch
#

A soft keyword for an example would be match

slate swan
#

How can I put custom emojis on the bot, that is, leave a text from that bot

primal token
pliant gulch
primal token
torn sail
unkempt canyonBOT
#

@torn sail :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 4
002 | 4
tawdry tendon
#

So lambda is like def func

#

And then x is the content inside the ()

primal token
#

lambdas are always helpful for one liners and stuff like map that take a callable as onenof their arguments

tawdry tendon
#

And you don’t type return in lambdas?

torn sail
tawdry tendon
primal token
#

lambdas always return the given expression

tawdry tendon
#

That’s for helping me understand

tawdry tendon
unkempt canyonBOT
#

Lib/keyword.py line 30

'def',```
primal token
#

i want to learn C to understand CPython more do you guys think its worth it?

tawdry tendon
#

What would this output

pliant gulch
#

It isn't really difficult but I would suggest knowing how to read the function first of all, and knowing some bytes & pointer stuff

#

E.g id(object) + int.basicsize

pliant gulch
#

Modulo operator checks for remainders

#

If the return is divided by two and has zero remainders it is even

tawdry tendon
#

Ahh

primal token
tawdry tendon
#

I see

pliant gulch
#

Cough vagrant cough

#

Or GDB

primal token
#

ive seen some books but theyre dummy thick with 700 pages easily

primal token
pliant gulch
#

And rust has it's whole own thing with memory management

#

Sure pointers exist but they use borrow checking mostly

#

But using pointers & ref in rust, some people would say it defeats the purpose of rust but

primal token
#

i just know the general knowledge of pointers, stack, the heap and i also do know about pythons memory management but i have 0 knowledge about C's

pliant gulch
#

Well that's the fun part

primal token
#

iirc C doesnt use OOP only cpp and C object oriented or something like that

pliant gulch
#

C is not really OOP based

primal token
#

im not very knowledgeable on a language like C😅

primal token
#

or is it like a mix?

pliant gulch
#

It can be functional

#

But C is official a procedural language

primal token
#

mhm thats quite interesting

pliant gulch
tawdry tendon
#

What does yield do

pliant gulch
#

But that is not really an excuse to use heap memory without freeing

slate swan
#

How can I put custom emojis on the bot, that is, leave a text from that bot

pliant gulch
tawdry tendon
#

Oh ok

#

Thanks

primal token
#

kinda have hit a learning block and i want to step up my skills by learn a low level programming language like C, i was trying rust but im not really sure about it

pliant gulch
#

I do know that CPP has it much easier when it comes to creating pointers

#

malloc calloc vs new, etc

primal token
#

mhm ic, its easier to make pointers with the use of abstractions or just how the language handles them?

#

sorry if i worded it a bit weirdly i cant really describe what i ment

pliant gulch
slate swan
#
Traceback (most recent call last):
  File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\tjdom\Dropbox\PC\Desktop\test\test.py", line 45, in on_ready
    link = await channel.create_invite(max_age=300, max_uses=1)
  File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\abc.py", line 881, in create_invite
    return Invite.from_incomplete(data=data, state=self._state)
  File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\invite.py", line 316, in from_incomplete
    guild_id = int(data['guild']['id'])
TypeError: string indices must be integers``` help
primal token
pliant gulch
#

CPP is just C with classes

#

that is all

pliant gulch
#

Python OOP?

#

OOP is a paradigm it isn't strict to one language

primal token
glad cradle
slate swan
glad cradle
#

don't make Api calls in on_ready event

pliant gulch
#

You have methods, these methods are bound to the class, etc

#

You don't get self through params rather you get it from this

#

E.g inside a method you'd use this->attribute

slate swan
#

@primal token I can't remember how to get author url 😭

primal token
pliant gulch
#

And if it's a pointer you would use pointer->attribute and if it wasn't a pointer you'd use variable.attribute

primal token
#

either way, thank you for your time, im going to learn cpp now!

primal token
pliant gulch
#

Not a pointer, hence using regular dotnotation

primal token
#

mhm ic

#

thanks

pliant gulch
#
std::string variable("something");
// verus
std::string *variable = new std::string("something");
primal token
slate swan
#

What's the field at the top left of an embed? the little circle you can add

primal token
unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

I think

slate swan
#

ok yeah

slate swan
primal token
slate swan
primal token
slate swan
#

how do i call this without a event

pliant gulch
#

name="** **"

primal token
#

bro chill

slate swan
pliant gulch
#

But logically speaking, if you think about it. It would kind of be weird to have an author with no name right?

slate swan
#

bro

#

how call no event

#

h c n e

slate swan
#

are you gonna spam make invite links or something?

#

how to make spacing inbetween fields

slate swan
desert badger
#
    guild = client.get_guild(785250885391220776)
    tenshi_role = guild.get_role(855870040129798164)
    komet_role = guild.get_role(855869125485264926)

AttributeError: 'NoneType' object has no attribute 'get_role'

slate swan
slate swan
slate swan
wicked atlas
#

Then you could get codeblocks and markdown formatting

slate swan
#

ok

#

😐

#

why so confuse

desert badger
#

the loop that included that function started before the bot was logged in lol

slate swan
#

im just tryna run it without a event 😐

#

lol

#

does test() not work

#

because theres no other event I KNOW OF that i could run it on without something except on ready

tawdry tendon
slate swan
#

of course

winged coral
#

The await syntax is only applicable inside running async functions

slate swan
#

^

#

other code

winged coral
#

Yeah so you can’t await it unless you’re in another function

slate swan
#

wait i think im stupid

tawdry tendon
#

Where the error is

winged coral
#

You can call it from the bot loop directly since it’s exposed

#

But I can’t see a use case for this that isn’t against standards

pliant gulch
#

Had whole bunch of discussion in this channel long ago about creating invites without permissions

#

We seemed to come to the consensus that it is against ToS

slate swan
winged coral
#

So show us your code where you did that

slate swan
#

i tried before

slate swan
#

?

wicked atlas
#

ah yes, old syntax

winged coral
#

So you’re literally not doing what I told you to do

pliant gulch
winged coral
#

You don’t necessarily always need the context manager

slate swan
wicked atlas
slate swan
#

i have literally no clue about discord.py ik only a little stuff from discord, youtube

winged coral
#

That they did. It should be ignored internally anyway but ig it’s indicative

slate swan
#

discord py is easiest module on py imo

winged coral
#

D.py relies heavily on both

pliant gulch
#

And even if you were able to await the function correctly you'd most likely get a NoneType AttributeError

#

Your relying on the cache so

heady citrus
#

how would i define role in a on_member_ban listener?

pliant gulch
#

You must make sure READY is dispatched before you call

winged coral
slate swan
#

i just wanna run its without a event 😭

slate swan
wicked atlas
pliant gulch
#

That's why on_ready is so appetising but it's also not ideal. The best bet would just be a command

pliant gulch
winged coral
pliant gulch
#

instance.attribute is apart of OOP

heady citrus
#
    @commands.Cog.listener("on_member_ban")
    async def anti_ban(self, guild, user):
        reason = "Anti-Nuke System | Banning Members"
        whitelisted = db.find_one({ "guild_id": guild.id })['whitelisted-users']
        antinuke = db.find_one({ "guild_id": guild.id })['anti-nuke']

        if antinuke == 'off':
          return

        banned_users = []
        async for i in guild.audit_logs(limit=1, after=datetime.now() - timedelta(seconds=5), action=discord.AuditLogAction.ban):
            banned_users.append(i.target)
   
            if self.bot.user.id == i.user.id:
                return

            if i.user.id not in whitelisted:
                await guild.edit(i.user, roles=[])
                await guild.ban(i.user, reason=f'{reason}')
                for target in banned_users:
                    try:
                        await guild.unban(target if target != i.user else target, reason='Anti-Nuke System | Unbanning User-Banned Users')
                    except:
                        pass

@wicked atlas @winged coral

primal token
#

python and the whole dpy framework is based on OOPducky_party

winged coral
heady citrus
#

await guild.edit(i.user, roles=[])

slate swan
#

i have tried on_ready, running it separatly both do not work 😐

winged coral
#

Right, so what do you want roles to be?

heady citrus
# winged coral Please explain what your initial question is alluding to

my error is

2022-08-28T23:04:37.551170+00:00 app[worker.1]: await coro(*args, **kwargs)
2022-08-28T23:04:37.551171+00:00 app[worker.1]: File "/app/cogs/antievents.py", line 37, in anti_ban
2022-08-28T23:04:37.551171+00:00 app[worker.1]: await guild.edit(i.user, roles=[])
2022-08-28T23:04:37.551172+00:00 app[worker.1]: TypeError: Guild.edit() got an unexpected keyword argument 'roles'

winged coral
#

Yeah because you’re editing the guild

heady citrus
winged coral
#

You want member.edit

sturdy willow
#

hi, i'm new to python and was interested in making discord bots but i can't seem to fix this problem, can someone help me?

winged coral
#

Intents is a required kwarg

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.

heady citrus
#

Im trying to get the bot to remove every role the member has

winged coral
#

Users don’t have roles

winged coral
#

Since this event is a ban event you don’t have a member

heady citrus
#

members

winged coral
#

You have a user who isn’t in the guild

wicked atlas
#

Don't roles get removed when a user gets banned anyway?

heady citrus
winged coral
#

The member doesn’t actually exist anymore but it might be in the cache. You can’t do anything to them though because they’ve been banned

#

I think you’re misunderstanding when this event fires

heady citrus
#

stripping every role the member has then banning = less members banned

winged coral
#

This event fires AFTER the ban

#

It doesn’t fire just before it

slate swan
#

@wicked atlas not really py related but you should use .hover on github logo and yt it looks better imo

heady citrus
#

dude what

pliant gulch
heady citrus
#

re read my code

winged coral
#

It’s a on_member_ban listener

wicked atlas
heady citrus
#

💀 i want it to strip every role the member who banned the other members before the bot bans

heady citrus
winged coral
#

🤦‍♂️ okay

#

!d discord.Member.roles

unkempt canyonBOT
#

property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
slate swan
heady citrus
#

it isnt pointless

winged coral
slate swan
winged coral
#

Some sort of nuke prevention

#

You’re basically using the wrong function

#

Guild.edit edits the guild not the user

slate swan
#

if u dont trust user dont give them ban perms, ez

winged coral
#

!d discord.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
winged coral
#

You want the above function

heady citrus
heady citrus
winged coral
#

Guild.edit edits the guild

#

E.g. changing the guild name

#

Member.edit edits the member

#

@heady citrus You can ask here instead of DMing, i’ve gtg now anyway, someone else could reply

#

But no, you don’t change the parameters

#

You change the function call where you edit

slate swan
primal token
winged coral
#

^ All of the above

#

Plus 4. This is not even slightly what OP asked for

primal token
#

just read the top reply KEK

#

missed his whole question by a long run😭

winged coral
#

😭

pliant gulch
#

await Member.edit(roles=[])

slate swan
#

no matter what i do i get this error ```Traceback (most recent call last):
File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\tjdom\Dropbox\PC\Desktop\test\test.py", line 59, in on_ready
print(await channel.create_invite())
File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\abc.py", line 880, in create_invite
return Invite.from_incomplete(data=data, state=self._state)
File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\invite.py", line 316, in from_incomplete
guild_id = int(data['guild']['id'])
TypeError: string indices must be integers

#

all i did this time is

deep mirage
#

on_ready gets called before the bot is actually ready, try this in setup_hook

#

actually try not to do anything in on_ready since that sometimes gets randomly called

pliant gulch
#

You said the opposite

#

on_ready is dispatched when, 1) Gateway sends READY dispatch 2) All guilds are chunked and accounted for

#

on_ready is when the bot is fully cached and ready

#

setup_hook get's called before the bot even connects to the gateway iirc

deep mirage
#

you got it mixed up, you could ask in the dpy server, and they will ensure you to not do anything in on_ready

pliant gulch
slate swan
pliant gulch
#

I'm saying you got it mixed up and if you don't believe me, check the source code

unkempt canyonBOT
#

discord/client.py lines 529 to 530

To perform asynchronous setup after the bot is logged in but before
it has connected to the Websocket, overwrite this coroutine.```
deep mirage
#

tag from dpy

pliant gulch
#

Did you... even read what I said?

winged coral
#

Andy is right but setup hook is called after setup

deep mirage
#

I did, thats not my point tho

winged coral
#

It’s just a one-time alternative to on_ready

pliant gulch
#

setup_hook is literally called before the bot even connects

#

Its not an alternative to on_ready because it isn't cached yet

#

If you were to do get_guild in setup_hook you'd get None

deep mirage
#

no you wouldnt

pliant gulch
#

Yes you would

deep mirage
#

I literally use setup_hook on all my bots for things like this bc on_ready wouldnt work

pliant gulch
#

If you aren't connected to the gateway during setup_hook how exactly did you get something from the cache????

slate swan
#

i just wanna make a invite 😐

pliant gulch
#

Please explain to me this my mind cannot comprehend

slate swan
winged coral
#

You don’t have to connect to the gateway to get guilds

#

The gateway fires events

#

Once the bot is logged in it can retrieve guilds from the REST

#

But you’re right, it isn’t gateway connected

slate swan
winged coral
#

You literally don’t lol?

pliant gulch
#

That's not how discord.py works with the way you said it no

winged coral
#

Yes it very much is

pliant gulch
#

Discord.py chunks when connecting to cache the channels...

#

It does not make a GET request for all channels

winged coral
#

It does if it’s not cached yet

#

As in, inside the setup hook

pliant gulch
#

?????????????

#

So get_channel inside of setup_hook would retrieve from a GET request???

#

yes a non-coroutine function making a request in discord.py

#

that logic is sound...

slate swan
#

setup_hook is a event right

winged coral
#

No you’d need to subclass

pliant gulch
#

????

#

What does that change at all?

torn sail
pliant gulch
#

setup_hook is called before ready is dispatched and ready is when the channels are cached

deep mirage
#

setup hook is coroutine

slate swan
pliant gulch
winged coral
#

You’d fetch not get

torn sail
slate swan
#

no i cannot

#

it does not work

pliant gulch
#

I'm only using get_channel as a means to show it's grabbing from cache

winged coral
#

I didn’t even look at the users code, I got here and read the convo between you and the other guy

#

I was arguing the lib behaviour not the user implementation

pliant gulch
#

The other guy is saying that setup_hook is called once the bot is cached and ready to go, where as on_ready is dispatched when the bot is not ready

#

Do you believe that statement whole heartedly?

winged coral
#

I said you’re right like years ago

slate swan
#

god

winged coral
#

I think you’re looking for a reason to argue

pliant gulch
winged coral
#

Because it works in setup hook, my bot is running next to me and does just that

slate swan
#

i just wanna make a invite 😭

winged coral
#

Sorry, could you send your code again

slate swan
#
guild = bot.guilds[0]
channel = guild.text_channels[0]
print(await channel.create_invite())```
winged coral
#

The full event if you don’t mind

#

And the error

slate swan
#

it was just on ready

#

idk what other event to put it on

winged coral
#

Well setup_hook is a coroutine belonging to the class, it fires once but it isn’t an event. You could subclass it or I think you could just setattr on the instance but you’d do that before the login is called

slate swan
# winged coral And the error
Traceback (most recent call last):
  File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\tjdom\Dropbox\PC\Desktop\test\test.py", line 59, in on_ready
    print(await channel.create_invite())
  File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\abc.py", line 880, in create_invite
    return Invite.from_incomplete(data=data, state=self._state)
  File "C:\Users\tjdom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\invite.py", line 316, in from_incomplete
    guild_id = int(data['guild']['id'])
TypeError: string indices must be integers```
primal token
#

pretty redundant

torn sail
slate swan
#

ima just give up this is to complicated

winged coral
winged coral
#

Yeah you’re right ofc it does, dk why I didn’t clock that

slate swan
primal token
slate swan
winged coral
pliant gulch
pliant gulch
slate swan
winged coral
pliant gulch
#

What a waste of time, poetry took me 22s just to install discord.py so I could test

slate swan
winged coral
#

🤔

#

Did the bot go online?

slate swan
#

yes

slate swan
primal token
#

⁉️

pliant gulch
#

v2.0.1

slate swan
#

😐

pliant gulch
#

Like that matters at all though???

slate swan
#

ima check my version

primal token
#

your issue isnt about versions?

winged coral
#

I mean setup_hook didn’t exist on old versions I suppose

primal token
#

im not sure what your issue about is exactly but it seems like caching etc

slate swan
#

i have no idea what is going on

#

ima reinstall

pliant gulch
#

Bro, even if you re-install it, it won't work

#

setup_hook is called before cache get's populated

primal token
#

iirc the order of callings is setup_hook > on_connect >on_ready

pliant gulch
#

Idk why that person keeps telling you to use setup_hook it literally does nothing to fix your problem

slate swan
#

then what do i do 😐

pliant gulch
#

Use a command?

#

Why do you even need to create an invite everytime the bot is ready

slate swan
#

idk

#

ig i make command

sick birch
#

I don't use disnake, sorry

torn sail
#

Looks clean

#

Except c++ is there twice

primal token
#

should replace the greenhearts value with javascript

#

discord.js has a good reputation being up to date

cerulean shale
#

But djs server has sooooo many damn announcements almost every single day bruh

#

And they mention everyone 💀

mossy jacinth
#

Already fixed it

#

I forgot to close the embed

cerulean shale
#

💀

sick birch
#

Looks slightly indented

shrewd apex
sick birch
#

Maybe it's inside of the function/class above?

#

You're sure? It looks indented in the image

#

Can you send a larger screenshot?

shrewd apex
sick birch
#

Sure

shrewd apex
#

bottom of the cog

sick birch
#

Because I don't see any other reason

#

Probably forgot to save or something

#

As a side note you shouldn't be making a database connection inside of the cog

scarlet sorrel
#

There are a million things you "shoulden't do" when making a bot but only like 3 really matter

sick birch
#

right

sick birch
scarlet sorrel
#

This is discord bots

#

No one cares

sick birch
#

Save the connection object as a bot variable, get your cursor from there

lost lichen
#

i cant install disnake?

sick birch
scarlet sorrel
#

No clue what a CI/CD pipeline is

#

And i don't want to

sick birch
#

devops tool that I think everyone should learn how to use

#

Does nextcord have setup_hook or something similar?

#

That's the perfect place to do it, then

#

I mean there's no need for a task

#

same stuff in here

scarlet sorrel
#

Hehehe

#

Why do people do things the hard way

#

I will never understand

sick birch
#

because usually the hard way is the better way

slate swan
#

Hey

sick birch
#

You're close, just remove the nested function declaration

#

and do something like self.conn = ...

pliant gulch
#

I would recommend using create_pool instead of connect as using a connection pool will handle connections for you

slate swan
#

How can i make all roles delete Incase of sortings

sick birch
#
async def setup_hook(self):
    async def login():

this is a nested function

async def setup_hook(self):
    ...

you don't need a function inside of another one

primal token
sick birch
sick birch
#
async def setup_hook(self):
  self.conn = await aiomysql.connect(...)
#

You can then access the connection object wherever you have access to your bot instance

primal token
# scarlet sorrel 🤓🤡

Thats your only response? 2 emojis when im trying to see what your point is to have a discussion about?

pliant gulch
#

Low tier shitposting

scarlet sorrel
primal token
scarlet sorrel
#

Im not gonna talk to someone who is just trying to look smart lol

primal token
#

who said im smart?

scarlet sorrel
#

🤡

sick birch
#

I think this person is just trying to stir up an argument by combating anything we say

primal token
#

Because i want to have a discussion with you doesnt mean im smart it means im a human🙈

sick birch
#

Just don't interact with them and move on

pliant gulch
#

Average discord-bots behaviour

primal token
sick birch
#

I'm just trying to save you all the headache

#

No, you can remove your login function inside of the cog

#

As long as you have access to bot, you have access to the conn obj

primal token
sick birch
#

yall start late af

#

we started like 2 weeks ago

primal token
#

sadly i need to go back

sick birch
#

yeah and you need to tweak the remaining code so it uses bot.conn instead of that

pliant gulch
#

In the case of your cog, self.bot.conn

primal token
pliant gulch
#

Yea in your settings class

#

Whever you access the connection you change it to self.bot.conn

mossy jacinth
#

Can someone help me? I added this at the time i created the bot, thats about 1 month ago and now it wont add the gif to the embed anymore since i switched to a hoster... Is there any way i could upload it as a file in the embed?

pliant gulch
#

Yes

sick birch
#

Also I don't see why you need your function to return both the connection object and a cursor

#

if you just obtain a cursor from the connection object again

pliant gulch
#

No you did it wrong

#

self.bot.conn is already an instance of the connection

#

You don't need to call it, or set it

#

It's already set, etc

sick birch
#
conn = self.bot.conn # this is not necessary, but easier to type
async with self.bot.conn.cursor() as cur:
  ...
pliant gulch
#

Which? The async with will work fine

sick birch
#

nextcord probably doesn't support setup_hook or you did it in the wrong place :wah:

pliant gulch
#

Yea make sure you create the connection before you do load_extension

#

If it doesn't you've already subclassed so, just override start and super

#
class A(commands.Bot):
    async def start(self, token: str) -> None:
        # do aiomysql connect here.
        # do load_extension here
        return await super().start(token)
sick birch
#

you also already have the setup_hook function so you may as well just do await self.setup_hook() inside the start override

shrewd apex
#

u can also make the token a default param that way in main.py u won't even have to pass the token

raven bolt
#

what happens if you pass your own account to the bot when running?

#
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=".",intents=intents)

@bot.event
async def on_ready():
    print(f"We have logged on as {bot.user}")

bot.run(my_account_token)
#

just a curious question.

pliant gulch
#

Well with an unpatched version of discord.py it'll error straight away

#

This is because an actual user has no intents avaliable

#

Actually no I remembered wrong I think, you just won't see any messages as a self bot, etc

#

Due to intents

primal token
#

either way if you run your token its againts TOS even if you dont do any automation discord discourages the use of unofficial clients

pliant gulch
#

I can only see discord.py as an actual "client" if I squint really, really and I mean, really hard

primal token
#

that sounded really weird, but it can probably be a client if you handle events etc, maybe a CLI discord client?😳

sick birch
pliant gulch
primal token
pliant gulch
primal token
pliant gulch
#

If you request them there is a likely chance you'll just get locked when using a user-account

valid vault
#

yo guys whats the unoffical discord api server invite?