#discord-bots

1 messages ยท Page 469 of 1

lament mesa
#

Your sql query is returning None

round yarrow
#

oh yeah...and what do i do fix this?

native harness
#

kk look

lament mesa
native harness
#

replace this with "?"

#

interrogation mark

lament mesa
native harness
#

could be the issue

#

kk

lament mesa
round yarrow
#

it will work but won't get updated and will remain in its old state

native harness
#

as Sir said

slate swan
#
await webhook.send(content, username=message.author.name,avatar_url = message.author.avatar_url)```



so i have been trying to make this webhook work but it does not show member avatar and i am getting this error-

```line 36, in on_message
    webhook = await message.channel.create_webhook(name="test",avatar_url = message.author.avatar_url)
   AttributeError: 'Member' object has no attribute 'avatar_url'```
native harness
#

@round yarrow may I ask how do you store the ID in your table?

#

can I see it?

zenith zinc
#

hekki

#

hello

maiden fable
#

Hi

lyric moat
#

why does this sends a error? py while True:

maiden fable
#

!indent

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

lyric moat
#

i did indent

#

and it did not worked

maiden fable
#

Read the error

#

There's a problem with yr indent

#

It doesn't match the base indent

slate swan
lyric moat
upbeat otter
#

Guys, i cant seem to find DiscordUtils' docs. anyone can help?

maiden fable
#

Hover over it and tell the error

slate swan
upbeat otter
valid galleon
#

so i was getting an error in heroku cuz i didnt put asyncpraw in the requirements.txt file. how would i add it in here?

aiohttp==3.7.4.post0
async-timeout==3.0.1
attrs==20.3.0
chardet==4.0.0
discord.py==1.7.3
idna==3.1
multidict==5.1.0
typing-extensions==3.7.4.3
yarl==1.6.3```
lyric moat
drifting arrow
bitter kite
#

Hey quick question - I'm wondering how can I set up the bot that it ignores commands via private message?

slate swan
#

@commands.guild_only() maybe

drifting arrow
lyric moat
#

anyone can help??

drifting arrow
#

definitely @commands.guild_only()

drifting arrow
lyric moat
#

yeah

stark bobcat
#

hi

lyric moat
#

i think its

drifting arrow
#

is your code overindented?

lyric moat
#
    while True:
stark bobcat
#
@bot.event
async def on_message(message: discord.Message):
  if message.guild is None and not message.author.bot:
    print(message.content)  
    print(message.author)

    embed = discord.Embed(title="Confirm Mail creation",description="This system is used for reporting bugs,reports concerning to the moderators.",color=0x3DFD1E)
  
    a=await message.author.send(embed=embed)
    await a.add_reaction('\u2705')
    await a.add_reaction('\U0001f6ab')

    def check(reaction, user):
      return user == message.author and str(reaction.emoji) in ['\u2705','\U0001f6ab']

    reaction, user = await bot.wait_for('reaction_add',check=check)

    print(reaction.emoji)```
lyric moat
#

lemme send full code

stark bobcat
lyric moat
#
  @commands.command()
  async def button(self, ctx):


    one = Button(style=ButtonStyle.blue, label="1", id="embed1") #create buttons
    two = Button(style=ButtonStyle.red, label="2", id="embed2")
    three = Button(style=ButtonStyle.green, label="3", id="embed3")
    four = Button(style=ButtonStyle.grey, label="4", id="embed4")
    invite = Button(style=ButtonStyle.URL, label="Invite here ๐Ÿค–", url="https://discord.com/oauth2/authorize?client_id=834155102293721138&scope=bot&permissions=306048230") 


    embed1 = Embed(title="This is embed 1", description="for the blue button.", colour=discord.Colour.blue()) # create embeds
    embed2 = Embed(title="This is embed 2.", description="for the red button.", colour=discord.Colour.red())
    embed3 = Embed(title="this is embed 3.", description="For the green button.", colour=discord.Colour.green())
    embed4 = Embed(title="This is embed 4.", description="for the grey button.", colour=discord.Colour.greyple())



    await ctx.send(
            "This is an embed test!",
            components=[                    # attach the buttons
                [one,
                two],
                [three,
                four],
                [invite]
            ]       
        )

                
    buttons = {
                "embed1": embed1,       
                "embed2": embed2,
                "embed3": embed3,
                "embed4": embed4        #assign the buttons to the embeds
        }

    while True:
        event = await self.bot.wait_for("button_click")          
        if event.channel is not ctx.channel:                # wait for the button click, get the button id
                return
        if event.channel == ctx.channel:
                response = buttons.get(event.component.id)     
                if response is None:
                    await event.channel.send(
                        "Something went wrong. Please try it again."            # error
                    )
                if event.channel == ctx.channel:
                    await event.respond(    
                        type=4,      # send the message (7 is editing the message)
                        embed=response
                    )```
drifting arrow
#

i rewrote the entire image before u sent that lol

drifting arrow
#

@lyric moat What do I need to import to use button?

unreal silo
#

Can i get the link to developers server

#

Rq

drifting arrow
#

Sent via dm @unreal silo

unreal silo
#

Not the .py

#

thnx tho

unreal silo
#

yea

#

gotcha

jolly saffron
#

b

rare saddle
#

how to send video from pc to chat using discord bot

lone aurora
warm terrace
#

hey, why am i getting this error and how to fix it ? thankss

hasty iron
hasty iron
#

check if its None first, if its not then stop it

warm terrace
hasty iron
#

pseudo code

if the voice client is None:
  tell the user the bot is not connected or something
else:
  stop the voice client
warm terrace
#

ohk and i assume its gonna be put below the vc part ?

#

after assigning the variable that is

hasty iron
#

below what

lone aurora
warm terrace
hasty iron
warm terrace
#

wait a second

#

how do we stop the voice client ?

#

