#discord-bots

1 messages Β· Page 831 of 1

slate swan
#

not sure how sorry

lapis meadow
#

I got it

#

It was import datetime not from datetime import datetime

#

Thanks for all the help @slate swan @maiden fable @quick gust

dreamy sluice
#

Anyone here know how I can find the row number in a sqlite3 table? (I am trying to use this in my bot for a queue function)

slate swan
dreamy sluice
#

Basically, I wanna find the index number of a particular field in a table, if that makes sense.

slate swan
#

you want to find a row by the position?

dreamy sluice
slate swan
dreamy sluice
#

Wait no-

dreamy sluice
#

I wanna find the position of a row

slate swan
#

πŸ‘οΈ πŸ‘οΈ

#

why

dreamy sluice
#

I wanna make a Queue command, which returns the position of a row in the db file

slate swan
#

so users can access your db?

dreamy sluice
#

Like, the command itself gives the info (the user_id, and some other parameters)

#

I wanna find the position of any row which has the matching data

slate swan
#

sql?

dreamy sluice
#

I know how to use the SELECT command

dreamy sluice
slate swan
#
f"SELECT * FROM TABLE WHERE USERID = {ctx.author.id};"
dreamy sluice
#

I wanna find the position of it

slate swan
#

not sure why youll need the position of a row and not sure if you can

dreamy sluice
slate swan
#

well you get all the rows and use .index() which returns the position of the row

#
async for row in cursor:
    row.index(ctx.author.id)
maiden fable
#

It returns a list of tuples, forgot?

slate swan
lapis meadow
#

TypeError: on_message_edit() missing 1 required positional argument: 'message'

maiden fable
#

Remove the message arg

lapis meadow
maiden fable
#

U already got 2 message objects, why u need a third one πŸ˜‚

lapis meadow
#

but now I have the error at the bottom

maiden fable
#

message_before.author.id

lapis meadow
#

o

#

File "c:\Users\13129\Desktop\Python Bot\Sloth.py", line 69, in on_message_edit
embed=discord.Embed(title=f" edited a message {message_before.member.name}", color=0xffff)
AttributeError: 'Message' object has no attribute 'member'

maiden fable
#

author bro

#

Not member

lapis meadow
#

just got it lol

rotund nova
#

Hello! I have that command

@bot.event
async def on_member_join(member):
    channel = bot.get_channel(942595754613149726)
    embed = discord.Embed(title=f"Witamy!", description=f"> Hej! {member.mention} witamy Cię na naszym serwerze, mamy nadzieję że będziesz się dobrze bawić!", timestamp=message.created_at, colour=0xff5252)
    embed.set_footer(icon_url="https://cdn.discordapp.com/icons/790998344268513292/c77b0abd957d8d5d1dbed207023886f0.png?size=4096", text="McZone.pl")

    await channel.send(embed=embed)
``` on what can i change timestamp=__message__.created_at ?
#

because this is not async def on_message and i dont have idea

manic wing
rotund nova
#

thank u, i try

lapis meadow
#

Make sure you import datatime

rotund nova
#

yes yes i know

silk goblet
#

hey, so i have a discordbot and i want to make a button which can copy a text into the button clickers (so not the host but anybody who can click the button) clipboard

rotund nova
#

@manic wing thats works, thank u very much

silk goblet
manic wing
silk goblet
#

i have a string and i have a button in discord. anybody on the server can press this button and then i want to paste the text into the the persons clipboard

#

like i have a message and below this message is a button that says copy and if you click it and press <strg>+v the message from above is there

slate swan
#

im not sure if a bot user has access to your clipboard

#

you can send them the msg ig

silk goblet
#

oh, but i can make it a link and if you press it it asks you to open or copy and then you can copy, can't you?

#

ups, nope. Doesn't work

rotund nova
#

hi again
i have that and not works
embed.set_thumbail(url="https://cdn.discordapp.com/icons/790998344268513292/c77b0abd957d8d5d1dbed207023886f0.png")

#

whats wrong?

#

ty

manic wing
#

wait

#

ignore that

rotund nova
#

hm

rotund nova
#

ooh

#

i try, wait

#

thats works thanks!

slate swan
vale wing
#

!d discord.TextChannel.set_permissions

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...
vale wing
#

But better use overwrites param in create_text_channel

#

!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...
cyan ermine
#

how to set thumbnail as user avatar

vale wing
#

Just use user.avatar.url

cyan ermine
#

in {} ?

green bluff
#

help pls

vale wing
#

The first argument is Member or Role

placid skiff
green bluff
vale wing
green bluff
#

ye

vale wing
green bluff
vale wing
#

The thing that automatically formats the argument and puts it into the query

#

No

#

Why are you str'ing it

#

You don't need to

#

And wrong function

#

@green bluff so basically

con.execute('INSERT INTO users (id, name) VALUES (?, ?)', (12345, 'good guy'))```
The `?`s will be replaced with arguments you provide in the tuple
```py
"INSERT INTO users (id, name) VALUES (12345, 'good guy')"```
keen talon
cyan ermine
#
client = commands.Bot(command_prefix=commands.when_mentioned_or('a!'))```
it ain't workin
vale wing
#

I would personally make another function that would accept arglist because tuples are crazy inconvenient if you ask me

cyan ermine
#

nor prefix nor after mentionin

#

can any1 sort it out?

#

i tried a! and mentionin it but didn't work

vale wing
#
await stuff.create_text_channel('the name of channel', overwrites={user: discord.PermissionsOverwrite(send_messages=True, read_messages=True, ...))```
cyan ermine
#

can you help meh with my code

