#discord-bots

1 messages ยท Page 991 of 1

echo wasp
#

@sick birch can ya help?

sterile hamlet
#

with ifttt?

sick birch
errant olive
#

Imma stick with replit for now...
this is to much for me wiht no sleep

sick birch
errant olive
echo wasp
sick birch
#

docker?

echo wasp
errant olive
sick birch
#

instead of running a full fledged VM i mean

sick birch
echo wasp
sick birch
errant olive
sick birch
#

all of our open source bots use docker, @unkempt canyon, @lament depot

sick birch
echo wasp
sick birch
#

FOSS

errant olive
sick birch
#

It's a tool used a lot in the industry and important to know

echo wasp
sick birch
#

As a good practice, you should always dockerize your apps when you can

echo wasp
#

I run 3 bots all small not large

slate swan
echo wasp
sick birch
echo wasp
vale wing
#

I am still having issues with bind mounts ๐Ÿ˜ฉ

sick birch
#

A list of command line arguments that will install python, your bot dependencies, put all your files in the right place, and finally call python3 bot.py

echo wasp
slate swan
#

could be a simple shell (.sh) file right?

sick birch
sick birch
#

actually python has their own docker image

sick birch
echo wasp
sick birch
#

Sure you can deploy docker containers within oracle

#

Not sure if they have a special service for that like AWS EKS

mortal dove
#

Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with

view = HelpMenu().add_item(CogSelect(self.bot))

Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)

echo wasp
sick birch
#

Yeah that's fine. No problem with a vm in a vm

abstract kindle
#

Hey guys

#

Is there a more efficient way in python to do this

#
users_farm = await self.bot.dbfarms.find_one({"_id": user_id})
        if users_farm['plot1'] == "Empty":
            style1 = discord.ButtonStyle.grey
        else:
            style1 = discord.ButtonStyle.green
        if users_farm['plot2'] == "Empty":
            style2 = discord.ButtonStyle.grey
        else:
            style2 = discord.ButtonStyle.green
        if users_farm['plot3'] == "Empty":
            style3 = discord.ButtonStyle.grey
        else:
            style3 = discord.ButtonStyle.green
paper sluice
#

i guess thats efficient, because u hard coded it

errant olive
paper sluice
#

but use a loop for such things

abstract kindle
#

Yeah

#

Wondering how to do that

#

Like how to pass out variables with different names for each loop

paper sluice
#
users_farm = await self.bot.dbfarms.find_one({"_id": user_id})
styles = {}
for key, value in users_farm.items():
    if value == 'Empty':
        styles[key] = discord.ButtonStyle.grey
    else:
        styles[key] = discord.ButtonStyle.green

paper sluice
abstract kindle
#

mm

#

Okay, thanks!

paper sluice
#

its supposed to be users_farm.items()

#

*edited

slate swan
#
    @commands.command(name='mute', description='mute a user from all channels', usage='mute (user) [duration] [reason]', aliases=['timeout'])
    async def mute(self, ctx, member: discord.Member, time=None, *, reason='no reason provided'):
        role = discord.utils.get(ctx.guild.roles, name="muted")
        if member is None:
            await ctx.send("missing arguments")
        if member is not None:
            if member.top_role >= ctx.guild.me.top_role:
                await ctx.send("i can't mute someone above my top role")
        if role not in ctx.guild.roles:
            perms = discord.Permissions(send_messages=False, speak=False)
            await ctx.guild.create_role(name="muted", permissions=perms)
        if time:
            if self.convert(time) > -1:
                if reason:
                    tempmute = self.convert(time)
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
                    await asyncio.sleep(tempmute)
                    await member.remove_roles(role)
                elif not reason:
                    tempmute = self.convert(time)
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
                    await asyncio.sleep(tempmute)
                    await member.remove_roles(role)

            elif self.convert(time) == -1:
                reason = time
                time = 'indefinite'
                if reason:
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
                elif not reason:
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
        elif not time:
            await member.add_roles(role)
            await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")

i want to make it so this works, which it doesn't currently:

        if member is None:
            await ctx.send("missing arguments")
        if member is not None:
            if member.top_role >= ctx.guild.me.top_role:
                await ctx.send("i can't mute someone above my top role")
#

anyone that can help?

#

set the default value of member argument to None

#

right, thank you

echo wasp
#

@sick birch can you help me in depth like step by step?

slate swan
abstract kindle
#

nother question

slate swan
slate swan
# slate swan show updated code
    @commands.command(name='mute', description='mute a user from all channels', usage='mute (user) [duration] [reason]')
    async def mute(self, ctx, member: discord.Member = None, time=None, *, reason='no reason provided'):
        role = discord.utils.get(ctx.guild.roles, name="muted")
        if member is None:
            return await ctx.send("missing arguments")
        if member is not None:
            if member.top_role >= ctx.guild.me.top_role:
                return await ctx.send("i can't kick someone above my top role")
        if role not in ctx.guild.roles:
            perms = discord.Permissions(send_messages=False, speak=False)
            await ctx.guild.create_role(name="muted", permissions=perms)
        if time:
            if self.convert(time) > -1:
                if reason:
                    tempmute = self.convert(time)
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
                    await asyncio.sleep(tempmute)
                    await member.remove_roles(role)
                elif not reason:
                    tempmute = self.convert(time)
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
                    await asyncio.sleep(tempmute)
                    await member.remove_roles(role)

            elif self.convert(time) == -1:
                reason = time
                time = 'indefinite'
                if reason:
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
                elif not reason:
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐Ÿ‘")
        elif not time:
            await member.add_roles(role)
            await ctx.send(f"**{member}** has been muted for **{reason}** - **indefinite** ๐Ÿ‘")
abstract kindle
#
        class Buttons(discord.ui.View):
            def __init__(self, *, timeout=180):
                super().__init__(timeout=timeout)
            @discord.ui.button(label="exit", style=discord.ButtonStyle.red)
            async def exit_button(self, ...):
              # Want to tell code that we don't need to count down
         message = await ctx.send(embed=embed, view=Buttons())
         # How do I tell code here that if we have used the exit button, don't count anymore.
         await asyncio.sleep(20)
         await message.delete()