i think this should have been play

#

not stop

hasty iron
#

whatever you need

#

thats not it

#

it can still raise the error

warm terrace
#

ohk

#

that means i have to declare vc at the top right ?

hasty iron
#

yeah

warm terrace
#

like below import but above the class ?

rare saddle
#

how to send video from pc to chat using discord bot

hasty iron
warm terrace
#

lmaooo

slate swan
warm terrace
#

this is fine ig

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
warm terrace
hasty iron
warm terrace
#

ahh man, its my first time making a discord bot, one second

hasty iron
#
vc = the voice client
if not vc:
  send message
else:
  do stuff
warm terrace
#

this any better ?

upbeat otter
#

Guys, is there a way to send a message to a channel ASA the bot joins a server

hasty iron
#

now thats correct

warm terrace
#

ohk lemme try it out

hasty iron
#

also why do you have a play in there

grim dawn
hasty iron
#

remove that ctx.voice_client.play after the ctx.voice_client.stop()

warm terrace
warm terrace
#

ohk i see

grim dawn
#

np, you should be able to find that stuff in the discord python docs to help you more

warm terrace
#

here you mean right ?

#

@hasty iron

hasty iron
#

yeah

warm terrace
#

ight lemme try it out

upbeat otter
hasty iron
#

so it doesnt execute whats after

grim dawn
warm terrace
grim dawn
#

Does anyone know (in terms of discord bot performace) if C# would be a much better option than using PyPy (python interpreter)

tardy swallow
#

can I make it look like the bot is typing before it sends a message?

warm terrace
#

like this ? @hasty iron

hasty iron
#

yes thats good

hasty iron
unkempt canyonBOT
#

async with typing()```
Returns a context manager that allows you to type for an indefinite period of time.

This is useful for denoting long computations in your bot.

Note

This is both a regular context manager and an async context manager. This means that both `with` and `async with` work with this.

Example Usage...
warm terrace
modest bear
#

Hey guys
How can i see which version of discord py is installed?

hasty iron
#

or print(discord.__version__)

warm terrace
#

btw how do we make the bot connect to vc ?

hasty iron
#

!d discord.VoiceChannel.connect

unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
warm terrace
#

hmm one second where do i put this in the code

modest bear
hasty iron
modest bear
#

it shows me that error

hasty iron
#

and again ctx.author.voice can be None

hasty iron
warm terrace
#

its done in this part

modest bear
warm terrace
#

it wont connect to the vc tho

#

tried returning it too

#

wait i think theres a typo

#

ok idk how to fix it lol

hasty iron
#

ctx.author.voice

#

not voicei

warm terrace
#

yeah, i changed it

hasty iron
#

it should work now

warm terrace
#

it still didnt work, its not connecting and saying its not connected in a vc

modest bear
#

Alr im trying to install discord components but it aint working

hasty iron
#

!d discord.VoiceClient.move_to

unkempt canyonBOT
#

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

Moves you to a different voice channel.
hasty iron
#

hm

modest bear
#

Tyty im new to cmd so i still struggle

warm terrace
#

is it fine if i send the whole code ? @hasty iron

hasty iron
#

yea

#

!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.pydis.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.

#

Hey @brazen fractal!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

warm terrace
#

here

brazen fractal
#

how to fix?

#

Traceback (most recent call last):
File "C:\Users\Xiv\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))

hasty iron
#

like even when you do <prefix>join

warm terrace
lyric moat
#

can someone help me with buttons command?

warm terrace
#

IT works !!! @hasty iron sorry it was my first time making a discord bot i forgot about the join thingy

hasty iron
#

its fine

warm terrace
#

thankss a lot tho

rare saddle
#

How to send a video correctly?

valid galleon
#

is there anyway i can restrict certain commands only to my account? im not referring to restricting through roles in a server. im talking about restricting it to my account, so no matter the server, or role, only i can use that particular command?

valid galleon
rare saddle
valid galleon
candid heron
#

What's the best alternative to dpy as it is discontinued?

rare saddle
valid galleon
valid galleon
rare saddle
candid heron
valid galleon
valid galleon
rare saddle
rare saddle
candid heron
wispy spade
#

Not too sure about that, it is an option tho.

candid heron
#

kk

#

ty

maiden fable
#

So if u r good with dpy syntax, then I would prefer u use a fork, else use hikari

candid heron
#

so as a beginner, hikari is better for me, right?

maiden fable
#

Well, sort of yea. But I don't really think many people here knows about hikari's syntax. Again I ain't sure

strong kettle
#

Hi

I have a problem when dealing with the log it gives me the wrong member

maiden fable
#

Code?

sick talon
#

how to create a command which disconnects the user from the VC when used it ?

rare saddle
#

@valid galleon Can you throw your example?

unkempt canyonBOT
sick talon
#

!d discord.Member.voice

unkempt canyonBOT
sick talon
#

...

maiden fable
#

Read the docs

#

If u don't understand then u can ping me

sick talon
maiden fable
sick talon
#

the bot seems to be offline

maiden fable
#

Which bot?

#

!d discord.Member.move_to pass it None to disconnect the member @sick talon

unkempt canyonBOT
#

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

Moves a member to a new voice channel (they must be connected first).

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

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.edit "discord.Member.edit").

Changed in version 1.1: Can now pass `None` to kick a member from voice.
rare saddle
#

Please tell me how to send the video correctly?

maiden fable
#

?

maiden fable
#

(:

sick talon
maiden fable
#

!d discord.Message.channel

unkempt canyonBOT
maiden fable
#

Compare the message.channel

#

To the channel object

sick talon
maiden fable
#

if message.channel == bot.get_channel(id):
. . . .

sick talon
#

thanks a lot man

maiden fable
#

(:

valid galleon
# rare saddle <@!577751099554136064> Can you throw your example?

sorry for the late reply, i was afk:

for cog in listdir(path.join(path.dirname(path.abspath(__file__)), "cogs")): #change the directory to where your video is stored
    if cog.endswith(".py"): #add your file extension here
        client.load_extension(f"cogs.{cog[:-3]}") #add the ctx.send() line here

    else:
        print(f'unable to load {cog[:-3]}') #dont really know what you could do here. maybe just change the string to unable to load file?
slate swan
#
    @commands.Cog.listener()
    async def on_message(self, msg):
        data = get_leveling_data()
        await create_leveling_acc(user, guild)
        xp = data[str(guild.id)][str(user.id)]["xp"]
        lvl = data[str(guild.id)][str(user.id)]["lvl"]
        to_the_next_lvl = data[str(guild.id)][str(user.id)]["to_the_next_lvl"]
        xp += 1
        print("test")
        if xp > to_the_next_lvl or xp == to_the_next_lvl:
            data[str(guild.id)][str(user.id)]["xp"] = xp - to_the_next_lvl
            data[str(guild.id)][str(user.id)]["to_the_next_lvl"] = round(to_the_next_lvl ** 1.02)
            data[str(guild.id)][str(user.id)]["lvl"] += 1
        with open("leveling.json", "w") as f:
            json.dump(data, f)```
