#discord-bots

1 messages · Page 682 of 1

brazen raft
#

There is a library called hikari which is a strong typed development library for discord bots in Python

small igloo
#

writing a novel maybe?

upbeat otter
#

yes

unkempt canyonBOT
upbeat otter
#

ohhh

upbeat otter
small igloo
upbeat otter
small igloo
small igloo
upbeat otter
small igloo
upbeat otter
strong shale
#

!pypi nextcord

unkempt canyonBOT
small igloo
small igloo
upbeat otter
upbeat otter
unkempt canyonBOT
strong shale
visual island
#

Once upon a time, lives a human named "Danny". He actually do work as a doctor in a hospital in Japan. He also made an API wrapper of Discord with python as a hobby. It's a big repo with 9k+ starts. But one day, he got pressured & hate so much by the community. Saying probably like "dpy is so slow on development" most of the times. But actually it's fine as all of the Devs does that as hobby and in free times. But finally the Devs decide to quit and yeah Danny also got frustated by the hate and decided to quit the development and archived the repo. Probably 99% of the community are mad at him but imo (and their opinion (the Devs)) it's not worth it. So yeah, now the library is fully undeveloped anymore and will may be unsupported in the near future. The end.

~ Based on real story

quick gust
#

disnake >

quick gust
small igloo
# upbeat otter why not

if the way an update just break old system that gud, THAT'S LITTERALY WINDOWS 10 UPDATE WAY

visual island
small igloo
small igloo
#

_sup @boreal ravine _

boreal ravine
#

how do I change the cog_check error

boreal ravine
boreal ravine
small igloo
visual island
boreal ravine
#

o

#

thats gtk

boreal ravine
strong shale
# small igloo hmm give proof

If I want to do advertising
Then I would send my own package here lol

If you want proof read about me in my profile

small igloo
cinder horizon
#

any code where we can give a hyper link in an embed where the link is of an announcement channel and wen the user clicks it kinda follows the channel....if ukwim

small igloo
strong shale
small igloo
strong shale
cinder horizon
small igloo
small igloo
strong shale
cinder horizon
strong shale
small igloo
strong shale
slate swan
#

ooof

small igloo
strong shale
small igloo
#

help #2

small igloo
velvet tinsel
#

ok

small igloo
velvet tinsel
#

show code

strong shale
small igloo
velvet tinsel
#

full traceback

small igloo
small igloo
small igloo
strong shale
# small igloo

You are getting an error in database file in add() func

strong shale
velvet tinsel
strong shale
velvet tinsel
#

!ot

unkempt canyonBOT
strong shale
#

👍

velvet tinsel
#

you should have a commands. before it I think

strong shale
# small igloo

See traceback carefully bro, the error is related to database file not in main.py or anything

placid skiff
#

Guys how can I assign NULL to a sqlite3 column with a query?

lament mesa
#

UPDATE TABLE_NAME SET COULMN_NAME = NULL WHERE CONDITION

brazen raft
#

As a query variable, you can use None

#

Probably.

bleak sinew
#

Guys, is it possible to make multiple nested commands group inside a command group in a Cog?

Like : Command Cog -> Commands Group -> Commands Group -> Commands

boreal ravine
#

how do i make my bot re-invoke a command

boreal ravine
#
@commands.group()
async def do(self, ctx):
  ...
@do.group()
async def this(self, ctx):
  ...
@this.group()
async def lol(self, ctx):
  ...