umbral aspen
#

Is it possible to do slash commands or buttons without using an external library?

abstract kindle
#

and I think slash commands do too, but I haven't figured those out yet

slate swan
abstract kindle
#

Yep

#

I also think there is support for Modals

umbral aspen
#

Thank you guys

paper sluice
abstract kindle
#

But it doesn't check again

#

The flag gets set to True, and it doesn't check to see if its False after the countdown has started

#

And I can't do a while loop, because it's a countdown

#

I suppose I could countdown by decreasing a value until it hits 0 lol

#

for every loop

umbral aspen
#

You would make it wait in a while loop also

#

By decreasing the time

abstract kindle
#

?

#

wait could I just do this

paper sluice
#
if flag:
    # code for couting
abstract kindle
#
while flag:
  await asyncio.sleep(20)
  await message.delete()
  break
abstract kindle
#

And then when flag is set to True it will just break it

#

Oh good

#

Here's the issue I'm running in to

#
@discord.ui.button(label="Exit", style=discord.ButtonStyle.red)
            async def exit_button(self, interaction: discord.Interaction, button: discord.ui.Button):
                if interaction.user != ctx.author:
                    return
                await ctx.bot.dbfarms.update_one({"_id": user_id}, {"$set": {"has_open_farm": False}})
                await message.delete()
                flag = False
#

flag in that code is greyed out, like it's not going to update when I run that code

#

would it reach the flag variable in the outer scope?

paper sluice
#

self.flag, i think u want it to be global

abstract kindle
#

self.flag? how come?

paper sluice
paper sluice
abstract kindle
#

oh, and then pass flag into the buttons class

#

Where would I make it global ๐Ÿ˜›

paper sluice
#

!e

class Foo:
    def __init__(self):
        self.bar = 'bar'
    
    def method(self):
        return self.bar
    

print(Foo().method())

using self before a variable name makes it a class attribute, which means that variable can be used anywhere in the class

unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

bar
abstract kindle
#
message = await ctx.send(embed=embed, view=FarmButtons(flag=flag))
#

How would I print FarmButtons().flag

paper sluice
#

wait can u explain what your trying to do, im not sure if i understand

vale wing
#

It's an attribute of the instance

abstract kindle
#

or probably FarmButtons().exit_button()

vale wing
#
o = MyClass()```
`o` is an object
abstract kindle
vale wing
#

Bring it out to a variable

abstract kindle
#

mmm

#

I see

#

It works kind of. When I click the button, it sets self.flag to be false, but it doesn't break the while loop

#
class Buttons(discord.ui.View):
    def __init__(self, *, flag, timeout=180):
        self.flag = flag
    async def exit_button(self, interaction: discord.Interaction, button: discord.ui.Button):
        self.flag = False
        return self.flag
view = Buttons(flag=True)
message = await ctx.send(embed=embed, view=view)
while view.flag is True:
    await asyncio.sleep(5)
    await message.delete()
    break
else:
    print("Exit button was pressed.")
#

is there a way to just return from the entire command if the exit button is pressed??

quaint epoch
#

!d disnake.Interaction

paper sluice
#

!e

class Foo:
    def __init__(self):
        self.bar = 'bar'
    
    def method(self):
        self.bar = False
    

a = Foo()
while a.bar:
    print(10)
    a.method()

unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

10
abstract kindle
#

but what if the flag changes while the while loop code is running?

#

Because that's currently how it works. The while loop starts and if the user presses the button during that time, it should exit the loop

paper sluice
abstract kindle
#

Yeah, and then stop counting down

paper sluice
#

just make it delete the message in the exit_button

abstract kindle
#

There's a 20 second countdown until the message auto deletes when the message is sent. If the button is pressed, it should delete the message and stop the countdown.

strong vector
#

lmao i just write hello world and press random numbers

abstract kindle
#

That works, but it still counts after and I get an error because there is no message to delete

abstract kindle
#

I don't want it to keep counting and then get an error if the button is pressed

#

I feel like it would be more efficient to stop the countdown

strong vector
#

and i found out im in the wrong channel

abstract kindle
#

Instead of handling the error so I don't get a traceback

strong vector
#

i get lost

paper sluice
#
async def exit_button(self, interaction: discord.Interaction, button: discord.ui.Button):
    self.flag = False
    await interaction.response.defer()
    await interaction.delete_original_message()
    self.stop()
    
view = Buttons(flag=True)
message = await ctx.send(embed=embed, view=view)
if view.flag:
    await asyncio.sleep(20)
    message.delete()

try this out

abstract kindle
#

What changed here?

paper sluice
#

im deleting message inside the exit-BUtton function

abstract kindle
#

I already make that happen

#

Issue is, the code reaches the flag check before the button is pressed

#

I need it to check for that flag all the time, so that if the button is pressed after it checks, it just cancels the countdown

paper sluice
#

oh wait we can just make the timeout be 20s instead of 180, and make it delete the button on timeout @abstract kindle

strong vector
abstract kindle
#

And then handle the timeout to delete the message?

paper sluice
#

ya u can write the code to delete message in on_timeout inside the Buttons class

strong vector
paper sluice
#

u want the docs?

strong vector
abstract kindle
#

any way to reset the timeout when a button is presset

#

or is that the default

#

is timeout idle for the duration or just starts upon creation

#

Oh it starts upon last interaction with the UI

paper sluice
#

timeout will be called when the time is passed without any interaction

#

lets say the timeout is 20 seconds, this means that if no one interacted with the buttons/view-items for 20 seconds, on_timeout will be called and u can stuff there

#

but if someone interacts with the buttons under 20 seconds, the timeout-timer resets

sterile imp
#

how to make the bot make a role in another server

slate swan
#

Hello anyone remember me

slate swan
#

How can my bot check if its a website? Like check if message contains https://? And if the website doesnt exist send a message?

maiden fable
#

And for the other part, u gotta send a simple GET request to the website and see the status code

velvet haven
#
@commands.command(name='volume')
    async def _volume(self, ctx: commands.Context, *, volume: int):
        """Sets the volume of the player."""

        if not ctx.voice_state.is_playing:
            return await ctx.send('Nothing being played at the moment.')

        if 0 > volume > 100:
            return await ctx.send('Volume must be between 0 and 100')

        ctx.voice_state.volume = volume
        await ctx.send('Volume of the player set to {}%'.format(volume))```
