#discord-bots

1 messages ยท Page 878 of 1

mellow gulch
#

And to continue counting from there on

#

So nextcord.channelname.history = text

boreal ravine
#

!d discord.TextChannel.last_message_id this gives the channnels most recent message ID, just use a method to get the message object to get the message content if thats what you want ```py
channel = ...
message = channel.get_partial_message(channel.last_message_id) #there are probably easier ways

await message.fetch()

content = message.content

unkempt canyonBOT
boreal ravine
mellow gulch
#

Ok and then how would i get the one before the most recent

boreal ravine
#

@mellow gulch this

mellow gulch
#

And also channel would be the channel id?

boreal ravine
#

uh no

#

you need the channel object first

#

just slap this into your code, pretty simple to understand samsungsmile

boreal ravine
final iron
slate swan
final iron
#

๐Ÿ˜ 

slate swan
final iron
slate swan
boreal ravine
#

Iterate through member.roles and remove the roles using the member.remove_role method. Store the roles somewhere so that you can give the roles back later

final iron
slate swan
#

read pep8PepePoint

final iron
#

No

#

๐Ÿ˜†

slate swan
#

take that badge off, its illegal to impersonate a cop you know that rightrooCop

final iron
#

It's not impersonation

#

๐Ÿšช ๐Ÿƒโ€โ™‚๏ธ

slate swan
#

!ot catgun

unkempt canyonBOT
sick birch
#

Store all of the users roles in a database, since if something happened and the bot goes offline when the user doesn't have their roles, it would be lost forever. when you run unmute, fetch from the database and give their roles back

slate swan
#

await a.add_reaction(u"\u2705") ## yes
    await a.add_reaction(u"\u274C") ## no
    def check(reaction, user):
        return user == member and reaction.message == a and str(reaction.emoji) in ([u"\u2705"], [u"\u274C"])
    try:
        reaction, user = await bot.wait_for('reaction_add', timeout=30.0, check=check)
    except asyncio.TimeoutError:
        await a.clear_reactions()
        await ctx.send("You didn't respond in time!")
    else:
        if reaction.emoji == u"\u274C":
            embed=discord.Embed(title="UnSuccesful")
            embed.set_thumbnail(url=url) 
            await ctx.send(embed=embed)
        if reaction.emoji == u"\u2705":
            for members in ctx.guild.members:
                if customRole in members.roles:
                    if members is not None:
                        memberss.append(members.mention)
                        await members.remove_roles(customRole, reason=f"Disbanded team by {ctx.author}")
#

why is the bot not responding to reactions

sick birch
#

it would be a many-to-many data relationship so you would need to figure out how to model that data

boreal ravine
#

try doing str(reaction.emoji)

slate swan
slate swan
boreal ravine
#

I mean in the if statements

slate swan
#

Ive tried that already aswell. Same Results

boreal ravine
#

send the code that you tried

slate swan
#

ok

#
    def check(reaction, user):
        return user == member and reaction.message == a and str(reaction.emoji) in ([u"\u2705"], [u"\u274C"])
    try:
        reaction, user = await bot.wait_for('reaction_add', timeout=30.0, check=check)
    except asyncio.TimeoutError:
        await a.clear_reactions()
        await ctx.send("You didn't respond in time!")
    else:
        if str(reaction.emoji) == u"\u274C":
            embed=discord.Embed(title="UnSuccesful")
            embed.set_thumbnail(url=url) 
            await ctx.send(embed=embed)
        if str(reaction.emoji) == u"\u2705":
            for members in ctx.guild.members:
                if customRole in members.roles:
                    if members is not None:
                        memberss.append(members.mention)
                        await members.remove_roles(customRole, reason=f"Disbanded team by {ctx.author}")
boreal ravine
#

what's the u string for?

stone beacon
#

That return statement is gonna prevent that try block from even executing no?

#

Anything after a return statement is blocked

stone beacon
#

Hmm

boreal ravine
#

the return statement is inside anothr function

slate swan
stone beacon
#

Lemme go on pc

#

ah I see it better now. On mobile the indents are messed up

final iron
slate swan
#

I just prefer seeing my code like that.

final iron
#

It's wrong

#

๐Ÿคทโ€โ™‚๏ธ

slate swan
#

ill give it a shot.

slate swan
#

The bot is not responding to checks, the code isn't even making it to the if statements. It responds with the timeout error even if I did react.

tacit storm
# final iron It's wrong

dude. fucking stop. you keep suggesting shit that has nothing to do. just because one person does something the way you dont like it, dont fucking bring them down for it.

genuinely, unless you have something to actually say towards his question or to help in the slightest, shut the fuck up.

final iron
#

To ping mods or to not ping mods

#

๐Ÿคทโ€โ™‚๏ธ

#

If you don't like what I'm saying, block me

#

Quite simple

#

Also

#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

tacit storm
unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
โ€ข PEP 8 document
โ€ข Our PEP 8 song! :notes:

quick gust
#

here we go again

final iron
#

Give this a read

final iron
quick gust
final iron
#

Sure

silk kelp
final iron
#

Just follow pep8 smh

#

If you're not following pep8 at least have an actual code style

boreal ravine
#

they do?

final iron
#

Not just naming things Willy nilly

boreal ravine
#

even stdlibs don't follow pep8

#

and most of them are made from guido worry_frog

final iron
#

I'm aware

boreal ravine
#

I think anyways

final iron
#

!ot ๐Ÿ—ฟ

unkempt canyonBOT
silk kelp
#

alright

slate swan
#

Thanks, it worked. Howcome unicode doesn't work?

silk kelp
slate swan
#

ah ok

slate swan
#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix = "avery ")
bot.remove_command("help")

@bot.group(invoke_without_command=True)
async def help(ctx):
    em = discord.Embed(title = "Avery Commands", description = "Use avery help <command> for extended information on a specific command.")

    em.add_field(name= "Fun", value = "8ball, happy, sad, meme")
    em.add_field(name="Moderation", value = "kick, ban, mute, unmute, unban, warn, purge")
    em.add_field(name="Utilities", value= "None")
    em.add_field(name= "Currency", value = "none")
    em.set_footer(text='[Google](https://google.com)')
    await ctx.send(embed = em)

@help.command()
async def kick(ctx):
    em = discord.Embed(title = "Kick", description = "Kicks a member from the guild")

    em.add_field(name = "**Syntax**", value= "avery kick <member> [reason]")

    await ctx.send(embed = em)
#

Literally everything I try to make masked links isnt working

#

This is the outcome:

#

As you can see I am trying to put the mask link in the footer

tacit storm
slate swan
#

I did "inline = True"

#

This is what it looks like

#

Id like it to look like Wizohd bots in terms of indent

tacit storm
#

if you want them all in a row like going up and down,

add inline=false
for wizohd type one just do inline=true iirc

slate swan
#

I currently have inline = true

#

it doesnt work

tacit storm
#

then idk.

#

inline = True is how it should look for that.

slate swan
#

Ok, maybe Ill do some research

wary zenith
#

why is ui not found

wary zenith
# slate swan

this is how its supposed to look, i dont think there is any other way to fix that

honest shoal
slate swan
#

I fixed it but does anyone know how to change a bots activity to watching and the amount of guilds it is watching?

slate swan
unkempt canyonBOT
slate swan
#

That didnt really help, Im talking about changing the bots status from "playing (bot.gg)" to watching (amount of servers)

#

it returns a list of guilds?

#

I tried it on my bot

#

len(bot_instance.guilds)

#

Still confused

slate swan
#

i mean it does have a value since its a truthy string 02smile0

wary zenith
# slate swan

but why did you put len(botvar.guilds) as a string ๐Ÿ’€

slate swan
# slate swan

and btw dont change presence in ready as it can trigger many times do it in the constructor

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
slate swan
wary zenith
#

how would i do that

slate swan
# wary zenith how would i do that
class A:
    def __init__(self, arg: str) -> None:
        pass

A("argument")

the class constructor is how the class is constructed

B = A()

here B is a class instance of A

#

not sure why i gaved a example on an instance of a class but whatever02comfy

wary zenith
slate swan
slate swan
jade tartan
#

Hi i have a question for a profiling system embed. if the user is verified. How do you make the bot know that that user is verified? if that make sense

#

ill show a ss if u dont understand

#

This is what i mean

alpine furnace
# jade tartan

How exactly are you storing the age and gender and, well, everything else? Because it would be the same thing for these two fields

jade tartan
#

Well i would be storing that in a JSON files for different files like have one file for gender.json, age.json etc

honest rover
#

well just store it somewhere, how you do it, its up to you ig

jade tartan
#

Well i dont know how would i do it in json file

slate swan
jade tartan
#

Why?

#

I never used dbs i know its a database but why

slate swan
jade tartan
#

Ok thats not a valid reason but okay

#

Then can i do it js files?

slate swan
#

javascript files? awkward1

alpine furnace
# jade tartan I never used dbs i know its a database but why

Why shouldnโ€™t I use a JSON file as a database?
โ€ข Performance is deterministic on Data size:
โ€“ As Data increases, reading/writing takes longer
โ€ข No concurrent writing (One write at a time):
โ€“ Effects performance, and can cause corruptions
โ€ข Human readable/Easily accessible by users:
โ€“ This can leave your text vulnerable for attacks
โ€“ If you can read the text, it's not encrypted

What should I use instead?
โ€ข SQL Databases:
SQLite, PostgreSQL, MariaDB, etc...
โ€ข NoSQL Databases:
MongoDB, RethinkDB, ArangoDB, etc...

For similarity, and easier porting, NoSQL is advised.

What can I use a JSON file for?
Storing Static Data (Not changed often), such as:
Configurations, Properties, or User-Defined Data

#

Tldr; fine now, bad later

jade tartan
#

Or i can store it in cogs

alpine furnace
#

You would lose the data after every restart

slate swan
slate swan
jade tartan
#

Idk

slate swan
small igloo
#

how to check is a user has a role in different server

slate swan
slate swan
#

just get the guild and then the member using their id

#

then use the roles property

#

if it meets the conditions

small igloo
slate swan
slate swan
# small igloo yeah

yeah, so first get the guild, then get the member using the Guild object, then use the roles property on the Member object

#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
slate swan
#

!d discord.Guild.get_member

unkempt canyonBOT
slate swan
#

!d discord.Member.roles

unkempt canyonBOT
#

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

These roles are sorted by their position in the role hierarchy.
small igloo
#

๐Ÿ—ฟwow, ok ty

alpine furnace
small igloo
small igloo
# slate swan !d discord.Member.roles
@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = bot.get_membed(ctx.author.id)``` after this what should i do ๐Ÿ—ฟ
slate swan
small igloo
slate swan
#