green bluff
cyan ermine
#
client = commands.Bot(command_prefix=commands.when_mentioned_or('a!'))``` 
any1?
vale wing
#

!d sqlite3.Cursor.execute

unkempt canyonBOT
#

execute(sql[, parameters])```
Executes an SQL statement. Values may be bound to the statement using [placeholders](https://docs.python.org/3/library/sqlite3.html#sqlite3-placeholders).

[`execute()`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.execute "sqlite3.Cursor.execute") will only execute a single SQL statement. If you try to execute more than one statement with it, it will raise a [`Warning`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Warning "sqlite3.Warning"). Use [`executescript()`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.executescript "sqlite3.Cursor.executescript") if you want to execute multiple SQL statements with one call.
green bluff
#

as when mentioned

cyan ermine
#

i got it in disnake library

green bluff
#

even with disnake that literally makes no sense

maiden fable
#

What

vale wing
#

!d disnake.ext.commands.when_mentioned_or

unkempt canyonBOT
#

disnake.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

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

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
green bluff
#

oh

#

sheesh

cyan ermine
#

see my code correct but still

vale wing
#

Define not work

#

No reacting to anything?

#

Woah woah

#

Don't

hidden stump
#

message.startswith for commands

#

XD

vale wing
hidden stump
vale wing
#

Don't watch that tutorial

cyan ermine
#

well none of my command respond to it

vale wing
#

Probably outdated or done by a stupid person

hidden stump
#

or both

cyan ermine
#

when i mention it or trigger command with prefix

vale wing
#

Check the one I sent above

cyan ermine
#

wait

vale wing
#

Outdated

hidden stump
#

@client.command()

vale wing
vale wing
#

It should be Bot

hidden stump
#

preference

#

i prefer client

vale wing
#

Not really

cyan ermine
#

I too prefer client

vale wing
#

Bot is a subclass of client

hidden stump
#

client = discord.Bot

#

just visual

vale wing
#

I mean you can call the variable whatever you like, but it should be commands.Bot

hidden stump
#

oh yeha

#

whats the difference between those two?

vale wing
#

The Bot is the subclass of Client and implements some functionality

#

Check docs for both classes and compare them

hidden stump
#

oh so its better

vale wing
#

Yeah

cyan ermine
#

how to define "Context" ?

hidden stump
#

async def hello(ctx):

cyan ermine
vale wing
#

It is passed as first attribute of command func

hidden stump
#

its like self in classes

cyan ermine
#

i just started py

vale wing
#

Oh

#

Then I don't recommend starting it from discord bot

cyan ermine
#

Like im doin py for a week

vale wing
#

You should get intermediate python knowledge first

cyan ermine
#

I learnt, kick,ban and slash command

hidden stump
#

just use (ctx, yourargs) with your def's if its a command

vale wing
#

Cause it's an advanced async application that requires a decent knowledge

cyan ermine
#

im tryin prefix mention bot thingy

hidden stump
cyan ermine
#

lol

hidden stump
#

people like the async-await ability tho i guess

vale wing
#
@bot.command()
async def command(ctx: commands.Context, arg1, arg2, ...):
    ctx <- is context```
unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

hidden stump
#

do you need to specify it as commands.Context?

vale wing
#

It's a typehint

#

Preference

cyan ermine
#

ty @vale wing

vale wing
#

I usually typehint literally everything for code editing convenience

prisma spoke
#

who here knows wavelink?

cyan ermine
#

commands.Context worked

hidden stump
#

does this mean it will run lets say a different command?

maiden fable
prisma spoke
#

https://wavelink.readthedocs.io/en/1.0/exts/spotify.html

trying to use spotify support in wavelink music sys but cant figure out that which attribute to use in track? for example in yt it was

    @commands.command()
    async def play(self, ctx: commands.Context, *, track: wavelink.YoutubeTrack:
        print(track)```

in spotify which it wud be?
`track: spotify.Spotify...?`
prisma spoke
maiden fable
#

Against ToS

rotund nova
#

i want bot find message and add reaction on that, when someone click same reaction bot add role someone have idea?

hidden stump
#

cuz if it continues the same function it might break, right?

prisma spoke
maiden fable
prisma spoke
#

lavalink

prisma spoke
#

nice edit

#

which lib shud i use then

vale wing
unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
green bluff
vocal snow
rotund nova
#

but bot must find message with id

green bluff
#

for them

vale wing
#

@green bluff yeah read that doc

green bluff
#

isnt f string just easier

prisma spoke
maiden fable
spring flax
#

what's the way to send a message from the api?

prisma spoke
maiden fable
hidden stump
#

.send() i guess

prisma spoke
#

aiohttp sorr

hidden stump
#

oh

maiden fable
#

Lol

vocal snow
prisma spoke
#

its aiohttp

hidden stump
#

so basically "use await if you want other stuff to run while waiting for a response from 3rd party stuff", so like a response from discord in that case

vale wing
# green bluff isnt f string just easier

As for SQLite it is probably ok as there are not many types, and you would only need to add quotes around strings, but when it comes to more complicated databases with more complicated types (like postgres), the injections are way more convenient

hidden stump
vale wing
#

The standard is to use injections and not the f strings

hidden stump
#

or just different ones then

green bluff
#

but can u help me with this

#

how to delete old prefix

vale wing
vocal snow
jade tartan
#

Hi, I have if i have an issue with code error for discord dashboard is this the right channel or do i have to go to #web-development ?

vale wing
vocal snow
vale wing
#

Also use aiosqlite for bots after you get used to normal one

#

!pypi aiosqlite

unkempt canyonBOT
vale wing
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
vocal snow
vale wing
#

Quart

#

I'd personally make a site and API that's cooler 😎

#

But I suck at design

jade tartan
#

nope this is for my discord dashboard

vale wing
#

@jade tartan print discord.__version__

jade tartan
#
from quart import Quart, render_template, redirect, url_for
from quart_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
from nextcord.ext import ipc
import nextcord

app = Quart(__name__)

app.secret_key = 
print(os.environ["OAUTHLIB_INSECURE_TRANSPORT"]) == "true"

app.config["DISCORD_CLIENT_ID"] = 
app.config["DISCORD_CLIENT_SECRET"] = ""
app.config["DISCORD_REDIRECT_URI"] = ""
app.config["DISCORD_BOT_TOKEN"] = ""

discord = DiscordOAuth2Session(app)

@app.route("/login/")
async def login():
    return await discord.create_sessions()

@app.route("/callback/")
async def callback():
    try:
        await discord.callback()
    except:
        return redirect(url_for("login"))
    return redirect(url_for("dashboard"))
vocal snow
#

I have never use quart_discord

jade tartan
#

Hey!
Thanks for watching todays video, todays video I really hope you enjoyed and join my discorddd :) Also thank you SO MUCH for 1370 subscribers!!

LINKS -
Join my Discord - https://discord.gg/twHW4UUJGq

Nextcord Server - https://discord.gg/Ucmae5Kbwb

Set Up VSC - https://www.youtube.com/watch?v=KpzkP...

Set Up PYTHON - https://youtu.be/h4...

β–Ά Play video
jade tartan
vocal snow
#

so I can't help you with this

jade tartan
#

@vale wing ^^

slate swan
#

how to make this:)

vocal snow
#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
vocal snow
#