idk what's wrong here . my command gets ignored
eternal apex
#

I want to make my discord bot send buttons but the interaction fails.

from discord_components import DiscordComponents, Button, ButtonStyle, InteractionEventType
@bot.command()
async def button(ctx):
  await ctx.send("Press Button",
                 components = [
    Button(style=ButtonStyle.blue,
           label="CLICK Me!")
    ]
  )
  rest = await bot.wait_for("button_click")
  await rest.respond(type=InteractionEventType.ChannelMessagewithSource,
                     content="Clicked!")```
slate swan
#

๐Ÿ‘Ž dont use 3rd party libraries for components, use discord.py master branch or a fork

#

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

cloud dawn
slate swan
#

Hm? Its volume

cloud dawn
slate swan
#

why are there brackets in the text? how can i remove them?

cloud dawn
#

A very music cog i might add.

#

Since it violates ToS 9/10 times.

#

And in this case I even back traced the original gist that uses ytdl

slate swan
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโ€™s robots.txt file; (b) with YouTubeโ€™s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

99% take music from yt

cloud dawn
#

It's a grey area, but we don't help with it here, we don't call out anyone just that we won't help someone break it.

slate swan
cloud dawn
slate swan
#

๐Ÿ‘

#

Thanks!

paper sluice
#

๐Ÿ‘€

umbral night
#

which looks better?

# help command
@bot.command()
async def help(ctx):
  em=discord.Embed(title='*help*', description='`utility , moderation`', colour=0x36393F)
  await ctx.send(embed=em)

or

# help command
@bot.command()
async def help(ctx):
  em=discord.Embed(title='*help*',
  description='`utility , moderation`',
  colour=0x36393F)
  await ctx.send(embed=em)
paper sluice
#

first one

umbral night
#

wdym

#

im trying to make it look as small as possible

#

ig

#

mk thanks ill use this

#

oh alright, thanks

severe rampart
#

you know how users can have custom rich presences? i was just wondering if bots can do the same thing?

#

here's an example, where the image for minecraft is shown

paper sluice
#

thats an interesting rich presence and status

umbral night
#

indeed

severe rampart
#

but you get the point, right?

paper sluice
severe rampart
#

i think i may have found something?

#

but i'm not totally sure

#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

โ€ข [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")

โ€ข [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
paper sluice
#

that just sets the thing like playing Game

severe rampart
paper sluice
#

๐Ÿ‘€

severe rampart
#

it looks like you can pass them in as kwargs

wide marlin
#

Anyone knows how to add this little icon on the bottom left of an embed?

wide marlin
#

legend

severe rampart
#

oh, bottom left

#

footer, my bad

#

it looked like it was in the top left

wide marlin
#

Oh, you just pass an url to the footer?

severe rampart
#

!d discord.Embed.set_footer

unkempt canyonBOT
#

set_footer(*, text=None, icon_url=None)```
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.
severe rampart
#

@wide marlin ^^

wide marlin
#

ohh shoot!

#

I never really noticed such a parameter existed!

#

Thanks!

severe rampart
# wide marlin Thanks!
embed = discord.Embed() # whatever is passed to the constructor
embed.set_footer(text = "example_text", icon_url = "fake_url")

await # do something with the embed

just as an example

paper sluice
#

lemme try a diff url ig

severe rampart
#

hence the application_id

paper sluice
#

ah ic

severe rampart
#

this is the one i attempted to do for my bot

#

im trying to make it work with the activity now

maiden fable
#

You cannot use assets in bot's rich presence

severe rampart
#

oof

#

that's sad

maiden fable
#

Discord Issue

severe rampart
maiden fable
#

No I meant, Discord doesn't allow it

severe rampart
#

oh, i see

maiden fable
#

Wrong words usage

umbral night
#
@bot.command()
async def avatar(ctx, user : discord.Member = None):
  if user==None:
    user=ctx.author
    useravatar=user.avatar_url
    em=discord.Embed(
      colour=0x36393F
    )
    em.add_field(
      name=f"{user.name}'s avatar",
      value=f'**[download]({user.avatar_url})**'
    )
    em.set_image(
      url=useravatar
    )
    await ctx.send(embed=em)

did i overdo this?

maiden fable
#

yes

severe rampart
#

you don't need half of that if you just add an error handler somewhere

maiden fable
#

user = user or ctx.author

severe rampart
maiden fable
#

And then remove an indent and bring everything outside the if statement

#

Since that is always gonna work only if user is None, ie, you never specify someone

umbral night
#

oh lol

severe rampart
#

also, if x == None: is functionally equivalent to if not x:

maiden fable
#

But you don't need it since or provides a more readable interface for the same thing and is also faster than an if statement

severe rampart
#

^

gaunt ice
#

hm

#

hunt

#

hows lif

paper sluice
#

hunter.hunt = 'hunter' lemon_pika

gaunt ice
#

i got ignored as usual

severe rampart
gaunt ice
#

ok

#

oh lord

vale wing
maiden fable
vale wing
#

Or a Sized

vale wing
#

Better practice is to use is None

maiden fable
paper sluice
maiden fable
umbral night
# maiden fable `user = user or ctx.author`

this?

@bot.command()
async def avatar(ctx, user:discord.Member = None):
  user=user or ctx.author
  ua=user.avatar_url
  em=discord.Embed(
    colour=0x36393F
  )
  em.add_field(
    name=f"{user.name}'s avatar"
    value=f'**[download]({user.avatar_url})**'
  )
  em.set_image(
    url=user.avatar
  )
  await ctx.send(embed=em)
maiden fable
#

But then everyone has their own opinion

umbral night
#

or am i stupid