then, check if u is not None and use the roles property on the u var representing a Member object

small igloo
slate swan
#

it will return a list of Role objects

small igloo
slate swan
#

wait

small igloo
slate swan
#
guild.get_member()```
#

not bot.get_member()

#

that doesnt exist

small igloo
small igloo
slate swan
small igloo
small igloo
slate swan
small igloo
slate swan
alpine furnace
#

if u: awkward, simple

slate swan
#

lmao

small igloo
slate swan
small igloo
#

holy cow, ok

small igloo
# slate swan yes <:ahhhhhh:904111213032665098>
@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = s.get_member(ctx.author.id)
    if u:
        if "gold patreon" in u.roles:
            await ctx.send("GGTY!")
        else:
            await ctx.send(":moyai: u r not a patreon, be one of them to access this command!")``` not send any message
slate swan
small igloo
slate swan
#

the member doesnt have any roles then

#

if the list is empty

small igloo
small igloo
small igloo
small igloo
slate swan
small igloo
slate swan
small igloo
alpine furnace
#

Check your intents

slate swan
#

yeah

small igloo
alpine furnace
#

They are on your botโ€™s app page in the dev portal

slate swan
#

member intents

dawn zinc
#

hey guys... I am trying to create a admin bot. I have a list of words that should not be spoken in channel(slangs) as a table in mysql. How do I traverse the table and see if anyone used that slang?

slate swan
alpine furnace
small igloo
#

k

alpine furnace
#

And your intents in code

#

When you create your Bot object

small igloo
small igloo
maiden fable
#

U need intents too

alpine furnace
small igloo
maiden fable
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

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

small igloo
#

oh, ok

small igloo
maiden fable
small igloo
#

k

#

d you understand what i try to do

if any u.roles in access:```
#

access is list

velvet tinsel
small igloo
small igloo
nimble plume
#

?

small igloo
# nimble plume ?

how to do that, i mean that's return an error, what's the real thing to do

nimble plume
#

u is member right

small igloo
nimble plume
#

What error

small igloo
nimble plume
small igloo
#

when i read "any" documentation, ig the "any" func is to check whether a thing in a list is True :V

nimble plume
#

Show ur full command

#

So i can see what is u and access

small igloo
# nimble plume Show ur full command

jesus christ, litteraly 2k lines of codes, also i not missed any ":", i just need the real thing to check if the user have any roles in "access"

nimble plume
small igloo
# nimble plume So i can see what is u and access

if just that then

@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = s.get_member(ctx.author.id)
    access=["gold patreon", ""]
    if u:
        if any u.roles in access:
            await ctx.send("GGTY!")
        else:
            await ctx.send(":moyai: u r not a patreon, be one of them to access this command!")```