``` `!do this lol`
slate swan
unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

slate swan
#

🤦 im high today ig

visual island
#

it exists

#

undocumented

boreal ravine
#

o

slate swan
#

oh , so you can basically Context.command.invoke() ;)

slate swan
#

thats different

#

but you can use that too in your case

boreal ravine
#

o

visual island
#

Command.invoke is used for the internals

boreal ravine
#

hm

small igloo
#

helo?

visual island
# small igloo

you're inserting something that isn't supported by sqlite3

visual island
#

we need your code

small igloo
small igloo
visual island
small igloo
visual island
#

str() it

small igloo
#

hmm

visual island
#

str(ctx.author) -> "name#0000"

small igloo
#

btw what is the code for create table if not exist?

visual island
#

CREATE TABLE IF NOT EXISTS tablename (...)

small igloo
boreal ravine
#

How do I make my bot make another embed if the index was over 10? (a paginator)

strong shale
#
# Use like this
conn.execute(f"INSERT INTO users_data (NAME, COIN, EXP, MAX_EXP) VALUES ('{name}', 25, 0, 125)")
placid skiff
boreal ravine
boreal ravine
strong shale
upbeat otter
strong shale
placid skiff
bitter perch
sage otter
strong shale
wide tartan
#

I'm getting this error even though I already have intents

placid skiff
placid skiff
slate swan
slate swan
#

most likely had a value of None

slate swan
#

You don't need any intents for that code, just as side note.

strong shale
placid skiff
wide tartan
placid skiff
#

we can't see what line the error raises

#

It's not the entire error -.-

slate swan
#

read the error shrug

placid skiff
cobalt jacinth
#

how to give default value to arguments...lets say i want to have 3 arguments from the command

wide tartan
slate swan
#

oh my fault

#

yeah send the entire error

placid skiff
slate swan
placid skiff
#

i can't check every line of your code D_D

wide tartan
#

oops wait

strong shale
cobalt jacinth
#

abc(ctx,one=None,two = None)

wide tartan
#

that's the entire error

slate swan
#

shrug not the entire error

placid skiff
#

yeah i'm checking

slate swan
#

not sure how to show the full error on a vps

visual island
#

tracebacks starts with "Traceback (most recent call last)"

cobalt jacinth
visual island
#

!tb

#

yea

slate swan
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

strong shale
wide tartan
#

so-

slate swan
#

show the full error

wide tartan
#

how-

placid skiff
cobalt jacinth
wide tartan
slate swan
#

idk tbh , try running the code locally or find a way to show the full error

strong shale
slate swan
wide tartan
placid skiff
wide tartan
#

what else am i supposed to use, a free server that uses shared IPs??

slate swan
placid skiff
#

no, usually it is better to develop in local D_D

slate swan
wide tartan
#

i did that and that's what it sent

slate swan
#

or something like that

#

logs only show the last 15 messages wither its an error or not

visual island
#

@wide tartan seems that ctx.guild is None. Do you invoke the command on dms?

slate swan
placid skiff
# wide tartan it's `pm2 logs` actually

Look, i know what the error is, but without knowing the line i can't tell where it raise D_D
Essentially you are passing a nonetype value and using it like a Guild, Channel or User object

visual island
#

@wide tartan can you print role?

small igloo
visual island
#

its the one that's None

small igloo
#

what did i missed

wide tartan
visual island
#

not ctx.guild apparently

silk mauve
#

Is it able that the bot gets the user banner? Same as a avatar command but just as banner

wide tartan
#

@placid skiff

wide tartan
slate swan
visual island
#

!e

def foo(a = None, b): ... 
foo()
```nah
unkempt canyonBOT
#

@visual island :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     def foo(a = None, b): ... 
003 |                       ^
004 | SyntaxError: non-default argument follows default argument
slate swan
#

mhmm

placid skiff
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
small igloo
slate swan
#

their was something that made all arg after it None i dont quite remember

slate swan
visual island
#

is there?

#

idk

slate swan
placid skiff
visual island
placid skiff
#

Not probably, is it something in the overwrites

slate swan
wide tartan
#

@visual island it returns none

visual island
#

yea

placid skiff
#

overwrites (Dict[Union[Role, Member], PermissionOverwrite]) – A dict of target (either a role or a member) to PermissionOverwrite to apply upon creation of a channel. Useful for creating secret channels.
@wide tartan

visual island
#

can you try with the ID instead?

#

!d discord.Guild.get_role

unkempt canyonBOT
wide tartan
#

oh wait

#

yeah, apparently i typed in the wrong role

slate swan
#

how do I add 2 buttons in a discord message

@bot.command()
async def donate(ctx):
    await ctx.send("doante below", components=[Button(style=ButtonStyle.URL, label="Steam", url="utl")])
    interaction = await bot.wait_for(
        "button_click", check=lambda inter: inter.custom_id == "button1" 
    )
    await interaction.send(content="Button Clicked")```
visual island
#

put 2 Button in the components list?

slate swan
wide tartan
#

Alright it works, ty

strong shale
visual island
visual island
slate swan
strong shale
slate swan
strong shale
#

oh ok

small igloo
strong shale
#

Use them for testing purposes only

small igloo
#

wait what :) u told me to use that

strong shale
slate swan
small igloo
#

also what's the long for "f" in f-string lol

visual island
#

format

small igloo
small igloo
slate swan
small igloo
slate swan
small igloo
slate swan
#

f-strings are bad with sql databases

visual island
small igloo
#

then i must use waht ;-; not use f string = error code

slate swan
slate swan
slate swan
small igloo
#

:v

slate swan
#

just asking

small igloo
#

ok

sick birch
small igloo
#

sup @sick birch

small igloo
sick birch
slate swan
sick birch
#

Lmao yeah

#

Sanitize your inputs kids 👍

slate swan
visual island
#

.execute(f"SELECT bla FROM bla WHERE {a}") lets say a is a param from a command. And let's say the value is "true; DROP TABLE bla" and the table will be deleted

slate swan
#

python has explanation to not use f-strings with sql databases i forgot what command it was

visual island
#

!tag injections

small igloo
# sick birch

maybe bcuz i'm a newbie i don't understand it, imma save it for later when i already mastered SQL database...

visual island
#

nah

small igloo
strong shale
small igloo
small igloo
brazen raft
slate swan
small igloo
slate swan
#

you guys cant Find walter?

brazen raft
#

It lets you alter tables. An example would be adding an entirely new column to a table

slate swan
strong shale
small igloo
silk mauve
#

Is it able that the bot gets the user banner? Same as a avatar command but just as banner

visual island
#

!d discord.Member.banner

unkempt canyonBOT
#

property banner```
Equivalent to [`User.banner`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.banner "discord.User.banner")
silk mauve
#