severe rampart
umbral night
#

ight tysm

vale wing
#

Like fr because of vulnerabilities there might be issues also pretty sure it's against some PEP but idk which

maiden fable
#

@umbral night u on dpy 1.7 or 2.0?

umbral night
maiden fable
#

Ah cool it will work then

vale wing
#

Anyways doesn't matter

umbral night
paper sluice
maiden fable
#

Breaking change.

severe rampart
#

so, i almost have something possibly working, but i need to know how to get the ids for these images:

paper sluice
#

ah yes

severe rampart
#

it wants me to pass the id ยฏ_(ใƒ„)_/ยฏ

maiden fable
#

I mean, those do not work for bots anyways

maiden fable
#

Uh

severe rampart
#

i just wanna see what error it throws, and no i'll show you what the api ref said

maiden fable
#

Sure

severe rampart
gaunt ice
#

hello there ashley

severe rampart
#

does it mean the name of it, or some id of some kind that i dont know how to get

gaunt ice
maiden fable
#

Can u give the link to those docs?

slate swan
gaunt ice
#

are u tryna use rich presence

maiden fable
#

also large_image and stuff are the literal image names

gaunt ice
severe rampart
maiden fable
gaunt ice
#

yes

maiden fable
#

(Prolly)

gaunt ice
#

rich presence

#

like the status

severe rampart
#

spelling is hard.

maiden fable
#

Cannot test it since my bot has no access to Presence intent, but since member.activity returns an instance of discord.Activity, soooo

severe rampart
#

unfortunate*

maiden fable
#

Its fine, u r not in a spell bee comp

gaunt ice
#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

