#discord-bots

1 messages · Page 660 of 1

slate swan
#

So its inheriting everything for the ui

sullen shoal
#

yes basically

slate swan
#

Yeah i assumed as i saw super()

sullen shoal
#

check what children returns

stone forge
#

What to do? Interaction error!
Code:
https://media.discordapp.net/attachments/343944376055103488/917823921200443413/unknown.png?width=299&height=138

# Выдача ролей при помощи select menu
@bot.command() 
async def rolesp(ctx):
    await ctx.channel.purge(limit=1)

    give_roles = discord.Embed(
        title = 'Автоматическая выдача ролей',
        description = '**Вы можете самостоятельно получить роль выбрав ее название в меню. \
            \n При выборе своей гендерной роли вы будете выделяться ее цветом. \
            \n Роли доступные для получения в данный момент:** \
            \n:female_sign: — <@&864246807353884722>\n:male_sign: — <@&864246881667383336>',
        color = 0x36393E,)

    give_roles.set_thumbnail(url='https://media.discordapp.net/attachments/865681789493051423/917820894234169454/static.png?width=172&height=172')
    give_roles.set_footer(text=':zap:Cascade:zap:')

    await ctx.send(
        embed=give_roles,
        components = [
            SelectMenu(
                placeholder = "Выберите гендерную роль",
                options = [
                    SelectOption(label = "Девушка", value = "Девушка:female_sign:", description = "Вы получите гендерную роль женского пола!", emoji = ':female_sign:'),
                    SelectOption(label = "Парень", value = "Парень:male_sign:", description = "Вы получите гендерную роль мужского пола!", emoji = ':male_sign:'),
                ]
            )
        ]
    )


    interaction = await bot.wait_for("select_option")
    # member = ctx.member()
    # await member.add_roles(interaction.values[0])
    await interaction.send(content=f"Роль {interaction.values[0]} была вадана!", embed=embeds)

bot.run(TOKEN) ```
slate swan
#

Why exactly?it disables the button but im just trying to know how to change a color when its disabled

sullen shoal
#

what you do next is that, you change the things of the instances like disabling it by doing
Button.disabled = True

slate swan
#

Yes i do not know much on childrens

sullen shoal
#

its all OOP and python classes

slate swan
#

Ikjam_cavedude

#

Thanksyert

sullen shoal
#

never think its any special thing of python specially added by python for this lib, it confuses

slate swan
#

Yeah i should go by that advice 😭

#

Im always thinking new stuff are really different when its all oop😭

sullen shoal
#

no its all just classes

slate swan
#

Thx bro😅

slate swan
lament mesa
maiden fable
#

Hahaha

full valley
#
            i = 1
            rankings = pstats.find().sort("MMR", -1)
            embed = discord.Embed(title=f"6Mans Rank {rank.upper()} Leaderboard:", color=0xE74C3C)
            for x in rankings:
                print(x)
                try:
                    print(f"0.1 = {x}")
                    temp = ctx.guild.get_member(x["id"])
                    print(f"0.2 {temp} = {x}")
                    temprank = x["Rank"]
                    print(f"0.3 {temprank}= {x}")
                    tempmmr = x["MMR"]
                    print(f"0.4 {tempmmr} = {x}")
                    tempwin = x["Wins"]
                    print(f"0.5 {tempwin} = {x}")
                    temploss = x["Losses"]
                    print(f"0.6 {temploss} = {x}")
                    embed.add_field(name=f"{i}: {temp.name}", value=f"MMR: {tempmmr}\n Rank: {temprank}\n Win Ratio "
                                                                    f"{round(tempwin / temploss, 2)}", inline=False)
                    print(f"0.7 = {x}")
                    i += 1
                    print(f"0.8 {i}= {x}")
                except:
                    pass
                if i == 11:
                    await ctx.channel.send('i=11')
                    break

only 1 embed field is being printed out?
and i only = 2 on the 10th iteration of the for loop

warm goblet
#

I'm having some trouble adding text colour to embed and keeping it all on the same line.

    if green in newone:
        green1 = '$' + currentprice + '** '+ change + '**'"```css\n"+ newone + "```"
        embedVar = discord.Embed(title=f"{companyname}", description=f"{green1}" f'{volume}''% from NHOD', color=0x00ff00)
#

The {newone} correctly gets turned green, but it's put on a different line when I want it all on the same line. I believe it's because the \n added to css\n"+ newone +"... the problem is, as far as I know, you need to add \n if you want to change colour.

#

I want the green text to be on the same line

slate swan
#

You can't.

uncut comet
#

whats the best way to reload cogs?

slate swan
#

Unload and load again

warm goblet
#

That's a shame

slate swan
#

That's how code blocks work

warm goblet
#

Is there an alternative way to changing text colours in embed that would allow me to put it on the same line?

slate swan
#

No

warm goblet
wicked atlas
slate swan
#

And instead of using css

#

You should use diff

#
+increase
-decrease
warm goblet
warm goblet
slate swan
#
-decrease
#

CSS doesn't change the color for -

wicked atlas
#

I’m on mobile, is the text before the - highlighted? I can’t remember if it does that```diff
Text -decrease

uncut comet
wicked atlas
uncut comet
#

ah kk

#

when using bot.reload_extension() what do i need to feed it? just the cog name?

stone forge
#

What to do? Interaction error!
Code:
https://media.discordapp.net/attachments/343944376055103488/917823921200443413/unknown.png?width=299&height=138

# Выдача ролей при помощи select menu
@bot.command() 
async def rolesp(ctx):
    await ctx.channel.purge(limit=1)

    give_roles = discord.Embed(
        title = 'Автоматическая выдача ролей',
        description = '**Вы можете самостоятельно получить роль выбрав ее название в меню. \
            \n При выборе своей гендерной роли вы будете выделяться ее цветом. \
            \n Роли доступные для получения в данный момент:** \
            \n:female_sign: — <@&864246807353884722>\n:male_sign: — <@&864246881667383336>',
        color = 0x36393E,)

    give_roles.set_thumbnail(url='https://media.discordapp.net/attachments/865681789493051423/917820894234169454/static.png?width=172&height=172')
    give_roles.set_footer(text=':zap:Cascade:zap:')

    await ctx.send(
        embed=give_roles,
        components = [
            SelectMenu(
                placeholder = "Выберите гендерную роль",
                options = [
                    SelectOption(label = "Девушка", value = "Девушка:female_sign:", description = "Вы получите гендерную роль женского пола!", emoji = ':female_sign:'),
                    SelectOption(label = "Парень", value = "Парень:male_sign:", description = "Вы получите гендерную роль мужского пола!", emoji = ':male_sign:'),
                ]
            )
        ]
    )


    interaction = await bot.wait_for("select_option")
    # member = ctx.member()
    # await member.add_roles(interaction.values[0])
    await interaction.send(content=f"Роль {interaction.values[0]} была вадана!", embed=embeds)