does anyone know why isn't it adding xp to the member? it prints test and I have no erorrs.
willow vine
#

Embed = discord.Embed(title=msg, timestamp=datetime.now(), color=0x2F3136, url = url)
why am i getting invalid syntax in this

sick talon
# maiden fable if message.channel == bot.get_channel(id): . . . .

uhh it isnt working
actually i am building a anti afk thing
where if a user joins a VC firstly he have to send some message and after every 2 hrs, the bot would ping the user and if fails to reply it he would be disconnected from the VC (this is for the XP grinder who gain XP by being AFK and staying in the VC)

sick talon
# maiden fable ok?

so when i joined the VC and sent some message in the channel whose ID i used in the code

#

it disconnected me after some time

maiden fable
#

Code?

sick talon
willow vine
sick talon
# maiden fable show the error

if message.channel == client.get_channel(886095797375074375):
this part isnt working
i checked using this await tc.send("ok")

#

and the bot didnt send anything

maiden fable
#

Hmm

#

try comparing the IDs

#

message.channel.id

sick talon
sick talon
maiden fable
#

Weird

#

make sure it is the correct channel ID

sick talon
maiden fable
#

Sure. What is the error?

sick talon
maiden fable
#

Lol

sick talon
maiden fable
#

Can u share the code please?

sick talon
#

ok

#

gimme a second

sick talon
# maiden fable Can u share the code please?
@client.event
async def on_voice_state_update(member, before, after):
  channel = before.channel or after.channel
  tc = client.get_channel(886095797375074375)

  if channel.id == 884734344558702596:
    if before.channel is None and after.channel is not None:
      role = discord.utils.get(member.guild.roles, id=886983232829141022)
      await member.add_roles(role)
      await tc.send(f'{member.mention} Hey')
      await asyncio.sleep(5)
      @client.event
      async def on_message(message):
        if message.channel.id == client.get_channel(886095797375074375):
          await tc.send("ok")
        else:
          await member.move_to(channel = None)

    elif before.channel is not None and after.channel is None:
      role = discord.utils.get(member.guild.roles, id=886983232829141022)
      await member.remove_roles(role)
maiden fable
#

hmm

#

so what is not working?

sick talon
maiden fable
#

yea it won't work

#

cz wrong syntax

sick talon
#

ohh.. how do we fix it ?

upbeat otter
#

guys, my music commands were working perfectly fine, but then replit, said they killed my program, and now the music commands give error: NoneType Object is non-subscriptable

maiden fable
sick talon
rare saddle
#

What is the maximum file size for a bot to send?

maiden fable
#

Hmm, u can use a bot var and set it to True or False if the person replies or not (u can make a dict)

#

!botvar

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

maiden fable
#

for more information ^^^

crimson cliff
#

!d help

rare saddle
sick talon
maiden fable
rare saddle
maiden fable
# sick talon could you send the code please ๐Ÿ˜“
bot.responses = {}
if message.channel == your channel:
    if message.content == "whatever":
        # update bot.responses with message.author.id as the key and True as the value

# Then in an on_voice_state_update check for each member's value from the dict.. I would prefer using a tasks.loop tho
#

!d discord.ext.tasks.Loop BTW

unkempt canyonBOT
#

class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.

The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
maiden fable
#