you can use this to wait for a reaction, then send a message

slate swan
#

i did but it wont work hehe

vocal snow
#

can you send what you tried?

slate swan
vocal snow
#

your check needs to check if user == ctx.author

#

message is a str

slate swan
#

so..

#

i guess

boreal ravine
slate swan
vale wing
#

You need to set the read_messages to False for guild.default_role

slate swan
vale wing
#

And could you like read the docs

vale wing
#

You should learn how to get info from docs

#

I gave you 2 links

#

!d discord.TextChannel.set_permissions

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
#
@bot.command(aliases=["rec"])
async def recruit(message):
        await channel.send('react to this message')

        def check(reaction, user):
            return user == message.author and str(reaction.emoji) == 'πŸ‘'

        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await channel.send('πŸ‘Ž')
        else:
            await channel.send('πŸ‘')```
vale wing
#

!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...
vale wing
#

The ctx should be the first argument

boreal ravine
#

messy

vale wing
#

And you access message by ctx.message

slate swan
# vale wing Um
async def recruit(ctx):
        await ctx.send('react to this message')

        def check(reaction, user):
            return user == message.author and str(reaction.emoji) == ':thumbsup:'

        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await ctx.send(':thumbsdown:')
        else:
            await ctx.send(':thumbsup:')```
#

like this?

#

im confused now brainmon

vale wing
#

You need to change the check function now

nimble plume
#

Im here

vale wing
#

As you don't have message defined

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

vale wing
#

It should be ctx.message

nimble plume
#

For better understanding u can use this

vale wing
#

Look in the docs what you need to parse to there

nimble plume
#

overwrite.permissions = True also u can use

vale wing
#

Yeah

#

See the power of docs

slate swan
vale wing
#

Wait no

slate swan
#

πŸ—Ώ

vale wing
#

I mean check function

#

!d discord.ext.commands.Context check docs

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
nimble plume
vale wing
#

Everyone role

#

The bot's Member object in the guild

slate swan
#

yert confuse

#

so i need ctx only or with message also

#

in the pramter

vale wing
#

You can provide it as a key to your dict

#
interaction.user: discord.PermissionOverwrite(read_messages=True)``` ex
#

Just get the role object

#

!d discord.Guild.get_role

unkempt canyonBOT
vale wing
#

Nope

#

The object must be Role not the int

heavy fox
#

you need ctx

#

oh nvm

#

wrong message

stray path
#

Hello can anyone link me to a good tutorial on how to make discord bots with cogs and classes, thank you.

vale wing
#

How is Role defined

#

I meant you need to parse object of that type

vale wing
#

Not the actual type

slate swan
#

they have series

vale wing
#

And you get that object from Guild.get_role

vale wing
heavy fox
# slate swan ```py @bot.command(aliases=["rec"]) async def recruit(message): await ch...
@bot.command(aliases=["rec"])
async def recruit(ctx):
        await ctx.channel.send('react to this message')

        def check(reaction, user):
            return user == ctx.message.author and str(reaction.emoji) == 'πŸ‘'

        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await ctx.channel.send('πŸ‘Ž')
        else:
            await ctx.channel.send('πŸ‘')

This works if thats what you are looking for

stray path
vale wing
slate swan
vale wing
#

The forks add features and not remove them mostly

stray path
#

Official discord.py not supported anymore tho right?

vale wing
#

Yes

stray path
#

Ook ok thanks

vale wing
#

You can learn forks after you learn base why not

slate swan
stray path
#

yeah yeah

slate swan
#

mind if you add me as friends?

heavy fox
slate swan
#

yea

heavy fox
#

i feel good helping you here

slate swan
brittle axle
slate swan
#

just like this

brittle axle
#

i used to use discord.py but i wanted timeouts so i switched to nextcord

stray path
#

k

vale wing
#

And Guild must be an object as well

heavy fox
# slate swan just like this
@bot.command(aliases=["rec"])
async def recruit(ctx):

        message = await ctx.channel.send('react to this message')
        await message.add_reaction('πŸ‘')
        await message.add_reaction('πŸ‘Ž')

        def check(reaction, user):
            return user == ctx.message.author and str(reaction.emoji) == 'πŸ‘'

        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await ctx.channel.send('πŸ‘Ž')
        else:
            await ctx.channel.send('πŸ‘')
        
``` Now it adds reactions to the message, when you press πŸ‘ it responds with πŸ‘
vale wing
#

May I ask what is your python knowledge

vale wing
#

Then don't start learning python from making discord bot

#

It is complicated for beginners

heavy fox
slate swan
heavy fox
#

ill try for you thogh

slate swan
#

I see

nimble plume
#
  File "c:\Users\hp\Desktop\bot\logs.py", line 18, in on_message_delete
    embed.set_author(name=f"{message.author}", icon_url=f"{message.author.avatar.url}")
AttributeError: 'NoneType' object has no attribute 'url'
#

how message.author not working

jade tartan
#

So what should i do about this

#

?

slate swan
#

bro may i ask what is the code for delete the bots msg?

nimble plume
slate swan
#

i want to change line 70 from reaction to delete

#

is it um message.channel.delete

fast vortex
#

No that deletes the channel

#

What do you want to delete? The message?

maiden fable
nimble plume
#

..

nimble plume
slate swan
nimble plume
#

lemee show u code

fast vortex
#

Use that instead of .avatar

nimble plume
#
    @commands.Cog.listener()
    async def on_message_delete(self, message):
     embed = disnake.Embed(description=f"**Message Sent by {message.author.mention} Deleted in** <#{message.channel.id}> \n Message : {message.content}",color=aqua,timestamp=datetime.utcnow())
     embed.set_author(name=f"{message.author}", icon_url=f"{message.author.avatar.url}")
     await channelslogs.send(embed=embed)
fast vortex
#

If the user has a default avatar then .avatar will return None

nimble plume
fast vortex
slate swan
#

and um what is the reactor called, example who run the command is author.

nimble plume
#

default avatar

fast vortex
nimble plume
#

it will return none?

#

i have no avatar cuz

#

??

fast vortex
#

There's a difference in what I'm telling you to use and what you're already using

slate swan
fast vortex
unkempt canyonBOT
#
Not in my house!

No documentation found for the requested symbol.

fast vortex
#

!d discord.ext.commands.Context.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
fast vortex
#

There

fast vortex
nimble plume
fast vortex
#

Yw

slate swan
#

and um the react thing

nimble plume
#

and server avatar?

slate swan
#

its not author right

nimble plume
#

F

slate swan
#

i want to mention

#

so what do i use :3

#

πŸ‡«

lyric tusk
slate swan
lyric tusk
potent spear
# slate swan not user.name?

you have to think about some other things too
for example:
how long do you want the bot to reply when someone reacts?
...

slate swan
#

So after a minute right

potent spear
#

good maths

fervent shard
#
@bot.listen()
async def on_message_delete(message):
    embed=discord.Embed(description=f"{} deleted a message".format(message.author.name) color=0)
    embed.add_field(name= message.content ,value="This is the message that he has deleted", inline=True)
    channel=bot.get_channel(943385924052602880)
    await channel.send(channel, embed=embed)```error:
