#discord-bots

1 messages · Page 1071 of 1

warped mirage
#

Ok sure but it must be something like mine

slate swan
#

apparently, something like yours aint working.

warped mirage
#

Ok

vale wing
#

Put the valid token in and run it

#

Or use .env file

#

Which is more preferable

loud junco
#

how do i start a cogs

warped mirage
#

Can u send in dms if u can when it’s ready cuz ima be afk for a while and chat will flow very fast @slate swan

loud junco
#

ive been looking at this for 10 mins and dk what to write

#

check the variable name

vale wing
#

It's not the same

warped mirage
loud junco
#

what now

vale wing
loud junco
#
class Economy(commands.Cog):
    ...

    async def withdraw_money(self, member, money):
        # implementation here
        ...

    async def deposit_money(self, member, money):
        # implementation here
        ...

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

    def coinflip(self):
        return random.randint(0, 1)

    @commands.command()
    async def gamble(self, ctx, money: int):
        """Gambles some money."""
        economy = self.bot.get_cog('Economy')
        if economy is not None:
            await economy.withdraw_money(ctx.author, money)
            if self.coinflip() == 1:
                await economy.deposit_money(ctx.author, money * 1.5)
#

what is the first ... for

#

declaring variable those?

vale wing
#

Init prolly

loud junco
#

so i write there?

def __init__(self, bot):
  self.bot = bot
vale wing
#

Does eval command block os.system calls

vale wing
#

I wanna run that code but don't wanna get yeeted by mods for using os.system

vale wing
#

!src e

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
slate swan
shrewd apex
slate swan
#

it generates a basic cog template

paper sluice
vale wing
#

Ok that thing is using API

loud junco
#

even the shell doesnt want to help me 😭

loud junco
#

dont mind the name its just a beta version for my bot

shrewd apex
#

🥲

loud junco
#

and idk how to change the name so its called database

slate swan
shrewd apex
#

umm sarth any idea?

loud junco
#

what is the comment talking about

#

utf-8

#

u tf 8

slate swan
slate swan
loud junco
#

oo

paper sluice
#

it will be fixed in 4.0

loud junco
#

how do i do the commands.cooldown in cogs

slate swan
paper sluice
#

ah didnt notice that

slate swan
#

for the command, you need to have self as the first argument before context

#

this applies to all methods inside a class

loud junco
slate swan
#

1 usage, per second, per user. it is

loud junco
#

async def ping(self, ctx):

slate swan
#

yep

loud junco
#

ok

slate swan
#

To access the "bot" you would have to use self.bot or ctx.bot

#

bot.load_extension("cogs.my_cog")

loud junco
slate swan
#

anywhere you want to

loud junco
#

ok

#

what i have to import
it says i dont have module named cogs

slate swan
#

show me your file structure

loud junco
#
import discord
from discord.ext import commands
import discord.ext.commands
import os, random
from replit import db
slate swan
loud junco
#

yaya

#

i changed the name to cog name otherCommands

slate swan
#

just load_extension("ping") it

loud junco
#

oo ok

#

but

#

thats not the problem?

slate swan
#

that is, since you changed the name the cogs folder...

#

And now ping.py is in your root directory

loud junco
#

alright

#

the prefix is rpm

#

if i write rpm ping
it should send the Pong! thing right?

#

but commandNotFound

slate swan
#

and added the cooldown decorator instead

loud junco
#

?

#

what command decorator

slate swan
#

above ping function

#

decorator

loud junco
#

the @commands.cooldown?

#

eh but no

slate swan
#

@commands.command() isnt there thats why it isnt a command rn

loud junco
#

docs do it like this

heady sluice
loud junco
#

like this?

slate swan
#

yes

heady sluice
#

no

slate swan
#

() paranthesis

heady sluice
#

yes

loud junco
#

like this?

heady sluice
#

yes

loud junco
#

apa ni

heady sluice
#

self.bot.latency

loud junco
#

oo ya
forgot that

vocal plover
#

though you should call it itr inter or interaction since it's different from a command Context object

slate swan
loud junco
#

how do i import atk_def

#

from progress import atk_def?

glad cradle
loud junco
#

then what

glad cradle
loud junco
#

there is a class named Item in item.py

#

how do i import the class

glad cradle
#

then you will be able to import atk_def like
from progress.atk_def import *

loud junco
#

ok

glad cradle
#

to access you function you need to do yourClass.yourFunction

#

btw that's not a Discord Bot related question

loud junco
loud junco
#

because u are using client.command instead of bot.command

tawdry perch
#

It works, yes. But most of time not the best method

loud junco
#

so whats the problem =.=

carmine hearth
#

what is that

paper sluice
# loud junco i mean it imports everything right?

u dont know which function came from where. there is a function in webbrowser called open. lets say i did from webbroser import * it overwrites the default open, now there is confusion of why u can't open files using open

carmine hearth
#

what's this?

tawdry perch
# loud junco so whats the problem =.=

Depends what you see as a problem, code readability, importing literally everything. Not necessarily a problem but if you don't need to do it, avoid it

loud junco
carmine hearth
#

ok:)

loud junco
carmine hearth
#

what do this code?

tawdry perch
loud junco
#
from discord.ext import commands
import discord

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