nimble plume
#

Ok

nimble plume
small igloo
nimble plume
#

Ok

small igloo
#

k

nimble plume
#

Ok got it

small igloo
#

ok :v

steep estuary
#

i want suggestion related with my discord bot

#

about host and database

small igloo
small igloo
steep estuary
nimble plume
small igloo
nimble plume
small igloo
small igloo
nimble plume
#

Huh?

steep estuary
small igloo
steep estuary
#

i want cheap host with free database

broken cave
#

I got this error after creating a command in discord.py

Traceback (most recent call last):
  File "/home/runner/NeulBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 222, in add
    if amount>bal[1]:
IndexError: list index out of range

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

Traceback (most recent call last):
  File "/home/runner/NeulBot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/NeulBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/NeulBot/venv/lib/python3.8/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: IndexError: list index out of range```

This is the code of the command
```py
@client.command()
async def add(ctx,member:discord.Member,amount=None):
  await open_account(ctx.author)
  await open_account(member)

  if amount==None:
    await ctx.send("Enter the amount in digits!")
    return

  bal = await update_bank(ctx.author)

  amount = int(amount)
  if amount>bal[1]:
    await ctx.send("Not Enough Money!")
    return
  if amount<0:
    await ctx.send("Amount isn't Positive!")
    return

  await update_bank(ctx.author, -1*amount,"wallet")
  await update_bank(member,amount,"wallet")

  await ctx.send(f"{amount} has been added to the users balance")```
#

can anyone help

small igloo
nimble plume
steep estuary
small igloo
small igloo
steep estuary
#

heroku can connect with that ?

broken cave
small igloo
nimble plume
small igloo
steep estuary
broken cave
steep estuary
#

also the data get lost when i stop the program

nimble plume
small igloo
small igloo
steep estuary
nimble plume
small igloo
broken cave
broken cave
# small igloo ๐Ÿ—ฟ then just bal, not bal[1]
Traceback (most recent call last):
  File "/home/runner/NeulBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 222, in add
    if amount>bal:
TypeError: '>' not supported between instances of 'int' and 'list'

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

Traceback (most recent call last):
  File "/home/runner/NeulBot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/NeulBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/NeulBot/venv/lib/python3.8/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: TypeError: '>' not supported between instances of 'int' and 'list'```
small igloo
broken cave
#

i got this

boreal ravine
small igloo
broken cave
nimble plume
small igloo
nimble plume
#

PC IS NOT USED AS A HOST EITHER

manic wing
#

relax, crikey

small igloo
nimble plume
#

Ur problem

small igloo
#

if any u.roles in access: me still need dis

small igloo
nimble plume
#

Use for loop

#

Idk

manic wing
nimble plume
small igloo
boreal ravine
#

there are 2 ins?

small igloo
nimble plume
#

Use for loooop

small igloo
nimble plume
#

Ah

#

Yes

small igloo
#

๐Ÿ—ฟ

nimble plume
#

for roles in u.role:
if roles in access:
f stuff

small igloo
manic wing
#

and whats access?

small igloo
manic wing
#

should work fine

#

try printing u.roles and access

nimble plume
#

Yes

manic wing
#

im not sure where the bool is coming from

small igloo
# manic wing try printing u.roles and access

full code

@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = s.get_member(ctx.author.id)
    access=["gold patreon", "iron patreon"]
    if u:
        if any(role for role in u.roles in access):
            await ctx.send("GGTY!")
        else:
            await ctx.send(":moyai: u r not a patreon, be one of them to access this command!")
small igloo
nimble plume
#

Try printing roles

small igloo
nimble plume
#

Yes

#

H?

small igloo
#

whoops

#

[<Role id=917956425681100801 name='everyone'>, <Role id=947402526410539020 name='gold patreon'>, <Role id=928503038371561542 name='playah'>, <Role id=924915779835691008 name='gods'>]

nimble plume
#

Oh yea

small igloo
nimble plume
#
@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = s.get_member(ctx.author.id)
    access=["gold patreon", "iron patreon"]
    if u:
        if any(role for role in u.roles.name in access):
            await ctx.send("GGTY!")
        else:
            await ctx.send("๐Ÿ—ฟ u r not a patreon, be one of them to access this command!")โ€Š
#

It willvwork

small igloo
# nimble plume It willvwork

"it will work"
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'list' object has no attribute 'name'

nimble plume
#

F

#

Show code

small igloo
#
@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = s.get_member(ctx.author.id)
    access=["gold patreon", "iron patreon"]
    if u:
        if any(role for role in u.roles.name in access):
            await ctx.send("GGTY!")
        else:
            await ctx.send(":moyai: u r not a patreon, be one of them to access this command!")``` ๐Ÿ˜  i hate error
slate swan
#

imagine

nimble plume
#

Im noob i know

slate swan
#

dont

small igloo
nimble plume
#

Imagine cant help

#

Ash u help

slate swan
nimble plume
#

Huh

slate swan
#

yes

#

using a list comp is generally easier

#

than writing lambda functions ||dont resist if you wanna look cool||

cunning ice
#

error ?

small igloo
# slate swan ```py role_name_list = [role.name for role in u.roles] #returns a list with role...

will this work :V

@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = s.get_member(ctx.author.id)
    access=["gold patreon", "iron patreon"]
    if u:
        role_name_list = [role.name for role in u.roles]
        if any(role for role in role_name_list in access):
            await ctx.send("GGTY!")
        else:
            await ctx.send(":moyai: u r not a patreon, be one of them to access this command!")```
slate swan
#

try, why asking before trying 2124_MikeSullyFaceSwap

small igloo
cunning ice
# cunning ice

in this the run bot command is below its just showing syntax error in 18th line

slate swan
#

use normal conditionals

small igloo
cloud dawn
#

I know lmao

slate swan
cunning ice
#

hi @maiden fable

maiden fable
slate swan
#

nvm awkward

maiden fable
small igloo
slate swan
#

Huni gonna help es_pepe_Toilet

cunning ice
slate swan
cunning ice
#

in there anything error in my code ?

maiden fable
cloud dawn
small igloo
maiden fable
#

I don't really have much time rn, tell me the issue

maiden fable
cunning ice
maiden fable
#

U need members intent

small igloo
slate swan
#

Client pepe_cri

maiden fable
cunning ice
slate swan
small igloo
# maiden fable I don't really have much time rn, tell me the issue

TypeError: 'bool' object is not iterable

@bot.command()
async def premium(ctx):
    s = bot.get_guild(917956425681100801)
    u = s.get_member(ctx.author.id)
    access=["gold patreon", "iron patreon"]
    if u:
        role_name_list = [role.name for role in u.roles]
        if any(role for role in role_name_list in access):
            await ctx.send("GGTY!")
        else:
            await ctx.send(":moyai: u r not a patreon, be one of them to access this command!")```