```  File "main.py", line 34
    embed=discord.Embed(description=f"{} deleted a message".format(message.author.name) color=0)
                                                                                        ^
SyntaxError: invalid syntax```
fervent shard
# potent spear a comma
    embed=discord.Embed(description=f"{} deleted a message".format(message.author.name), color=0)
                                    ^
SyntaxError: f-string: empty expression not allowed```
potent spear
#

you should know what f strings are by now, I've seen you here before

shit_times = "daily"
print(f"I shit {shit_times}")
# is the same as
print("I shit {}".format(shit_times))```
tough lance
#

I'm here after a very long time.

slate swan
#
async def f(ctx):

        message = await ctx.channel.send("F kawan kawan:Empe_MafuSad:", delete_after=60)
        await message.add_reaction('πŸ‡«')

        def check(reaction, user):
            return user == ctx.message.author and str(reaction.emoji) == 'πŸ‡«'

        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await ctx.channel.send('f banget')
        else:
            await ctx.channel.send('πŸ‡«, Respect by {}'format(user.name))
        ```
#

I cannot use it :)

potent spear
lyric tusk
slate swan
#

already

#

but, the others wont get the response

#

only me

potent spear
# slate swan

think about what you're doing in your code pls
it only does it once, you don't have a while loop
you're waiting for ONE reaction, then the waiting is done

slate swan
#
@bot.command()
async def f(ctx):

        message = await ctx.channel.send("F kawan kawan:Empe_MafuSad:", delete_after=60)
        await message.add_reaction(':regional_indicator_f:')

        def check(reaction, user):
            return user == ctx.message.author and str(reaction.emoji) == ':regional_indicator_f:'

        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await ctx.channel.send('f banget')
        else:
     while True:
            await ctx.channel.send(':regional_indicator_f:, Respect by {}'.format(user.name))```
#

like this?

potent spear
#

ofc not

#

you have to while loop the whole wait_for stuff

#

think first, then code

#

I also highly suggest you to clear the reactions after the timeout is over

#

it's guild.default_role

nimble plume
#

how to get display avatar of guild

potent spear
nimble plume
#

if the server has no avatar

nimble plume
potent spear
#

try and see

nimble plume
potent spear
# nimble plume ?

well, what's the use of displaying a default avatar if there isn't one?

potent spear
nimble plume
potent spear
#

error says it all, no?

#
async def button_callback(interaction):
    new_text_channel = await interaction.guild.create_text_channel(str(interaction.user))
    await new_text_channel.set_permissions(interaction.guild.default_role, view_channel=False)```
the channel name is pretty bad imo, since it can cause issues, like idk for sure if a # can be in a channelname
#

ofc, your bigbrain set view_channel to False

#

you can do the following:

nimble plume
#

voice channel limit ?

potent spear
#

nope

#
overwrites = {
  guild.default_role: discord.PermissionOverwrite(view_channel = False),
  interaction invoker: discord.PermissionOverwrite(view_channel = True),
  guild.me: discord.PermissionOverwrite(view_channel = True)}
await interaction.guild.create_text_channel(name=..., overwrites=overwrites)
#

this is obviously not something to simply copy paste, you need to edit some stuff

#

you'll see...

#

name is ...
interaction invoker
...

#

guild is probably undefined too, ...

#

yeah, your indentation is off, that's why you don't copy paste

slate swan
#

I love your code indents

potent spear
#

just type it out, you can't make mistakes that way

#

you'll also LEARN what you coded, instead of just copy pasting

slate swan
#

Use a code formatter

potent spear
#

also, make sure you know what you typed
for example
I doubt you know what guild.me is or why I put it there

slate swan
#

help me guys

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

rip pip

#

πŸ˜”

#

Also, see the channel name, thanks

grim oar
slate swan
slate swan
grim oar
#

oh

potent spear
maiden fable
#

python -m pip

grim oar
#

python -m pip install discord.py

maiden fable
grim oar
#

both work

#

iirc

potent spear
#

buzzer

maiden fable
#

Discord is a mirror package

grim oar
#

Oh ok

potent spear
#

you have to replace that with the user who clicked the button ofc

#

try and see

#

yup, now it's just interaction.guild instead of just guild 🧠

#

**interaction.**guild

#

last line needs to also be IN the function

#

cur.execute("INSERT INTO members WHERE id = ?", inter.author.id)

#

you know how to do this without python? show me first

#

plain SQL

#

well, show me

#

a 1 line example

#

of how you would insert

#

not what I asked tho

#

you do, as you mentioned

grim oar
#

What are you trying to ask...

vocal snow
#

hi nova

grim oar
#

Who you

potent spear
#

what're your columns in "members" and what exactly do you want to add in the existing row?

grim oar
#

do you want some way of doing it without sql queries?

potent spear
vocal snow
#

UPDATE

potent spear
#

correct, but let him figure

#

that's a terrible thought process

vocal snow
#

then not UPDATE

potent spear
#

you want EVERY row to have the same columns, you DON'T want some rows to not have certain columns while others do in the same table

#

you have to rethink your data model
I suggest to use an extra table for the verification stuff

#

so table VERIFICATION has an ID, ...

vocal snow
#

@grim oar can u help me

grim oar
#

No

vocal snow
#

ok

grim oar
#

can you help me @vocal snow

vocal snow
#

No

grim oar
#

ok

vocal snow
#

@grim oar can u show me how to run shards in seperate threads

grim oar
#

No lol

vocal snow
#

ok

quick gust
#

lmao

small igloo
#
@bot.command()
async def top(ctx):
    users = []
    async with ctx.typing():
        lb = discord.Embed(title="leaderboard", description="top salcash players", color=ctx.author.color)
        l = database.length()
        for i in range (int(l)):
            s = database.get(i)
            user = await bot.fetch_user(s)
            level = database.check_level(s)
            o = user.display_name
            users.append((o, level))
        users.sort(key=lambda a: a[1], reverse=True)
        leaderboard = map(lambda user: user[0] + " level: " + str(user[1]), users)
        g = list(leaderboard)
        ln = len(g)
        for i in range (ln):
            lb.add_field(name=i+1, value=g[i], inline=False)
        await ctx.send(embed=lb)```