######   ######
##  ##   ##
######   ######
##       ##
##       ##
  @commands.command(aliases =['p'])
  @commands.cooldown(1, 1, commands.BucketType.user)
  async def profile(ctx): 
    try:
      stats = Stats(ctx)
      my_emote = My_emote(ctx)
      embed = discord.Embed(
        description = f'''
    **PROGRESS**
    **LEVEL**: **{stats.level}**({stats.xp}/{stats.maxxp})
    **AREA**: **{stats.area}** (Max: **{stats.highestArea}**)
    **STATS**
    {my_emote.earmorfull}**DEF**: {stats.defend}
    :iron_sword:**ATK**: {stats.atk}
    {my_emote.eheartfull}**HP**: {stats.hp}/100
    ''', 
        color = discord.Color.blue())
      embed.set_thumbnail(url = ctx.author.avatar_url)
      embed.set_author(name= f"{ctx.author.display_name}'s profile", 
      icon_url = ctx.author.avatar_url)
      await ctx.send(embed=embed)
    except KeyError: #error handler
      await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or not at the latest version. Try using `rpm start`')

def setup(bot):
  bot.add_cog(profileCommands(bot))
paper sluice
#

self, ctx

loud junco
#

where

paper sluice
#

profile

loud junco
#

the command?

#

oops ashley told me i forgot :/

loud junco
carmine hearth
#

what

loud junco
#

that is a command for showing player's profile

carmine hearth
#

what do this command?

#

oh

#

i understand

#

this command shows ur stats

#

like hp and lvl

slate swan
#

oh wait nvm ryuga answered

#

and replit...

carmine hearth
#

|meow|

#

how u do this?

pliant gulch
#

Double the pipe's

unkempt canyonBOT
#

Type Hints

A type hint indicates what type a variable is expected to be.

def add(a: int, b: int) -> int:
    return a + b

The type hints indicate that for our add function the parameters a and b should be integers, and the function should return an integer when called.

It's important to note these are just hints and are not enforced at runtime.

add("hello ", "world")

The above code won't error even though it doesn't follow the function's type hints; the two strings will be concatenated as normal.

Third party tools like mypy can validate your code to ensure it is type hinted correctly. This can help you identify potentially buggy code, for example it would error on the second example as our add function is not intended to concatenate strings.

mypy's documentation contains useful information on type hinting, and for more information check out this documentation page.

pliant gulch
#

So, ||

#

||Foo||

carmine hearth
#

||sdasdadasda||

#

no this

slate swan
carmine hearth
#

m e o w

slow fog
#

Ashley

carmine hearth
#

M e O w

#

MEOW

wispy sequoia
#

this is nice 👍

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.

dense swallow
#

how do i disable a select menu after timeout using the on_timeout function?

carmine hearth
#

guys i have one question for you

slate swan
#

Is there any way that i could make this with discord py 1.7.3? Python version if it helps: Python 3.9

slate swan
#

ok thanks 😔

urban lichen
#

Hello. I have an API in django, when ever I call that API, it returns the output in my discord channel. Is there any way that when some one posted the query with some prefix, it automatically calls that API with the parameter which is that query.

carmine hearth
#

cactus is cool plant

urban lichen
#

If some one can guide me, please help. I'm stuck

urban lichen
#

Don't worry about Django. Just wanted to call the link when some one query

urban lichen
#

Oksy

carmine hearth
slate swan
slate swan
warped mirage
#

@slate swan hi

#

How do I import slash commands and that

warped mirage
#

So is there a huge difference with 2.0

slate swan
lethal moat
#
import nextcord
from nextcord.ext import tasks
import mysql.connector

bot = nextcord.Client()

@bot.event  
async def on_ready():
    print("-----------------------------------------")
    print(f"{bot.user} has connected to discord!")
    print("-----------------------------------------")
    bot_guild = bot.get_guild(GUILD ID)
    whitelisted_role = bot_guild.get_role(WHITELIST ROLE ID)
    waitlist_role = bot_guild.get_role(WAITLIST ROLE ID)
    check.start(mycursor, bot, waitlist_role, whitelisted_role)

mydb = mysql.connector.connect(
  host="206.82.251.54",
  user="app",
  password="vUl2k!82",
  database="app"
)

mycursor = mydb.cursor()

@tasks.loop(minutes=5)
async def check(mycursor, bot, waitlist_role, whitelisted_role):
  mycursor.execute("SELECT * FROM users")
  myresult = mycursor.fetchall()
  for x in myresult:
    dood = bot.get_user(int(x[0]))
    if int(x[5]) == 1 and whitelisted_role not in dood.roles:
      dood.add_role(whitelisted_role)
      if waitlist_role in dood.roles:
        dood.remove_role(waitlist_role)
    elif waitlist_role not in dood.roles:
      dood.add_role(waitlist_role)  



bot.run("TOKEN AS STRING")

How do I fix this? the bot is just supposed to get values from a database and assign roles according to the result
(ALL IDS AND TOKENS ARE CORRECT I DOUBLE CHECKED)

warped mirage
#

Wait so it’s not from discord.ext import commands another

slate swan
#

yes

warped mirage
#

Now it’s from discord import app_commands

slate swan
#

yeah its not an extension

#

and can be used with Client

warped mirage
#

Does app_commands also include slash

#

This is so confusing lmao

slate swan
warped mirage
#

Ashley can u help me fix my code now I guess

#

Codes*

fading marlin
slate swan
warped mirage
#

Ok so how would I import it in the client

#

Ah just wait

#

Lemme explain

slate swan
warped mirage
#

Or nah

slate swan
#

yes its the same

warped mirage
#

Ok good

slate swan
#

wait

warped mirage
#

what do i do here , lets go one by one

maiden fable
#

Uh

#

Why not switch to 2.0 instead tho

warped mirage
#

bro someone said dont delete discord... what do i do

slate swan
#
from discord import app_commands
from discord.ext import commands
import discord

class MyBot(commands.Bot):
  def __init__(self):
    self.test_guild = 1234567890 #replace your guild's id here
    self.intents = discord.Intents.default()
    self.intents.message_content = True
    super().__init__(command_prefix="uwu", intents=self.intents)
  
  async def setup_hook(self): #this function will run while this class is instantiated, you don't need to run it explicity
    self.tree.copy_global_to(guild=self.test_guild)
    await self.tree.sync(guild=self.test_guild)