maiden fable
unkempt canyonBOT
#

Using intents in discord.py

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

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

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

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

maiden fable
cloud dawn
cunning ice
cunning ice
maiden fable
cloud dawn
#

Why is it so cropped thenpithink

maiden fable
#

The any function is wrong lol

small igloo
maiden fable
cunning ice
slate swan
cloud dawn
small igloo
maiden fable
#

@small igloo yr issue fixed?

slate swan
nimble plume
#

๐Ÿ˜ถ lemon_sentimental

small igloo
nimble plume
#

Lol

maiden fable
#

Okay

cunning ice
maiden fable
#

Replit lemon_pensive

slate swan
#

how can i set slash command visible in specific channel pycord

small igloo
maiden fable
#

Idk, never used pycord

maiden fable
nimble plume
#

^_^

cunning ice
small igloo
cloud dawn
maiden fable
cloud dawn
nimble plume
#

Im mid pythoner

cloud dawn
maiden fable
#

Stop.

cloud dawn
slate swan
nimble plume
maiden fable
#

No

nimble plume
#

Wait not str

maiden fable
#

IDs are int lol

nimble plume
modest plover
#

Hi, can I make it to that if a message has anything *other than a channel mention in it, it still waits for a channel?

maiden fable
modest plover
#
    def channelCheck(message: disnake.Message):
        	return (len(message.channel_mentions) > 0) and (message.author == inter.author)
        	
        welcomeChannel = await self.bot.wait_for("message", timeout=30.0, check=channelCheck)
       
        await inter.channel.send(embed = announcementsConfig)
        ```
maiden fable
#

Uh

modest plover
#

Where would I set that?

slate swan
cloud dawn
# maiden fable Stop.
@bot.command()
async def premium(ctx):
    await ctx.send("GGTY!") if any([role for role in (ctx.guild.get_member(ctx.author.id)).roles if role.name in ["gold patreon", "iron patreon"]]) else await ctx.send(":moyai: u r not a patreon, be one of them to access this command!")
``` kek
modest plover
#

sorry if it sounds dumb I legit just woke up

maiden fable
#
def cmd(..., channel:TextChannel = None):
    if not channel:
        channel = await bot.wait_for(...) 
        # use channel converter to convert the channel to a TextChannel instance
nimble plume
#

...

maiden fable
#

What

modest plover
#

How do I use the channel converter?

#

Like what is that?

maiden fable
cloud dawn
slate swan
maiden fable
#

!d discord.ext.commands.TextChannelConverter @modest plover

unkempt canyonBOT
#

class discord.ext.commands.TextChannelConverter(*args, **kwargs)```
Converts to a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel").

All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.

The lookup strategy is as follows (in order)...
nimble plume
#

Ok,.

cloud dawn
#

You can also just use the text channel object.

cunning ice
#

!intemts

#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

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

small igloo
#
data = message.content.split(" ")
user = re.sub("\D","",data[1])
s = bot.get_guild(917956425681100801)
u = s.get_member(user)
access=["gold patreon"]
if u:
  role_name_list = [role.name for role in u.roles]
  if any(role for role in role_name_list if role in access):
    database.give_vote_premium(user)
  else:
    database.remove_vote_premium(user)``` why not give vote premium ๐Ÿ—ฟ and user output is 828182019841327115 (id)
slate swan
#

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

small igloo
dull terrace
maiden fable
#

!d discord.TextChannel.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
dull terrace
#

channel = client.get_channel(channel id)
message = await channel.fetch_message(message id)

unkempt canyonBOT
#
any

any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:

```py
def any(iterable):
    for element in iterable:
        if element:
            return True
    return False
small igloo
cloud dawn
cunning ice
cloud dawn
small igloo
cunning ice
cloud dawn
#

!d iter

unkempt canyonBOT
#

iter(object[, sentinel])```
Return an [iterator](https://docs.python.org/3/glossary.html#term-iterator) object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, *object* must be a collection object which supports the [iterable](https://docs.python.org/3/glossary.html#term-iterable) protocol (the `__iter__()` method), or it must support the sequence protocol (the `__getitem__()` method with integer arguments starting at `0`). If it does not support either of those protocols, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") is raised. If the second argument, *sentinel*, is given, then *object* must be a callable object. The iterator created in this case will call *object* with no arguments for each call to its [`__next__()`](https://docs.python.org/3/library/stdtypes.html#iterator.__next__ "iterator.__next__") method; if the value returned is equal to *sentinel*, [`StopIteration`](https://docs.python.org/3/library/exceptions.html#StopIteration "StopIteration") will be raised, otherwise the value will be returned.
cloud dawn
small igloo
cunning ice
#

like this @cloud dawn

cloud dawn
small igloo
cloud dawn
cloud dawn
cunning ice
dull terrace
#

why not make the welcome_channel a global variable so you don't have to keep fetching

cloud dawn
unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
โ€ข Decorators (see !tags decorators)
โ€ข Inheritance (overriding methods)
โ€ข Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
โ€ข Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

cloud dawn
#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
cloud dawn
#

loop is a kwarg aswell as **options

small igloo
cloud dawn
#

options representing most of the time a collection of other kwargs

slate swan
cunning ice
cloud dawn
dull terrace
#

happens to me when i try to fetch stuff before the client is ready

cloud dawn
cloud dawn
slate swan
small igloo
cloud dawn
#

list, string, tuple, set can be iterables. You are making a for loop comprehension without using a list.

small igloo
cloud dawn
small igloo
cloud dawn
#

if role.name in ["gold patreon"]

cunning ice
#

also @cloud dawn how do i mention a person
(member.mention)
like this ?

small igloo
red nest
#

yes

small igloo
small igloo
#

hi tvrsier

small igloo
placid skiff
#

message.author returns the member object of the guild where the message is sent, if it is in pm it returns an user object which doesn't have any guild permissions

small igloo
placid skiff
small igloo
# cloud dawn Ah

:V

data = message.content.split(" ")
user = re.sub("\D","",data[1])
if any(role for role in message.author.roles if role.name in [access]):
    database.give_vote_premium(user)
else:
    database.remove_vote_premium(user)``` will work?
cunning ice
#

@cloud dawn syntax error ?

small igloo
cunning ice
small igloo
cunning ice
cunning ice
small igloo
cunning ice
small igloo
small igloo
cunning ice
placid skiff
cunning ice
small igloo
placid skiff
#

should do

small igloo
placid skiff
#

but why the [] before access?

placid skiff
cunning ice
#

why is it mentioning like this @small igloo

small igloo
small igloo
cunning ice
cunning ice
placid skiff
cunning ice
small igloo
placid skiff
# small igloo my solution just mention.name

btw if I can suggest you a thing try to allways use the ID of the object to compare them, because if you compare the name and you will change the name of the role your code will not work, if you compare the ID you can change whatever you want, the ID still is the same

placid skiff
slate swan
#

guys, does anyone know how to edit messages in dm

#

?

cunning ice
small igloo
placid skiff
#

Well your bot is sayin that it is a None object ๐Ÿ˜†

small igloo
small igloo
placid skiff
#

!d disnake.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://docs.disnake.dev/en/latest/api.html#disnake.Member "disnake.Member") with the given ID.

Note

This method is an API call. If you have [`Intents.members`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.members "disnake.Intents.members") and member cache enabled, consider [`get_member()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.get_member "disnake.Guild.get_member") instead.
placid skiff
#