thanjs

small igloo
sinful pasture
#

How can I make a change prefix command?

silk mauve
#

ty

visual island
#

in 2.0 yes

sinful pasture
#

lol

small igloo
silk mauve
sinful pasture
visual island
small igloo
#

wait :v it's exist

#

lol

#

there we go

sinful pasture
#

Very informative answer, ngl, ty

strong shale
#
# Try this 
conn.execute("INSERT INTO users_data (NAME, COIN, EXP, MAX_EXP) VALUES ('?', 25, 0, 125)", (name,))
small igloo
#

ok, back to the f-string, can give explanation why it's not recommended

small igloo
slate swan
small igloo
slate swan
strong shale
small igloo
slate swan
#

anybody have command ideas

small igloo
slate swan
visual island
#

1 fps?

strong shale
slate swan
small igloo
# strong shale working or not ?

Ignoring exception in on_command_error
Traceback (most recent call last):
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 11, in start
database.add(str(name))
File "C:\Users\thosiba\PycharmProjects\main.py\database.py", line 11, in add
conn.execute("INSERT INTO users_data (NAME, COIN, EXP, MAX_EXP) VALUES ('?', 25, 0, 125)", (str(name),))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.

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

Traceback (most recent call last):
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 21, in on_command_error
raise error
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.

yert

visual island
#

? Shouldn't be quoted

small igloo
small igloo
visual island
#

yea ?

slate swan
small igloo
# small igloo Ignoring exception in on_command_error Traceback (most recent call last): File...
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 11, in start
    database.add(str(name))
  File "C:\Users\thosiba\PycharmProjects\main.py\database.py", line 11, in add
    conn.execute("INSERT INTO users_data (NAME, COIN, EXP, MAX_EXP) VALUES ('?', 25, 0, 125)", (str(name),))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.

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

Traceback (most recent call last):
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 21, in on_command_error
    raise error
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.

yert

small igloo
small igloo
slate swan
visual island
#

''

slate swan
#

you pasted the entire tracebook usually the line which is causing error and why is in the traceback

strong shale
# small igloo :l what quote
# try this
name = str(name)
conn.execute("INSERT INTO users_data (NAME, COIN, EXP, MAX_EXP) VALUES (?, 25, 0, 125)", (name,))
slate swan
small igloo
slate swan
small igloo
strong shale
small igloo
#

yert funny emoji, check

visual island
slate swan
#
 await ctx.send("Arigato-Gozaimashita For Using This Command\nWe Currently Accept Donations Down Below", components=[Button(style=ButtonStyle.URL, label="Steam", url="url2",), Button(style=ButtonStyle.URL, label='Paypal', url='url`')])
    interaction = await bot.wait_for(
        "button_click", check=lambda inter: inter.custom_id == "button1" "button2"
    )
    await interaction.send(content="Button Clicked")```
the buttons are horizontol how do I make them vertical?
#

command ideas?🧍‍♂️

small igloo
strong shale
small igloo
small igloo
#

ok, then do that

#

CCCCC:

slate swan
#

.-.

small igloo
visual island
small igloo
#

uhm, now can someone explain how to use select?

slate swan
small igloo
slate swan
#

to many modules for it

visual island
#

SELECT col, col2, ... FROM table the most basic use

small igloo
slate swan
small igloo
slate swan
visual island
slate swan
visual island
#

wont it?

slate swan
#

all results go to terminal and with a exception it does but results never get shown

small igloo
slate swan
#

yall need the results to get redirected

small igloo
#

try to guess my gender from all of my messages

visual island
slate swan
visual island
small igloo
slate swan
#

im just gonna learn sql bye now

small igloo
slate swan
#

lol

small igloo
small igloo
slate swan
visual island
small igloo
slate swan
slate swan
small igloo
visual island
#

either fetchall() or fetchone()

small igloo
small igloo
visual island
#

!d sqlite3.Cursor.fetchall

unkempt canyonBOT
#

fetchall()```
Fetches all (remaining) rows of a query result, returning a list. Note that the cursor’s arraysize attribute can affect the performance of this operation. An empty list is returned when no rows are available.
slate swan
#