bot = MyBot()
tree = bot.tree

@tree.command()
async def ping(interaction: discord.Interaction):
    await interaction.response.send_message("Pong!")

bot.run("token")

a simple example of slash commands for discord.py 2.0

maiden fable
#

There u go

warped mirage
#

from discord.ext import commands oh this is still a thing?

slate swan
#

yes....

maiden fable
#

I mean, that is the core of the lib lol

slate swan
#

yeah....

warped mirage
#

shall i do pip install discord?

slate swan
#

okay im leaving now

warped mirage
#

bruh

slate swan
#

you already have

warped mirage
#

ok

#

but so many people confused me

slate swan
#

...

warped mirage
#

ok what now

slate swan
#

I just sent an example....

urban lichen
#

Yes, I want the signal type of thing.

warped mirage
#

ok nice

#

first i need to fix code , then ill focus on slash commands

#
  client.load_extension('cogs.giveaway')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
C:\Users\Dom\Desktop\beta test\bot.py:16: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  client.load_extension('cogs.slowmode')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
C:\Users\Dom\Desktop\beta test\bot.py:17: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  client.load_extension('cogs.eightball')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
C:\Users\Dom\Desktop\beta test\bot.py:18: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  client.load_extension('cogs.welcomesystem')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):``` whats all this
maiden fable
#

BTW did u know there is a way to create a user bot with all the events and stuff without going against discord tos lol

maiden fable
warped mirage
#

oj

maiden fable
maiden fable
slate swan
#

wtf

lethal moat
maiden fable
warped mirage
#

wait error is await only aloud in a async function @maiden fable

slate swan
maiden fable
slate swan
#

imagine self-botting

maiden fable
#

Well since pypresence is also mentioned in the official docs, I would take it as if its not against ToS to do that stuff

warped mirage
#

shall i add async aswell

maiden fable
#

I remember, when the owner asked Mason to add PyPresence to docs, he specially said to add the Client class (to receive events and stuff), only then he will add it

fading marlin
warped mirage
#

setup_hook??

maiden fable
#

So that tells that u can receive events

warped mirage
#

right so what do i do now

#

im super confused

fading marlin
slate swan
maiden fable
#

Agreed

warped mirage
#
async def set_hook():
   await client.load_extension('cogs.giveaway')
   await client.load_extension('cogs.slowmode')
   await client.load_extension('cogs.eightball')
   await client.load_extension('cogs.welcomesystem')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
``` does this work
fading marlin
#

yes

warped mirage
#

ok

fading marlin
#

setup_hook though

warped mirage
#

ye

fading marlin
#

not set_hook

warped mirage
#
Traceback (most recent call last):
  File "C:\Users\Dom\Desktop\beta test\bot.py", line 310, in <module>
    main()
  File "C:\Users\Dom\Desktop\beta test\bot.py", line 306, in main
    client.loop.create_task(setup_db())
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 110, in __getattr__
    raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook```
maiden fable
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

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

Removes [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s from this member.

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, and the removed [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
warped mirage
#

How can I fix my error

maiden fable
#

@slate swan can ya help him

slate swan
#

csgo*

maiden fable
#

help him and then play

slate swan
#

my friends are calling me

maiden fable
#

I never used dpy 2.0 so idk anything about it

slate swan
warped mirage
#

Ok

maiden fable
warped mirage
slate swan
slate swan
warped mirage
#

Wtf

fading marlin
warped mirage
slate swan
#

or just use it as an event

warped mirage
slate swan
warped mirage
#

Right class and what

#
import asyncio
import discord
from discord import app_commands
from discord.ext import commands
import aiosqlite
import random
from easy_pil import *
from config import token
import os

intents = discord.Intents.default()
intents.members = True
intents.presences = True
client = commands.Bot(command_prefix='>', intents=intents)

async def setup_hook():
   await client.load_extension('cogs.giveaway')
   await client.load_extension('cogs.slowmode')
   await client.load_extension('cogs.eightball')
   await client.load_extension('cogs.welcomesystem')  ``` where does all this stuff go
slate swan
#

I'm done

warped mirage
#

bro my code and urs is way differnet

#

i cant tell

slate swan
#

yeah....

fading marlin
#

await client.change_presence(status=discord.Status.online, activity=discord.Game(f">help | {len(client.guilds)} Servers")) 😔
don't change presence in on_ready, use status and activity kwargs when building your commands.Bot obj

warped mirage
#

soooo what do ioooo i ii i iido

slate swan
#

Can someone tell me why I can't import discord_slash?

fading marlin
slate swan
# slate swan

pip install discord-py-slash-command or better upgrade to discord.py v2 (has slash commands in-built)

slate swan
warped mirage
#
@client.event
async def setup_hook():
   await client.load_extension('cogs.giveaway')
   await client.load_extension('cogs.slowmode')
   await client.load_extension('cogs.eightball')
   await client.load_extension('cogs.welcomesystem')
async def setup_db():                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    client.db = await aiosqlite.connect("level.db")
    await client.db.execute(
        "CREATE TABLE IF NOT EXISTS levels (level INTEGER, xp INTEGER, user INTEGER, guild INTEGER)")
    await client.db.execute(
        "CREATE TABLE IF NOT EXISTS levelSettings (levelsys BOOL, role INTEGER, levelreq INTEGER, guild INTEGER)")
    await client.db.commit()``` @fading marlin like this?
slate swan
maiden fable
#

member is None @slate swan

slate swan
#

same mistake

#

im frustrated, I'll just leave

warped mirage
maiden fable
#

w h a t

fading marlin
maiden fable
#

U don't write it anywhere?

slate swan
maiden fable
#

Dude yr member variable is None

warped mirage
#
def main():
    client.loop.create_task(setup_db())
    client.run(token)

if __name__ == '__main__':
    main()``` what about this @fading marlin