with this

cosmic agate
#

help

@bot.command(aliases=["HELP","Help"])
async def help(ctx):
  await ctx.send("De Help Command.",embed = hembed, components=[Button(label="Page 2", custom_id="button1", style = ButtonStyle.blue)])
  interaction = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button1")
  await interaction.respond(type=7,content="De Help Command.",embed=hembed2, components=[Button(label="Page 3",
  custom_id="button2", style = ButtonStyle.blue)])
  interaction2 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button2")
  await interaction2.respond(type=7,content="De Help Command.",embed=hembed3, components=[Button(label="Page 4",
  custom_id="button3", style = ButtonStyle.blue)])
  interaction3 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button3")
  await interaction3.respond(type=7, content="De Help Command.", embed=hembed4, components=[])

how to make this a loop?

small igloo
cunning ice
small igloo
unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
small igloo
# cunning ice

then define it :V

async def idk_ur_comand_name(ctx, mention:discord.Member=None):
#blah

cosmic agate
#

?

slate swan
#

the option isnt being added to my slash cmd, its been over 12 hrs ๐Ÿ˜ฉ

cosmic agate
placid skiff
cosmic agate
#

ls for loops?

small igloo
# placid skiff !d disnake.Guild.fetch_member

am i doin it right

        s = bot.get_guild(917956425681100801)
        u = await s.fetch_member(user)
        access=["gold patreon"]
        if any(role.name == access for role in u.roles):
            database.give_vote_premium(user)
        else:
            database.remove_vote_premium(user)
``` if yes, why still not give me premium vote ;-;
placid skiff
cosmic agate
#

which?

placid skiff
placid skiff
cosmic agate
#

ok

small igloo
placid skiff
small igloo
placid skiff
#

Which database are you using?

small igloo
placid skiff
#

You have a db browser open?

small igloo
#
s = bot.get_guild(917956425681100801)
        u = await s.fetch_member(user)
        access=["gold patreon"]
        if any(role.name == access for role in u.roles):
            print("yess")
        else:
            print("no ;-;")```why output-
small igloo
placid skiff
#

yes

small igloo
placid skiff
#

You have to close it, do the command again and then check

small igloo
placid skiff
#

?

small igloo
heavy radish
#

Is there anything wrong with discord API?

#

Why is my BOT not working

small igloo
heavy radish
#

It was working fine yesterday

cloud dawn
small igloo
small igloo
cloud dawn
heavy radish
cloud dawn
heavy radish
#

Yes

small igloo
cloud dawn
placid skiff
heavy radish
#

What's wrong?

cloud dawn
heavy radish
#

It worked before

#

yes

small igloo
heavy radish
#

Shhh

#

Anyways, what's the prob

cloud dawn
heavy radish
#

How do I check?

cloud dawn
placid skiff
#

!e

string = "abcd"
list_of_string = ["abcd", "abc", "bc", "cd"]

print(True if any(data == string for data in list_of_string) else False)
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

True
small igloo
# heavy radish How do I check?
r = requests.head(url="https://discord.com/api/v1")
try:
    print(f"Rate limit {int(r.headers['Retry-After']) / 60} minutes left")
except:
    print("done")```
heavy radish
#

No errors

heavy radish
#

Where do I add this?

cloud dawn
#

c would insult you

placid skiff
#

I know, but this is Python D_D

small igloo
heavy radish
#

ok

placid skiff
#

btw in c you can do an any function which does that lol

small igloo
placid skiff
cloud dawn
visual island
#

you don't need to do True if ...

#

just directly print(any(...))

heavy radish
small igloo
cloud dawn
#

s

small igloo
visual island
#

what are you trying to do

#

requests is blocking

placid skiff
visual island
#

but simpler ๐Ÿ™‚

heavy radish
#

or rate limits

cloud dawn
#

What even is the issue?

small igloo
heavy radish
#

My BOT just stopped working

small igloo
heavy radish
#

It barely even gets any use

cloud dawn
heavy radish
#

My BOT is a quotes bot for a private server

#

I used it a few days ago

#

it was all good

small igloo
heavy radish
#

Yes

#

It's logged in

small igloo
heavy radish
#

BOT went offline and went i put the token in the code

#

it went back online but the commands don't work

small igloo
heavy radish
#

IDK

small igloo
heavy radish
#

Ummm

small igloo
placid skiff
#

? i'm workin so i'm not totally focussed on the conversation

small igloo
#

๐Ÿ—ฟ ok

cunning ice
#

inline with async def ?

small igloo
#
        s = bot.get_guild(917956425681100801)
        u = await s.fetch_member(user)
        access=["gold patreon"]
        if any(role.name == access for role in u.roles):
            print("yess")
        else:
            print("no ;-;")``` again
small igloo
small igloo
placid skiff
#

print u.roles

cloud dawn
#

get is cache