tf wrong
potent spear
small igloo
potent spear
#

but it most likely means you forgot an await somewhere

small igloo
# potent spear but it most likely means you forgot an `await` somewhere
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 167, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\User\Downloads\PycharmProjects\main.py\main.py", line 1224, in top
    g = list(leaderboard)
TypeError: 'coroutine' object is not iterable

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

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Downloads\PycharmProjects\main.py\main.py", line 117, in on_command_error
    raise error
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 894, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 176, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'coroutine' object is not iterable```
potent spear
quick gust
#

?

small igloo
#

what

small igloo
# potent spear print leaderboard, it's probably not what you think
<coroutine object Command.__call__ at 0x000001E13886CF20>
C:\Python310\lib\site-packages\discord\ext\commands\core.py:167: RuntimeWarning: coroutine 'Command.__call__' was never awaited
  ret = await coro(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
visual island
#

!rule 6 thanks

unkempt canyonBOT
#

6. Do not post unapproved advertising.

potent spear
small igloo
potent spear
#

the VERIFICATION table should in relation with the members table

potent spear
small igloo
potent spear
#

since you probably want to "add extra columns" when he's verified or whatever
instead you only add stuff in the extra table if the user is verified

#

well, what's your goal?

#

that's insert into <table name>

#

now be concrete pls

#

example:

#

if a user verified, I want to change the verified column from False to True and add ...

#

hear me out: why don't you just only add users once they're verified? what's the use of adding users that aren't verified?

#

what's the use of storing an unverified user?

#

hmm alright, so now, isn't it a bit more useful to only store verified users? since unverified users don't really have an extra value to the db

marble pilot
#

how do i get the missing role from commands.Missing role

potent spear
#

I'm asking you these questions so you SEE why it would be useless to store unverified users when they don't contain useful info...

#

what useful data does an unverified user have?

#

in the long run, you could have thousands of AFK accounts in your db, because they joined once and are now just catching dust

#

still...

#

which is?

#

so just nothing actually
my thought process
if user not in DB => unverified

small igloo
potent spear
potent spear
#

that's why the members table should contain 2 columns:
guild_id user_id

small igloo
#

and sort

potent spear
small igloo
# potent spear are you sure a map is iterable and the elements in the map are not coroutines (s...
@bot.command()
async def top(ctx):
    users = []
    async with ctx.typing():
        lb = discord.Embed(title="leaderboard", description="top salcash players", color=ctx.author.color)
        l = database.length()
        for i in range (int(l)):
            s = database.get(i)
            user = await bot.fetch_user(s)
            level = database.check_level(s)
            o = user.display_name
            users.append((o, level))
        users.sort(key=lambda a: a[1], reverse=True)
        leaderboard = map(lambda user: user[0] + " level: " + str(user[1]), users)
        print(leaderboard)```

i...dk?
potent spear
nimble plume
#

how do i do

small igloo
potent spear
#

ofc, you only execute db commands when the user is in the server? I don't get your point

nimble plume
#

i have a emty list
else not going??

if ctx.author.id == ownvc[0]:
potent spear
nimble plume
#

my list is empty thats why it said index out of range

small igloo
small igloo
nimble plume
small igloo
nimble plume
#

if this if didnt work go to else statement but it gives error and stop

#

should i use try except?

potent spear
small igloo
nimble plume
#

ok ill use try except

#

guys how to reload a variable???

small igloo
nimble plume
#

channel10 = something
channel10 = channel10
will it work?

small igloo
nimble plume
#

reload the varaible

potent spear
small igloo
nimble plume
small igloo
nimble plume
#

string varaiable

#

u send

small igloo
nimble plume
#

list is good

#

list.append(item)

small igloo
nimble plume
#

*list.append(item)

small igloo
#

ok?

nimble plume
#

list = []

#

no syntax error now

#

item = "dyno ka bhai"

small igloo
#

if to True and False, use comparator "=="

small igloo
small igloo
potent spear
small igloo
potent spear
#

seems fine, as long as the interaction.user refers to the user who clicked the button

potent spear
small igloo
# potent spear what happens when you print leaderboard tho?