fading marlin
fading marlin
slate swan
fading marlin
maiden fable
slate swan
#

it works the same but its more preferred for v2

maiden fable
#

O

slate swan
#

but yes it will be deprecated in the future updates, it works fine for now

warped mirage
fading marlin
#

yes (or do what Ashley proposed), just make sure you've moved your setup_db stuff to the correct function

slate swan
warped mirage
#

ill stick with mine for now

fading marlin
warped mirage
#
r"C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
#

the error is big but i cant paste

slate swan
#

thanks for the support

lethal moat
#

AttributeError: 'User' object has no attribute 'add_role'

dood.add_role(whitelist_role)

wat

slate swan
stone beacon
#

lemon_thinking Hunter , and python just told you that member is Nonetype

#

Which means it's nothing, nada zilc

warped mirage
#
  File "C:\Users\Dom\Desktop\beta test\bot.py", line 18, in setup_hook
    await client.load_extension('cogs.giveaway')
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 994, in load_extension
    await self._load_from_module_spec(spec, name)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 933, in _load_from_module_spec    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.giveaway' raised an error: TypeError: object NoneType can't be used in 'await' expression
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001FEE7F52EF0>
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
lethal moat
#

dood = bot.get_user(int(x[0])) or await bot.fetch_user(int(x[0]))
alright then how do I make this give me a Member object
(Im using nextcord)

stone beacon
#

hence you cannot call any attributes on it

#

Whatever member is is None

slate swan
unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.

Changed in version 2.0: `user_id` parameter is now positional-only.
stone beacon
#

Same none you learn about in python

slate swan
#

!d discord.Guild.get_member

unkempt canyonBOT
#

get_member(user_id, /)```
Returns a member with the given ID.

Changed in version 2.0: `user_id` parameter is now positional-only.
shrewd apex
#

tip: u don't need to use await in this as well

lethal moat
#

right ima try that

warped mirage
lethal moat
#

AttributeError: 'Client' object has no attribute 'get_member'

bot = nextcord.Client()
#

Idontevenknowwhatisgoingonanymore

maiden fable
#

!d nextcord.Client.get_guild

unkempt canyonBOT
maiden fable
#

ic, Python taking time

slate swan
#

bot = Client

#

ohmi god

warped mirage
#

does anyone know how to fix my error please

stone beacon
#

☠️

maiden fable
#

@warped mirage what is yr issue

stone beacon
#

Idk how yall do it

#

Big respects to hunter

warped mirage
# maiden fable <@944343972258648115> what is yr issue
  File "C:\Users\Dom\Desktop\beta test\bot.py", line 18, in setup_hook
    await client.load_extension('cogs.giveaway')
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 994, in load_extension
    await self._load_from_module_spec(spec, name)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 933, in _load_from_module_spec    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.giveaway' raised an error: TypeError: object NoneType can't be used in 'await' expression
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001FEE7F52EF0>
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed``` I can’t fill the entire error
shrewd apex
#

commands.bot?

maiden fable
shrewd apex
#

oh

warped mirage
slate swan
stone beacon
#

Did you learn about error types in python yet?

stone beacon
lethal moat
#

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

@tasks.loop(minutes=5)
async def check(mycursor, bot, waitlist_role, whitelist_role, guild):
  mycursor.execute("SELECT * FROM users")
  myresult = mycursor.fetchall()
  for x in myresult:
    print(x)
    dood = guild.get_member(int(x[0]))
    if int(x[5]) == 1:
      dood.add_role(whitelist_role)
    else:
      dood.add_role(waitlist_role)

what is wrong with my code today bruh

#

this never happens

slate swan
#

wtf

lethal moat
#

?

slate swan
#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.

Changed in version 2.0: `member_id` parameter is now positional-only.
slate swan
#

nvm, both are guild methods

#

reason I love lightbulb and hikari

lethal moat
#

AttributeError: 'Member' object has no attribute 'add_role' okwhatthefuck

maiden fable
lethal moat
#

VSC is takin out all its anger on me today

slate swan
maiden fable
maiden fable
stone beacon
#

To be fair my intelisense does save me from using docs like 80% of the time

maiden fable
#

Same

slate swan
#

imagine using intellisense

mental coral
#

can anyone tell me like how to make the bot send u an invite when it joins a server?

warped mirage
#

Hunter any ideas for my code then

maiden fable
#

At least not using GitHub Co Pilot

maiden fable
#

The Event loop is closed one?

slate swan
#

NameError: name 'View' is not defined

maiden fable
maiden fable
slate swan
maiden fable
slate swan
maiden fable
#

Oh py-cord

#

@slate swan u know it better than me

#

Tho that is just a warning and it should work @slate swan

warped mirage
maiden fable
shrewd apex
warped mirage
slate swan
shrewd apex
maiden fable
#

CS:GO

shrewd apex
#

oh nice

#

lmao

warped mirage
maiden fable
#

Bruhhhh

#

@stone beacon do u mind helping him?

warped mirage
#

And why do I use asyncio for loops lol

maiden fable
#

Cz asyncio.loop is what async code depends on?

warped mirage
#

Ok

stone beacon
shrewd apex
#

ooh

#

should be pretty pure ones lab

stone beacon
#

All

#

At this point I accept that I'm just a living carbon compound

heady sluice
#

you're a beautiful carbon compound

#

❤️

warped mirage
#