why does everyone assume because you know python that your old lmfao😭

small igloo
#

coin = fetchall(conn.execute("SELECT coin from USER_DATA"))

...?

visual island
#

no

small igloo
slate swan
visual island
#

conn.execute(...)
result = conn.fetchall()

visual island
slate swan
#

bye now

small igloo
visual island
#

cya

#

thats okimii

small igloo
sick birch
small igloo
visual island
#

not coin

small igloo
small igloo
small igloo
visual island
small igloo
strong shale
small igloo
strong shale
#

😅

small igloo
# visual island try it

one more check, is this right?

def check_coin(name):
name = str(name)
conn.execute("SELECT coin from USER_DATA where NAME = ?" (name,))
coin = conn.fetchall()
return coin

visual island
#

yes

#

coin would be a list of tuple

small igloo
#

:D ok, thanks

full valley
#

Anyone here good with asyncio tasks

small igloo
# visual island yes

this code creates this error, why

def check_coin(name):
    name = str(name)
    conn.execute("SELECT coin from USER_DATA where NAME = ?" (name,))
    coin = conn.fetchall()
    return coin
small igloo
tawdry perch
small igloo
tawdry perch
#

it's alrd a string afaik

slate swan
small igloo
slate swan
#

they need to do that

tawdry perch
#

oh I did not know that

small igloo
tawdry perch
#

can you show the full traceback

small igloo
full valley
slate swan
spring flax
#
@bot.command()
async def clone(ctx, role : disnake.Role):
    new_role = await ctx.guild.create_role(name="Altmute")
    for channel in ctx.guild.channels:
        overwrites = channel.overwrites_for(role)
        await channel.set_permissions(new_role, overwrites=overwrites)```
this raises `it says invalid permission given to the keyword now`
small igloo
small igloo
small igloo
#
import sqlite3
conn = sqlite3.connect('database.db')
conn.execute('''CREATE TABLE IF NOT EXISTS users_data
         (
         NAME           TEXT    NOT NULL,
         COIN           INT     NOT NULL,
         EXP            INT     NOT NULL,
         MAX_EXP        INT     NOT NULL
         );''')
def add(name):
    name = str(name)
    conn.execute("INSERT INTO users_data (NAME, COIN, EXP, MAX_EXP) VALUES (?, 25, 0, 125)", (name,))

def add_coin(name, amount):
    conn.execute("UPDATE users_data set coin = coin + ? where NAME = ?", (amount, name))

def check_coin(user):
    user = str(user)
    conn.execute("SELECT coin from USER_DATA where NAME = ?" (user,))
    coin = conn.fetchall()
    return coin
#

and also it shows this

#

ooooh ok ok, ig i know it

slate swan
tawdry perch
#

you have to pass permissionsoverwrites?

small igloo
#

ok, what is it

tawdry perch
unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
slate swan
#
anti_add = 'on'
@client.event
async def on_message(message):
    global anti_add
    if ".link" in message.content.lower():
        if anti_add == 'on':
            await message.delete()
            await message.channel.send("Απαγορεύετε να στέλνετε λίνκς!")
            await client.process_commands(message)
``` hey how can i add more links.. like .com?
tawdry perch
#

let me find my sql things

small igloo
spring flax
#

oops

#

my bad

#

sorry ghost ping

visual island
#

then change to cur.fetchall()

visual island
slate swan
slate swan
visual island
small igloo
visual island
#

um yea you can do that. But that's not what I meant

spring flax
small igloo
slate swan
slate swan
tawdry perch
#

!d discord.TextChannel.overwrites_for

unkempt canyonBOT
spring flax
small igloo
slate swan
barren oxide
#

hi

tawdry perch
barren oxide
#

hi

tawdry perch
#

db = connection object

barren oxide
#

hi'

#

hi

#

hi

sly elbow
#

Hello

visual island
slate swan
tawdry perch
#

wdym?

barren oxide
tawdry perch
#

I just said what that variable meant in my case

sly elbow
slate swan
tawdry perch
#

ah

barren oxide
small igloo
#

btw it finnaly can send this, but why the coin empty, and from my observation, it's a list...?

tawdry perch
slate swan
#