(:

willow vine
# maiden fable show the error
    ^
SyntaxError: invalid syntax

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 17, in load
    bot.load_extension(f'cogs.{extention}')
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 678, in load_extension
    self._load_from_module_spec(spec, name)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 609, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.embeds' raised an error: SyntaxError: invalid syntax (embeds.py, line 95)

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ExtensionFailed: Extension 'cogs.embeds' raised an error: SyntaxError: invalid syntax (embeds.py, line 95)```
maiden fable
#

can I see some more code?

#

above it

zenith zinc
#

hai

#

hunter

maiden fable
#

Hi

zenith zinc
#

i trying make Missing Permission comman and evry try error

maiden fable
#

Mhm

zenith zinc
#

do you give me script

#

๐Ÿฅบ

maiden fable
#
if isinstance(error, commands.MissingPermissions):
    . . . .
zenith zinc
#

aaaaaaand

maiden fable
#

understand it

#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3.10/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3.10/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3.10/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3.10/library/stdtypes.html#types-union).
zenith zinc
#

naaah

maiden fable
#

hm lemme get it

zenith zinc
#

what

zenith zinc
#

mhm

#

if it works thank you very much

maiden fable
#

(:

zenith zinc
#

i can't find the page can you help me?

#

@maiden fable

maiden fable
#

?

zenith zinc
#

Helpp

maiden fable
#

with?

zenith zinc
#

this how see code?

crimson cliff
#
with youtube_dl.YouTubeDL(YDL_OPTIONS) as ydl:
    info = ydl.extract_info(url, download=Flase)
    url2 = info['formats'][0]['url']
    source = await discord.FFmpegOpusAudio.from_probe(url2,
    **FFMPEG_OPTIONS)
    vc.play(source)

Bro That is coming error
what should i do?

maiden fable
crimson cliff
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)
zenith zinc
#

i can't find the page can you help me?

crimson cliff
zenith zinc
#

@maiden fable

maiden fable
maiden fable
zenith zinc
#

for thisss

maiden fable
#

that is the page...

zenith zinc
#

yessssssss

crimson cliff
maiden fable
crimson cliff
maiden fable
zenith zinc
zenith zinc
crimson cliff
# maiden fable sorry

Bruh yesterday I also asked someone
but they also said against ToS
What SHOULD I DO?

zenith zinc
#

HUNTERR

#

pls help for missing permissionn

maiden fable
#

Bro I just did...

crimson cliff
zenith zinc
#

NO

#

I CANT FIND IN PAGE

maiden fable
zenith zinc
#

I CANT FIND CODE IN PAGE

#

PLS SEND ME DM CODEEE @maiden fable

maiden fable
zenith zinc
#

FUCK OFF

crimson cliff
hasty iron
#

chill

maiden fable
#

I am not here to spoonfeed

crimson cliff
hasty iron
#

hi

zenith zinc
crimson cliff
hasty iron
#

why

zenith zinc
#

bye

#

everyone

crimson cliff
reef trail
#

what the hell

reef trail
#

pls don't host on repl

neat birch
#

Can anyone say what's wrong

neat birch
hasty iron
#

whats up with that console

reef trail
#

^

hasty iron
#

and client.say isnt a thing anymore

reef trail
#

and because it's garbage for bot hosting

neat birch
hasty iron
#

and every command must have ctx as first argument

#

dont go blindly copying code

crimson cliff
neat birch
zenith zinc
#

who is here for help me

#

Dm

reef trail
#

what do you want help with

zenith zinc
#

๐Ÿ™‚

#

Missing Permission message

reef trail
#

Can I have some context?

#

that doesn't say a lot

slate swan
#

someone know how do i get rid of this

reef trail
#

class your help command

#

lemme find a pin

neat birch
#

I'm a nub

reef trail
#

go look at that

crimson cliff
#

NOBODY IS HELPING ME

reef trail
#

you aren't obligated for help

#

Give me a sec

reef trail
upper plover
crimson cliff
zenith zinc
reef trail
upper plover
reef trail
reef trail
crimson cliff
reef trail
#

wrong ping mb

reef trail
unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

reef trail
#

!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)
reef trail
#

read it

crimson cliff
hasty iron
#

as many times as you'd like

crimson cliff
reef trail
#

Until it gets through your head that we won't help you.

reef trail
crimson cliff
reef trail
#

sucks

#

there's plenty of code online

neat birch
reef trail
crimson cliff
neat birch
crimson cliff
reef trail
#

Just skid off of GitHub lol

neat birch
reef trail
#

that's what most of us do for music systems anyhow

neat birch
reef trail
neat birch
#

Ima dump replit KEKW

reef trail
#

you should

vale pendant
crimson cliff
neat birch
#

lmao gotta learn to use heroku

crimson cliff
vale pendant
#

You host on repl?

neat birch
reef trail
crimson cliff
vale pendant
#

Don't use repl or heroku.

reef trail
reef trail
#

that's what I'm sayin

reef trail
vale pendant
crimson cliff
#

Ok sir

brazen fractal
#

how to fix?

vale pendant
#

fix what

crimson cliff
#

click Alt+F4 to get fix this ๐Ÿ™‚

crimson cliff
vale pendant
#

also if that's a selfbot we can't help lol

brazen fractal
crimson cliff
brazen fractal
#

its discord bot

vale pendant
#

purge dm?

brazen fractal
#

purge

vale pendant
#

didn't know bots could purge dms

brazen fractal
crimson cliff
vale pendant
#

They can purge messages in channels

#
  • is sketch how it says "discord-purge-dm-main\purgedm.py"
#

but what's the problem

crimson cliff
hasty iron
reef trail
#

doesn't show a problem
how do I fix this?

brazen fractal
crimson cliff
hasty iron
#

what is the issue

crimson cliff
hasty iron
#

i dont see anything??

#

sends an image -> "how to fix"??

crimson cliff
brazen fractal
hasty iron
#

bot=False, not a self bot bro totally

vale pendant
#

selfbot

brazen fractal
#

?

hasty iron
#

"?"

vale pendant
#

I told you guys lmfaoooo

hasty iron
#

i mean it seemed kinda suspicious at the beginning

crimson cliff
vale pendant
crimson cliff
brazen fractal
#

to help someone

#

?

hasty iron
#

we cant help with selfbots

brazen fractal
#

u guys are making everything lame bitching over a selfbot

hasty iron
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

vale pendant
#

there's rules in this server

heavy island
#

what the hell is self bot

brazen fractal
#

ur bitching over a selfbot

hasty iron
#

and its against discord tos

#

keep whining

vale pendant
#

maybe you should read the rules and ToS

brazen fractal
hasty iron
#

sure

crimson cliff
brazen fractal
#

he said whining

#

dis kid is ass

vale pendant
#

go ask ur friends, they prob have a skidded script

hasty iron
#

good one lulw

crimson cliff
hasty iron
#

ok now lets stop

brazen fractal
crimson cliff
heavy island
#

what place do you guys recommend for hosting discord bots, lets say its kinda friendly to use

brazen fractal
#

nothing here is funny "axl" ๐Ÿคก

brazen fractal
#

he wanna simp over a female he doesnt knows irl

crimson cliff
vale pendant
hasty iron
#

guys just stop

brazen fractal
vale pendant
#

can someone just mute this skid or sum

brazen fractal
hasty iron
#

contact modmail

brazen fractal
#

"axl" not sus at all

vale pendant
#

gc?

brazen fractal
#

did u know the facts ur mom made a mistake in giving u to the adoption center?

hasty iron
#

<@&831776746206265384>

brazen fractal
#

i bet shes regretting it rn

brazen fractal
tight obsidian
#

hello

brazen fractal
#

of what?

crimson cliff
#

@copper quartz Sir Can u pls mute @brazen fractal
I am really sorry for mentioning u
Next time I won't do that
PLS SEE MSG HISTORY FOR PROFF

heavy island
#

this chat went from discord bot to adoption center

vale pendant
hasty iron
brazen fractal
#

blanket is the one bitching about something over a sb

grim oar
#

No

vale pendant
#

it's against the rules

crimson cliff
#

@tight obsidian also its against ToS

#

mute him for 1 month

#

if u can
or pls explain him

tight obsidian
#

!ban 805856858564329557 3d You came here just to get help with a selfbot, and when told about our rules, started making inappropriate comments. Goodbye.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @brazen fractal until <t:1631812657:f> (2 days and 23 hours).

hasty iron
#

thanks

heavy island
#

which place is recommended to host a bot?

grim oar
#

Check our pins

#

Of this channel

hasty iron
visual yarrow
heavy island
#

thanks

crimson cliff
#

Can anyone explain me this?

slate swan
crimson cliff
slate swan
#

It'll be running on a private server, so you don't have to locally host the bot on your device

slate swan
crimson cliff
#

thanks

slate swan
#

Different things

crimson cliff
#

ok thanks bro

slate swan
#

๐Ÿ‘

reef trail
heavy island
vale pendant
# reef trail ruh roh

nun big he didnโ€™t say nun , i didnโ€™t want it to get br a huge problem in the server

slate swan
crimson cliff
grim oar
#

Sure

crimson cliff
#

that eivl's pfp look scary

grim oar
#

I agree

crimson cliff
#

Everytime I come to this server his name is in top and its make me scary
also He look like Demon

grim oar
#

You rite

reef shell
#

f

#

i noticed now lol

reef shell
#

same issue tho, imma repost it

def get_emojis(self, s_query):
        #here are some codes that will maka a list
        return final_list

@commands.command()
@commands.has_permissions(manage_emojis = True)
@commands.bot_has_permissions(manage_emojis = True)
async def search(self, ctx, *,name: str):
    name.replace(" ", "+")
    el = get_emojis(name)
    await ctx.send(el)```
so when i invoke the command it says `get_emojis` is not defined. why am i getting this error
grim oar
#

self.get_emojis

reef shell
#

ty

#

ugh i'm so nub

#

is using requests module inside a bot is ok?

grim oar
#

Inside a script which uses concurrency, yeah a bad idea, in your case too

#

it causes blocking

reef shell
#

what is an alt to this

grim oar
#

aiohttp

reef shell
#

i just tried it with requests and it worked but i guess if any exception is raised it will cause the bot to shutdown , r8?

grim oar
#

No, but it will block the event loop until the operation is complete, so yeah chances of a shutdown exist, more read here

#

!blocking

unkempt canyonBOT
#

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

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

import discord

# Bunch of bot code

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

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

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

stuck flare
#
from discord.ext import comands

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

@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
  await ctx.send("hello world")``` so this is my first lines of code but its showing error in the bot = commands., line
#

and in the ctx: commands.context line

grim oar
#

from discord.ext import commands

stuck flare
#

ohh aight

#

i dont understand what decorators do can someone explain?

#

!decorator

unkempt canyonBOT
#

Decorators

A decorator is a function that modifies another function.

Consider the following example of a timer decorator:

>>> import time
>>> def timer(f):
...     def inner(*args, **kwargs):
...         start = time.time()
...         result = f(*args, **kwargs)
...         print('Time elapsed:', time.time() - start)
...         return result
...     return inner
...
>>> @timer
... def slow(delay=1):
...     time.sleep(delay)
...     return 'Finished!'
...
>>> print(slow())
Time elapsed: 1.0011568069458008
Finished!
>>> print(slow(3))
Time elapsed: 3.000307321548462
Finished!

More information:
โ€ข Corey Schafer's video on decorators
โ€ข Real python article

stuck flare
#

ohh

#

alr

grim oar
#

mhm

#

you shud also learn about class decorators (cuz I like them)

stuck flare
#

so uhh do i store my token in a .env file or .json?

stuck flare
grim oar
#

whichever format you want, just don't share this file publicly

stuck flare
#

what do i call my .env file

#

token.env?

grim oar
#

people mostly jus call it .env

stuck flare
#

ohh so no name?

grim oar
#

Yeah

stuck flare
#

so if i like do from dotenv import .env should i do this?

grim oar
#

!dotenv

unkempt canyonBOT
#

Using .env files in Python

.env (dotenv) files are a type of file commonly used for storing application secrets and variables, for example API tokens and URLs, although they may also be used for storing other configurable values. While they are commonly used for storing secrets, at a high level their purpose is to load environment variables into a program.

Dotenv files are especially suited for storing secrets as they are a key-value store in a file, which can be easily loaded in most programming languages and ignored by version control systems like Git with a single entry in a .gitignore file.

In python you can use dotenv files with the python-dotenv module from PyPI, which can be installed with pip install python-dotenv. To use dotenv files you'll first need a file called .env, with content such as the following:

TOKEN=a00418c85bff087b49f23923efe40aa5

Next, in your main Python file, you need to load the environment variables from the dotenv file you just created:

from dotenv import load_dotenv()

load_dotenv(".env")

The variables from the file have now been loaded into your programs environment, and you can access them using os.getenv() anywhere in your program, like this:

from os import getenv

my_token = getenv("TOKEN")

For further reading about tokens and secrets, please read this explanation.

stuck flare
#

okay

#

should i also import os?

grim oar
#

Yes

stuck flare
grim oar
#

Not sure what you are trying to say

stuck flare
#

last in the code

grim oar
#

Follow the style guide, import in the top lines

stuck flare
#

tyy

#

so to run the bot i type bot.run("my_token")?

grim oar
#

No

grim oar
stuck flare
#

alr

forest depot
#

What lib is @unkempt canyon going to use after April 2022?

slate swan
#

You will see ยฏ_(ใƒ„)_/ยฏ

#

Maybe discord.py will be taken over by another developer

stuck flare
slate swan
#

Sit back, relax, wait and see

shell wing
#

i have a json file filed with user ids how do i dm them all ?

stuck flare
#

bot.run(TOKEN) or bot.run(my_token)?

grim oar
#

Do what you have named your variable

stuck flare
grim oar
#

If it's TOKEN = getenv(...) then bot.run(TOKEN) and same for any other var name

stuck flare
#

alr

grim oar
shell wing
stuck flare
#

i get this error File "bot.py", line 14, in <module> bot.run(my_token) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run return future.result() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner await self.start(*args, **kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start await self.login(*args, bot=bot) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) AttributeError: 'NoneType' object has no attribute 'strip'

grim oar
#

Something like this

seq = map(lambda u: Bot.get_user(u), your ids here)

#

then use a for loop and send

shell wing
#

idk about map sry

stuck flare
#
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv(".env")
from os import getenv

my_token = getenv("TOKEN")

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

@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
  await ctx.send("hello world")

bot.run(my_token)``` this is my code
grim oar
shell wing
grim oar
#

Sry didn't see

stuck flare
#

same error

grim oar
#

yeah, I didn't see that there

stuck flare
grim oar
#

Yeah

upbeat otter
#

Guys, why does this say, 'request takes 2 positional argument but three were given

@client.command()
async def lyrics(ctx,*,name=None):
  try:
    if name is None:
      player = music.get_player(guild_id=ctx.guild.id)
      name1 = player.now_playing()
      name = name1.name
      async with aiohttp.request("GET", LYRICS_URL, name, headers={}) as r:
        if not 200 <= r.status <= 299:
          await ctx.send("No Lyrics Found")
        data = await r.json()
#

What do i change in this ;-;

stuck flare
upbeat otter
grim oar
slate swan
slate swan
upbeat otter
slate swan
#

it takes 2 arguements, you gave 3

upbeat otter
#

which one should i remove, i was watching a tutorial ;-;

slate swan
#

um im not 100%

#

sorry

grim oar
#

@stuck flare uhh are you sure the name of variable in env file is TOKEN?

upbeat otter
#

but thanx

stuck flare
#

i am in replit and i am new to the enviroment thingy so i made a .env file in that

upbeat otter
#

they disabled it

#

u have to make env variables now

stuck flare
#

wdym?

upbeat otter
scarlet snow
#

I keep getting this error

AttributeError: module 'discord' has no attribute 'ui'

simple error, but I don't know why it shows up since my dpy is up to the latest version

stuck flare
upbeat otter
grim oar
#

๐Ÿ˜ฉ

stuck flare
#

json?

upbeat otter
#

do u see a lock option on the left sidebar?

#

@stuck flare

grim oar
#

or just installed from pypi

scarlet snow
#

I just downloaded simply pip install discord

#

and updated it also

grim oar
#

Yeah no, thats not 2.0

scarlet snow
#

do you know how to download the 2.0 version? if you mind telling me tho

grim oar
#

are you using poetry or something? you will have to modify the pyproject.toml or just in normal python -m pip install -U git+https://github.com/Rapptz/discord.py.git

scarlet snow
#

No idea what is the use of poetry

grim oar
#

Hmm just run that command

scarlet snow
#

okay

#

its working now thank you! @grim oar

grim oar
#

np

slate swan
#

hello

#

how do i get rid of this

#

the "none"

sour bolt
#

what is your code?

slate swan
#

do i change the description or smth

frosty prairie
#

can we not edit a sent image?

slate swan
#

oh sorry

#

1 second

grim oar
#

!d discord.Guild.description

unkempt canyonBOT
grim oar
#

Optional[str]

#

Are you sure there's a description in that guild

slate swan
#

got it

#

got it nvm thanks!

#

:)