can someone help me fix my bot please

stone beacon
shrewd apex
# stone beacon All

yeah learn the differentiating test for them properly tollens fehlings dnp and their confirmatory tests

stone beacon
maiden fable
shrewd apex
#

yeah a bit ig

#

practicals right?

stone beacon
stone beacon
shrewd apex
shrewd apex
# stone beacon yep

yeah so all the test for checking precipitation and stuff is important if they ask u to write the steps u need to write the formulas as well so u pretty much need to by heart🤷

warped mirage
#

i think at this point go back to 1.7.3

#

i will never be able to fix my bot in 2.0

shrewd apex
#

lmao u have to get back to 2.0 sooner or later

stone beacon
#

^

stone beacon
#

You from Barbados by chance?

shrewd apex
stone beacon
#

Ahh ik someone from there with your name and likes chem

shrewd apex
#

OoO

#

i am from india

heady sluice
stone beacon
#

Small world frls 🤣

warped mirage
heady sluice
#

how's life on an island like that

shrewd apex
heady sluice
#

yes

warped mirage
#

Right .. my current error is event loop is closed how do I fix

shrewd apex
#

i cant even scroll

stone beacon
warped mirage
stone beacon
#

Idk where it is although I swore hunter legit sent a patebin with ur solution earlier

shrewd apex
#

yeah he did

stone beacon
#

300 lines

shrewd apex
#

lmao send the error again as well

stone beacon
#

Can I see your giveaway cog m8

warped mirage
shrewd apex
#

btw in 2.0 cogs can be added async and u can do bot.start async as well using asyncio.run()

stone beacon
#

Put it in a pastebin

shrewd apex
#

like this

warped mirage
shrewd apex
#

so it shows your cogs as none type items its not detecting your cogs

warped mirage
#

so my cogs is the current problem?

stone beacon
warped mirage
#
import discord
from discord.ext import commands

class slowmode(commands.Cog):

    def __init__(self, client):
        self.client = client 
def setup(client):
    client.add_cog(slowmode(client))```
stone beacon
#

try what asher said

warped mirage
#

i have these in each cog

stone beacon
#

convert the setup to async

warped mirage
#

def async?

shrewd apex
#

the new 2.0 requries async cogs atleast i had to

stone beacon
#

Yea

#

I checked the github as well , it await's all setup functions in cogs now

shrewd apex
#

in all your cogs

warped mirage
#

i get 8 errors in each file now

stone beacon
#

Wha..t?

shrewd apex
warped mirage
#

instead of def setup i did def async

shrewd apex
#

lmao

stone beacon
#

Nobody said to do def async that's not a thing

warped mirage
#

async def -(

warped mirage
#

ok

shrewd apex
#

i just literally wrote it out

random kelp
#
@client.command()
async def name(ctx):
    for guild in client.guilds:
        for member in guild.members:
            print(member)

why this is showing only bot name

shrewd apex
#

only bot is there in the guild?

random kelp
#

no

#

3 members are there but that print bot name 3 times

warped mirage
#

omg

shrewd apex
#

hmm i dont see anything wrong here i could be wrong tho

warped mirage
#

Bot goes online for once ……

shrewd apex
#

cool

warped mirage
#

Umm

#

My bot doesn’t respond to any commands

shrewd apex
#

well atleast its progress

shrewd apex
warped mirage
#

Bro do I have to recode my entire bot or what

#

Nothing is working …..

stone beacon
shrewd apex
warped mirage
#

can i do client.run

stone beacon
#

🗿

shrewd apex
warped mirage
#

bruh nothing still works

warped mirage
#

i legit said i added it

shrewd apex
#

whats ur code rn

#

the main one

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.

shrewd apex
warped mirage
shrewd apex
#
async def main():
    async with client:
       await client.start(token)
asyncio.run(main())
#

and remove if name == "main"

#

main()

warped mirage
#

I did that

shrewd apex
#

part

warped mirage
#

And didn’t work

stone beacon
#

It's an async function bro

#

you need to call it in asyncio.run()

warped mirage
#

Bruh nothing still works

#

@stone beacon I did it and nothing still works

#

Shall I just send all of my files

#

In paste ins

#

Or @shrewd apex

shrewd apex
#

...

warped mirage
#

Why not cogs and stuff bruh I was told 2.0 has SO MANY CHANGES

torn sail
#

Are you awaiting client.start

warped mirage
torn sail
#

Oh ok

shrewd apex
#
# before
bot.load_extension('my_extension')

# after using setup_hook
class MyBot(commands.Bot):
    async def setup_hook(self):
        await self.load_extension('my_extension')

# after using async_with
async def main():
    async with bot:
        await bot.load_extension('my_extension')
        await bot.start(TOKEN)

asyncio.run(main())
shrewd apex
#

new way to load the cogs u can load the cogs in the async with bot part

#

since u are not passing client in setup_hook

warped mirage
#

Bro

#

None of my commands even work in main.py

#

Why can’t I fix it what’s going on

#

@shrewd apex maybe it’s too early for 2.0 no one knows how to fix

shrewd apex
#

it does for me?

#

are u loading the cogs in main()?

#

just follow the docs

warped mirage
#

Wait

#

Do I have to have interaction.response now instead of ctx.send

stone beacon
#

That's only for slash commands

warped mirage
#

Ok

#

So why ain’t any of my commands working

stone beacon
#

SEcondly

#

setup_hook is for subclasses of Client

#

it's not an event listener

warped mirage
#

Could u be a legend and maybe update my code

stone beacon
#

you never subclassed Client anywhere so your cogs aren't even loading

warped mirage
#

I’m just confused

stone beacon
#

man just try loading your cogs here

#

after the async with client

#

and see if your cog loads rq

#

If not then idk what to tell you anymore

shrewd apex
#

lmao helping isnt a problem but sometimes its just so tiring...

stone beacon
#

Back to polymers I go

shrewd apex
#

gl

warped mirage
shrewd apex
#

instead of just complaining and saying i have this and that why dont u just do what was said...

oak wagon
#

how to get thus

#

????

warped mirage
#

But sure

#

So do I add my hook under that

wanton steeple
#

he not found module help me pls

shrewd apex
#

just copy paste ur load extension there

oak wagon
#

@shrewd apex how to make this

shrewd apex
#

make 4 spaces

#

in indent or just a tab which is worth 4 spaces but NEVER mix them up

shrewd apex
wanton steeple
shrewd apex
#

ok so do python --version

#

in your cmd and in your terminal

#

do you get same version in both

wanton steeple
shrewd apex
#

both?

#

windows shell and vcs terminal

wanton steeple
#

yes

shrewd apex
#

if so then do pip freeze

#

what do u get?

wanton steeple
#

pip freeze ? how

warped mirage
shrewd apex
#

also part of your toke in showing i suggest u remove that

shrewd apex
#

in terminal of vcs

tacit horizon
#

can create role with permissions with bot

warped mirage
shrewd apex
warped mirage
#

Bro I’m trying to be serious here and ur making jokes about

tacit horizon
shrewd apex
#

then run the bot

shrewd apex
shrewd apex
warped mirage
#
``async def setup_hook():
   await client.load_extension('cogs.giveaway')
   await client.load_extension('cogs.slowmode')
   await client.load_extension('cogs.eightball')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
   client.db = await aiosqlite.connect("level.db")
   await client.db.execute(
        "CREATE TABLE IF NOT EXISTS levels (level INTEGER, xp INTEGER, user INTEGER, guild INTEGER)")
   await client.db.execute(
        "CREATE TABLE IF NOT EXISTS levelSettings (levelsys BOOL, role INTEGER, levelreq INTEGER, guild INTEGER)")
   await client.db.commit()``` bro what do i do then