<coroutine object Command.call at 0x000001E13886CF20>
C:\Python310\lib\site-packages\discord\ext\commands\core.py:167: RuntimeWarning: coroutine 'Command.call' was never awaited
ret = await coro(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

nimble plume
potent spear
small igloo
potent spear
#

I already told you the fix for that

nimble plume
#
         if ctx.author.id == ownvc[0]:
             s = disnake.Embed(title=f"U Already own a private voice channel",color=red,timestamp=datetime.utcnow())
             await ctx.reply(embed=s) 
         elif not channel1:
```else not going it says index out of range
potent spear
#

ownvc probably isn't what you think it is

nimble plume
#

the list is empty

potent spear
#

no, guild = interaction.guild

small igloo
potent spear
small igloo
# potent spear show me the code once again, I'll do a quick rewrite
@bot.command()
async def top(ctx):
    users = []
    async with ctx.typing():
        lb = discord.Embed(title="leaderboard", description="top salcash players", color=ctx.author.color)
        l = database.length()
        for i in range (int(l)):
            s = database.get(i)
            user = await bot.fetch_user(s)
            level = database.check_level(s)
            o = user.display_name
            users.append((o, level))
        users.sort(key=lambda a: a[1], reverse=True)
        leaderboard = map(lambda user: user[0] + " level: " + str(user[1]), users)
        print(leaderboard)
        # g = list(leaderboard)
        # ln = len(g)
        # for i in range (ln):
        #     lb.add_field(name=i+1, value=g[i], inline=False)
        # await ctx.send(embed=lb)```  ignore comment
potent spear
#

what's s? print it for me and show the result

small igloo
nimble plume
potent spear
#

just do

print(f"{s}, {type(s)}")```
potent spear
small igloo
potent spear
small igloo
grim oar
nimble plume
#

if the list is empty

grim oar
#

Have you re defined map function

nimble plume
#

maybe check for the list at first

potent spear
nimble plume
oblique adder
#

I am unable to use gear emoji βš™ in my button when I put it it look like this instead βš™
please help

@nextcord.ui.button(
        label="βš™",style=nextcord.ButtonStyle.green, custom_id="help_setup", row=0
    )
    async def help_setup(
        self, button: nextcord.ui.Button, interaction: nextcord.Interaction
    ):
        await Help.handle_click(self, button, interaction)
nimble plume
#

nextcord.

potent spear
#

but you have better notationsl

slate swan
nimble plume
#

someone suggested me dont use nextcord

#

nvmd

#

nvmd

slate swan
potent spear
nimble plume
oblique adder
#

same result for me

nimble plume
#

cool buttons

potent spear
oblique adder
#

this is some other bot

potent spear
#

that's not this tho βš™οΈ

#

it's another emoji, a custom one probably

oblique adder
#

what is it ?

nimble plume
#

this guy i mean

oblique adder
potent spear
#

^that's it ig

#

it's called ephemeral

heavy folio
#

!ephemeral

oblique adder
potent spear
#

it's a kwarg in the send method, you have to set it to True

oblique adder
heavy folio
#

eh wasnt there a tag

grim oar
oblique adder
grim oar
#

pass an emoji or partialemoji object

oblique adder
maiden fable
#

What?

small igloo
#

@potent spear

762854807068344321, <class 'str'>
752729024442138673, <class 'str'>
840224507036696616, <class 'str'>
695337807782215771, <class 'str'>
786157376213352458, <class 'str'>
886120777630486538, <class 'str'>
761187678287953920, <class 'str'>
628604207402057760, <class 'str'>
906520975951142912, <class 'str'>
879000165757890570, <class 'str'>
406955601881727007, <class 'str'>
592545312837468170, <class 'str'>
902373236849922078, <class 'str'>
873085052655927336, <class 'str'>
676829520980082718, <class 'str'>
858874474639523850, <class 'str'>
210177401064390658, <class 'str'>
879159531232452678, <class 'str'>
C:\Python310\lib\site-packages\discord\ext\commands\core.py:167: RuntimeWarning: coroutine 'Command.__call__' was never awaited
  ret = await coro(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
<coroutine object Command.__call__ at 0x000001E36146CEB0>```
maiden fable
#

What u searching for

small igloo
#

ephemeral = True if u wondering how to use

maiden fable
#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., view=..., tts=False, ephemeral=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
maiden fable
#

There (:

small igloo
maiden fable
#

Istg why dpy broke the naming convention

oblique adder
#

How do I make button like first image

heavy folio
#

its a custom emoji prolly

maiden fable
#

!d discord.ButtonStyle.grey

unkempt canyonBOT
potent spear
potent spear
small igloo
# potent spear show your code again

@bot.command()
async def top(ctx):
users = []
async with ctx.typing():
lb = discord.Embed(title="leaderboard", description="top salcash players", color=ctx.author.color)
l = database.length()
for i in range (int(l)):
s = database.get(i)
user = await bot.fetch_user(s)
level = database.check_level(s)
o = user.display_name
users.append((o, level))
users.sort(key=lambda a: a[1], reverse=True)
leaderboard = map(lambda user: user[0] + " level: " + str(user[1]), users)
print(leaderboard)
# g = list(leaderboard)
# ln = len(g)
# for i in range (ln):
# lb.add_field(name=i+1, value=g[i], inline=False)
# await ctx.send(embed=lb)

oblique adder
potent spear
#

I mean fetch_user, in your case

small igloo
maiden fable
#

Those are just custom emojis ig? Idrk

small igloo
potent spear
small igloo
potent spear
#

well, then why are you passing a STRING?

small igloo
#

?

potent spear
#

s is a string

#

you literally printed the type

small igloo
potent spear
#

what lib are you using? I'll doublecheck

small igloo
potent spear
#

not dpy probably

small igloo
#

!e import discord

unkempt canyonBOT
#

@small igloo :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'discord'
slim ibex
#

πŸ—Ώ

small igloo
#

ded

potent spear
#

nextcord? what are you using...

small igloo
small igloo
potent spear
#

bruh, your python discord package, which one is it?

small igloo
potent spear
#

you don't know?

potent spear
#

have you ever checked documentation?

small igloo
potent spear
#

irrelevant for now, where do you learn what methods an object has etc?

#

like how do you know that member has a .id attribute etc, what website do you use?

potent spear
#

YT, really?

small igloo
potent spear
#

so you've never used the docs?

small igloo
potent spear
#

oh my

#

don't ever use YT for this kind of libraries

small igloo
potent spear
#

that's for python, you don't find stuff for libraries on there

potent spear
small igloo
potent spear
#

none of them are official documentation

rain olive
#

πŸ€¦β€β™‚οΈ

small igloo
potent spear
#

and still you just proceeded?

small igloo
potent spear
#

you know why we can answer all your questions right? because we read the docs

small igloo
potent spear
#

some goes for people who answer on stackoverflow etc

potent spear
small igloo
potent spear
#

you know python right? or is this your first python project? :/

heavy folio
rain olive
#

hi

surreal sierra
#

hi Im very confused
I have this code but it doesnt send the embed

    @commands.command()
    @commands.has_permissions(administrator=True)
    async def rules(self, ctx):
        with open('prefixes.json', 'r') as f:
            prefixes = json.load(f)
        print(
            f'{datetime.now()}: {ctx.message.author} executed command - {prefixes[str(ctx.guild.id)]}{ctx.invoked_with}')

        server_id = ctx.message.guild.id
        if discord.utils.get(ctx.guild.text_channels, name="rules"):
            channel = discord.utils.get(ctx.guild.channels, name="rules")
            rules_id = channel.id
            print(rules_id)

            print(f'Channel #RulesΒ΄already exist in server, server ID: {server_id}')

            print(f"Sending Rules.Embed to #Rules \n Channel ID: {rules_id}")

            ascii_banner = pyfiglet.figlet_format("RULES & INFORMATION")
            rules_embed = discord.Embed(title=ascii_banner,
                                        description="Welcome to Eivee's Community Discord server")
            await bot.get_channel(rules_id).send(embed=rules_embed)
        else:
            create_channel = await ctx.guild.create_text_channel('rules')
            print(create_channel.id) 

is it not await bot.get_channel(channel-id).send(embed=your-embed) or did I do something wrong?

potent spear
#

since I'll use terms which are understandable if you know programming terms

potent spear
bitter depot
#

@small igloo would you please change your nickname so that it abides by our #rules (i.e. doesn't have cusses or other profanities in it)

surreal sierra
potent spear
#

also, this is terrible

if discord.utils.get(ctx.guild.text_channels, name="rules"):
   channel = discord.utils.get(ctx.guild.channels, name="rules")```
you know why, right?
bitter depot
small igloo
oblique adder
small igloo
#

ok pep8

final iron
small igloo
potent spear
potent spear
surreal sierra
potent spear
# small igloo and?

today, you'll learn how to use the docs instead of reddit and stackoverflow

potent spear
slate swan
small igloo
surreal sierra
potent spear
#

YT is like reading a book's summary, you'll only know what the summary tells you and you have no idea about the details
especially the parts which YOU need to implements, since there's no way you need an exact copy of what the guy on yt tells you

small igloo
potent spear
surreal sierra
small igloo
slim ibex
potent spear
surreal sierra
small igloo
potent spear
surreal sierra
potent spear
#

depends

slate swan
#

Who in the world imports the Bot class...

potent spear
#

right

small igloo
potent spear
#

just
from discord.ext import commands

slim ibex
potent spear
#

you can drop all what's underneath from imports

heavy folio
potent spear
slate swan
small igloo
heavy folio
#
import discord 
import discord.utils
``` ![blobpain](https://cdn.discordapp.com/emojis/739614945045643447.webp?size=128 "blobpain")
slim ibex
#

When I’m subclassing I like just having the name

small igloo
slim ibex
#

not commands.

potent spear
small igloo
small igloo
potent spear
#

show me your imports first

slate swan
small igloo
slate swan
#

I'll cry if you search "Library" docs on google

potent spear
#

grab your tissues

slate swan
#

I'll simply leave to save the pain

nimble plume
slate swan
nimble plume
potent spear
nimble plume
small igloo
nimble plume
#

woah

slate swan
#

oh fuc

potent spear
nimble plume
#

light

small igloo
nimble plume
slate swan
small igloo
final iron
nimble plume
small igloo
nimble plume
#

blue***

small igloo
nimble plume
#

blur*

small igloo
slate swan
slate swan
nimble plume
#

my monitor resolution is low then πŸ˜…

small igloo
slate swan
#

Ahhhhhhh

small igloo
slate swan
boreal ravine
nimble plume
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.

small igloo
slate swan
surreal sierra
# potent spear depends

it didnt fix it and I tried a few different things but still not working, and there is this error now complaining about the id

slate swan
unkempt canyonBOT
small igloo
slate swan
final iron
small igloo
nimble plume
boreal ravine
final iron
small igloo
slate swan
surreal sierra
#

but I dont understand what Im doing wrong, I changed the code a little bit from last time. it looks like this now and in my eyes I think it should be working

    @commands.command()
    @commands.has_permissions(administrator=True)
    async def rules(self, ctx):
        with open('prefixes.json', 'r') as f:
            prefixes = json.load(f)
        print(
            f'{datetime.now()}: {ctx.message.author} executed command - {prefixes[str(ctx.guild.id)]}{ctx.invoked_with}')

        server_id = ctx.message.guild.id
        if channeli := discord.utils.get(ctx.guild.text_channels, name="rules"):
            id = channeli.id
            print(channeli.id)
            channel = Bot.get_channel(id)

            print(f'Channel #RulesΒ΄already exist in server, server ID: {server_id}')

            print(f"Sending Rules.Embed to #Rules \n Channel ID: {id}")

            ascii_banner = pyfiglet.figlet_format("RULES & INFORMATION")
            rules_embed = discord.Embed(title="ascii_banner",
                                        description="Welcome to Eivee's Community Discord server")
            await channel.send(embed=rules_embed)
        else:
            create_channel = await ctx.guild.create_text_channel('rules')
            print(create_channel.id)
small igloo
# slate swan Oh God

i just fking need answer to fix

  ret = await coro(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
<coroutine object Command.__call__ at 0x000001E36146CEB0>``` :')
boreal ravine
small igloo
# boreal ravine You didn't await something
@bot.command()
async def top(ctx):
    users = []
    async with ctx.typing():
        lb = discord.Embed(title="leaderboard", description="top salcash players", color=ctx.author.color)
        l = database.length()
        for i in range (int(l)):
            s = database.get(i)
            print(f"{s}, {type(s)}")
            user = await bot.fetch_user(s)
            level = database.check_level(s)
            o = user.display_name
            users.append((o, level))
        users.sort(key=lambda a: a[1], reverse=True)
        leaderboard = map(lambda user: user[0] + " level: " + str(user[1]), users)
        print(leaderboard)
        # g = list(leaderboard)
        # ln = len(g)
        # for i in range (ln):
        #     lb.add_field(name=i+1, value=g[i], inline=False)
        # await ctx.send(embed=lb)```
boreal ravine
#

oh god

nimble plume
small igloo
nimble plume
final iron
nimble plume
#
  @commands.guild_only()
    @commands.command(name="prvoice")
    async def prvoice(self , ctx, arg=None , arg2=None, arg3=None):
        ownvc = []
        vclist = ["PRVC-1","PRVC-2","PRVC-3","PRVC-4","PRVC-5","PRVC-6","PRVC-7","PRVC-8","PRVC-9","PRVC-10"]
        overwrite = disnake.PermissionOverwrite()
        overwrite.connect = False
        overwrite2 = disnake.PermissionOverwrite()
        overwrite2.connect = True
        category = ctx.channel.category
        channel1 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-1')
        channel2 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-2')
        channel3 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-3')
        channel4 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-4')
        channel5 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-5')
        channel6 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-6')
        channel7 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-7')
        channel8 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-8')
        channel9 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-9')
        channel10 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-10')
        if arg == "create":
         if ctx.author.id == ownvc:
             s = disnake.Embed(title=f"U Already own a private voice channel",color=red,timestamp=datetime.utcnow())
             await ctx.reply(embed=s) 
         elif not channel1:
             await ctx.guild.create_voice_channel("PRVC-1", category=category)
             ownvc.append(ctx.author.id)
```help?
small igloo
# boreal ravine Show full error

dk if u also need the print(s) and type

762854807068344321, <class 'str'>
752729024442138673, <class 'str'>
840224507036696616, <class 'str'>
695337807782215771, <class 'str'>
786157376213352458, <class 'str'>
886120777630486538, <class 'str'>
761187678287953920, <class 'str'>
628604207402057760, <class 'str'>
906520975951142912, <class 'str'>
879000165757890570, <class 'str'>
406955601881727007, <class 'str'>
592545312837468170, <class 'str'>
902373236849922078, <class 'str'>
873085052655927336, <class 'str'>
676829520980082718, <class 'str'>
858874474639523850, <class 'str'>
210177401064390658, <class 'str'>
879159531232452678, <class 'str'>
C:\Python310\lib\site-packages\discord\ext\commands\core.py:167: RuntimeWarning: coroutine 'Command.__call__' was never awaited
  ret = await coro(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
<coroutine object Command.__call__ at 0x000001E36146CEB0>```
nimble plume
#

await

slim ibex
#

It tells you the issue and @boreal ravine said alread

small igloo
small igloo
final iron
nimble plume
#

lol

small igloo
small igloo
final iron
#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

slate swan
final iron
slate swan
boreal ravine
#

Why are you guys being rude

nimble plume
#

h

small igloo
slate swan
#

Like wth

small igloo
boreal ravine
nimble plume
#

how to check if the item is in list

boreal ravine
boreal ravine
nimble plume
boreal ravine
#

yes

slate swan
slim ibex
#

bro

#

Ok it’s too much at this point

heavy fox
#

who can explain me how to work with json and mapping?

slate swan
boreal ravine
gaunt ice
nimble plume
#
ownvc.append(ctx.author.id)
```not working??
heavy fox
nimble plume
final iron
#

camelCase should never be used in python. The convention is to use snake_case for variable and function names. Therefore userID would become user_id

boreal ravine
boreal ravine
nimble plume
small igloo
nimble plume
#

lol

heavy fox
nimble plume
small igloo
boreal ravine
small igloo
nimble plume
# boreal ravine Your if statements are never true, thats why
         elif not channel1:
             await ctx.guild.create_voice_channel("PRVC-1", category=category)
             channel1 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-1')
             await channel1.set_permissions(ctx.guild.default_role, overwrite=overwrite)
             await channel1.set_permissions(ctx.author, overwrite=overwrite2)
             ownvc.append(ctx.author.id)
             s = disnake.Embed(title="Created a Private voice PRVC-1",description="use : `!prvoice modify`",color=green,timestamp=datetime.utcnow())
             await ctx.reply(embed=s)
```its sending msg + creating a channel
kindred drum
#
 elif type == "address":
                try:
                    for i in range (0, len(Json_Items)):
                        for x in Json_Items[i]:
                            for c in Json_Items[i][x]:
                                    if (','.join(Json_Items[i][x]["P A"])) == str(id):
                                        if finished == False:
                                            print("hello")        
                                            finished = True
                                            break 
                                        else: 

                                
                                    # invalid = discord.Embed(title="Cosmic Overground Check", description="You have entered an **invalid** payment address, you have either entered a ``user p a`` that doesn't exist or ``user  a` not in our data base", color = discord.Color.red())
                                    # await ctx.send(embed=invalid)
                                    print("bye")
                                    finished = True

yo why does "bye" never run?, I need to so if they enter a invalid P A, it prints the bye statement once

nimble plume
#

indents

small igloo
kindred drum
nimble plume
boreal ravine
small igloo
nimble plume
kindred drum
small igloo
kindred drum
#

all indents are correct

boreal ravine
small igloo
heavy fox
kindred drum
#

I need it to print (bye) once, right now it prints it for every time of the loop

#
 elif type == "address":
                try:
                    for i in range (0, len(Json_Items)):
                        for x in Json_Items[i]:
                            for c in Json_Items[i][x]:
                        
                                    if (','.join(Json_Items[i][x]["Payment Address"])) == str(id):
                                        if finished == False:
                                            print("hello")        
                                            finished = True
                                            break 
                                        else:
                                            # invalid = discord.Embed(title="Cosmic Overground Check", description="You have entered an **invalid** payment address, you have either entered a ``user payment address`` that doesn't exist or ``user payment address`` not in our data base", color = discord.Color.red())
                                            # await ctx.send(embed=invalid)
                                            print("bye")
                                            finished = True```
nimble plume
small igloo
boreal ravine
nimble plume
#

who send the msg then? @boreal ravine

small igloo
#

r u friggin troll

nimble plume
#

no

#

never true means i didnt understand

#

mean the elif statement didnt pass?

small igloo
nimble plume
slim ibex
#

If he is saying your if statement is never true he means it never results in a true value

nimble plume
#

ok

small igloo
nimble plume
#
channel1 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-1')
#
         elif not channel1:
             await ctx.guild.create_voice_channel("PRVC-1", category=category)
             channel1 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-1')
             await channel1.set_permissions(ctx.guild.default_role, overwrite=overwrite)
             await channel1.set_permissions(ctx.author, overwrite=overwrite2)
             ownvc.append(ctx.author.id)
             s = disnake.Embed(title="Created a Private voice PRVC-1",description="use : `!prvoice modify`",color=green,timestamp=datetime.utcnow())
             await ctx.reply(embed=s)
#

ok

nimble plume
#

yes

nimble plume
cold sonnet
slate swan
small igloo
#

ok

slate swan
#

whats the issue?

nimble plume
#

append not working

slate swan
#

umm?

nimble plume
slate swan
nimble plume
slate swan
nimble plume
#

yes even it send the message ctx.reply*

final iron
#

How do you know appending isn't working?

oblique adder
#

is there a position arg for button

nimble plume
slate swan
#

hm I see

#

are you sure ownvc is a list lol

nimble plume
#

wait

#

very very weird thing happened

#
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'set_permissions'
#
         elif not channel4:
             await ctx.guild.create_voice_channel("PRVC-4", category=category)
             channel4 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-4')
             await channel4.set_permissions(ctx.guild.default_role, overwrite=overwrite)
             await channel4.set_permissions(ctx.author, overwrite=overwrite2)
             ownvc.append(ctx.author.id)
             s = disnake.Embed(title="Created a Private voice PRVC-4",description="use : `!prvoice modify`",color=green,timestamp=datetime.utcnow())
             await ctx.reply(embed=s)
slim ibex
#

your channel4 is returning None

nimble plume
#

it creates a channel but

slate swan
slate swan
#
channel = await discord.Guild.create_voice_channel(name="uwu")
await channel.set_permissions()
nimble plume
#

channel4 = disnake.utils.get(ctx.guild.voice_channels, name='PRVC-4')