placid skiff
#

!e

data1 = ["test"]
data2 = "test"
print(data2 in data1)
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

True
cloud dawn
#

Yeah but you are awaiting a cached object

placid skiff
#

Wait he is right why you are keeping doin access = []? just do access = ""

small igloo
#

holy jesus christ finnaly work, GGTY

lament mesa
spring flax
#

Whats ~ mean?

lament mesa
#

bitwise not

spring flax
#

What?

cunning ice
#

invalid syntax ??

slate swan
spring flax
#

Wth

placid skiff
#

more than invalid

lament mesa
slate swan
#

cursed

cunning ice
placid skiff
#

How much do you know python?

spring flax
#

Probably started immediately with dpy

cunning ice
slate swan
slate swan
cunning ice
slate swan
cunning ice
#

so i can mention in description not in title

cunning ice
dull terrace
#

UPDATE inventory SET m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, r0, r1, r2, r3, r4, r5, r6, r7, r8, s0val25, s0val50, s0val100, s1val2, s1val4, s1val6, s2val1, s2val2, s2val3, s3val1, s3val2, s3val3 WHERE id = ?```
placid skiff
#
UPDATE table SET column_1 = new_value_1, column_2 = new_value_2, ..., column_n = new_value_n WHERE search_condition
dull terrace
#

oh am i just missing a placeholder

#

so UPDATE inventory SET m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, r0, r1, r2, r3, r4, r5, r6, r7, r8, s0val25, s0val50, s0val100, s1val2, s1val4, s1val6, s2val1, s2val2, s2val3, s3val1, s3val2, s3val3 = ? WHERE id = ?

placid skiff
#

yup, you're telling to update column but without giving the value

#

you have to set the value for all the columns xD

dull terrace
#

๐Ÿ˜ค

#

pretty sure i fixed it now thanks

placid skiff
#

pretty useless if so xD

cunning ice
#

is it right way to use line break ?

dull terrace
#

it's an periodic save for all the values

#

comma then line break if that's what youre asking

cunning ice
dull terrace
#

oh i misunderstood the question

cunning ice
#

i hv decided i will learn python through discord.py
i have learnt python till functions not more than it
and also the bot i am making doesnt require many new python commands ,
the bot is made using simple commands
but sometimes i get stuck in some silly commands bcz i havent learnt them yet (and i am kinda busy too)
and
when i ask people questions or errors they always ans and help me happily
so i think i will learn it this way eventually will be a good in python

placid skiff
cunning ice
#

ok so i quit dpy

placid skiff
#

it's not quitting

cunning ice
#

i will make simple projects and be happy with that

placid skiff
#

bro everyone started with discord.py from 0, and it is a really mess when you start. But with a base knowledge you can understand more and find help all by your own just by reading discord.py documentation

maiden osprey
#

Can anyone tell me a good website for hosting discord bots except heroku and replit aPES_Think

placid skiff
cunning ice
#

yes thats a good idea

maiden osprey
placid skiff
#

all except heroku and replit can be trusted xD

#

an hosting is a private space that you buy in a server

slate swan
placid skiff
#

no one can read your code except user authorized by you

maiden osprey
#

ya but bot token is public

placid skiff
#

bruh in hosting you don't paste your code, you export your project in the hosting

maiden osprey
#

rs_yeduniya i am new a newbie

placid skiff
#

because replit is ||shit||

slate swan
maiden osprey
#

Ok sadge

slate swan
placid skiff
#

but because when you create a local repository it creates folder with enviroment variable showed in an xml file

slate swan
#

lol

#

@slate swan did your issue get fixed though?

#
@slash_command(guild_ids = [849629843745800204])
    async def mrps(self, ctx, member: Option(discord.Member, "Whom do you wanna play with", required=True)):
        global p1
        global p2
        p1 = ctx.author
        p2 = member
        global plist
        plist = [p1, p2]

        view = MyView()

        if member == None:
            await ctx.send(f"Invalid syntax\n\n{prefix}mrps <member>\n Mention the member next time")

        elif member == ctx.author:
            await ctx.send("Bruh, how can you play with yourself?")

        elif member == self.bot.user:
            await ctx.send(f"Do `!rps` if you wanna play with me")

        elif member.bot:
            await ctx.send("Imagine trying to play games with a bot")

        else:
            await ctx.respond(f"{member.mention}")
            reply = f"{p1.name} is choosing...\n{p2.name} is choosing..."
            global msg
            msg = await ctx.respond(reply, view=view)```
option doesn't show up
#

orait, cool

placid skiff
# slate swan ;-;

Maybe is because of typehints, you are giving discord.Member as first parameter which is a type, but the first parameter is the name of the option

small igloo
#
def add_item(name, amount, item):
    ae = item.upper()
    list = ae.split(" ")
    if len(list) > 1:
        item = list[0]+"_"+list[1]
    else:
        item="".join(list)
    cur.execute("UPDATE item_list set ? = ?+? where NAME=?", (item, item, amount, name))
    conn.commit()``` disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: near "?": syntax error :V why
placid skiff
small igloo
placid skiff
placid skiff
#

!e

lst = ["abc", "ab", "ac", "bc"]
item = lst[0]+"_"+lst[1] if len(lst)>1 else "".join(lst)
print(item)
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

abc_ab
small igloo
#

gg

small igloo
placid skiff
#

right

#

except the query of course XD

small igloo
placid skiff
#

? this is not the problem of your query

small igloo
placid skiff
#

I don't follow you, what are you talkin' about?

slate swan
small igloo
placid skiff
#

BRUH WHAT THE HELL IS THAT HAHAHHAA

placid skiff
small igloo
slate swan
#

๐Ÿ˜ฉ

small igloo
#

disnake better ๐Ÿ—ฟ

placid skiff
# small igloo holy-

uhm honestly i dunno if there is a way to make it easier, i can study a way but not sure

slate swan
#

nvm sqlite3 blobsweats

small igloo
placid skiff
# small igloo but not sure i'll edit

you can try this:
cur.execute("UPDATE item_list set ? = ? - ? WHERE NAME = ?", (item.upper(), item.upper(), amount, name)
Can't ensure that will work, but you can try

small igloo
placid skiff
#

that you will rid off all your if and elif

#

if it works

cloud dawn
#

Isn't upper a string method

placid skiff
#

item == "carrot" it is a string till someone prove otherwise

placid skiff
#

that makes things more complicate

small igloo
#

:v

cloud dawn
#
    elif item == "woter":
        cur.execute("UPDATE item_list set WOTER_BOTTLE = WOTER_BOTTLE - ? where NAME = ?", (amount, name))
``` inconsistency is killing me
vocal snow
#