#

i need this stuff

wanton steeple
#

no work

shrewd apex
#
await client.db.execute(
        "CREATE TABLE IF NOT EXISTS levels (level INTEGER, xp INTEGER, user INTEGER, guild INTEGER)")
   await client.db.execute(
        "CREATE TABLE IF NOT EXISTS levelSettings (levelsys BOOL, role INTEGER, levelreq INTEGER, guild INTEGER)")
   await client.db.commit()
heady sluice
#

pip3.10 install discord

shrewd apex
#

these go in bot on ready event

heady sluice
wanton steeple
# shrewd apex what did u get when u did pip freeze
async-generator==1.10
async-timeout==3.0.1
attrs==21.4.0
certifi==2022.5.18.1
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.12
cryptography==37.0.2
discord==1.7.3
discord.py==1.7.3
h11==0.13.0
idna==3.3
multidict==6.0.2
outcome==1.1.0
Pillow==9.1.1
pycparser==2.21
PyNaCl==1.4.0
pyOpenSSL==22.0.0
PySocks==1.7.1
requests==2.27.1
selenium==4.2.0
six==1.16.0
sniffio==1.2.0
sortedcontainers==2.4.0
trio==0.20.0
trio-websocket==0.9.2
typing_extensions==4.2.0
urllib3==1.26.9
wsproto==1.1.0
yarl==1.7.2```
warped mirage
shrewd apex
#
await client.load_extension('cogs.giveaway')
await client.load_extension('cogs.slowmode')
await client.load_extension('cogs.eightball')              
client.db = await aiosqlite.connect("level.db")
shrewd apex
warped mirage
#

bro what the f is all this

heady sluice
shrewd apex
#

yeah

heady sluice
#

pip3.10 install discord

warped mirage
#

@shrewd apex can u do me a favour and edit my code and send updated

#

this doesnt make no sense

slate swan
#

Lol

warped mirage
#

async with aiosqlite.connect("level.db") is a seperate function tf?

#

check what u said mate

shrewd apex
#

i am already trying my best to help u from phone and u keep saying this and that why dont u just check the docs and learn on your own all of us have the same resources and same starting line

warped mirage
wanton steeple
heady sluice
shrewd apex
oak wagon
#

Hello

#

I need help

slate swan
#

Ok

oak wagon
#

Im using python

wanton steeple
shrewd apex
#

yeah

oak wagon
#

How do I type this symbol

shrewd apex
oak wagon
#

OH

#

LMAO

heady sluice
#

that's not a symbol...

shrewd apex
#

lmao

warped mirage
shrewd apex
#

ok lmao i am speechless and am giving up

#

i think coding is not for u

heady sluice
#

okay the first thing I see is a changed activity on_ready

shrewd apex
#

no offence but wth hell is this

async def main():
    async with client:
       await client.start(token)
asyncio.run(main(await client.load_extension('cogs.giveaway')
                 await client.load_extension('cogs.slowmode')
                 await client.load_extension('cogs.eightball')              
                 client.db = await aiosqlite.connect("level.db")))
wanton steeple
heady sluice
#

did you install discord @wanton steeple

wanton steeple
heady sluice
#

did you reload vsc

thick basin
#

If we try to send a video from https://cdn.discordapp.com/ (using aiohttp > converting to bytes > then sending) , sometimes it is bigger than guild.filesize_limit , is it a good idea to compress it using zlib (because it basically compresses bytes) or should I use ffmpeg to do the same. If yes then please send a minimal snippet showing how should I do that

warped mirage
#

So don’t blame me tbf

wanton steeple
heady sluice
#

except you should check for your python interpreter

warped mirage
#

bruh now ur acting like I did it from a blind eye

#

U told me how to do it

shrewd apex
#
async def main():
    async with client:
       await client.load_extension('cogs.giveaway')
       await client.load_extension('cogs.slowmode')
       await client.load_extension('cogs.eightball')
       await client.start(token)                                                 
       client.db = await aiosqlite.connect("level.db")
asyncio.run(main())
tacit horizon
#
@client.command()
async def e(ctx):
    server = ctx.message.server
    perms = discord.Permissions(send_messages=False, read_messages=True)
    await ctx.guild.create_role(server, name='NoSend', permissions=perms)

why this not working

wanton steeple
shrewd apex
#

lmao did i?

stone beacon
slate swan
shrewd apex
#

i even sent the docs

stone beacon
warped mirage
#

I don’t really mind

slate swan
#

uhh

warped mirage
#

I’ll just get a cup of coffee to relax

shrewd apex
stone beacon
warped mirage
#

damn offended lol

slate swan
warped mirage
#

Coding is not for me @shrewd apex ur right , I’ll just come back one day

tacit horizon
# shrewd apex server = ctx.guild

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Guild.create_role() takes 1 positional argument but 2 were given

shrewd apex
#

hmm my bad i dont work with discord much so i dont know all aliases

torn sail
oak wagon
#

what happened

slate swan
#

!d discord.Guild.create_role

unkempt canyonBOT
#

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

Creates a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

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

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

New in version 2.0: The `display_icon` keyword-only parameter was added...
tacit horizon
#
@client.command()
async def e(ctx):
    server =  ctx.guild
    perms = discord.Permissions(send_messages=False, read_messages=True)
    await ctx.guild.create_role(server, name='NoSend', permissions=perms)
shrewd apex
#
await ctx.guild.create_role(name='NoSend', permissions=perms)
shrewd apex
shrewd apex
stone beacon
slate swan
shrewd apex
#

yeah ik he added a |

shrewd apex
slate swan
heady sluice
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.

shrewd apex
wanton steeple
#

help me pls

heady sluice
#

I can't find indentation in the resources

shrewd apex
#

welp

heady sluice
#

now why's that

shrewd apex
#

small stuff not required

heady sluice
slate swan
#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

heady sluice
#

completely forgot about this

shrewd apex
shrewd apex
heady sluice
#

what

#

same namespace

shrewd apex
#

coz u have to install 2.0 using git link

oak wagon
#

ok

slate swan
wanton steeple
wanton steeple
heady sluice
#

ctrl + shift + p
select python interpreter
select 3.10
pip3.10 install git+https://github.com/Rapptz/discord.py
reload visual studio code

shrewd apex
slate swan
#

too smart for this shit

shrewd apex
#

he already has interpreter set to 3.10

heady sluice
#

then idfk

shrewd apex
#

just install dpy2.0 and see

heady sluice
#

a whole ass token

shrewd apex
#

don't show ur token hasan

oak wagon
#

well how do i make the commands work

warped mirage
slate swan
#

am I the only one who copied the image with the token or what?

modern fiber
#

But bot isn't coming online..?

shrewd apex
#

@bot.command()

shrewd apex
wanton steeple
oak wagon
#

i put @bot.command()

modern fiber
oak wagon
#

its not working

shrewd apex
#

and do git add . commit and push again

modern fiber
shrewd apex
#

also not sure but isn't it git commit -am 'updates'

modern fiber
#

want me to screenshare?

slate swan
#

how would i do unix timestamps

warped mirage
#
  File "C:\Users\Dom\Desktop\beta test\bot.py", line 37, in on_message
    async with client.db.execute("SELECT levelsys FROM levelSettings WHERE guild = ?",
AttributeError: 'Bot' object has no attribute 'db'
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 393, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Dom\Desktop\beta test\bot.py", line 37, in on_message
    async with client.db.execute("SELECT levelsys FROM levelSettings WHERE guild = ?",
AttributeError: 'Bot' object has no attribute 'db'```
#