@visual islandcan you tell me pls

barren oxide
#

where can i spam?

sly elbow
tawdry perch
visual island
barren oxide
visual island
#

seems that the result is empty so it returns an empty list

barren oxide
#

i want to spammmmmmmmmmmm

tawdry perch
#

please don't do that here

barren oxide
#

ok...k

visual island
small igloo
small igloo
boreal ravine
#

is there a tutorial on discord-ext-menus

tacit horizon
visual island
small igloo
slate swan
visual island
#

it should be cur.execute tho not conn.execute

boreal ravine
tawdry perch
#

there was a tutorial I had used but I don't think I remember it, let me see my history

barren oxide
visual island
slate swan
small igloo
tacit horizon
barren oxide
#

u wont understand

visual island
small igloo
visual island
barren oxide
#

if i don't spam i will always get irritated

small igloo
slate swan
tawdry perch
visual island
#

!d sqlite3.Connection.execute

small igloo
unkempt canyonBOT
#

execute(sql[, parameters])```
This is a nonstandard shortcut that creates a cursor object by calling the [`cursor()`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.cursor "sqlite3.Connection.cursor") method, calls the cursor’s [`execute()`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.execute "sqlite3.Cursor.execute") method with the *parameters* given, and returns the cursor.
barren oxide
tacit horizon
visual island
#

hmm, should work eitherway

tawdry perch
barren oxide
#

/recources

#

i wanttttttttt

small igloo
visual island
#

nah, my mistake

barren oxide
#

jhmf

tawdry perch
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.

tacit horizon
barren oxide
#

thank

visual island
#

@small igloo have you commited the INSERT INTO statement?

barren oxide
#

(phew)

slate swan
slate swan
barren oxide
barren oxide
gloomy ferry
#

!rtfm

barren oxide
gloomy ferry
#

.rtfm

barren oxide
visual island
barren oxide
visual island
small igloo
barren oxide
#

invis msg

small igloo
visual island
#

huh?

slate swan
# visual island can you show your updated code?
anti_add = 'on'
@client.event
async def on_message(message):
    global anti_add
    if ".link" or 'discord.gg' or '.com' or 'xyz' or 'www.' or 'www' in message.content.lower():
        if anti_add == 'on':
            await message.delete()
            await message.channel.send("dont spam links!")
            await client.process_commands(message)
tawdry perch
small igloo
visual island
#

yea

barren oxide
visual island
#

below it put conn.commit()

unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
barren oxide
#

~can i not what?~

tawdry perch
small igloo
barren oxide
#

ok

small igloo
barren oxide
#

~i know html5~

visual island
#

below <cur/conn>.execute()

barren oxide
#

hi

slate swan
small igloo
visual island
small igloo
visual island
small igloo
visual island
slate swan
barren oxide
sullen shoal
#

when i opened the channel for a sec i thought im in #databases

barren oxide
#

lol

small igloo
visual island
#

no

slate swan
visual island
#

bruh this is getting confusing

visual island
small igloo
#

btw imma sleep, gn all

visual island
barren oxide
#

😥

small igloo
visual island
visual island
small igloo
tawdry perch
#

gn 👋

visual island
tawdry perch
#

finally the spam is gone

visual island
#

yeah just ignore things like that and they will eventually leave

tawdry perch
#

I just press the block most of time

#

I made a temp mute command once and now the whole thing is broken down (database broke)

#

is there a method to get a cog by name?

#

and unload it after

visual island
#

yea get_cog exists

#

!d discord.ext.commands.Bot.get_cog

unkempt canyonBOT
slate swan
#

in <string>' requires string as left operand, not tuple py anti_add = 'on' @client.event async def on_message(message): global anti_add if ('www','https','.com','link','xyz','www.','.link','.gr') in message.content.lower(): if anti_add == 'on': await message.delete() await message.channel.send("dont spam links!") await client.process_commands(message) @visual island

slate swan
#

your saying if tuple in message content

#

its like doing py if [python discord\'s members] in Mr.Katsaa:

visual island
#

no they want to see if a string in the content

tawdry perch
slate swan
#
if list in "str":

is what your doing

visual island
#

any() is the best

valid barn
#

what does this error mean and how can i fix it?

@client.command()
async def buy(ctx, itemm):
  await register(ctx.author)
  users = await get_bank_data()
  bal = users[str(ctx.author.id)]["balance"]

  for i in range(len(shopp)):
    if itemm.lower() in shop[i]:
      item = shop[i]
      break
visual island
#

shop is a command

slate swan
#

oh users is defined , so its shop

slate swan
#

its correct , but too less spaces used

visual island
#

it is correct isn't it

slate swan
#

mhmm

#

but is it following pep8?

slate swan
# slate swan if message content in tuple

so like this py anti_add = 'on' @client.event async def on_message(message): global anti_add if message.content.lower in ('www','https','.com','link','xyz','www.','.link','.gr')(): if anti_add == 'on': await message.delete() await message.channel.send("dont spam links!") await client.process_commands(message)

#

?

valid barn
#

i think its how i pasted it

sullen shoal
#

why is it itemm instead of item are you doing some global shit

whole sparrow
#

how does one add the commands of a discord bot into the / commands

slate swan
visual island
slate swan
visual island
#

!PEP 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

sullen shoal
#

it aint

slate swan
sullen shoal
#

it is supposed to be 4 spaces

#

but thats 2

slate swan
#

yep

slate swan
visual island
#

Use 4 spaces per indentation level.

#

yea

slate swan
#

has been months

#

yup

whole sparrow
quaint epoch
#

I have a question

slate swan
#

!pypi disnake is what i'd suggest or other forks like nextcord / pycord etc

unkempt canyonBOT
whole sparrow
#

thats acc really sad i didnt know that

slate swan
slate swan
slate swan
quaint epoch
#

in a command if i use py await asyncio.sleep(10) will it wait 10 seconds but still asynchrnously run the command?

whole sparrow
quaint epoch
slate swan
#

as when the command is invoked the time restarts

#

youll need a db to store the time

sullen shoal
#

not really

quaint epoch
visual island
#

no, it will create a different object

quaint epoch
visual island
#

a different task

slate swan
visual island
#

mb

whole sparrow
sullen shoal
#

it will call the function every time someone invokes the command

whole sparrow
#

rip

sullen shoal
#

the other function's session will still be running

quaint epoch
sullen shoal
#

that's what async is

#

you do not tbh

quaint epoch
slate swan
#

but , if your bot restarts , it wont continue with the function's older session.

#

thats why you need a db

sullen shoal
# slate swan then how?

python handles all that, it will wait 15 minutes then remove it but meanwhile the script will be running fine

quaint epoch
sullen shoal
#

you can call the function again

slate swan
quaint epoch
slate swan
sullen shoal
slate swan
#

i suppose hes trying to make a func that will add a role sleep with asyncio and then remove it

slate swan
#

because its just 15 minutes

slate swan
#

jk

quaint epoch
slate swan
whole sparrow
#

is pycord one of the best maintained forks of discord.py?

gaunt ice
#

yes

slate swan
whole sparrow
#

coolio, ty for letting me know

#

idk any other forks thats why

slate swan
#

wouldnt say best but it is a good fork

slate swan
whole sparrow
#

oh alrighty

slate swan
#

!pypi disnake

unkempt canyonBOT
whole sparrow
#

coolio ill go have a look at both of them

#

ty for letting me know

slate swan
#

has buttons and slash command and same syntax

quaint epoch
#

what are the benefits of disnake/pycord vs discord.py?

manic wing
#

slash commands

slate swan
sullen shoal
quaint epoch
#

is discord.py and disnake very similar, because i don't want to rewrite 1010 lines of code.

sullen shoal
#

change the imports, you're good to go

quaint epoch
slate swan
#

its pretty easy

quaint epoch
slate swan
#

and most ides have a find and replace which makes it easier

sullen shoal
#

even notepad

slate swan
#

or just import disnake as discord lol

slate swan
#
 await ctx.send("A", components=[Button(style=ButtonStyle.URL, label="Steam", url="url1",), Button(style=ButtonStyle.URL, label='Paypal', url='url2')])
    interaction = await bot.wait_for(
        "button_click", check=lambda inter: inter.custom_id == "button1" "button2"
    )
    await interaction.send(content="Button Clicked")```