โ€ข [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")

โ€ข [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
severe rampart
#

client.change_presence() accepts discord.Activity() as a type

umbral night
#
# avatar command
@bot.command()
async def avatar(ctx, user:discord.Member = None):
  user=user or ctx.author
  ua=user.avatar_url
  em=discord.Embed(
    colour=0x36393F
  )
  em.add_field(
    name=f"{user.name}'s avatar",
    value=f'**[download]({user.avatar_url})**'
  )
  em.set_image(
    url=user.avatar
  )
  await ctx.send(embed=em)

no errors, doesn't work?

maiden fable
unkempt canyonBOT
#

class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
umbral night
#

it used to work

maiden fable
#

this is what is accepted in change_presence iirc

#

!d discord.Client.change_presence

unkempt canyonBOT
#

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

Changes the clientโ€™s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter...
maiden fable
#

You can try, but it won't work

severe rampart
#

and that gives you this ^^

severe rampart
maiden fable
#

I tried it, uhhh, long ago

slate swan
maiden fable
#

I don't think the ws returned any error

umbral night
#

oh wait that worked

#

wtf

#

thx @slate swan

cold sonnet
#

Ashley W

slate swan
slate swan
maiden fable
cold sonnet
#

discord.Game is literally a discord.Activity

slate swan
cold sonnet
#

activitytype

maiden fable
#

Okay okay my bad stop

umbral night
#

like literally half an hour ago

maiden fable
#

Prolly 2 python versions

umbral night
#

im pre sure im not on 2.0

cold sonnet
#

and avatar_url is 1.7

umbral night
cold sonnet
#

avatar.url is 2.0

umbral night
#

ye i did _url

slate swan
#

cool

paper sluice
#

I added this thing to my asset, when i switch tabs, it disappears lemon_angrysad

maiden fable
#

Ik

#

Discord issues. Caching takes a few minutes, upto 10-15

severe rampart
paper sluice
#

ah k

severe rampart
#

no reason for the offtopic channel mention

slate swan
severe rampart
#

shown here ^^

slate swan
#

havent seen any bot with that before, goodluck though

severe rampart
#

yeah, lol

#

it might not be possible, but i couldn't find a definitive answer

slate swan
severe rampart
#

what does that mean lol

slate swan
severe rampart
#

oof

#

client.change_presence() can accept a discord.Activity() object which can be instantiated using the assets dictionary shown before

slate swan
#

what?

severe rampart
#

which is what made me think there was a shot i could do it

slate swan
#

idk

slate swan
slate swan
slate swan
#

uh

#

elaborate your answer/query

#

i want to add ๐ŸŽ‰ this emoji

#

so what i write in add_reaction()

slate swan
#

already tried name ;-;

slate swan
#

just left unicode

#

that im asking here

#

what is the unicode for ๐ŸŽ‰ emoji

paper sluice
#

doesn't add_reaction(:tada:) not work?

slate swan
#

no

#

\๐ŸŽ‰
try copying this

paper sluice
#

try add_reaction('\N:tada:')

slate swan
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji

#

see

#

unknown emoji

spring flax
unkempt canyonBOT
slate swan
#

uh

paper sluice
#

owo

slate swan
#

thats what i needed

slate swan
slate swan
#

oh ok

#

not used add_reaction much

#

cuz of buttons

#

ยฏ_(ใƒ„)_/ยฏ

paper sluice
#

same.

slate swan
severe rampart
#

it's just the unicode version

slate swan
#

ik jk

severe rampart
#

achieved by adding a backslash in front

slate swan
#

right

severe rampart
#

\๐ŸŽ‰

slate swan
#

\๐ŸŽ‰

#

๐ŸŽ‰

maiden fable
#

:๐ŸŽ‰

#

On phone u gotta add a :

slate swan
#

it only works with custom emojs hunter

slate swan
maiden fable
#

I'm just sending the unicode

#

\๐ŸŽ‰

#

Oh works
Didn't work before

slate swan
slate swan
#

doesnt work with a colon

#

for default emojis

maiden fable
#

Okay

placid skiff
#

hello hunter, ash

umbral night
#
# welcome message
@bot.event
async def on_member_join(member):
  channel=bot.get_channel(944112299151618128)
  await channel.send(f'{member.mention}, welc to saudi\n{member.guild.member_count}')

how come the member count doesnt embed

#

i mean

#

like send

placid skiff
#

!d discord.Guild.member_count

unkempt canyonBOT
#

property member_count```
Returns the member count if available.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.

Changed in version 2.0: Now returns an `Optional[int]`.
umbral night
#

when a member joins, it just says welc to saudi

placid skiff
#

do you have members intents?

umbral night
#

uh

#

no

#

sorry, i didnt even think abt that

placid skiff
#

well you can do it with len(members) if you don't want to enable it

#

it will count the bot too of course

#

but you can remove them looping through discord.members

#

guild.members*

#

!d discord.Guild.members

unkempt canyonBOT
umbral night
#

ye

maiden fable
maiden fable
placid skiff
maiden fable
#

Cool!

umbral night
#
@bot.command()
async def perks(ctx):
  em=discord.Embed(
    title='*boost & inv perks*',
    colour=0x36393F
  )
  embed.add_field(
    name='boost perks',
    value='` 1x bst = custom role + rich role + pic perms \n 2x bst = ^ + lowmod + bypass gw reqs         `'
  )
  embed.add_field(
    inline=False,
    name='invite perks',
    value='` 5x invs = custom role + pic perms            \n 10x invs = ^ + lowmod + gang role            `'
  )
  await ctx.send(embed=em)

any clue why this doesnt work anymore?

#

it should?

#

nothing

#

and no errors

#

idk

#

nope it doesnt

#

weird, i cant see anything wrong with it

#

yes

#

no error

#

oh

#

oh

#

how do i fix it while keeping the error handler

#

alright

slate swan
#

roll = (958979841292648459)
key = ''.join((random.choice('abcdefghijklmnopqrstuvwxyz1234567890')) for x in range(6))```
```py

@bot.event
async def on_member_join(message):
  await message.send(f"reply to this message with key: ||{key}||")
  m = await bot.wait_for('message',timeout=60.0)
  if m.content == key :
    memberr = message.author
    await bot.add_roles(memberr, roll)
    await message.send('Role added')
  else:
   await message.send('Incorrect key');```
slate swan
umbral night
#
  File "/home/me/suede/main.py", line 151, in perks
    embed.add_field(
AttributeError: 'Command' object has no attribute 'add_field'

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

Traceback (most recent call last):
  File "/home/me/suede/env/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/me/suede/env/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/me/suede/env/lib/python3.9/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: AttributeError: 'Command' object has no attribute 'add_field'
maiden fable
#

u have a command named embed

slate swan
#

huh?

#

very

severe rampart
slate swan
#

do em

severe rampart
#

^

umbral night
#

OHH

slate swan
#

fast

slate swan
#

bruh just add em

umbral night
#

bruh ive been staring at this code for like 10 minutes and couldnt see that

#

lmao

slate swan
#

Maybe try use embed docs to your advantage

umbral night
#

till like 3 minutes ago

slate swan
#

oh...

umbral night
#

true

#

thanks guys

slate swan
#

roll = (958979841292648459)
key = ''.join((random.choice('abcdefghijklmnopqrstuvwxyz1234567890')) for x in range(6))```
```py

@bot.event
async def on_member_join(message):
  await message.send(f"reply to this message with key: ||{key}||")
  m = await bot.wait_for('message',timeout=60.0)
  if m.content == key :
    memberr = message.author
    await bot.add_roles(memberr, roll)
    await message.send('Role added')
  else:
   await message.send('Incorrect key');```
It wonโ€™t read the key sent
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") join or leaves 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.
supple thorn
slate swan
#

Ok thanks

slate swan
#

My problem is bot.wait_for('message',timeout=60.0) doenst work pretty much it doenst read the message

#

Explain ?

#

Check event?

#

O

maiden fable
#

Add a print at the top of the function

slate swan
#

ok

#

nothing prints

velvet haven
#

i am making a tictactoe game when i challenge someone and if they don't respond within 30 seconds i want the game to be over. How do i do that

maiden fable
umbral night
#

hm

maiden fable
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
slate swan
#

i have ticket_logs.start()

maiden fable
#

!d discord.Role.delete @umbral night

unkempt canyonBOT
#

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

Deletes the role.

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

hi guys I have a question about height and width in tkinter why these parametrs are not the same?I mean height unit is greater than width
why?

umbral night
#

@maiden fable

# deleterole command
@bot.command()
@commands.has_permissions(manage_roles=True)
async def deleterole(ctx, *, role:str=None):
  guild=ctx.guild
  await deleterole(
    name=role,
  )
  await ctx.send(f'{role} was deleted')

does this make sense

#

no

#

guild.delete

#

or something

maiden fable
#

and then do await role.delete()

umbral night
#

oh

#

thanks

livid elk
#

how do i make an unban cmd

#

most of the ones i see on yt vids are shit

#

@kind hill

slate swan
#

whats that called in which we hover and see the time according to timezone

maiden fable
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.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
maiden fable
unkempt canyonBOT
#
Not likely.

No documentation found for the requested symbol.

maiden fable
#

!d discord.Guild.unban *

unkempt canyonBOT
#

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

Unbans a user from the guild.

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

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
kind hill
livid elk
#

no its ok

#

uh wait

maiden fable
#

Oh hi Seb

livid elk
#

could u help me make ban cmd

slate swan
#

bru

#

rip helpers

cloud dawn
#

๐Ÿ˜‚

livid elk
#

wait i just realised we are in 2 mutual servers

#

rpi server and python

kind hill
#

No, I can't help you with a ban command. Someone else probably can, though.

livid elk
#

no unban

#

unban i mean

slate swan
#

stop

livid elk
#

i did ban alr

slate swan
#

im here

#

many people are here

cloud dawn
#

!d discord.Member.unban

unkempt canyonBOT
#

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

Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
slate swan
#

just ask

cloud dawn
#

Yeah agreed, not really needed to ping staff.

livid elk
#

how bout the whole cmd and the async def paramters

slate swan
#

see panda helped u no need of owners

slate swan
livid elk
#

ok t hanks

slate swan
#

we just help with problems

slate swan
livid elk
#

ctx.guild.unban?

cloud dawn
livid elk
#

yeah

slate swan
#

ok

cloud dawn
#

You can literally copy the commands and place un in front every ban

umbral night
#

is there a way to center-align text in an embed?

cloud dawn
livid elk
#

that actually might work

umbral night
slate swan
#

inline field also

slate swan
cloud dawn
#

You can have a blank inline field with a invisible character and then it's in the middle, kinda.

livid elk
jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 144, in kick
    msg= await ("Checking perms...")
TypeError: object str can't be used in 'await' expression

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\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object str can't be used in 'await' expression``` can someone help me with this?
livid elk
#

u cant use string in await

#

show me ur code

#

oh i see

#

msg=await ("checking perms ")

jade tartan
olive osprey
brisk dune
#

So just wondering... does ytdl itself break YouTube TOS, or downloading music from ytdl break YouTube TOS?

livid elk
#

it dosent break tos i think

#

ytdl is youtube downloader

cloud dawn
earnest shuttle
#

Hi

brisk dune
#

But if I were to not download, but rather just straight up steam the audio to a discord call, that wouldn't be breaking their TOS, would it?

cloud dawn
#

ytdl break around 40 ToS since it has more sites than just yt

olive osprey
jade tartan
brisk dune
cloud dawn
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโ€™s robots.txt file; (b) with YouTubeโ€™s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
brisk dune
#

oh damn

cloud dawn
brisk dune
#

didn't see the "transmit, boradcast, display" part

#

So... in summation, is there any way to make a music bot that doesn't infringe on somebody's TOS?

cloud dawn
#

Since people have ruined that trust.

olive osprey
#

Wrong reply

brisk dune
jade tartan
brisk dune
olive osprey
olive osprey
#

No

jade tartan
#

msg

olive osprey
#

!d discord.Message.edit

unkempt canyonBOT
#

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

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
warm tulip
#

I have a question guys

olive osprey
olive osprey
warm tulip
#

how i can add welocmer to my bot when i type
@bot.event
async def on_member_join(member: discord.Member):
await member.send("Welcome to the server!")

#

it dosent work

#

hmmm??????/

olive osprey
#

!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") join or leaves 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.
olive osprey
jade tartan
#

I am not sure what this means

slate swan
#
class source(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

    @discord.ui.button(label='Source', style=discord.ButtonStyle.link)
    async def Source(self, interaction: discord.Interaction, button: discord.ui.Button):
        #open link or smth
``` How would I make my button component open a link?
warm tulip
#

how i can set a channel for welcomer for my bot guys????

jade tartan
#

Hello

#

Anyone?

supple thorn
paper sluice
jade tartan
slate swan
#

opinions on a whole 2070 laptop as a server

slate swan
#

TAKES money to make a chungus hoy

maiden fable
unkempt canyonBOT
jade tartan
final iron
slate swan
#

life ruining answerr

#

no one cares

final iron
#

Read tracebacks is useful

supple thorn
slate swan
final iron
slate swan
slate swan
#

any ideas?

maiden fable
#

@jade tartan await msg.edit(msg, new_content="I was unable to kick the passed member. The member may have a higher role than me, I may have crashed into a rate-limit, or an unknown error may have occured. In that case, try again.")

supple thorn
maiden fable
#

change it do edit(content=...)

slate swan
supple thorn
slate swan
#

because homework takes my time

jade tartan
#

Only so just get rid of msg?

slate swan
maiden fable
slate swan
slate swan
maiden fable
#
# in the init
self.add_item(Button(..., style=ButtonStyle.link, url="https://totallynotafakewebsite.com"))
slate swan
#

that domain tho

#

๐Ÿ˜ณ

formal basin
#

How can i make it say 60 minutes instead of seconds

slate swan
#

!d round

unkempt canyonBOT
#

round(number[, ndigits])```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.

For the built-in types supporting [`round()`](https://docs.python.org/3/library/functions.html#round "round"), values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.

For a general Python object `number`, `round` delegates to `number.__round__`.
slate swan
#

use round and do math!

maiden fable
jade tartan
#

Weird it didnt kick a member of my server

#

No errors on my code

dense swallow
slate swan
#

do i need to import anything?

slate swan
maiden fable
slate swan
#

bro im loving it

maiden fable
#

What

slate swan
#

..

slate swan
maiden fable
#

You don't even know it

slate swan
#

bro

#

loll

#

hun giving me a stroke

slate swan
#

just pass de parsed payload

#

What ๐Ÿ’€

#

๐Ÿ’€

#

my datetime is glitching

#

its showing 11 for somereason

#

but its not my pc time

brisk dune
slate swan
#

bro๐Ÿ˜ณ

#

h why?

brisk dune
#

Lol dw

slate swan
brisk dune
#

was just wondering what the code was for your datetime to be glitching

slate swan
#

whats in this? hidden error?

#
timestamp=datetime.utcnow()
#

Define the member ๐Ÿ™„

#

i just did it for showing!!!

#

@brisk dune yo

warm tulip
#

guys why my command dont work?

@commands.command(name="help MOD")
async def help_MOD(self, ctx: commands.Context):
await ctx.send("MOD HELP MENU:\n\nWARN MENU HELP t!warn mentionUSER reason")

brisk dune
#

@slate swan huh?

warm tulip
#

it says eror

#

yea

slate swan
warm tulip
#

how i can fix it so?

cloud dawn
warm tulip
#

no its for test

#

im learning

#

for my best bot

slate swan
#

nice

#

message commands cant have spaces in between

brisk dune
#
from datetime import datetime
datetime.now().astimezone().replace(microsecond=0).isoformat()
'2022-04-22T21:40:57+10:00'
#

@slate swan

brisk dune
slate swan
#

ok

#

uh but in dc we use

brisk dune
slate swan
#

just use pytz with datetime

#

!E

from datetime import datetime
datetime.now().astimezone().replace(microsecond=0).isoformat()
unkempt canyonBOT
#

@slate swan :warning: Your eval job has completed with return code 0.

[No output]
cloud dawn
#

!pypi pytz

unkempt canyonBOT
slate swan
#

uh

cloud dawn
slate swan
#

!e

from datetime import datetime
print(datetime.now().astimezone().replace(microsecond=0).isoformat())
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

2022-04-22T11:43:46+00:00
brisk dune
#

There we go

#

sorry, I was using shell (so no print)

slate swan
#

T11?

slate swan
slate swan
cloud dawn
#

Doesn't datetime grab your own system time?

slate swan
#

not for me

#

it show 11:30 smh

#

does glitch for me sometimes too

#

...

supple thorn
cloud dawn
#

I got the right time

slate swan
#

my bot is very slow nower days :(

maiden fable
slate swan
#

idk it was working fine before

austere herald
#

I'd recommend using aiomysql, or better yet asyncpg as operations on a database server can be blocking

slate swan
#

like 1 month ago

austere herald
#

I'm not a fan of MySQL personally

slate swan
#

ok

austere herald
#

You could also use a context manager for cursors

austere herald
slate swan
#

lol

cloud dawn
#

๐Ÿ˜‚

brisk dune
#
>>> from datetime import datetime
>>> datetime.utcnow()
datetime.datetime(2022, 4, 22, 11, 49, 42, 814847)

Carrying on the datetime debate, why is it showing you 11 @slate swan? What are you using to get the time man (now I'm curious).

slate swan
#

the thing u used above

brisk dune
#

uh huh...

maiden fable
slate swan
#

uh wait

boreal ravine
brisk dune
#

from datetime import datetime or datetime.datetime.now()

slate swan
boreal ravine
slate swan
brisk dune
#

Also...

Answer I found on SO regarding your situation:

I know I'm five years late, but I had the same problem tonight. In my experience, the solution to the problem was to use the aware UTC datetime:

utc_dt_aware = datetime.datetime.now(datetime.timezone.utc)
If you google "utcnow() wrong" this is the first result you get, so I thought it would be good to answer anyway.

slate swan
#

and my pc time is fine

#

bro

#

why

brisk dune
#

I don't wanna do chem homework

#

that's why

slate swan
#
class ImageView(discord.ui.View):
    def __init__(self, file: str):
        super().__init__()
        self.value = None
        self.add_item(discord.Button(discord.ButtonStyle.link, url=file))
``` and im getting the error ```__init__() got an unexpected keyword argument 'url'```
#

๐Ÿ—ฟ

#

@slate swan are you getting the utc time right?

boreal ravine
cloud dawn
slate swan
#

let me check

#

utc*

slate swan
maiden fable
#

Imagine saying pls

slate swan
slate swan
brisk dune
#

PLEASE

maiden fable
#

Hm?

cloud dawn
brittle bear
#

how can i fix this

ImportError: cannot import name 'Button' from 'discord.ui' (unknown location)

im hosting my bot on replit

slate swan
brittle bear
cloud dawn
slate swan
#

Shit elec gorn

boreal ravine
slate swan
#

Wait 5 min

boreal ravine
brittle bear
cloud dawn
slate swan
#

2.0

boreal ravine
#

thats not 2.0

brisk dune
# slate swan How
>>> try:
...     int('a')
... except ValueError as e:
...     raise(e)
Traceback (most recent call last):
  File "<pyshell#6>", line 4, in <module>
    raise(e)
  File "<pyshell#6>", line 2, in <module>
    int('a')
ValueError: invalid literal for int() with base 10: 'a'
slate swan
maiden fable
#

Wow

brittle bear
unkempt canyonBOT
#

@cloud dawn :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 |   File "<string>", line 2, in <module>
004 | AttributeError: 'NoneType' object has no attribute 'get'
silver magnet
#
@bot.command(name="question")
async def question(message):
    redditsub = await reddit.subreddit('AskReddit')
    for post in redditsub.random_rising(limit=1):
        await message.channel.send(post.title)

Gives out this:

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'ListingGenerator' object is not iterable

What's going on?

cloud dawn
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#

Im pretty sure this guy also comed yesterday

#
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped        
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'url'   
``` here is the traceback ๐Ÿ—ฟ
#

Code

#

paths reveled

boreal ravine
slate swan
#
class ImageView(discord.ui.View):
    def __init__(self, file: str):
        super().__init__()
        self.value = None
        self.add_item(discord.Button(discord.ButtonStyle.link, url=file))
``` code ```Traceback (most recent call last):
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped        
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'url'``` traceback]
slate swan
#

Harckepy

cloud dawn
slate swan
silver magnet
slate swan
#

I read the example of url buttons and this is what it said

slate swan
#
class Google(discord.ui.View):
    def __init__(self, query: str):
        super().__init__()
        # we need to quote the query string to make a valid url. Discord will raise an error if it isn't valid.
        query = quote_plus(query)
        url = f'https://www.google.com/search?q={query}'

        # Link buttons cannot be made with the decorator
        # Therefore we have to manually create one.
        # We add the quoted url to the button, and add the button to the view.
        self.add_item(discord.ui.Button(label='Click Here', url=url))
#

this is the example

boreal ravine
silver magnet
slate swan
#

discord.ui.button oh damn ๐Ÿ˜ญ

slate swan
#
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped        
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given```
#
class ImageView(discord.ui.View):
    def __init__(self, file: str):
        super().__init__()
        self.value = None
        self.add_item(discord.ui.Button(discord.ButtonStyle.link, url=file))```
#

๐Ÿคจ

loud junco
#

is there another way to make bot pick random except
randint.random?

cloud dawn
unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
paper sluice
loud junco
slate swan
cloud dawn
slate swan
#

@maiden fable

#

Why google cmd tho?

brisk dune
slate swan
#

difference between is and are

brisk dune
#

difference between my attention span and yours

slate swan
#

..

brisk dune
#

๐Ÿ˜Ž

#

For some reason I keep thinking your pfp is a planet with a blue flaming mohawk...

slate swan
#

Huh

paper sluice
#

what?

brisk dune
#

LMAO sparked discussion

slate swan
#

Your must be off your shit rn god damn

brisk dune
#

@slate swan's profile pic looks like a planet with a mohawk when you zoom out enough

brisk dune
slate swan
#

censoring your messages is fitting tbh

silver magnet
brisk dune
slate swan
#

wait 2020 vision means 20/20 and not the year???

slate swan
brisk dune
stable leaf
#

does someone know how to execute action of reacting on message in command?

stable leaf
slate swan
#

Cool

#

@paper sluice

paper sluice
#

what ๐Ÿฅด

slate swan
paper sluice
slate swan
#

๐Ÿ”ฅ

slate swan
maiden fable
slate swan
maiden fable
#

Code

paper sluice
slate swan
#

check the message i repllied to

loud junco
#

visible confusion

slate swan
paper sluice
slate swan
#

I forgot the error

paper sluice
slate swan
maiden fable
#

This is one thing I love about dpy

slate swan
slate swan
#

Any way to check if a discord invite link is valid?

#

IDK

#

!d

slate swan
loud junco
loud junco
slate swan
slate swan
loud junco
#

check the invite in ur server settings
scroll to the bottom

paper sluice
loud junco
slate swan
#

Click join and try it out

slate swan
brisk dune
slate swan
#

I am sending it in #discord-bots for a reason, I wanna try if it's valid programmatically

brittle bear
#

i updated my dpy to 2.0, now it wont load cogs

slate swan
#

Repkit whyyyyyyyyy

loud junco
#

btw

#

what is this VISIBLE CONFUSION

slate swan
slate swan
#

oh dict key

#

No, dict

loud junco
slate swan
#

Lmao

loud junco
#

its not working

paper sluice
cloud dawn
# slate swan Any way to check if a discord invite link is valid?
INVITE_RE = re.compile(
    r"(discord([\.,]|dot)gg|"                     # Could be discord.gg/
    r"discord([\.,]|dot)com(\/|slash)invite|"     # or discord.com/invite/
    r"discordapp([\.,]|dot)com(\/|slash)invite|"  # or discordapp.com/invite/
    r"discord([\.,]|dot)me|"                      # or discord.me
    r"discord([\.,]|dot)li|"                      # or discord.li
    r"discord([\.,]|dot)io|"                      # or discord.io.
    r"((?<!\w)([\.,]|dot))gg"                     # or .gg/
    r")([\/]|slash)"                              # / or 'slash'
    r"(?P<invite>[a-zA-Z0-9\-]+)",                # the invite code itself
    flags=re.IGNORECASE
)
brisk dune
loud junco
#

whats this lmao

slate swan
slate swan
slate swan
slate swan
#

I am just looking for if discord has an API or something for it

paper sluice
slate swan
#

(not gonna self bot don't suggest chromium and stuff)

#

Didnt understand even 1 line

loud junco
#

remember to set the invite link to this

slate swan
cloud dawn
slate swan
loud junco
loud junco
brisk dune
loud junco
#

ez

slate swan
loud junco
#

u cant make an expired link not expired ๐Ÿคฆโ€โ™‚๏ธ

slate swan
loud junco
#

whatever

slate swan
#
class ImageView(discord.ui.View):
    def __init__(self, file):
        super().__init__()
        self.value = None
        self.add_item(discord.ui.Button(discord.ButtonStyle.link, url=file))
``` ```Traceback (most recent call last):
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped        
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given```
brisk dune
# brisk dune <@456226577798135808> https://stackoverflow.com/questions/62354045/how-do-i-chec...

SO answer:

If you're wanting the user to input an invite via a command argument, it will throw an exception if the invite is invalid (a discord.NotFound error, to be exact):

@bot.command()
async def inv(ctx, invite: discord.Invite):
    await ctx.send("That invite is valid!")
@inv.error
async def inv_error(ctx, error):
    if isinstance(error, commands.BadArgument):
        if isinstance(error.original, discord.NotFound):
            await ctx.send("That invite is invalid or has expired.")

Or you can use fetch_invite():

try:
    invite = await bot.fetch_invite(URL_OR_ID_HERE)
    await ctx.send("That's a valid invite!")
except:
    await ctx.send("Sorry, that invite was invalid or has expired.")

There's no need for any other modules - just the discord library is capable of telling you information about the invite.

slate swan
#

still awaiting on a valid reply tbh

jade tartan
#

How do you have the bot send a dm the member?

cloud dawn
loud junco
loud junco
#
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandOnCooldown):
    seccd = round(error.cooldown.get_retry_after())
    mincd = 0
    hrcd = 0
    rseccd = 0
    rmincd = 0

    if seccd > 59:  
      rseccd = int(seccd % 60)
      mincd = int((seccd - rseccd) / 60)
      if mincd > 59:
        rmincd = int(mincd % 60)
        hrcd = int((mincd - rmincd) / 60)
    else:
      rseccd = seccd
    await ctx.send(f'''
Dont spam :/ 
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
    
  elif isinstance(error, commands.CommandNotFound):
    await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
    
  elif isinstance(error, KeyError):
    await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
    
  else:
    raise error
slate swan
#

59

loud junco
loud junco
#

59 means 60

#

every 60 second in my bot a minute pass

cloud dawn
loud junco
slate swan
#

Im not asking 1.

paper sluice
slate swan
#

!d datetime.timedelta

unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
slate swan
#

Yo worked omg

loud junco
#

:/

loud junco
#

but it works perfectly somehow
so whatever

jade tartan
#

What does it mean by when my code error says member is a required argument that is missing.

loud junco
slate swan
#

Define member.

jade tartan
#
async def kick(user, ctx, member: discord.Member, *, reason=None):
    await member.kick(reason=reason)
    await member.send("You have been Kicked from the server")
    ```
loud junco
#

what about me ;-;

slate swan
#

Huh

#

remove the user

brisk dune
# loud junco whats time delta

Python docs description:

class datetime.timedelta
A duration expressing the difference between two date, time, or datetime instances to microsecond resolution.

slate swan
#

Also u cant send after kick

jade tartan
slate swan
#

If not in mutual servers

loud junco
#

bot can i think

slate swan
cloud dawn
slate swan
maiden fable
# loud junco ?

It has kwargs where it feels like pos args don't make sense

slate swan