how can i fix this

slate swan
shrewd apex
#

oh ok didn't know that thanks

#

make a connection for aiosqlite in an async function first

#

then run that command in main

modern fiber
#

it keeps saying nothing to commit even tho i deleted whole command

#

like 10 lines

#

can someone help me? i can screenshare

slate swan
warped mirage
modern fiber
shrewd apex
modern fiber
warped mirage
#

no

shrewd apex
modern fiber
#

i did..

warped mirage
#

i did 2.0 today , no one showed me how to fix the system if i just got the error?

modern fiber
#

but doesnt work

slate swan
slate swan
warped mirage
shrewd apex
# warped mirage no

async def connection():
async with aiosqlite.. #stuff
client.db = await connect....
async def main()
await connection ()

modern fiber
#

dude.. it keeps saying nothing to commit even tho i changed BUNCH of lines

#

can anybody help? screenshare?

slate swan
#

too lazy

modern fiber
#

anybody..

shrewd apex
#

lmao

warped mirage
#

wait what about the client.event @shrewd apex

shrewd apex
modern fiber
shrewd apex
modern fiber
#

how do i even check bruh

warped mirage
shrewd apex
#

yeah u don't need to change anything which. has client.db

modern fiber
warped mirage
#

Right

shrewd apex
#

only make a function for declaring it

slate swan
# modern fiber anybody..
  1. you have to use git add <filename> to track changes again or use a . instead for every single file
  2. you can only commit stuff when you use the add command prior to it
warped mirage
#

nah im so confused ,, i was told to move the connections and now declare lmao 2.0 is so difficult .. ill just try but ill fail

slate swan
#

send the current code, ill help ya

shrewd apex
#

u never declared connection for client.db till now...