#

woo

frosty prairie
#

CAN WE NOT EDIT A SENT MESSAGE?

grim oar
#

We can

spring flax
unkempt canyonBOT
#

await edit(**fields)```
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.
grim oar
#

But can't edit an image

frosty prairie
frosty prairie
spring flax
#

Nope

frosty prairie
#

but

#

uh .. can we edit image when inside embed?

grim oar
#

Yes

#

But will have to create new embed

reef shell
#

can i use more than 1 event in bot.wait_for func?

grim oar
#

(In every case)

frosty prairie
#

how.. i get json error -_-

#

uh.

grim oar
#

Message.edit(embed=newembed)

frosty prairie
grim oar
#

You awaited it?

boreal ravine
brazen seal
#

Why when i using minimum 1 or, this if all the time is true?

grim oar
#

cuz "kurwo" Is True

vale root
#

How can i make my bot react to its own embed?

#

I want it to put a check and a x on the embed i just cant figure it out

#
@commands.command(name="ssuvote")
    async def ssuvote(self,ctx):
        embed = discord.Embed(title = f"SSU VOTE", description =f"Vote With the โœ… mark if you plan on attending." "\n" "\n" " Vote with a โŒ if you can not join." "\n" "\n" "If you vote with the check you must join when ssu opens if not you will be warned!" "\n" "\n" "** If you get warned and join the Sesh then you can dm a admin to get it taken away!**")
        embed.set_thumbnail(url = 'https://images-ext-2.discordapp.net/external/jftnVFITYRGaMwbf6aY7Qutqp6Q_2gA4v72nXBbpALg/%3Fsize%3D512/https/cdn.discordapp.com/icons/857793161370533938/c38dde5d462235e12a3e10a2dc789dc6.png?width=461&height=461')
        await ctx.send(embed=embed)
        await ctx.message.delete()
brazen raft
brazen seal
brazen raft
brazen seal
tough wagon
unkempt canyonBOT
#

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

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
vale root
#

Thx

grim oar
brazen raft
brazen seal
vale root
brazen raft
#

You can think of it as the length of the iterable isn't 0 (which is False), everything non-zero is True, therefore non empty iterables are True.

brazen raft
brazen seal
brazen raft
#

I did.

vale root
#

So i take the send() and add Message to it?

brazen seal
grim oar
vale root
#

OK so put that under ctx.send embed k

brazen raft
vale root
#

im guessing i out the msg= in the wrong spot

#
  @commands.command(name="ssuvote")
    async def ssuvote(self,ctx):
        embed = discord.Embed(title = f"SSU VOTE", description =f"Vote With the โœ… mark if you plan on attending." "\n" "\n" " Vote with a โŒ if you can not join." "\n" "\n" "If you vote with the check you must join when ssu opens if not you will be warned!" "\n" "\n" "** If you get warned and join the Sesh then you can dm a admin to get it taken away!**")
        embed.set_thumbnail(url = 'https://images-ext-2.discordapp.net/external/jftnVFITYRGaMwbf6aY7Qutqp6Q_2gA4v72nXBbpALg/%3Fsize%3D512/https/cdn.discordapp.com/icons/857793161370533938/c38dde5d462235e12a3e10a2dc789dc6.png?width=461&height=461')
        await ctx.send(embed=embed)
        msg = await ctx.send() 
        await msg.add_reaction("โœ…")
        await ctx.message.delete()
grim oar
vale root
#

So put it up top with my imports?

grim oar
#

assign it to the send() above where it is at the moment

vale root
#

ok so change the await ctx.send(embed=embed) to
msg = await ctx.send(embed=embed)
?

grim oar
#

Yes

vale root
#

ok let me try that

grim oar
#

Remove the one below it

brazen seal
#

@brazen raft it is good?

brazen raft
#

That's the same screenshot.

brazen seal
#

nope

#

i add this

stiff nexus
#

how do i get logs from audit log like in a embed with full details???

brazen raft
#

That's not what I instructed you to do...

brazen seal
grim oar
unkempt canyonBOT
#

class discord.AuditLogEntry(*, users, data, guild)```
Represents an Audit Log entry.