woter ๐Ÿฅธ

placid skiff
#
item = item.upper().replace(" ", "_") if " " in item else item.upper()
cur.execute("UPDATE item_list set ? = ? - ? WHERE NAME = ?"), (item, item, amount, name)
placid skiff
cloud dawn
#

idk why he would make a column for each item, at that point just make a list with int's or dict per user.

vocal snow
#

that schema doesn't look right, you shouldn't be using placeholders for the columns

placid skiff
#

yeah and some columns are named differently from the variables tho, @small igloo to rewrite that block of code you have to entirely change that structure in you database

cloud dawn
#

Or just use an int list for inventory since no one likes a lot of work.

placid skiff
#

he is saving them that means he needs them even when he reloads the bot

placid skiff
#

What you can do is trying to save them in a file

#

or using pickle

small igloo
placid skiff
#

will not work

small igloo
cloud dawn
# small igloo yes :D

!e ```py
item_data = {
"woter": 0,
"cheese": 1,
"ham": 2,
"beef": 3,
"banana": 4
}

user_inventory = [10, 22, 32, 9, 10]

print(user_inventory[item_data["cheese"]])

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

22
placid skiff
cloud dawn
#

He can keep the dict inside a json and load that on startup and save it in a var.

steep estuary
#

how to restore the downloaded heroku backup ?

cloud dawn
placid skiff
steep estuary
cloud dawn
steep estuary
#

and i am also finding that way for my discord bot

cloud dawn
placid skiff
cloud dawn
#

Since it is using indexing to get the data.

steep estuary
cloud dawn
#

Every "new" user would then have a list like this [0, 0, 0, 0, 0, 0]

placid skiff
placid skiff
#

firs rule of algorithms: No ambiguity

cloud dawn
#

Give an example why this wouldn't work

#

You could even create a class and setattr to get even fancier.

unkempt canyonBOT
placid skiff
#

let's assume that he saves the int value of the dict, then he needs to access one of those data

value = 22
item_data = {"carrot": = 22, "water": = 22, "fish": = 22}
cur.execute("SELECT value FROM item_list WHERE value = ?", (value)
rows = cur.fetchone()
print(item_data.keys()[item_data.values().index(rows)]

#output = carrot

Ambiguity because there are more value with 22

#

this is the most stupid example, but that's the point

#

if you need to find the key from the value this method will not work

#

because is a stupid example as i said hahahaha

#

and he wants to find a way to get rid off all if-elif

cloud dawn
small igloo
#

lol

cloud dawn
#

The list of ints is all he saves in his database

maiden fable
#

It would have been so fun if dpy allowed us to return custom objects, not just for Context but for other things too

placid skiff
cloud dawn
lament mesa
maiden fable
maiden fable
cloud dawn
lament mesa
#

you cant ? for column names since the module will add quotes to strings

placid skiff
#

i gave him the same hint more or less, but there is some problem like this:

elif item == "heal potion":
        cur.execute("UPDATE item_list set HEAL_POTION = HEAL_POTION - ? where NAME = ?", (amount, name))```
or this:

elif item == "woter":
cur.execute("UPDATE item_list set WOTER_BOTTLE = WOTER_BOTTLE - ? where NAME = ?", (amount, name))```

cloud dawn
#

๐Ÿ˜ 

lament mesa
#

yeah, f-strings will be ok here because the column names aren't user input

placid skiff
#

check item value and then column name

cloud dawn
#

If you gotta use f-strings inside a query you gotta look better at your code

quaint crow
#

hey, My discord.py bot commands are executing twice, even though I don't have await self.bot.process_commands(message) in the on_message event?

boreal ravine
#

Long time no see rush

lament mesa
placid skiff
lament mesa
quaint crow
#

how's that possible?

#

I host the bot on Heroku

jade tartan
#

Can someone help me with something

#

Hi i have a question for a profiling system embed. if the user is verified. How do you make the bot know that that user is verified? if that make sense. for example store info like this one

quaint crow
#

it ran fine until I added some commands, but after seeing that the commands ran twice, i reverted back those changes but the problem still persists

jade tartan
#

embed.set_author(url=ctx.message.author.avatar_url) am trying to have the user profile picture and its giving me this error. Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'

jade tartan
#

Well for that i have averification system where the user has to react to the rules to get verified

#

If thats what ur talking about

#

yes it adds the verification role

lament mesa
jade tartan
#

to the user once they read the rules and

#

Well ill show u my code

#
async def start(ctx):
    embed=discord.Embed(title="Profile", description="", color=0x00ff00)
    embed.add_field(name= f"User: {ctx.author.mention}", value="โœ…Verified 18+โœ…", inline=False)
    embed.add_field(name='Name', value=str(ctx.author.name), inline=True)
    embed.set_author(url=ctx.message.author.avatar.url)
    await ctx.send("What Is Your Name?")
    msg = await client.wait_for('message')
    await ctx.send("What Is Your Name?")
    msg = await client.wait_for('message')
    await ctx.send(embed=embed)
    print(f"The embed has been send")
    ```
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
    ret = await coro(*args, **kwargs)
  File "d:\discord server bot\Bot2.py", line 298, in start
    embed.set_author(url=ctx.message.author.avatar.url)
TypeError: Embed.set_author() missing 1 required keyword-only argument: 'name'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 1055, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 933, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
    raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Embed.set_author() missing 1 required keyword-only argument: 'name'
unkempt canyonBOT
#

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

This function returns the class instance to allow for fluent-style chaining.
jade tartan
#

Do i need to add name argument on the async def?

small igloo
#

๐Ÿ—ฟ ?

#

how does that work :V

jade tartan
#

ohh i know what u mean

cloud dawn
lament mesa
#

I wasn't saying to use psycopg2 for discord bots lemon_sweat
I was saying that psycopg2 has a utility that fixes the issue they were having

jade tartan
#

embed.set_author(name= client.user.name, url=ctx.message.author.avatar.url) @slate swan ?

cloud dawn
#

Or just use a normal inventory using a list of ints like a sane person.

small igloo
#

you could use f-strings which was one of the final conclusions

(i forgor who) he says that f string in sqlite realy not recomended

small igloo
cloud dawn
#

I don't think coding 100 elif statements and adding 50 columns is preference.

modest plover
#

I asked earlier, I think @maiden fable gave an answer but I can't find it. How do I make it so the bot only takes messages containing exclusively a text channel?