warped mirage
slate swan
shrewd apex
slate swan
#

it doesnt update....

modern fiber
#

I did, doesn't work

slate swan
#

it prepares files for the staging area

shrewd apex
#

yeah adds

#

yes ma'am🥲

slate swan
#

try running git status

#

my replies never work

shrewd apex
#

don't commit just do git add . once and push directly

modern fiber
slate swan
oak wagon
#

YO IT WOKRED

shrewd apex
shrewd apex
oak wagon
#

thx

shrewd apex
shrewd apex
#

u revealed it once

slate swan
oak wagon
#

Ok

slate swan
#

.db

#

yes

slate swan
warped mirage
# slate swan yes
    await client.db.execute(
AttributeError: 'Bot' object has no attribute 'db'``` there we go an error
shrewd apex
#

u didn't declare

#

async with aiosqlite.connect as db
client.db = db

shrewd apex
#

then call the function in main()

slate swan
#

that should settle it

shrewd apex
warped mirage
slate swan
shrewd apex
slate swan
#

^

shrewd apex
#

😳

#

lmao

#

well i GTG cya

slate swan
#

bai bai take care

warped mirage
#

Or @slate swan lol

slate swan
#

!d discord.ui.button

#

!d discord.ui.button

slate swan
#

!d discord.ui.button

slate swan
#

nvm

slate swan
oak wagon
#

hats wrong

#

whats

#

nvm

slate swan
#

no need for the indent level lol

heady sluice
#

indentation is hard

slate swan
heady sluice
#

you can't take a joke can you

carmine hearth
heady sluice
#

this is YET ANOTHER problem

slate swan
heady sluice
#

you won't choose javascript because you don't need indentation there

#

or will ya Confused_Dog

potent spear
#

or just use a good IDE I'd say

heady sluice
#

I'd also do so if I knew js

slate swan
oak wagon
slate swan
#

vsc lmao

oak wagon
#

waht that

slate swan
oak wagon
#

I use ipad

carmine hearth
#

i use for coding and hosting my ds-bot

oak wagon
#

same

#

botghost is so annoying

warped mirage
oak wagon
#

it puts its dumb stuff in the bio

#

status

carmine hearth
slate swan
#

about 42mb for me

#

less than 100mbs lol

warped mirage
#

@slate swan are u good with the 2.0 of dpy or nah

slate swan
#

not really i dont like its impl

warped mirage
#

f

#
 File "C:\Users\Dom\Desktop\beta test\bot.py", line 23, in on_ready
    await client.db.execute(
AttributeError: 'Bot' object has no attribute 'db'``` @slate swan i still get this error
slate swan
#

still same error

warped mirage
#

yes could u please help me fix this ,, then one more thing ill ask help for

#

and u will never recieve a ping from me ever again

slate swan
#

Client.start() will only return once the bot is closed

#

You want to do any initialization before calling .start()

warped mirage
slate swan
#

Where?

warped mirage
slate swan
#

You didn't call the function in your code

warped mirage
slate swan
#

I already did

warped mirage
#

updated cpde

slate swan
#

Client.start() has a while loop, it blocks the coroutine until the client is closed, meaning you should put your aiosqlite.connect() calls before it.

slate swan
warped mirage
slate swan
#

I thought you removed the function

#

Wait I'm so confused what problem are you facing again?

warped mirage
#

File "C:\Users\Dom\Desktop\beta test\bot.py", line 23, in on_ready
await client.db.execute(
AttributeError: 'Bot' object has no attribute 'db' current error

slate swan
#

Put the aioqslite.connect() call before client.connect() bruh

#

I.e, on the previous line

#

Or before loading all your extensions

warped mirage
#

ok

#

ruh

#

0 commands work'

#

@slate swan

slate swan
#

Your on_message event listener is breaking command processing. You should use the @client.listen() decorator for it instead of @client.event

warped mirage
slate swan
#

Oh wait hold on

warped mirage
#

or do i need to do it for every

slate swan
#
    await client.process_commands(message)

Remove this last line from your on_message listener and replace the decorator

slate swan
terse coyote
#

how to check if a user is banned?

warped mirage
#

oh ye i had this before i added it because my commands didnt work

slate swan
unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

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

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
warped mirage
#

@slate swan i have 2 await client.process_commands(message)
should i remove both

slate swan
warped mirage
#

i changed the decorator

#

and removed them both

slate swan
#

Does it still not work?

warped mirage
#

no

#

maybe my cogs affect it?

slate swan
#

Oh you need message_content intents

intents = discord.Intents.default()
intents.message_content = True

You need to set .message_content to True and enable it in your Discord Developers dashboard

#

For this you need to be on 2.0 as well

warped mirage
#

yes im doing 2.0

#

@slate swan i have it enabled , i put the code im on 2.0

#

and it still doesnt work

slate swan
#

Any errors?

warped mirage
#

no

#

0 response

slate swan
#

Can you send your code

warped mirage
#

sure

slate swan
#

You didn't change the decorator

#

@client.listen() for on_message, not @client.event

warped mirage
#

i changed it before

#

and it didnt work

#

ill try again

slate swan
#

Does on_ready get called?

warped mirage
#

ys

#

yes

#

YES most of my commands work wait

#

YESSSS

#

@slate swan thank u soooo much

#

but can u help me fix next error

slate swan
#

Sure

warped mirage
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'```
slate swan
#

Hm

torn sail
#

It was changed to member.avatar**.**url

slate swan
#

Yeah

#

!d discord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.avatar "discord.User.avatar")
slate swan
#

Oh my bad

#

It returns an Asset, which has a .url attribute

torn sail
#

!d discord.Asset.url

unkempt canyonBOT
terse coyote
#

how to get all users with X role?