the buttons are horizontol how do I make it vertical?
quaint epoch
sullen shoal
#

also what lib are you using

slate swan
#

just a sm0L doubt , is disnake's old method of making slash command deprecated ? or both new and old methods work

slate swan
sullen shoal
#

idk then, use some forks (discord.py 2.0.x will have everything except slash cmds)

slate swan
#

disnake however, yes

quaint epoch
#

what's the best discord.py fork i could alternatively?

quick gust
#

disnake

whole sparrow
#

yeah im looking at disnake its looking great

quaint epoch
full valley
quick gust
#

no

full valley
#

whys that?

slate swan
# full valley not pycord?

the only thing pycord does better than disnake is the advertising, all they got is popularity and shit code

full valley
#

lmao

slate swan
#

kraots always on the go :^)

slate swan
#

i am chill wdym 👁️

sullen shoal
#

i heard they use converters to even typehint args as int, is that true

slate swan
#

never used pycord , so cant say

sullen shoal
#

they did unnecessary shitty changes to imports thats for sure

#

pycord.Bot lol

west shuttle
#

Im trying to do thanks system:

thanks = await self.db.execute("SELECT thanks FROM thxcounter WHERE user_id = ?", (member.id,))
await self.db.execute("INSERT INTO thxcounter (thanks, user_id, guild_id) VALUES (?, ?, ?)", (thanks + 1, ctx.member.id, ctx.guild.id))