You retrieve these via [`Guild.audit_logs()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.audit_logs "discord.Guild.audit_logs").

`x == y` Checks if two entries are equal.

`x != y` Checks if two entries are not equal.

`hash(x)` Returns the entryโ€™s hash.

Changed in version 1.7: Audit log entries are now comparable and hashable.
brazen raft
#
if any(word in message.content for word in ["kurwo", "test", "testtt"]):
brazen seal
stiff nexus
grim oar
unkempt canyonBOT
#

async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/stable/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guildโ€™s audit logs.

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

Examples

Getting the first 100 entries:

```py
async for entry in guild.audit_logs(limit=100):
    print('{0.user} did {0.action} to {0.target}'.format(entry))
```...
grim oar
#

There

stiff nexus
#

whats the difference

grim oar
#

Guild.audit_logs() returns that object

floral jacinth
#

hello,
async def sendSingleRole(ctx, role: discord.Guild.role):
is this right?

hasty iron
#

no

grim oar
#

No

hasty iron
#

its discord.Role

grim oar
#

discord.Role

floral jacinth
#

oh okok thx, and it get the ID or the Name?

grim oar
#

Id, name, mention

hasty iron
#

its gets with the name or id or mention

floral jacinth
#

oh nice, so i can use what i prefer

grim oar
#

Yes

floral jacinth
#

thx a lot ^^

grim oar
#

๐Ÿ˜Ž ๐Ÿ‘

tidal hawk
#

Why is it NoneType, if i clearly made development channel objekt?

#

It's nonetype when i run the code on my raspberry

#

but if i run it on pc, it works

grim oar
#

It's probably not cached

tidal hawk
#

entire code:

grim oar
#

try doing await self.client.fetch_channel(...)

tidal hawk
#

oh okay

grim oar
#

Bruh

#

Noo

#

Don't do it in on_ready

tidal hawk
#

Where should I do it then?

grim oar
#

you can use tasks

wispy sequoia
#

please-

tidal hawk
#

Task which runs when I turn on the bot?

#

i know tasks are basically loops

grim oar
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

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

its response

#

xD

tidal hawk
#

so task, which runs only 1 time?

grim oar
#

yes

tidal hawk
#

But why is bad practise to run the code on on_Ready?

#

does it impact the performance?

hasty iron
#

because it can be called more than once

slate swan
#

i want to particular id of particular name.
that stores in json like

"data": [{
    "object": "egg",
    "attributes": {
      "id": 1,
      "name": "mewo"
      }
    },
    "object": "egg",
    "attributes": {
        "id": 2,
            "name": "bhao"
      }
   }
]

i want id where name is meow. How can i do this in python?

tidal hawk
#

how?

tidal hawk
hasty iron
#

what do you mean "how"?

kindred epoch
#

bruh

hasty iron
#

thatโ€™s just how the discord gateway works

tidal hawk
#

how can on_ready be called more than once

#

aight

hasty iron
#

on_ready gets called whenever discord sends the READY event

#

which can happen multiple times, due to reconnections or other things

tidal hawk
#

okay

#

ty

upbeat otter
#

Guys, i want to make a blacklisting words command
but when i open my txt file using readlines, why does it show \n, and can i remove it?

kindred epoch
#

why are you using a .txt files to save words

upbeat otter
#

should i use a database?

kindred epoch
#

yea duh

upbeat otter
#

umm kk, thenx

slate swan
#

Hello, someone knox how do I get a guild objet by the id ?

slate swan
upbeat otter
slate swan
#

@upbeat otterhey can u help me?

upbeat otter
slate swan
#

i want to get id of particular name that are store in json.

upbeat otter
#

umm.......i dont really much know how to use json files, am sorry

slate swan
#

k

wispy sequoia
#

how to make the name field empty in embeds?

kindred epoch
#

\u200b

vale root
#

With my embed is there a way to change the size of the font

#

So that my discord invite dose not go onto the next line?

vagrant brook
#

No

vale root
#

damn cus it looks bad

vagrant brook
#

I mean if you zoom in enough

#

It will go onto the next line anyway

wispy sequoia
#

how to get the message content without the command?

#

example

#

test hello

bot: you said "hello"

wispy sequoia
#

no?

#

I don't need wait for

#

this is a command

willow vine
wispy sequoia
willow vine
#

oh

#

isnt the function uppercase though

full lily
#

you're missing a closing bracket on the line with size =

willow vine
#

OHHH

#

thankss

full lily
#

the variable name should be lowercase as per convention

willow vine
#

oh

#

yeah thanks that makes sense

reef shell
#

Is it possible to set_image of embed in the embed constructor?

vague quarry
#

hi! so if I have this code

user = client.get_user(int(key))

and "key" is a Variable with the ID of a user, why does user = None

reef trail
#
        for role in member.roles:
            await member.remove_roles(role, reason=f"{ctx.author} (ID: {ctx.author.id})")``` would this work for removing all roles from someone?
bitter depot
#

One api call instead of n

reef trail
#

can i really do that

bitter depot
#

Or if not None then []

#

Can't remember which it is

reef trail
#

Its probably None

bitter depot
reef trail
#

Why have i never tried doing that.. That would clean up so much of my code

vague quarry
reef trail
#

can you add a reason to it?

bitter depot
#

!d discord.Member.edit

unkempt canyonBOT
#

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

Edits the memberโ€™s data.

Depending on the parameter passed, this requires different permissions listed below...
reef trail
#

so member.edit(roles=[muted_role], reason="")

bitter depot
#

Yep

reef trail
#

ah you can, noice

bitter depot
reef trail
#

I know i know but people are dumb

reef trail
#

i know it wont be reboot persistent

bitter depot
#

The correct approach would be a database

reef trail
#

or.. store their roles then remove all of them then call them back again

#

I knoow but my db guy isnt here rn

#

im still learning how to do it

bitter depot
#

Well, the correct approach would be to just make people do permissions correctly

#

You shouldn't be removing any roles in the first place

reef trail
#

Mmmmmmmm

#

you've got a point

#

well shite, alright ty

vague quarry
slate swan
#

Is it possible to edit a module with a python program by converting it to txt, adding lines of code then closing it and converting it back to .py

bitter depot
vague quarry
#

all good

bitter depot
#

But you can just fetch_user which doesn't rely on cache

#

That's your solution

#

user = bot.get_user(id) or await bot.fetch_user(id)

vague quarry
#

I got

#

AttributeError: 'Bot' object has no attribute 'fetch'

bitter depot
#

fetch_user not fetch

vague quarry
#
user = client.fetch_user(int(key))
#

thats what i have in my code

bitter depot
#

And you have to await it

vague quarry
#

so

#

how could I use an await

#

if i wanted to the username = a variable

#

what does the fetch method actually do

high flame
hasty iron
#

you just use an await

high flame
#

do whatever you want with that

hasty iron
#

there is no special behaviour or anything

vague quarry
#

So what do i do

#

Lmao

high flame
#

i told you

kindred epoch
#

im fetching a channel and mentioning it in an embed, but if i click on it, it does not teleport me to the channel. why?

#

i might be using get_channel idr

slate swan
#

That's how discord works

#

On mobile at least

kindred epoch
#

hm

hasty iron
#

just stop using discord, easy fix

kindred epoch
#

yea nvm

#

lmao

ruby cosmos
#

Any recommendation on how to make a task loop run at a specific time each day?

kindred epoch
#

i was told to use sleep_until

#

from discord utils

ruby cosmos
#

Ok thanks

kindred epoch
#

but idk what kind of a timestamp works in it

hasty iron
#

it takes in a datetime object

kindred epoch
#

so this 2021-09-13 20:54:18.761287 and 2021-09-13 20:54:12.761287 would work?

#

or only utc

#

first one is utc

hasty iron
#

if thatโ€™s a datetime object then yeah

kindred epoch
#

ok

slate swan
#

@vocal magnet@neon harborcan i screenshare something for u?

#

wait i cant screenshare

dim wing
#

Is it possible to update my bot code without shutting it down. And how Big bots do that?

#

Using git maybe?

neon harbor
vague quarry
#

how to i assign the username to

#

variable named "user"

vague grove
#

hi, how can I detect when an image is sent & then do things with it (like post it in another channel or download it)

#

or maybe get the link of it

median isle
#

yo

#

my bot aint working

#

whats wrong

lucid vale
#

How do you access the member ID of the user that used a slash command? The solutions i've found on stack overflow are just giving me the member ID of the bot's response to the slash command.

stark hearth
valid niche
#

on_ready is just an event that fires somewhere just before the bot is actually ready to send/receive API calls

#

and has a chance to be called multiple times