cloud dawn
#

I stopped reading after you suggested f-strings yes.

modest plover
cloud dawn
#

Honestly we can't be suggesting someone to use f-strings under any circumstances.

modest plover
#

Sorry shit internet, so it shouldn't take a message like that

small igloo
#
def add_item(name, amount, item):
    ae = item.upper()
    lst = ae.split(" ")
    item = item.upper().replace(" ", "_") if " " in item else item.upper()
    cur.execute(f"UPDATE item_list set {item} = {item} - {amount} WHERE NAME = {name}")
    conn.commit()```
#

๐Ÿ—ฟ

#

then what

modest plover
cosmic agate
#

Help

@bot.command(aliases=["HELP","Help"])
async def help(ctx):
  await ctx.send("De Help Command.",embed = hembed, components=[Button(label="Page 2", custom_id="button1", style = ButtonStyle.blue)])
  interaction = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button1")
  await interaction.respond(type=7,content="De Help Command.",embed=hembed2, components=[Button(label="Page 3",
  custom_id="button2", style = ButtonStyle.blue)])
  interaction2 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button2")
  await interaction2.respond(type=7,content="De Help Command.",embed=hembed3, components=[Button(label="Page 4",
  custom_id="button3", style = ButtonStyle.blue)])
  interaction3 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button3")
  await interaction3.respond(type=7, content="De Help Command.", embed=hembed4, components=[])```
I want to make a loop
like
```py
await ctx.send("De Help Command.",embed = hembed, components=[Button(label="Page 2", custom_id="button1", style = ButtonStyle.blue)])
  interaction = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button1")```
this is the first line  of code
```py
interaction3 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button3")
   await interaction3.respond(type=7, content="De Help Command.", embed=hembed4, components=[])```
this is the last line of code
so I want to make a button that will loop back to the first line of code
but discord.ext.tasks.loop doesnt work
small igloo
#

what message

modest plover
#

It's being used across a lot of servers, meaning that I can't specify one id

cloud dawn
#

This is literally the same as my suggestion but with extra steps.

small igloo
#

holy not understand what to do

maiden fable
modest plover
maiden fable
#

inter.channel

#

!d discord.Interaction.channel

unkempt canyonBOT
faint mason
#

help i upload bot to heroku

cloud dawn
cloud dawn
unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

small igloo
small igloo
cloud dawn
cosmic agate
#

Help

@bot.command(aliases=["HELP","Help"])
async def help(ctx):
  await ctx.send("De Help Command.",embed = hembed, components=[Button(label="Page 2", custom_id="button1", style = ButtonStyle.blue)])
  interaction = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button1")
  await interaction.respond(type=7,content="De Help Command.",embed=hembed2, components=[Button(label="Page 3",
  custom_id="button2", style = ButtonStyle.blue)])
  interaction2 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button2")
  await interaction2.respond(type=7,content="De Help Command.",embed=hembed3, components=[Button(label="Page 4",
  custom_id="button3", style = ButtonStyle.blue)])
  interaction3 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button3")
  await interaction3.respond(type=7, content="De Help Command.", embed=hembed4, components=[])```
I want to make a loop
like
```py
await ctx.send("De Help Command.",embed = hembed, components=[Button(label="Page 2", custom_id="button1", style = ButtonStyle.blue)])
  interaction = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button1")```
this is the first line  of code
```py
interaction3 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button3")
   await interaction3.respond(type=7, content="De Help Command.", embed=hembed4, components=[])```
this is the last line of code
so I want to make a button that will loop back to the first line of code
but discord.ext.tasks.loop doesnt work
small igloo
jade tartan
#

Well that didnt work I want it to where it will add the user profile image

#

or profile pic ture

lament mesa
lament mesa
cosmic agate
#

Help

@bot.command(aliases=["HELP","Help"])
async def help(ctx):
  await ctx.send("De Help Command.",embed = hembed, components=[Button(label="Page 2", custom_id="button1", style = ButtonStyle.blue)])
  interaction = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button1")
  await interaction.respond(type=7,content="De Help Command.",embed=hembed2, components=[Button(label="Page 3",
  custom_id="button2", style = ButtonStyle.blue)])
  interaction2 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button2")
  await interaction2.respond(type=7,content="De Help Command.",embed=hembed3, components=[Button(label="Page 4",
  custom_id="button3", style = ButtonStyle.blue)])
  interaction3 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button3")
  await interaction3.respond(type=7, content="De Help Command.", embed=hembed4, components=[])```
I want to make a loop
like
```py
await ctx.send("De Help Command.",embed = hembed, components=[Button(label="Page 2", custom_id="button1", style = ButtonStyle.blue)])
  interaction = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button1")```
this is the first line  of code
```py
interaction3 = await bot.wait_for("button_click", check=lambda inter: inter.custom_id == "button3")
   await interaction3.respond(type=7, content="De Help Command.", embed=hembed4, components=[])```
this is the last line of code
so I want to make a button that will loop back to the first line of code
but discord.ext.tasks.loop doesnt work
cloud dawn
cosmic agate
#

SOMEONe pls HELp psl

jade tartan
#

and the expected to be

modest plover
# maiden fable !d discord.Interaction.channel
   def channelCheck(message: disnake.Message):
        	return (len(message.channel_mentions) > 0) and (message.author == inter.author)

I don't think I explained right lmao.
The command called is a config command, meaning that it needs to save the users input. Assuming the message is saved in its entirety a #bot-commands for example, then if I call that from a database, then try to use the message as a channel to send to, it won't.
So inter.channel isn't what I need to use.
TL;DR I need to save the channel to a db, if it has a letter other than the channel, it doesn't work.

jade tartan
#
async def start(ctx):
    embed=discord.Embed(title="Profile", description="", color=0x00ff00)
    embed.add_field(name= f"User: {ctx.author.mention}", value=":white_check_mark:Verified 18+:white_check_mark:", inline=False)
    embed.add_field(name='Name', value=str(ctx.author.name), inline=True)
    embed.set_author(name=, icon=embed.Empty, icon_url=client.user.avatar_url)
    await ctx.send("What Is Your Name?")
    msg = await client.wait_for('message')
    await ctx.send("What Is Your Name?")
    msg = await client.wait_for('message')
    await ctx.send(embed=embed)
    print(f"The embed has been send")
    ```
jade tartan
#

Command raised an exception: AttributeError: 'ClientUser' object has no attribute 'avatar_url'

cosmic agate
#

wdym?

cloud dawn
lament mesa