Its giving me this error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for +: 'Cursor' and 'int'
full valley
#

Well one shit thing with pycord is that you cant have multiple of the same named cogs at the same time

sullen shoal
#

discord.py was an api wrapper of the entire discord api
commands is just a command handler for bots it should have remained as an extension

quick gust
slate swan
west shuttle
slate swan
#

you can add ints only with ints

pulsar moth
#

Hello guy how are you ?

I'm learning to develop discord bot in python but I wonder

#

how Can I make the bot handle multiple servers ?

west shuttle
sullen shoal
#

they handle all the sharding

visual island
west shuttle
slate swan
#

can anyone tell how to fix dat

sullen shoal
#

!d discord.Guild.kick

unkempt canyonBOT
#

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

Kicks a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

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

not discord.ext.commands.Bot.kick

slate swan
proven osprey
#

i want to create a text channel only for one user, like only one guy will see this channel. how to do this? will be very greatful!

visual island
pulsar moth
visual island
#

or fetchone

slate swan
slate swan
sullen shoal
boreal ravine
#

looking at r. danny's source code, what type of object is rows?

slate swan
# slate swan ...

your trying to kick a member which you have a arg as a member obj so use it

pulsar moth
#

ok so it's not possible to handle multiple discord server with discord.py ?

sullen shoal
pulsar moth
#

I mean, my problem is , if an admin want to modify the prefix of the bot

sullen shoal
#

¯\_(ツ)_/¯

velvet tinsel
#

Hey myxi

pulsar moth
#

I dont want it modify for ALL servers

slate swan
slate swan
velvet tinsel
#

Hi carrot

pulsar moth
#

wait the end haha

velvet tinsel
#

Okimii jam_cavedude

#

Cyberweapon jam_cavedude

slate swan
#

if people were to actually choose based on code, pycord would be at rock bottom

tawdry perch
pulsar moth
#

I want the bot be able to have different "setting" on different server

sullen shoal
# boreal ravine How would I? ok

github has some feature, hold the ctrl key then click on it, then it should pop the source code to that if its type hinted properly

slate swan
velvet tinsel
#

Ok

sullen shoal
pulsar moth
#

maybe on 1 server the admin want the bot to write in a B channel , but not on another

sullen shoal
velvet tinsel
#

What’s the problem

#

😳

sullen shoal
#

:/

velvet tinsel
#

Or is there no problem

#

Meh
Ok

sullen shoal
#

there probably isnt

velvet tinsel
#

Ok

#

GitHub copilot

sullen shoal
#

where you could like hold the ctrl key and click on the name and see what it returns

velvet tinsel
#

How does copilot work

#

Lmao

sullen shoal
#

it basically is trained with lots of code from stack overflow and stuff idk much about it tho

#

also not the right channel

velvet tinsel
#

Shit

#

Ok

#

Maybe it can code discord js for me

quaint epoch
#

So, when i try to log a message on the console it can't log dm's okay so i added a try/excepts blocks to and the except block contains a lot of errors, and the attributeerror but it still raises an attribute error because the dm guild has no id, so it raised an error instead of printing out 'log error', why?!

#

It doesn't log "log error" instead it raises an error, it just doesn't work

quaint epoch
cobalt jacinth
#

does printing to console slows down the bot ?

#

like when two people use commands same moment

cobalt jacinth
#

the console can only print one command output

quaint epoch
#

there aren't enough ppl in my server lol

sullen shoal
boreal ravine
#

printing something is like the lightest shit to do in python