bot.run(TOKEN) ```
#

help pls

cunning shard
blissful crane
#

error: ```py
C:\Users\HiTech\Desktop>python hhh.py
Traceback (most recent call last):
File "C:\Users\HiTech\Desktop\hhh.py", line 2053, in <module>
from discord import ui
ImportError: cannot import name 'ui' from 'discord' (C:\Users\HiTech\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_init_.py)


even tho i have dpy 2.0

https://cdn.discordapp.com/attachments/381965515721146390/917843491407663105/unknown.png
blissful crane
#

data is probably a list, not a dict

slate swan
#

line 2053
from discord import ui

#

something doesn't make sense to me there

cunning shard
slate swan
#

!d json.loads

unkempt canyonBOT
#

json.loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *s* (a [`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray") instance containing a JSON document) to a Python object using this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).

The other arguments have the same meaning as in [`load()`](https://docs.python.org/3/library/json.html#json.load "json.load").

If the data being deserialized is not a valid JSON document, a [`JSONDecodeError`](https://docs.python.org/3/library/json.html#json.JSONDecodeError "json.JSONDecodeError") will be raised.

Changed in version 3.6: *s* can now be of type [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray"). The input encoding should be UTF-8, UTF-16 or UTF-32.

Changed in version 3.9: The keyword argument *encoding* has been removed.
slate swan
#

returns list ig?

#

waiting for another newbie to post their token here

#

that doesn't happen usually

#

:(

#

hey guys what's your token, lemme know so I can promote your bots on my new website

#

👍

tough lance
#

Wait what

wanton cipher
#

How can I check if any word in a string is in a message?

slate swan
#

that would actually need a for loop

wanton cipher
slate swan
#

any word in a string in a string

slate swan
#

yeah like

maiden fable
slate swan
#

that's what he said

maiden fable
#

They just wanna check a single word

wanton cipher
#

no

maiden fable
#

Oh nvm

#

My bad. Misinterpreted

wanton cipher
#

a word in a list

slate swan
#

Ohhh

wanton cipher
#

nws

slate swan
#
    if word in message.content:```
tough lance
#

Any

#

!any

wanton cipher
#

how do you use any for that?

slate swan
#

I was dumb

slate swan
#

no?

maiden fable
slate swan
#

lmao

wanton cipher
#

I had it the wrong way round xD

tough lance
slate swan
#

I'm not sure about that statement bruther

maiden fable
slate swan
#

I know more about the dpy library than normal py

maiden fable
#

Same

tough lance
#

I tried working on a mass DM bot, failed horrendously

maiden fable
#

🤣

slate swan
#

wait how

tough lance
slate swan
#

wait what

#

that would be interesting

#

even tho I didn't understand that

#

is that against ToS?

#

👀

tough lance
slate swan
#

fawk

maiden fable
#

Haha

tough lance
#

It won't even work cause discord now locks tokens. You can't get them

#

I learned it all

#

I mean how it works

maiden fable
#

Ig delete it before a mod deletes it

tough lance
maiden fable
#

Okay

opal skiff
#

0x2ecc71 what is the color type of this and are there any color picker extensions that help with this color type?

sick birch
#

It’s a hex color code

#

Just look up color picker on google and you’ll find a nice tool

maiden fable
#

html color codes is a website

slate swan
# opal skiff `0x2ecc71` what is the color type of this and are there any color picker extensi...

Heres a list of them you can .bm if you want:

default = 0
teal = 0x1abc9c 
dark_teal = 0x11806a
green = 0x2ecc71 
dark_green = 0x1f8b4c
blue = 0x3498db 
dark_blue = 0x206694 
purple = 0x9b59b6 
dark_purple = 0x71368a 
magenta = 0xe91e63
dark_magenta = 0xad1457
gold = 0xf1c40f 
dark_gold = 0xc27c0e 
orange = 0xe67e22 
dark_orange = 0xa84300 
red = 0xe74c3c
dark_red = 0x992d22 
lighter_grey = 0x95a5a6 
dark_grey = 0x607d8b 
light_grey = 0x979c9f
sick birch
#

It’s not necessarily HTML color codes, they’re just hexadecimal representations of RGB that can be used in websites

opal skiff
ebon island
#

What is the best way to create a handler for dropped messages eg connection issues for a bot? Say if there is a momentary lapse, send a retry rather than leaving the task unresolved?

#

The issue I am facing at present is that I have a script sending messages on an interval but if it encounters a connection issue it simply stops like dropping the ball while juggling rather than having an error that can be excepted and handled

polar ice
#

Is it possible to have custom presence activity? Instead of the default watching, straming, listening .etc

slate swan
#

so i have something like

role = message.guild.get_role(id)
await ctx.author.add_roles(role)``` but i dont know if ive done the right attributes 😬
slate swan
slate swan
#

No they don't iirc

slate swan
#

well technicallyyyy

#

See they dont

#

ActivityType.custom is an str of member.activity.type

#

@maiden fable bots dont have access to custom statuses right?

patent bluff
#

hi guys

slate swan
#

i mean what i can imaging would be something like
f'{member.activity.type}'.replace("ActivityType.custom", f'{member.activity.name}')

patent bluff
slate swan
#

@slate swan ^^

polar ice
#

is it possible ?? 😄

slate swan
#

Afaik no

polar ice
#

await bot.change_presence(
activity=discord.Activity(type=discord.ActivityType.custom, name='XXXX'))

slate swan
#

it works fine for me lol

#

OHHH to put custom status on a bot

#

well no not that i know of

slate swan
slate swan
slate swan
#

Because bots cant access statuses

unreal prism
#

how can i see the data/message type from a bot, e.g. card game bot when it shows u a random card?

polar ice
#

Thanks for the quick reply guys 🙂

slate swan
#

having an issue with my verification

@bot.command()
async def verify(ctx):
    def check(m):
        return m.author.id == ctx.author.id
    msg = await bot.wait_for('message', check=check)
    role = message.guild.get_role(917654915311099944)
    embed = discord.Embed(title=f'Verification', description=f'You have `1` attempt to verify. If you fail, you may be re-evaluated by executing the command again', color=clr)
    failbed = discord.Embed(title=f'Verification', description=f'You have failed the verification process! Please try again', color=clr)
    passbed = discord.Embed(title=f'Verification', description=f'You have passed the verification process! Enjoy your stay', color=clr)
    captcha = random.randint(1, 4)

    if captcha == '1':
        embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283179843452970/wickCaptcha.png')
        await ctx.send(embed=embed)
        if msg.content == 'KZEXEH':
            await ctx.send(embed=passbed)
            await ctx.author.add_roles(role)
        else:
            await ctx.send(embed=failbed)

    elif captcha == '2':
        embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283141130006578/wickCaptcha.png')
        await ctx.send(embed=embed)
        if msg.content == 'SXOXMM':
            await ctx.send(embed=passbed)
            await ctx.author.add_roles(role)
        else:
            await ctx.send(embed=failbed)```
not sure if ive used the right attributes for `get_role()`
patent bluff
#

not necessarily an error but you are using f-strings when they are not needed

slate swan
#

Can anyone give pointers or help

#

on creating a channel with a command but only allowing the author to use it

patent bluff
#

create channel then set channel permission

slate swan
#

Can you send the docs for the permission part please

slate swan
patent bluff
#

just use a regular string literal

pliant gulch
slate swan
patent bluff
slate swan
#

!d discord.Guild.get_role

unkempt canyonBOT
slate swan
#

when you hover over text, how can you add more text?

patent bluff
#

ok i was wrong

slate swan
#

so would it be ctx.guild or just straight up discord.Guild... considering its not invoked

pliant gulch
#

discord.Guild is the class itself, you want the instance of it, E.g ctx.guild

slate swan
#

okay

#

how would i do the bit where you hover over?

patent bluff
#

that's a timestamp

slate swan
patent bluff
#

look at the link

slate swan
#

<t:1618953630>

#

ah got it

#

thank you 😄

patent bluff
#

nice

#

no problem

slate swan
#

eh

pliant gulch
#

If you're using discord.py v2.0.0a you can use format_dt as well

#

!d discord.utils.format_dt

unkempt canyonBOT
#

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

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

whats the doc for add_roles?

#

nevermind, member.add_roles

unkempt canyonBOT
#

cl(ear) [filename:lineno | bpnumber ...]```
With a *filename:lineno* argument, clear all the breakpoints at this line. With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation).
slate swan
#
role = ctx.guild.get_role(917654915311099944)
await member.add_roles(role)```
`AttributeError: 'NoneType' object has no attribute 'id'`
#

on line 2^

grand stag
#

Does anyone know how I can make my bot use emojis that require nitro on any server?

wicked atlas
#

For roles though, I usually find it easier just to use snowflakes

await member.add_roles(discord.Object(917654915311099944))
#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
wicked atlas
#

you need to use the full package name

slate swan
#

How would I set the permission

#

to make the author of the command to be able to read the channel

wicked atlas
#

Use the delete_after kwarg on the send() method

await channel.send("message", delete_after=15)
slate swan
#

me^

#

just a simple question, if i get a bad request 400 from sending a message and it says invalid body form not snowflake or something like that, does that mean that the message is over 2000 characters?

velvet tinsel
#

you can set a check variable

#

I think

wicked atlas
tender geyser
#

'Bot' object has no attribute 'send_message'

#

anyone know why im getting this error code?

velvet tinsel
tender geyser
#
async def help(ctx):
    author = ctx.message.author

    embed = discord.Embed(
        colour=discord.Colour.orange()
    )

    embed.set_author(name='Help')
    embed.add_field(name='ban', value='Bans someone!', inline=False)

    await bot.send_message(author, embed=embed)```
velvet tinsel
#

Uhhh

#

you should do await author

#

await author.send_message()

slate swan
#

How do I save the channel ID

velvet tinsel
#

Or just ctx.author

slate swan
#

Where the command is used

velvet tinsel
#

Try this

slate swan
#

ive switched over to await member.add_roles(discord.Object(917883065362161684)) but now it says unknown role, yes the role exists, yes the bot has perms in the server the roles from, yes its the right role id

tender geyser
#

i cant find it in the docs

slate swan
#

is it

tender geyser
#

what did it change to

slate swan
#

channel.delete?

velvet tinsel
#

?

#

I told you the answer already

#

Damn, muted for 2 days, a lot has changed

wicked atlas
#

This was a while ago. If you're following a tutorial, it might be old

verbal cairn
#

how can u define a specific person to .mention

velvet tinsel
#

No need

velvet tinsel
#

Or ctx.author

#

Or declare a variable for ctx author

tender geyser
#

i dont wanna send it to a channel tho

#

i wanna send it to the user asking

wicked atlas
tender geyser
#

await bot.send_message(author, embed=embed)

wicked atlas
#
await author.send(embed=embed)
verbal cairn
#

what is the equivalent of self.bot.owner.mention, but for any specific member

tender geyser
#

wdym

#

that is the send method is it not?

verbal cairn
wicked atlas
tender geyser
#

ojya

#

okay ty

wicked atlas
verbal cairn
#

member.mention doesnt work

wicked atlas
verbal cairn
#
@bot.command()
@commands.is_owner()
async def oops(ctx, *args):
    channel = bot.get_channel(ID)
    await channel.send(f"{member.mention} {args}")
    await ctx.send("Sent!")
slate swan
#

Is it possible to read the content of a hidden message?

verbal cairn
slate swan
#

I mean only one you can see

verbal cairn
#

confused by what u mean on that but seems possible if u can access it

wicked atlas
slate swan
#

I attached a button to it, need to read its title

#

As ctx.origin_message & ctx.message returns none

wicked atlas
#

What are you trying to do?

verbal cairn
#

what command are they using to make the title

verbal cairn
wicked atlas
verbal cairn
#

wdym member variable

#

im just saying straight up @ the person, using their ID

wicked atlas
#

Then you need to get a member object, and get the mention attribute of it

verbal cairn
#

that doesnt help

#

if im not using ctx

wicked atlas
#

How are you getting the ID?

slate swan
#

Disregard my question, found another way

verbal cairn
#

its a specifc ID that I'd rather not share so ppl here dont go bugging that person

#

ID is the same each time

wicked atlas
sick birch
velvet tinsel
opal skiff
#

Ty

sick birch
velvet tinsel
#

||or maybe I could||

verbal cairn
sick birch
verbal cairn
#

thats what it returns

slate swan
#

trying to use await member.add_roles(discord.Object(917883065362161684)) but now it says unknown role, yes the role exists, yes the bot has perms in the server the roles from, yes its the right role id. ive defined member as ctx.author, discord.Member was not invoked however, just ctx.

verbal cairn
#

or ill try again

velvet tinsel
sick birch
#

add_roles takes in a discord.Role not a Snowflake

velvet tinsel
#

or maybe not

slate swan
sick birch
sick birch
wicked atlas
sick birch
#

hm i see

slate swan
#

How do I delete the channel where the command is used

sick birch
wicked atlas
#

hmm

sick birch
#

as long as it mentions who cares haha

wicked atlas
#

Oh well, that's just what they say in the docs

sick birch
#

or is it just ctx.channel.delete()

wicked atlas
sick birch
#

nice, note it's a coro so await it

slate swan
#
member = ctx.author.id
    guild = ctx.guild
    print(member)
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(read_messages=False),
        member: discord.PermissionOverwrite(read_messages=True),
    }
    channel = await guild.create_text_channel(f"{str(member)}", overwrites=overwrites)```
#

trying to do this but I get this

AttributeError: 'int' object has no attribute 'id'

sick birch
#

code block please

#

thanks

#

indents look off

wicked atlas
#

that's just discord

wicked atlas
sick birch
#

along w/ line numbers

#

i mean i only see one .id

slate swan
#
Traceback (most recent call last):
  File "C:\Users\fish\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\fish\Desktop\..\test.py", line 29, in create
    channel = await guild.create_text_channel(f"{str(member)}", overwrites=overwrites)
  File "C:\Users\fish\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 948, in create_text_channel
    data = await self._create_channel(name, overwrites, ChannelType.text, category, reason=reason, **options)
  File "C:\Users\fish\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 844, in _create_channel
    'id': target.id
AttributeError: 'int' object has no attribute 'id'
sick birch
#

ah

slate swan
#

trying to make a channel but the name of it with there ID

sick birch
#

the member key in the overwrites dict has to be a discord.Member object, not an int

stone forge
#

Assigning roles using the select menu. How? My initial code, how do I make it give out the selected role in the select menu?

async def rolesp(ctx):
    await ctx.channel.purge(limit=1)

    give_roles = discord.Embed(
        title = 'Автоматическая выдача ролей',
        description = '**Вы можете самостоятельно получить роль выбрав ее название в меню. \
            \n При выборе своей гендерной роли вы будете выделяться ее цветом. \
            \n Роли доступные для получения в данный момент:** \
            \n ♀ — <@&864246807353884722>\n ♂ — <@&864246881667383336>',
        color = 0x36393E,)

    give_roles.set_footer(text='CASCADE')

    await ctx.send(
        embed=give_roles,
        components = [
            SelectMenu(
                placeholder = "Выберите гендерную роль",
                options = [
                    SelectOption(label = "Девушка", value = "Девушка♀", description = "Вы получите гендерную роль женского пола!", emoji = '♀'),
                    SelectOption(label = "Парень", value = "Парень♂", description = "Вы получите гендерную роль мужского пола!", emoji = '♂'),
                ]
            )
        ]
    ) ```
slate swan
#

so then I can have a delete command where it only works if the channel is there ID name

#

You get me?

sick birch
#

Yeah i see what you mean

#

though there's no reason to make a seperate member variable

#

ctx.author provides you with one

#

str(ctx.author.id) should be the channel name, in your case the user's ID would be the channel name

slate swan
#
      ctx.author.id: discord.PermissionOverwrite(read_messages=True),
    }
    channel = await guild.create_text_channel(f"{ctx.author.id}", overwrites=overwrites)
#

like that?

sick birch
#

then inside your overwrites, instead of having member: ... you should have ctx.author: ...

#

mmhm

slate swan
#

testing now 😄

sick birch
#

still won't work until you fix the overwrites

slate swan
#

What is wrong with them

slate swan
#

overwrites = {
        guild.default_role: discord.PermissionOverwrite(read_messages=False),
        ctx.author.id: discord.PermissionOverwrite(read_messages=True),
    }
    channel = await guild.create_text_channel(f"{ctx.author.id}", overwrites=overwrites)
#

ah

sick birch
#

overwrites should have a discord.Role or discord.Member key, and have a discord.PermissionOverwrite as their value

slate swan
#

it worked!!

sick birch
#

awesome!

slate swan
#

How would I get around with deleting a channel with its name

sick birch
#

using discord.utils.get(...)

slate swan
#

channel = discord.utils.get(ctx.guild.channels, name=given_name)

pliant gulch
sinful barn
#

how can we separate commands into different files?

slate swan
sick birch
pliant gulch
#

Extensions?

sick birch
#

that's what they're called yes

pliant gulch
#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
slate swan
#
channel = discord.utils.get(ctx.guild.channels, name=ctx.author.id)
await channel.delete()
#

returns AttributeError: 'NoneType' object has no attribute 'delete'

sinful barn
#

ah ok Thanks

sick birch
#

probably means it didn't find the channel

pliant gulch
slate swan
#

That worked holy this channel is a blessing haha thank you so much

pliant gulch
pliant gulch
#

You have the channel just barely created assigned to channel already,

#

Just do await channel.delete()

#

Unless you are deleting in a different command

slate swan
#

^

#

How would I catch the error this creates channel = discord.utils.get(ctx.guild.channels, name=str(ctx.author.id))

#

if the channel does not exist?

pliant gulch
#

Check if channel is None

#

If it is, the channel doesn't exist

slate swan
#

That works, thank you

You used golang error handling? shit is a dream

pliant gulch
#

Golang

#

Kek

slate swan
slate swan
#

it does

#

917883065362161684

#

thats the role id, freshly copied

#

from the role itself :/

#

maybe the member does not exist

slate swan
#

:/

#

oh

#

try that

slate swan
pliant gulch
#

Are you sure the role is in the same guild the command was invoked in?

#

And maybe the role isn't cached

#

you might need to fetch

slate swan
slate swan
#

I need some help 😳

#

???

#

wth

slate swan
#

DMS

#

just send it here

#

It won't let me

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
pliant gulch
slate swan
pliant gulch
#

Unless your not in a command, if so I must've been confused

slate swan
slate swan
pliant gulch
#

Well, you already have ctx, so you must've invoked the command

slate swan
#

how can i invoke guild role and discord.Member without passing args pepeugh

#

its not working

slate swan
#

learn python, thats your best bet

pliant gulch
#

Otherwise, it may or may not be cached, so you would need to fetch

slate swan
pliant gulch
#

No, I can already tell the problem is because either those two things I said

#

get_role returns None if not found inside of the internal roles cache of the guild

slate swan
#

and that is infact the correct id

pliant gulch
#

So then it isn't cached

slate swan
#

ive tripple checked

sick birch
#

probably not cached like he said

slate swan
#

ok what about this then

member = ctx.author
role = ctx.guild.get_role(917883065362161684)
await member.add_roles(role)```
slate swan
pliant gulch
slate swan
pliant gulch
#

Can you print ctx.guild.roles and show us the output

slate swan
sick birch
#

fetch it

slate swan
slate swan
pliant gulch
# sick birch fetch it

Sad part is discord seems to have no endpoint to fetch a specific role? Only all of the roles per guild

slate swan
#

those are basic things

#

!resources

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.

slate swan
sick birch
#

too much to ask haha

pliant gulch
slate swan
pliant gulch
#

I'm not saying if its there or if it isnt there, nor trying to disprove you

#

I simply want to see what discord thinks

slate swan
#

can role ids change

#

cuz i swear thats not what it was 5 minutes ago

pliant gulch
#

You still haven't printed out the roles of the guild

slate swan
# pliant gulch You still haven't printed out the roles of the guild

roles: [<Role id=890306563565305866 name='@everyone'>, <Role id=917231994251927653 name='Quarantine'>, <Role id=917231993593421905 name='Muted'>, <Role id=917284127701598250 name='Member'>, <Role id=917226561697103972 name='Bots'>, <Role id=917285027421769749 name='Crew'>, <Role id=917284786471596035 name='Staff'>, <Role id=917134314091728907 name='Developer'>, <Role id=917134069953855539 name='Owner'>, <Role id=890319379919691848 name='Acrella'>, <Role id=917226385171419167 name='Wick'>, <Role id=890319185580793927 name='*'>]

#

the role would be Member role

#

so this.. 917284127701598250

pliant gulch
#

Uhh....

#

The role id is different from the one you sent

slate swan
#

I KNOW

#

and you saw me copy it

#

its so weird

pliant gulch
#

¯_(ツ)_/¯

#

Just change the ID to the one just shown

slate swan
#

@slate swan Invite me to ur server Ima test it out

pliant gulch
#

That should work

slate swan
#
@bot.command()
async def verify(ctx):
    member = ctx.author.id
    def check(m):
        return m.author.id == ctx.author
    role = ctx.guild.get_role(917284127701598250)
    embed = discord.Embed(title=f'Verification', description=f'You have `1` attempt to verify. If you fail, you may be re-evaluated by executing the command again', color=clr)
    failbed = discord.Embed(title=f'Verification', description=f'You have failed the verification process! Please try again', color=clr)
    passbed = discord.Embed(title=f'Verification', description=f'You have passed the verification process! Enjoy your stay', color=clr)
    captcha = random.randint(1, 4)
    print(f"roles: {ctx.guild.roles}")
    print('worked3.0')

    if captcha == 1:
        print('worked3.1')
        embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283179843452970/wickCaptcha.png')
        await ctx.send(embed=embed)
        msg = await bot.wait_for('message', check=check, timeout = 15)
        if msg.content == 'KZEXEH':
            await ctx.send(embed=passbed)
            await member.add_roles(role)
        else:
            await ctx.send(embed=failbed)```
output:

worked3.0
worked3.1
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TimeoutError: ```

pliant gulch
#

Your wait_for is timing out

#

You didn't response within 15 seconds

slate swan
#

yeah, but i replied almost instantly

#

before it timed out

pliant gulch
#

Don't know what else to say other than that /shrug

#

Maybe try again

slate swan
faint echo
slate swan
#

idiot ¯_(ツ)_/¯

faint echo
#

Who?

slate swan
#

me lemon_fingerguns_shades

faint echo
#

Not very polite btw

#

Why you calling urself an idiot?

slate swan
#

I dunno

faint echo
#

You fixed the problem with your bot?

slate swan
#

I keep forgeting how to start it up

faint echo
#

Send me the main file, the one containing the run for your client
Don't include TOKEN!!

faint echo
#

Worked?

slate swan
#

trying it lol

slate swan
# faint echo Worked?
role = ctx.guild.get_role(917284127701598250)
await member.add_roles(role)```
`AttributeError: 'int' object has no attribute 'add_roles'`
faint echo
#

well.. think about it.

#

You made member an int on your first line of that func

slate swan
#

add_role isnt it

faint echo
#

Nah

slate swan
#

oh wait

#

ok yep nope im clueless

#

i passed member already

#

i passed role

faint echo
#

member = ctx.author.id
That is clearly an integer.
Your variable member is now an int containing the ID of the ctx.author

Which means... 'int' object has no attribute 'add_roles'

faint echo
#

Do: member = ctx.author

#

and then you can use add_roles

slate swan
#

that took me way too long

faint echo
#

You just needed another view...

slate swan
faint echo
slate swan
#

bet

faint echo
#

just dont include token...

slate swan
#

Dms?

faint echo
#

I don’t do DMs, just send it here

#

A custom help command ? You should watch some videos online on it— it can get pretty hard depending on how complex you want it to be

slate swan
#

1 sec

unkempt canyonBOT
#

Hey @slate swan!

It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

slate swan
#

bruh

#

see? I need to send it in DMs. It is the folder of the bot.

#

@faint echo

pliant gulch
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

uhhh there is alot of coding.

pliant gulch
#

You only need to send the relevant part, E.g the starting code

slate swan
#

Trust me.

pliant gulch
#

The whole issue is you forgetting how the start the bot is it not?

faint echo
#

that seems quite simple

sinful barn
#

I saw how the python bot ran code in discord after a command, how could I replicate that in my own bot
not asking for the code to be handed to me necessarily just want to be pointed in the right direction as I cant find results online.

slate swan
#

Here. I cannot

pliant gulch
#

Discord.py commands extension has a built in help command, you need to remove that before setting your own

#

In your bot's constructor, E.g commands.Bot(...)

#

You can pass help_command=None

#

And to make the help command I recommend subclassing the HelpCommand class

#

!customhelp

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

pliant gulch
#

Heres a guide you can read

sinful barn
#
client = commands.Bot(command_prefix='!', help_command=None) ```
faint echo
#

In this video, we learn how to use the built in help command and create our own custom version of it.

If you have any suggestions for future videos, leave it in the comments below.

GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/

OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN...

▶ Play video
faint echo
faint echo
quaint epoch
#

Is it possible to do ctx.channel.history(limit=10) instead of channel.history(limit=10)

#

so that i don't have to manually enter the channel object

quaint epoch
slate swan
#
import os
from keep_alive import keep_alive
from discord.ext import commands

bot = commands.Bot(
    command_prefix="TN",
    case_insensitive=True
)

bot.author_id = 795811559456768010  

@bot.event 
async def on_ready(): 
    print("I'm in")
    print(bot.user)


extensions = [
    'cogs.cog_example' 
]

if __name__ == '__main__':  
    for extension in extensions:
        bot.load_extension(extension) 
    
keep_alive() 
token = os.environ.get("DISCORD_BOT_SECRET") 
bot.run(token)  ```
faint echo
#

And the problem is your bot is not running correct?
Like at all.. it doesn't even start?

slate swan
#

Yea.

faint echo
#

Does it print ("I'm in") on console?

slate swan
#

It does,

#

But it fails When I try to boot it up.

faint echo
#

Commands don't work at all right?

slate swan
#

yea.

faint echo
#

your variable name should not be tuple, as that is a type.

slate swan
#

also worked on the README.md file, So, it came out as,

# TNLmusic

Hi there! Name's TNLmusic I am a 14 Year Old Developer

### Music

I create music and put them on spotify. 
### TNbot 
TNbot is an In Progress Discord bot Created By, TNLmusic#5027
### End
Have a great day!```
#

and that works.

#

OH FUCK

#

I JUST REALIZED

#

I GOTTA GO FIX IT

pliant gulch
#

Is this a typehint you have somewhere

#

Ok, so maybe your python is a lower version that doesn't support typehinting like that

#

Or you can just do, ```py
from future import annotations

#

This will turn all annotations into strings

prime wolf
#

are there any major differences between hikari and pycord?

pliant gulch
#

HIkari is it's own discord API wrapper, pycord is a fork of discord.py

slate swan
#

anybody have ideas for a bot?

modest plover
#

Hey I got an issue with pip?
Pretty much, I'm tryna install disnake, a fork of discord.py and whenever I run pip install disnake it throws an error that says this:

ERROR: Failed building wheel for yarl
Failed to build multidict yarl
ERROR: Could not build wheels for multidict, yarl, which is required to install pyproject.toml-based projects

There's a bunch more text above it but idk what it is, it's red and says stuff like:

running build_ext
  building 'yarl._quoting_c' extension
  creating build/temp.linux-aarch64-3.10
  creating build/temp.linux-aarch64-3.10/yarl
  aarch64-linux-android-clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -O3 -fstack-protector-strong -O3 -fPIC -I/data/data/com.termux/files/usr/include/python3.10 -c yarl/_quoting_c.c -o build/temp.linux-aarch64-3.10/yarl/_quoting_c.o
  CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang": cannot locate symbol "__emutls_get_address" referenced by "/data/data/com.termux/files/usr/lib/libclang-cpp.so"...
  error: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
``` for example.

I can install packages that aren't this, but anything discord related doesn't install. Anyone know a fix?
I asked in [#help-bagel](/guild/267624335836053506/channel/696840434462228480/) and got nothing.
modest plover
pliant gulch
slate swan
pliant gulch
#

🧠

modest plover
slate swan
pliant gulch
#

It is released

#

Its in alpha

slate swan
#

is it fully released?

pliant gulch
pliant gulch
#

Allowing for a bot to work at the very least normally

#

I'm talking about the commands ext*

modest plover
pliant gulch
#

You upgraded pip then tried pip installing disnake?

modest plover
#

Yep

pliant gulch
#

How are you invoking pip?

modest plover
#

Wdum?

slate swan
pliant gulch
#

python -m pip ...?

slate swan
#

@commands.command()
async def play(self, ctx, *, url):
player = await YTDLSource.from_url(url, loop=self.client.loop, stream=True)
ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
play1 = discord.Embed(title=">>> MUSIC 🎵", description="► Now playing: {}")
play1.timestamp = datetime.datetime.utcnow()
play1.set_footer(text="☆ Creator LL#0884 ☆")
await ctx.reply(embed=play1)
await ctx.reply('Now playing: {}'.format(player.title))

@play.before_invoke
async def ensure_voice(self, ctx):
    if ctx.voice_client is None:
        if ctx.author.voice:
            await ctx.author.voice.channel.connect()
        else:
            play2 = discord.Embed(title=">>> MUSIC 🎵", description="► You are not connected  \nto a voice channel.")
            play2.timestamp = datetime.datetime.utcnow()
            play2.set_footer(text="☆ Creator LL#0884 ☆")
            await ctx.reply(embed=play2)
            raise commands.CommandError("Author not connected to a voice channel.")
    elif ctx.voice_client.is_playing():
        ctx.voice_client.stop()
#

Any who xan help my play command dont work

modest plover
pliant gulch
#

Try python -m pip install disnake

modest plover
#

Still didn't work

#

Gave same error as before.

pliant gulch
thick sigil
#

3.10

#

are u trying to install a discord lib on an android?

modest plover
#

3.10, and yes I am.

#

I'm using Termux, it's a Linux command line emulator

pliant gulch
#

Maybe its an andriod specific issue?

#

I'm running arch linux as my main driver and I'm installing packages fine

modest plover
#

I'm able to install other packages fine

#

Like I can install something like python-dateutil perfectly fine

slate swan
modest plover
#

A joke bot? Like a bot that tells jokes?

slate swan
modest plover
#

Not exactly, some people would use it

slate swan
#

Not really....

slate swan
#

I asked for an idea that was good no offense

#

A joking bot seems useless to me

half sun
# slate swan anybody have ideas for a bot?

Have a bot that communicates to a SQL database to store data such as XP for example

Have a bot which you can interact with on a website. E.g send a message on the website, and the bot output it in a channel. Obviously this can expand way more into a "hub" of sorts

slate swan
#

Good idea tho

half sun
#

So you mean commands?

slate swan
#

Ig so

half sun
#
  • games
  • image manipulation
  • Reddit scraper (e.g get random post in subreddit)
slate swan
half sun
#

For example, doing a custom rank card

#

So doing ?rank would output that

#

The image manipulation is placing the avatar on the image

#

Or applying a filter to an avatar, etc

slate swan
#

Oh lol

finite apex
#

Hi

slate swan
#

why is the Member not disconnected when they are deafened?

@bot.command()
async def isDeafen(ctx,member: discord.Member):
    if(member.voice.self_deaf):
        await member.disconnect()
#

AttributeError: 'Member' object has no attribute 'disconnect'

#

but I can't find any other function to disconnect a member.

wicked atlas
#
await member.edit(voice_channel=None)
slate swan
#

thank you

ionic pebble
#

trying to make my first slash command bot but upon inviting to my server the slash commands arent showing up. im guessing this is a common thing but i dont see anything because I'm using the applications.commands scope and I verified that my cog is being loaded in the bot

#

hm, based on the library's quickstart looks like the github is maybe outdated

polar ice
#

Hello, is there a way to download all messages in a channel?

jade tartan
#

What's the field code?

#
async def on_member_join(member):
        guild = client.get_guild(730651046459998218)
        channel = client.get_channel(885464532959526913)
        Myembed = discord.Embed(title= f"Welcome",
        description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)")
        Myembed.add_field(name = 'Account created:', value= {member.created_at} inline = True)
        await channel.send(embed=Myembed)
        roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
        for roles in roles_list:
            role = discord.utils.get(member.guild.roles, name=roles)
            await member.add_roles(role)
            ```
slate swan
#

could someone tell me where i can find the docs for slash commands

polar ice
loud junco
#

best error 2021

boreal ravine
#

its an inb module

boreal ravine
boreal ravine
jade tartan
#

How do i make it say like this?

jade tartan
boreal ravine
#

hm

jade tartan
#

like to where itll say how many days the member has created the account or month or year

boreal ravine
jade tartan
#

Nope

#

I dont want the date

unkempt canyonBOT
#

property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
boreal ravine
jade tartan
boreal ravine
jade tartan
#

or maybe ill put that in another embed field

boreal ravine
#

i mean <t:1995535233:R> looks cool

loud junco
#

replit being replit

#

just another normal day in replit

boreal ravine
#

nice

jade tartan
#

to get out off

boreal ravine
#

bruh

#

thats literally what I did earlier but with another format

jade tartan
#

No but u did month day year and time

boreal ravine
#

@jade tartan

jade tartan
slate swan
#

using this function

@bot.event
async def on_message(message):
    if message.author.id == 890318171817537577:
        return
    purgeChannel = bot.get_channel(917289006335680592)
    await purgeChannel.purge(limit=1, check=checkk)
    await bot.process_commands(message)```how can i prevent the bot from deleting its own messages?
loud junco
#
if message.author.id == yourBotId:
  dontDeleteMessage()
#

i think something like this

slate swan
loud junco
#

:D

slate swan
boreal ravine
unkempt canyonBOT
#

property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
boreal ravine
jade tartan
#

i mean to where itll say that how long has this person has created the account

#

?

boreal ravine
boreal ravine
jade tartan
#

User.created_at Is that right?

#

@boreal ravine

#

right

boreal ravine
#

!d discord.User.created_at

unkempt canyonBOT
#

property created_at: datetime```
Returns the user’s creation time in UTC.

This is when the user’s Discord account was created.
loud junco
slate swan
loud junco
#

i wanna do

if user type 'rpm area 1'
area = 1

if user type 'rpm area 2'
area = 2

if user type 'rpm area 3'
area = 3

#

how do i do

#

i need bot.group() one by one?

slate swan
sullen shoal
fading harness
#
async def abc(ctx):
  #can i do class here? i wanna do dropdown 
  #dpy 2.0
slate swan
jade tartan
#

Its telling me that user is not defined

#

Are you sure its User?

sullen shoal
sullen shoal
#

read my message again

maiden fable
unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.

x == y Checks if two activities are equal.

x != y Checks if two activities are not equal.

hash(x) Returns the activity’s hash.

str(x) Returns the custom status text.

New in version 1.3.
sullen shoal
#

it won't work for buttons and stuff if thats what they're talking about

jade tartan
#

@boreal ravine Are you sure its User?

slate swan
maiden fable
#

Nah just a joke

slate swan
#

Ill bet you a big mac tho

maiden fable
#

Hmmm

slate swan
maiden fable
#

Yea...

#

!d discord.Member.activities

unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.

maiden fable
#

Just loop through them and use isinstance

slate swan
maiden fable
#

The bot can surely get the status

jade tartan
#

Myembed.add_field(name="Account Created at:", value=f"{User.created_at(datetime)}", inline=True) Is that right? because it wants me to define User

slate swan
jade tartan
#

!d discord.User.created_at

unkempt canyonBOT
#

property created_at: datetime```
Returns the user’s creation time in UTC.

This is when the user’s Discord account was created.
maiden fable
#

Ah

slate swan
maiden fable
#

It can't

maiden fable
slate swan
jade tartan
#

Tried it, but it doesnt work still

final iron
#

Let's see the code

jade tartan
#

ok hang on

loud junco
#

i wanna do

if user type 'rpm area 1'
area = 1

if user type 'rpm area 2'
area = 2

if user type 'rpm area 3'
area = 3
how do i do
i need bot.group() one by one?

jade tartan
#
async def on_member_join(member, User):
        guild = client.get_guild(730651046459998218)
        channel = client.get_channel(885464532959526913)
        Myembed = discord.Embed(title= f"Welcome",
        description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)"))

        Myembed.add_field(name="Account Created at:", value=f"{User.created_at(datetime)}", inline=True)
        await channel.send(embed=Myembed)
        await member.send(embed=Myembed)
        roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
        for roles in roles_list:
            role = discord.utils.get(member.guild.roles, name=roles)
            await member.add_roles(role)```
#
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: on_member_join() missing 1 required positional argument: 'User'```
final iron
#

on_member_join() only takes in member

#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

it isn't possible to set that

boreal ravine
full valley
#

How do I make an error handler for key errors?

Like my old handler for another command is

# Handling error if no games are available to leave from
@report.error
async def report_error(ctx, error):
    if isinstance(error, commands.CommandInvokeError):
        pass
#

but the error I want to catch is KeyError

boreal ravine
boreal ravine
#

like you did with CommandInvokeError error

full valley
#

so is it just error, KeyError?

boreal ravine
full valley
#

nothing before KeyError?

jade tartan
full valley
#

ok cheers

boreal ravine
full valley
maiden fable
boreal ravine
#

o

boreal ravine
full valley
slate swan
#

hi, im still new to making discord bots and python in general and I am looking for some help.

I am trying to make a discord bot that will take information from a game's api to list useful information. and to update every few minutes.
I have the basic embed down and stuff but I cant figure out how to show the data from the api the way I want it too.

#

where I am at currently is I have the data from the api in a variable called myJson. and I can pull information from there fine but its raw data

#

i just dont know how to make it look much more readable

#

much more readable*

shrewd laurel
#

Hi guys. Please tell me how to implement the command - take the last USER_ID message from the CHANNEL_ID and place it in the current channel?

maiden fable
sullen shoal
#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Examples

Deleting bot’s messages...
sullen shoal
#

you can google that

slate swan
#

alright

sullen shoal
#

the checks kwarg

#

it will pass message to the check iirc

#

unless the author of the message is the bot, it should return True otherwise False

loud junco
#

i wanna do

if user type 'rpm area 1'
area = 1

if user type 'rpm area 2'
area = 2

if user type 'rpm area 3'
area = 3
how do i do
i need bot.group() one by one?

#

rpm is prefix

sullen shoal
#

make the integer an argument of the area command

loud junco
#

how

sullen shoal
loud junco
sullen shoal
#

are you using the commands extension

loud junco
#

yes

sullen shoal
#

do you know to make a command with it

loud junco
#

im using this one
from discord.ext import commands

loud junco
#

i just wanna ask

#

is there another way instead of

@bot.group()
sullen shoal
# loud junco yes

every argument of the function will be passed the content, the command was invoked with

#

why do you want to make a group

loud junco
#

cuz its gonna be
rpm area 1
rpm area 2
rpm area 3
rpm area 4

#

till 14

#

rpm is prefix

sullen shoal
#

the integer can be an argument of the command area

#

show me how you make a command

loud junco
#
@bot.command(name = 'profile')
@commands.cooldown(1, 5, commands.BucketType.user)
async def profile(ctx: commands.Context):
loud junco
sullen shoal
#
@bot.command()
async def my_cmd(ctx, arg)
    print(arg)

now if I do

my_cmd 1

it will print 1

loud junco
#

ooooo

#

u dont need (name = 'profile)?

#

=.=

final iron
#

The name will default to the function name

loud junco
#

but is the 1 int or str

sullen shoal
#

if you dont pass the name, it will use the name of the function

loud junco
#

oo ok

sullen shoal
loud junco
#

ok

sullen shoal
#

by default it will be str

loud junco
#

so i do int()

#

?

final iron
loud junco
#

ok

sullen shoal
#

arg: int

slate swan
sullen shoal
#

arg: typing.Union[int, str]
this will first try to convert it to int
and if it fail it will try to convert it to str which will never fail

loud junco
#

hmm

slate swan
#

Yeah

loud junco
#

but i only want the user to type in 1-14

sullen shoal
#

if statements

final iron
#

Now I finally understand how to use Union[]. You learn something every day

loud junco
#

so i dont think its necessary

sullen shoal
final iron
sullen shoal
#

it try to convert it to every type the user passed to Union

#

i mean one by one

#

if the current one fails

pliant gulch
#

Discord.py reads the command signature, and its annotations. They do this to internally call the corresponding converters E.g member: discord.Member would call MemberConverter

#

In normal python typehinting is only for you and other people who may read your code to know what the arg type is expected to be. This can be checked with type checkers such as pyright, mypy... Etc

loud junco
#
arg = round(arg)
```this will round off the number to int right?
sullen shoal
#

no

pliant gulch
#

If the arg is a float it would round it off

sullen shoal
#

its the default value

pliant gulch
#

Otherwise if its an int it would be the same

loud junco
#

oo ok

pliant gulch
#

!e ```py
print(round(1))
print(round(1.5))

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 2
sinful barn
#

!e import flask

unkempt canyonBOT
#

@sinful barn :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 'flask'
sinful barn
#

was curious

boreal ravine
#

#bot-commands <=

sinful barn
#

for sure

loud junco
#
@bot.command(name = 'area')
@commands.cooldown(1, 5, commands.BucketType.user)
async def area(ctx, arg: int):
  userid = ctx.author.id
  highestArea = db[userid + 'highestArea']
  if 1 <= arg <= 14:
    if arg <= highestArea:
      db[userid + 'area'] = arg
      await ctx.send(f'**{ctx.author.name}** has moved to **AREA {arg}**')
    else:
      await ctx.send(f'**{ctx.author.name}** fight more bosses :D')
  else:
    await ctx.send('404 area not found')
pliant gulch
loud junco
#

oo

#
userid = str(ctx.author.id)
```should be this one
#

i keep forgetting

pliant gulch
#

That can work yes

loud junco
#

🤦

sullen shoal
#

the db must be looking ugly

pliant gulch
#

But that's an odd key to set the value under

#

You'd need to access it via idarea

loud junco
#

my area variable name
757508305256972338area

#

userid + 'area'

pliant gulch
#

Might be good to change that into something easier to use

loud junco
#

hmm

#

like what

pliant gulch
#

Well wouldn't it make sense to have

#

db[arg] the actual area

tiny ibex
#

!source eval

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
pliant gulch
#

And add ctx.author.id to it?

tiny ibex
#

!source pypi

unkempt canyonBOT
#
Command: pypi

Provide information about a specific package from PyPI.

Source Code
sullen shoal
#

#bot-commands

tiny ibex
#

Has pypi got some kind of api?

loud junco
#

idk how

#

but its working

tiny ibex
pliant gulch
#

No clue, do a google search

tiny ibex
grand yew
#

Anyone who code bots for free dm me

tiny ibex
#

Oof

tiny ibex
#

Learn coding yourself
Go on fiverr

sullen shoal
#

json ig

pliant gulch
#

Prob the replit's database

boreal ravine
#

doesn't look like that

sullen shoal
#

!e

db = {}
db["92828"+"area"] = "huh"
print(db)```
unkempt canyonBOT
#

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

{'92828area': 'huh'}
boreal ravine
#

^^ replit's db

pliant gulch
#

Json isn't even a database, its a file format

#

You can use it for stuff like databases though

shadow wraith
pliant gulch
#

Such as a JSON document database, like mongo

shadow wraith
#

i use json database because its simple

pliant gulch
#

😬

sullen shoal
#

🥶

shadow wraith
#

🥵

boreal ravine
#

yes, JSON is good as a configuration file and what not

shadow wraith
#

why are we all discussing about databases and JSON

sullen shoal
#

because chat ded

boreal ravine
#

Agreed

sick birch
boreal ravine
#

?

pliant gulch
#

🤔

boreal ravine
#

someone sent something earlier, but it got deleted

shadow wraith
sick birch
#

mongo isn't json, sure it's similar but they run completely differently

boreal ravine
#

^

sick birch
#

true dat

pliant gulch
#

Mongo uses the JSON format

boreal ravine
#

but it's JSON like anyways

pliant gulch
sick birch
#

the format/syntax is

shadow wraith
#

is mongo just a better version of json

boreal ravine
shadow wraith
#

hmmm

sick birch
#

in a very simplified manner yes

#

it's much more complex and can do many more things

loud junco
sick birch
#

it's a full fledged database, while, json is only a file format that wasn't meant for storing persistent data

loud junco
#

Im using discord py

#

😂😂😂😂😂😂

shadow wraith
loud junco
#

Db

#

Replit db

shadow wraith
#

🤔

sick birch
#

Replit has a db?

loud junco
#

Ya

pliant gulch
sick birch
#

dang i wonder how terrible it is haha

pliant gulch
#

I was speaking upon the format, E.g json document

sick birch
pliant gulch
#

I could've phrased it better

loud junco
#

main py

sick birch
#

nah its good haha

boreal ravine
shadow wraith
#

i only know basic sql and thats it :c

sick birch
#

apparently replit's files are ephemeral? at least that's what i've been told

pliant gulch
#

Yes they are

sick birch
#

something about system-written changes that disappear after a restart

pliant gulch
sick birch
#

i guess they made their own database for it

pliant gulch
#

A local database is impossible on replit if you want persistent data

boreal ravine
#

I think that means whatever you use in the shell is ephemeral, everything else isn't

pliant gulch
#

Unless replit's builtin database goes past that

sick birch
#

serverless computing i guess

pliant gulch
#

Otherwise the only choice would be a cloud hosted database

sick birch
#

i'd assume replit's database is as terrible as their service itself

spare creek
#

e

boreal ravine
#

i mean replit isn't terrible; it's the people that use it is terrible

dusk narwhal
pliant gulch
#

Replit is a fine on the go environment, it isn't good for discord.py although

misty nexus
#

why do people use replit for bots actually

slate swan
#

hiiiiiiiiiiiiiiiiiiii

arctic gyro
#
@client.event
async def on_message(message):
  if message.channel == 'suggestions':
    channel2 = client.get_channel(883635075743375361) 
    author = message.author
    await channel2.send(message + ' by ' + f"{message.author.mention}")

Can anyone tell me what's wrong with this code?

sick birch
#

why do people use replit for anything

misty nexus
#

for me it doesn't make sense to use replit

boreal ravine
#

new people

#

im out, bye

sick birch
#

yay

dusk narwhal
pliant gulch
#

What if I didn't have my workstation with me?

dusk narwhal
#

but itll prolly be laggy

sick birch
#

i suppose you could but i never like to code when i'm not at my workstation

#

typing code on mobile must be ugh

dusk narwhal
# misty nexus why

well u cant make any application or test application for short time use bc replits console isnt complex enough to display those

sick birch
sullen shoal
pliant gulch
slate swan
sick birch
#

Off the top of my head you're comparing a discord.TextChannel to a string

dusk narwhal
misty nexus
boreal ravine
dusk narwhal
arctic gyro
sick birch
dusk narwhal
arctic gyro
#

i'll try that

sick birch
#

you're comparing an object to a string

shadow wraith
pliant gulch
#

When comparing two objects its not good practice to use ==, rather you should use is

sick birch
#

yep you can have multiple channels with the same name i think

shadow wraith
#

:troll:

boreal ravine
#

!e

class B:
  def __str__(self):
    return 'B'

if B() == 'B':
  print(True)
else:
  print(False)
``` this is what your doing ^^