sullen shoal
#
except (exc1, exc2):```
cobalt jacinth
#

two things cant print same time

#

imagine 7 people using same time

quaint epoch
#

That's the problem

sullen shoal
west shuttle
sullen shoal
#

!e print(None or "it should print this")

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

it should print this
sullen shoal
#

thats the job of or

cobalt jacinth
#

if 100 people use command same time

sullen shoal
#

use tuple.

sullen shoal
cobalt jacinth
#

console cant print all

#

it must wait

#

i am saying because i noticed my bot pausing to print the commands ran simulatenosly

quaint epoch
#

okay got it i think

sullen shoal
#

False or None basically

#

!e print(False or None or "its gonna print this")

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

its gonna print this
sullen shoal
#

!e
print("a string is truthy.", bool("str"))
print("however an empty one isnt.", bool(""))

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

001 | a string is truthy. True
002 | however an empty one isnt. False
west shuttle
#

@sullen shoal can u help me?

sullen shoal
#

with?

west shuttle
# sullen shoal with?

New code:

thank = await self.db.execute("SELECT thanks FROM thxcounter WHERE user_id = ?", (member.id,))
thanks = await thank.fetchall()
await self.db.execute("INSERT INTO thxcounter (thanks, user_id, guild_id) VALUES (?, ?, ?)", (thanks + 1, ctx.member.id, ctx.guild.id))

Error: TypeError: can only concatenate list (not "int") to list

sullen shoal
#

which line is the error from, whats the content of it

#

the line number is included in the traceback

west shuttle
sullen shoal
#

looks like thanks is a list?

slate swan
#

can anybody give me command ideas im kinda bored

slate swan
west shuttle
sullen shoal
#

print the type of it

#

!d type

unkempt canyonBOT
#

class type(object)``````py

class type(name, bases, dict, **kwds)```
With one argument, return the type of an *object*. The return value is a type object and generally the same object as returned by [`object.__class__`](https://docs.python.org/3/library/stdtypes.html#instance.__class__ "instance.__class__").

The [`isinstance()`](https://docs.python.org/3/library/functions.html#isinstance "isinstance") built-in function is recommended for testing the type of an object, because it takes subclasses into account.
west shuttle
sullen shoal
#

print(type(thanks))

#

do it in the code before the line that errors

slate swan
#

i like learning things slowly

west shuttle
#

Uh yea

sullen shoal
#

there it is, you cant basically add int with a list

slate swan
sullen shoal
#

!e
[] + 1

unkempt canyonBOT
#

@sullen shoal :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: can only concatenate list (not "int") to list
slate swan
#

im learning sqls syntax so i can go to sqlite3 and then jump to postgresql

upbeat otter
west shuttle
slate swan
sullen shoal
slate swan
west shuttle
sullen shoal
upbeat otter
upbeat otter
sullen shoal
#

!e
l = [1,2,3,4,5]
print(l[2])

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

3
sullen shoal
#

2 is the index, not to be confused

sick birch
slate swan
#

@slate swan im learning from sqlbolt and when i learn parts and find it a bit complicated i stop so i can understand it and then i start from the start and work my way more then the time before

upbeat otter
slate swan
#

pretty good

slate swan
#

i learned sql in my school lol

slate swan
sick birch
slate swan
devout iris
#

i want to make a command and it should be "when bot has logined, bot will send message to where i want"

sullen shoal
#

k

devout iris
#

yep

#

how can i make

sick birch
#

uh

slate swan
sick birch
#

It’s really simple

slate swan
#

!d discord.on_ready

unkempt canyonBOT
#

discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful and the [`Client.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.guilds "discord.Client.guilds") and co. are filled up.

Warning

This function is not guaranteed to be the first event called. Likewise, this function is **not** guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.
upbeat otter
#

smh

sick birch
#

The whole thing is 3 lines of code

slate swan
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
slate swan
sick birch
#

Doubt

slate swan
#

i think

devout iris
#

i know it but idk how can i set channel with id idk

slate swan
#

wait nvm

#

can do that in 2 lines . no less

sullen shoal
#

semicolon supremacy

sick birch
#

The decorator and function declarator is 2

slate swan
#

since 1 has to be the decorator surely

sullen shoal
#

exec

slate swan
#
@bot.event
async def on_ready():
    a = await bot.get_channel(int).send("msg")
#

what i would do

#

no even need for a var

upbeat otter
slate swan
#

@maiden fable wont work mr

sullen shoal
#

!e
def func(f): f()

exec("@func\ndef f():print('hello')")

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

hello
sullen shoal
#

hehe

maiden fable
slate swan
upbeat otter
#
@bot.event
async def on_ready(): return await bot.fetch_channel(int).send("msg")
maiden fable
#

yea saw it later

slate swan
#

lol

maiden fable
upbeat otter
slate swan
valid barn
#
@client.command()
async def buy(ctx, itemm):
  await register(ctx.author)
  users = await get_bank_data()
  bal = users[str(ctx.author.id)]["balance"]
  item = {}
  for i in range(len(shopp)):
    if itemm.lower() in shopp[i]:
      item = shopp[i]
      break

  name = item["name"]```
why?
upbeat otter
#

I am not dumb enough

#

lol