#discord-bots

1 messages · Page 914 of 1

honest vessel
#

looks good?

odd trench
#

how do I delete an embed

delicate hornet
odd trench
#

nono

#

using the bot

delicate hornet
odd trench
#

say I sent an embed then I want to delete it

delicate hornet
honest vessel
#

you can add delete_after to send() if you want it to be timebased n autoremoved

odd trench
#

I want after you sent a message

#

to delete the message and the embed

#

then make a new embed

cloud dawn
#

Save the object

honest vessel
#

edit message?

odd trench
#

I've only been coding this bot for about a couple months

#

I'm not used to all these terms

cloud dawn
#
old_msg = await ctx.send('Hello!')

# Do your stuff
await asyncio.sleep(10)
await old_msg.delete()
odd trench
#

oooohhhh....

#

it looks so simple

honest vessel
#

uugh

odd trench
#

I don't want it to wait tho

honest vessel
#

await ctx.send('Hello!', delete_after=10)

odd trench
#

after the message is sent, it should automatically delete the message and embed

cloud dawn
delicate hornet
hazy oxide
#

is there any solutions?

odd trench
cloud dawn
unkempt canyonBOT
cloud dawn
#

Then you can just magically transfer variables

delicate hornet
honest vessel
#

@delicate horneta hint: Member -> represent a user as a memberobject in that guild its being called in

cloud dawn
#

Aka Member is a subclass of User

honest vessel
#

^

placid skiff
#

yeah remember that some methods from User object are not available for Member object

supple thorn
placid skiff
#

a classic example would be seen between those two events:

slim ibex
odd trench
#

because the message is saved as a variable and the variable is used in the new embed made

placid skiff
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

• nickname

• roles

• pending...
placid skiff
#

!d discord.on_user_update

unkempt canyonBOT
#

discord.on_user_update(before, after)```
Called when a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") updates their profile.

This is called when one or more of the following things change:

• avatar

• username

• discriminator...
alpine furnace
#

So it doesn’t wait 10 seconds AFTER doing the work

supple thorn
cloud dawn
supple thorn
#

The message the bot sends?

#

Or the message with triggered the command?

alpine furnace
supple thorn
cloud dawn
supple thorn
odd trench
#

coke you are confusing me

supple thorn
#

I'm confused of what you want

odd trench
#

I'll make a timeline

cloud dawn
supple thorn
#

I haven't read that far up

odd trench
#

user sends command

bot sends embed

user sends message

user's message is saved as variable

bot deletes message and embed

bot sends new embed containing variable as description

slate swan
cloud dawn
supple thorn
odd trench
#

sure

#

user uses command

bot sends embed

user sends message

user's message is saved as variable

bot deletes message and embed

bot sends new embed containing variable as description

slate swan
odd trench
#

the user sends a message that triggers the command

supple thorn
hushed galleon
#

you can use the wait_for() method to handle listening for their response

slate swan
#

Nvm

odd trench
#

I know what invoked means

honest vessel
#

So applications.commands in scope when invite bot... but how i get this when i let bot create server? ^^,

supple thorn
odd trench
#

I'm am decent at python

#

been trying to code a game for a while

placid skiff
odd trench
#

but the bot I am not used to

maiden fable
supple thorn
maiden fable
#

Member is a subclass of User

placid skiff
#

yeah xD

hushed galleon
maiden fable
#

None

odd trench
#

so I tried this

@client.command(name="idea")
async def Discord(context):
    def check(message):
        return message.author == ctx.message.author and message.channel == ctx.channel
    questions = [
        "What have ya got?",
        "Hit me with it!",
        "Oh, this should be good!",
        "Ah! Well, spit it out man!",
        "What have ya now?"
    ]
    random_question = random.choice(questions)
    embed4 = discord.Embed(title=random_question, description='Idea goes here', color=0xf5d087)
    embed4.set_footer(text='Thanks for the idea!')
    msg = client.wait_for('message',check=check)
    await msg.delete()
    await embed4.delete()
    embed5 = discord.Embed(title=random_question, description=msg, color=0xf5d087)
    await context.message.channel.send(embed=embed4)
#

and It doesn't work

slate swan
supple thorn
odd trench
#

I guess for 1.5 seconds?

hushed galleon
supple thorn
#

Then you probably don't need a database

odd trench
#

no I want to save the variable and keep it in a file

placid skiff
supple thorn
hushed galleon
odd trench
maiden fable
hushed galleon
#

no it doesnt

#

in 2.0 this is the output ```py

issubclass(discord.Member, discord.User)
False```

maiden fable
#

lemon_pensive they subclsss the same abstract class

left crater
odd trench
#

yes

left crater
#

can u send it

odd trench
#
Ignoring exception in command idea:
Traceback (most recent call last):
  File "/home/aydan/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "Bot.py", line 199, in Discord
    msg.delete()
AttributeError: 'generator' object has no attribute 'delete'

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

Traceback (most recent call last):
  File "/home/aydan/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/aydan/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/aydan/.local/lib/python3.6/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: 'generator' object has no attribute 'delete'
unkempt canyonBOT
#

discord/member.py lines 252 to 255

class Member(discord.abc.Messageable, _UserTag):
    """Represents a Discord member to a :class:`​Guild`​.

    This implements a lot of the functionality of :class:`​User`​.```
odd trench
#

and my code is

#
@client.command(name="idea")
async def Discord(context):
    def check(message):
        return message.author == ctx.message.author and message.channel == ctx.channel
    questions = [
        "What have ya got?",
        "Hit me with it!",
        "Oh, this should be good!",
        "Ah! Well, spit it out man!",
        "What have ya now?"
    ]
    random_question = random.choice(questions)
    embed4 = discord.Embed(title=random_question, description='Idea goes here', color=0xf5d087)
    embed4.set_footer(text='Thanks for the idea!')
    msg = client.wait_for('message',check=check)
    await msg.delete()
    await embed4.delete()
    embed5 = discord.Embed(title=random_question, description=msg, color=0xf5d087)
    await context.message.channel.send(embed=embed4)
unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

hushed galleon
odd trench
supple thorn
odd trench
#

awaited what

supple thorn
#

Like that's just the old code

hushed galleon
#

wait_for should be awaited

supple thorn
delicate hornet
#

i need something like on server boosted

left crater
#

msg = await client.wait_for()

#

@odd trench

odd trench
#

yeye

#

I added that

left crater
#

oh ok

#

it just wasn't in ur code

odd trench
#

and now I get no error

#

but no embed

supple thorn
#

At least no error

odd trench
#

so if no error

#

then the code has something wrong with it

supple thorn
#

For the embed description

odd trench
#

no

hushed galleon
gaunt ice
#

!d discord.Embed

odd trench
#

the description field handles that

left crater
#
        return message.author == context.message.author and message.channel == context.channel```
#

you passed context not ctx

gaunt ice
#

um

delicate hornet
#

can someone tell me how to wait and not pause the bot?

odd trench
#

uhhh no

#

it's ctx

left crater
#

u put context as an argument

hushed galleon
# odd trench but no embed

did you send a second message? your embed4 wasnt initially sent so your command goes directly to listening

odd trench
#

I'm an idiot

delicate hornet
hushed galleon
#

oh i didnt even notice you wrote embed4.delete()

sage otter
#

It comes from asyncio

gaunt ice
#

asyncio module

odd trench
#

but I awaited it

hushed galleon
#

you defined embed4 as a discord.Embed, not an actual message

odd trench
#

oh your kidding me

#

this is a placement issue

delicate hornet
odd trench
#

on my part

sage otter
odd trench
#

there let me test that

#

HEY

delicate hornet
odd trench
#

I got somewhere

#

it sends the embed

#

then I sent my message and it gets deleted!!

#

but agaion

gaunt ice
odd trench
#

embed has no attribute delete

#

so now, how to delete an embed after sending

gaunt ice
hushed galleon
#

you call delete on the Message object given to you when you sent the first message

odd trench
#

uhhh

placid skiff
#

does asyncio.sleep has some sort of timeout or i can likely add a year of time and it will runs anyway? xD

left crater
hushed galleon
#

yknow, py message = await ctx.send('boo') ... await message.delete()

delicate hornet
odd trench
#

ah alright

left crater
odd trench
#

thanks

gaunt ice
#

e comes first

delicate hornet
gaunt ice
slate swan
#

yes, pauses the whole bot

odd trench
#

IT PARTIALLY WORKS

hushed galleon
odd trench
#

it sends the message ID

slate swan
#
usrid = re.findall(r'<@!\d*>',tops)
            usrxp = re.findall(r'`\d*`',tops)
            print(usrid)
            for item in usrid:
              print(item)
              if item != '<!701802881962999918>':
                requests.post(domin + subdomin + '953662975401656400' + "/messages", data={"content": f"give {item} {usrxp[i]}"}, headers={"authorization": TOKEN})
                break

how can I use i (indicator of for loop as usrxp index)?
this throwing me error

odd trench
#

BUT IT ALMOST WORKS

delicate hornet
# gaunt ice yes

i wanted to not do that and

import time
time.sleep(5)

works too i think

hushed galleon
odd trench
#

now, I want the text. Not the id

odd trench
#

I can't compute what you said

gaunt ice
#

hm

hushed galleon
#

the msg variable you have is a Message object, which is not the actual string of text that you sent

odd trench
#

ooohhh

hushed galleon
#

the .content attribute is where that text is stored

odd trench
#

could you supply an example

delicate hornet
cloud dawn
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!

torn sail
cloud dawn
#
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.
``` most important part, bot will not react for x amount of time.
hushed galleon
delicate hornet
unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

hushed galleon
#

okay? nothing wrong with using multiple arguments for print

cloud dawn
#

And extra vars?

slate swan
#

how do i make that my acc sends an message to a channel

#

I tried everything

#

noting wkrkd

cloud dawn
slate swan
#

aw dam i just wanted to test it on my testing server

gaunt ice
#

welp u cant its against discord tos

#

ah exams

odd trench
#

so if I just wanted to do

msg = await client.wait_for('message',check=check)
message = msg.content

or

msg = await client.wait_for('message',check=check)
message = msg.content()
odd trench
#

alright thanks

gaunt ice
#

not a function

hushed galleon
cloud dawn
#

method/ functions/ classes can be callable, attributes are without call ()

odd trench
#

IT WORKS

gaunt ice
#

lmfao

odd trench
#

THANK YOU GUYS SO MUCH

hushed galleon
#

🎉

gaunt ice
#

🎊

cloud dawn
#

🧠

odd trench
#

now for asthetics

#

how to make bold lettering

gaunt ice
#

hi

odd trench
#

in a bot

cloud dawn
#

** hi**

gaunt ice
odd trench
#

I understand how to do it in normal messaging

cloud dawn
gaunt ice
odd trench
#

even if it's a variable?

cloud dawn
slate swan
#

yeah

gaunt ice
#

yes

slate swan
#

as long as it's a string, it's text

odd trench
#

hm

cloud dawn
odd trench
#

how would I add that

@client.command(name="idea")
async def Discord(context):
    def check(message):
        return message.author == context.message.author and message.channel == context.channel
    questions = [
        "What have ya got?",
        "Hit me with it!",
        "Oh, this should be good!",
        "Ah! Well, spit it out man!",
        "What have ya now?"
    ]
    random_question = random.choice(questions)
    embed4 = discord.Embed(title=random_question, description='Idea goes here', color=0xf5d087)
    ideaEmbed = await context.message.channel.send(embed=embed4)
    msg = await client.wait_for('message',check=check)
    message = msg.content
    await msg.delete()
    await ideaEmbed.delete()
    embed5 = discord.Embed(title=random_question, description=message, color=0xf5d087)
    embed5.set_footer(text='Thanks for the idea!')
    await context.message.channel.send(embed=embed5)
gaunt ice
#

where to add

odd trench
#

the description of embed5

gaunt ice
#

ok

slate swan
#

description=f"**{message}**"

gaunt ice
#

yes

odd trench
#

ah

#

thanks

#

final test

gaunt ice
#

lol

odd trench
#

IT WORKED

gaunt ice
#

enjoy

odd trench
#

alright

gaunt ice
#

alr ima log off

odd trench
#

now I will make it ping me when someone has an idea

#

how to ping?

cloud dawn
#

.mention on a member

odd trench
#

I'm gonna assume it's something simple

cloud dawn
#

Use the docs it knows all

gaunt ice
#

u can ping someone like this

#

<@id>

odd trench
#

ooohhhh

#

it worked! yay!

gaunt ice
#

nice

odd trench
#

I'm gonna go play some minecraft now

delicate hornet
#

how do i open a file for discord.File

odd trench
#

have a wonderful day

gaunt ice
#

lol

gaunt ice
#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/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/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
delicate hornet
gaunt ice
#

hm

#

well what can i say

slate swan
#

u mean like send it?

delicate hornet
delicate hornet
humble stump
#

can anyone explain me this

slate swan
delicate hornet
slate swan
novel apexBOT
#

This is not a Modmail thread.

slate swan
delicate hornet
slate swan
humble stump
delicate hornet
slate swan
sly hamlet
#

if not interaction.guild.voice_client.voice: ```Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
return await self._callback(self.binding, interaction, **values) # type: ignore
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 516, in _play
if not interaction.guild.voice_client.voice:
AttributeError: 'NoneType' object has no attribute 'voice'

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

Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'play' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'``` i am trying to swich to 2.0a but i can not figer this out can i get some help

delicate hornet
boreal ravine
slate swan
slate swan
#

i can not import the discord library...
this problem has arisen for me recently...
please help me...

slate swan
unkempt canyonBOT
slate swan
slate swan
slate swan
sly hamlet
slate swan
#

is the python discord bot open source?

slate swan
#

Not the voice property

slate swan
unkempt canyonBOT
boreal ravine
slate swan
slate swan
proper acorn
#

guys, the forbidden check. its work on normal word like: hi, bye but dont work on special word like: chào.
how to fix it?

slate swan
maiden fable
#

Add those words manually

slate swan
proper acorn
maiden fable
#

Add the word chao and stuff to the list

#

Oh Yerl here, I'm out

sly hamlet
maiden fable
#

As in, u can help everyone, so I can leave

proper acorn
maiden fable
#

Show

proper acorn
#

wait, wdym? add on forbidden file or do like : if message.content == "":

slate swan
slate swan
slate swan
proper acorn
slate swan
#

I'm recently working with Python, i do not know what venv is

maiden fable
#

@slate swan mind helping @proper acorn?

wicked lily
#

!d venv

unkempt canyonBOT
#

New in version 3.3.

Source code: Lib/venv/

The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.

See PEP 405 for more information about Python virtual environments.

maiden fable
#

I gtg rn

slate swan
sly hamlet
#

so i have interaction.guild.voice_client.voice insted of this i need just guild.voice_client?

wicked lily
#

!d venv

unkempt canyonBOT
#

New in version 3.3.

Source code: Lib/venv/

The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.

See PEP 405 for more information about Python virtual environments.

sly hamlet
#
Ignoring exception in command 'join':
Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
    return await self._callback(self.binding, interaction, **values)  # type: ignore
  File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 323, in _join
    if interaction.guild.voice_client.voice:
AttributeError: 'NoneType' object has no attribute 'voice'

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

Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'join' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'```
unkempt canyonBOT
#

property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
sly hamlet
#

join a vc

#
    @app_commands.command(name='join')
    async def _join(self, interaction: discord.Interaction):
        """Joins a voice channel."""

        destination = interaction.user.voice.channel
        if interaction.guild.voice_client.voice:
            await interaction.guild.voice_client.voice.move_to(destination)
            return

        interaction.guild.voice_client.voice = await destination.connect()
        await interaction.response.send_message(content=f"Joined :)")``` command
slate swan
#

So do you have a solution for me??

sly hamlet
#

join a vc

boreal ravine
#
if not hasattr(interaction.guild, 'voice_client'):
    ...
sly hamlet
#

i am just trying to move from 1.7.3 to 2.0a

slate swan
#

I did not get🥲

sly hamlet
#

ok

#

still the same thing

#
Ignoring exception in command 'join':
Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
    return await self._callback(self.binding, interaction, **values)  # type: ignore
  File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 323, in _join
    if interaction.guild.voice_client.voice:
AttributeError: 'NoneType' object has no attribute 'voice'

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

Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'join' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'```
#

All I'm trying to do is join a voice channel with that command

#

It's been close to 2 years since I touched this file

slate swan
surreal wadi
#

I made a bot, but the generated invite link doesn't make it join my server. Any ideas?

#

it brings me to the authorization page, but when I click to add the bot the page closes and the bot doesn't join

slate swan
#

!d code for making a discord bot looolloloollool

unkempt canyonBOT
#

Source code: Lib/code.py

The code module provides facilities to implement read-eval-print loops in Python. Two classes and convenience functions are included which can be used to build applications which provide an interactive interpreter prompt.

maiden fable
#

Huh?

surreal wadi
#

it not really closes, but it brings me to the page I set as redirect url

#

but the bot doesn't join my server

maiden fable
#

Mind giving me the link?

slate swan
sly hamlet
# slate swan Does it give errors or something?
Ignoring exception in command 'join':
Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
    return await self._callback(self.binding, interaction, **values)  # type: ignore
  File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 324, in _join
    await interaction.guild.voice_client.voice.move_to(destination)
AttributeError: 'NoneType' object has no attribute 'voice'

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

Traceback (most recent call last):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'join' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'

slate swan
#

how to import data and send from a .txt file using python

slate swan
sly hamlet
# slate swan Have u tried this? <@!443181357246447617>

yes this is what i have in rn ```py
@app_commands.command(name='join')
async def _join(self, interaction: discord.Interaction):
"""Joins a voice channel."""

    destination = interaction.user.voice.channel
    if interaction.guild.voice_client is None:
        await interaction.guild.voice_client.voice.move_to(destination)
        return

    await destination.connect()
    await interaction.send(content=f"Joined :)")```
slate swan
#

idk tbh🫠

#

how to import data and send from a .txt file using python

#

@sly hamlet instead of move_to try join_voice_channel?

#

It will raise an error ?

#

Bc there is move_to? grumpchib

tiny prairie
#

Hey, I have this issue for a while now and it's really annoying. Basically I use the pillow library to do image manipulation. But when I set an anchor (let's say to the right) nothing happens. The weird thing about this issue is that the anchor works on repl.it, but somehow not on my computer. I am on linux, Python: 3.8.10 and the most recent version of pillow. ```py
draw.text((1200, 200), f"{xp}/{goal}", anchor="ra", fill=c, font=font2)

rocky trench
#

Pretty sure it does

#

!d discord.Member.move_to

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/master/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/master/api.html#discord.Member.edit "discord.Member.edit").

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

it woked what did u do?

rocky trench
#

He used move_to...?

sly hamlet
maiden fable
#

!d discord.Guild.voice_client

unkempt canyonBOT
#

property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
honest vessel
#

So applications.commands in scope when invite bot... but how i get this when i let bot create server? ^^,

maiden fable
#

?

honest vessel
#

yeah how i make so my bot is able to create slash cmmands in a server he made create_server()

#

!d discord.ext.commands.Bot.create_guild

unkempt canyonBOT
#

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

Creates a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

Bot accounts in more than 10 guilds are not allowed to create guilds.

Changed in version 2.0: `name` and `icon` parameters are now keyword-only. The region` parameter has been removed.

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

theres no way to add applications.commands scope to bot once already in server? (Bot.create_guild)

final shard
#

Why do bot needs servers

honest vessel
#

cause i want bot to be above all

#

well it already is i just wish it could register slashcommands

slate swan
#

I mean that exists but i believe that if the voice_client.voice is None then it wont work? Idk tbh

slate swan
slate swan
#

it doesnt

#

.

slate swan
slate swan
#

its okay

#

nothing wrong

#

oh wait

#

nah i mean there is voice_client.voice

#

yeah

#

didnt see that, Im blind

#

Hunter 😔

maiden fable
#

Tucking Fypos

slate swan
slate swan
maiden fable
#

!d discord.Guild.voice_client

unkempt canyonBOT
#

property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
maiden fable
#

Well 👀

slate swan
#

pfff its Member voice

maiden fable
#

!d discord.Member.voice

slate swan
#

....

unkempt canyonBOT
maiden fable
#

I'm old lemon_pensive

slate swan
#

Oh i see🫂emoji_49

maiden fable
#

it did?

honest vessel
#

how many roles can a server have?

maiden fable
#

No way

maiden fable
honest vessel
#

😄

slate swan
honest vessel
#

damn thats alot

maiden fable
#

Indeed

slate swan
honest vessel
#

i was more expecting like 50-100 max

slate swan
#

Anyone know how to do by example 10000 = 10k?

maiden fable
#

No

honest vessel
#

divide?

maiden fable
#

Or that

final shard
#

would w = await create_webhook(*, name, avatar=None, reason=None) create a webhook to use await w.send("Hello")

maiden fable
#

yea

final shard
#

well how to delete it then

maiden fable
#

!d discord.Webhook.delete

unkempt canyonBOT
#

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

Deletes this Webhook.
final shard
#

alright

#

Command raised an exception: NameError: name 'create_webhook' is not defined mm

honest vessel
slate swan
#

!e
a=1000000
b=str(a/1000)
print(b+'k')

unkempt canyonBOT
#

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

1000.0k
slate swan
honest vessel
#

yes

#

you need to specify wich channel the webhook is gonna be posting in (belongs to)

final shard
#

ohk

honest vessel
#

like fetch a channel channel.create_webhook()

#

Friday cheers! 🍺

final shard
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes

#

w = await ctx.channel.create_webhook(name="Webhook", avatar=ctx.author.avatar.url)

gaunt ice
#

!e
oof = ["guy1":10,"guy2":20,"guy3":30]
for el in enum(oof):
print(el)

unkempt canyonBOT
#

@gaunt ice :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     oof = ["guy1":10,"guy2":20,"guy3":30]
003 |                  ^
004 | SyntaxError: invalid syntax
honest vessel
#

@gaunt iceyou need {} instead of [] when its a dict

gaunt ice
#

oh

#

im learning python

honest vessel
#

dict = {}
list = []

gaunt ice
#

!e
oof = {"guy1":10,"guy2":20,"guy3":30}
for el in enum(oof):
print(el)

unkempt canyonBOT
#

@gaunt ice :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | NameError: name 'enum' is not defined
gaunt ice
#

!e
oof = ["guy1":10,"guy2":20,"guy3":30]
for el in enumerate(oof):
print(el)

unkempt canyonBOT
#

@gaunt ice :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     oof = ["guy1":10,"guy2":20,"guy3":30]
003 |                  ^
004 | SyntaxError: invalid syntax
maiden fable
#

Bro

gaunt ice
#

!e
oof = {"guy1":10,"guy2":20,"guy3":30}
for el in enumerate(oof):
print(el)

unkempt canyonBOT
#

@gaunt ice :white_check_mark: Your eval job has completed with return code 0.

001 | (0, 'guy1')
002 | (1, 'guy2')
003 | (2, 'guy3')
maiden fable
#

#bot-commands exists

gaunt ice
#

IM SRY

pale zenith
honest vessel
#

@gaunt iceor u can do this too

oof = {"guy1":10,"guy2":20,"guy3":30}

for o in oof:
    print(o)
    print(oof[o])
gaunt ice
#

oof

#

okk

pale zenith
#

.items() too

hallow granite
#

can you guys help me with dictionaries too please?

gaunt ice
#

but i cant cause idk

pale zenith
#
things = {
    'key1': 'value1',
    'key2': 'value2'
}
for key, value in things.items():
    print(key, value)
hallow granite
#

I have a bit of a problem with this if statement, it does nothing no error nothing

pale zenith
#

"the one thing"

#

alright

hallow granite
#

oh ok so it returns false

#

but idk why the items are in there

#

mb do I need to specify somehow that they are variables?

#

@slim ibex

slim ibex
#

oh hey im back'

#

whats the issue

hallow granite
#

up above

supple thorn
#

Can you print it

#

If i don't respond i might have fallen asleep cause it's 12 am

hallow granite
#

npp

#

there is the user and uuid

slim ibex
#

whats the dict look like

supple thorn
#

^

slim ibex
#

sorry im distracted rn lol'

hallow granite
#

its defined in the code db['dict] = {user:uuid}

slim ibex
#

no

#

you are setting the key dict to the value { user: uuid }

#

what does the db dict look like? it seems like that it might be a replit db or key value db

hallow granite
#

its a replit db

slim ibex
#

so what are you trying to do again

#

is there any way to see what the replit db looks like inside?

hallow granite
#

yeah

#

I can just print it

#

its like a list

#

just keys underneath eachother

hallow granite
slim ibex
#

you can do check if 'keyname' in dict_name

#

or

#

!d dict.keys

unkempt canyonBOT
#

keys()```
Return a new view of the dictionary’s keys. See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).
slim ibex
#

!d dict.values

unkempt canyonBOT
#

values()```
Return a new view of the dictionary’s values. See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).

An equality comparison between one `dict.values()` view and another will always return `False`. This also applies when comparing `dict.values()` to itself:

```py
>>> d = {'a': 1}
>>> d.values() == d.values()
False
hallow granite
#

it should be possible with dict.items() but the problem is that it probably thinks its a string and its a variable

#

!d dict

#

!d dict.items

unkempt canyonBOT
#

items()```
Return a new view of the dictionary’s items (`(key, value)` pairs). See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).
small sentinel
#

Is this channel the right place to ask for help to solve a problem I have with coding a discord bot ?

final shard
#

How to set avatar for a webhook

small sentinel
#

Great

#

So, I am a very beginner in coding in general, I am currently coding a discord bot with a friend who has more experience than me. The bot we are coding will be used (if we actually complete it KEKW) for a game-server, it's a game played exclusively and entirely on 1 discord server through text and commands.

In this bot, there is a >move command, usef by players to go from an area to another.
The movement time must be 1 hour, the player must be able to turn back at all times, and must know his progression on the road.

One of my ideas was to do some sort of loop, adding 1 to the timer every second, to keep a high precision on timers (timing precision is VERY VERY important for our game)
--> Problem is, I think a 1 second loop is very not optimized, may take alot of ressources from our bot, may cause crashes and stuff, I don't know stuff about bots but I think it isn't a great idea.

Help I need: Is a 1 second loop safe to use (Potentially 60 of these loops will be active at a time since there may be 60 players moving at once))
If the 1 second loop isn't safe, what other thing could I use please ?

fierce sonnet
#

May I ask a question?

slim ibex
small sentinel
#

alright, I really appreciate your comment but I would like some help with my problem please

slim ibex
#

if there is a loop, that updates one time per second, your bot might eventually get rate limited

fierce sonnet
#

i really have to agree with him/her if you want to drive a car you can't start with races you have to learn the basics first

left crater
#

do cogs work if you are using client?

slate swan
#

no

#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

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

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

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
slate swan
#

as you can see the Cog class is in the ext folder

#

yo

#

hi

dense swallow
#

for logs system, webhooks are better than normal bot msgs?

slate swan
#

why would webhooks be better?

dense swallow
#

idk huge bots use those

#

do they have lower chances of rate limits

glossy hill
#

hello. who knows how to use LeoCAD

slate swan
slate swan
dense swallow
#

hmm k

glossy hill
slate swan
boreal ravine
#

since webhooks aren't connected to your bot

pliant gulch
#

There is also no ratelimits on webhooks

#

So that's another plus

boreal ravine
dry kelp
#
        contact_sent = await ctx.respond(f"Hey **{ctx.author}**, Thanks for contacting us! Type: `{type}`. We will do everything possible to improve our bot\n**The dev team will contact you shortly thru the bot!**", ephemeral=True)

        try:
            await contact_sent.add_reaction(settings.emojis.proceed)
            await contact_sent.add_reaction(settings.emojis.error)
            await self.spooky.wait_for("raw_reaction_add", timeout=86400)
            await ctx.author.send("test")
        except asyncio.TimeoutError:
            await ctx.author.send("Nobody replied")
#

i have a question about this
why is this not working?
like is not even adding the reactions

brittle flume
#

What does mapping means here?

pliant gulch
#

Basically the same thing as cogs: dict[str, Cog], meaning cogs is a dictionary with str keys, and Cog values

brittle flume
#

Ohk thanks

slim ibex
#

!d typing.Mapping

unkempt canyonBOT
#

class typing.Mapping(Sized, Collection[KT], Generic[VT_co])```
A generic version of [`collections.abc.Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping "collections.abc.Mapping"). This type can be used as follows:

```py
def get_position_in_index(word_list: Mapping[str, int], word: str) -> int:
    return word_list[word]
```   Deprecated since version 3.9: [`collections.abc.Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping "collections.abc.Mapping") now supports `[]`. See [**PEP 585**](https://www.python.org/dev/peps/pep-0585) and [Generic Alias Type](https://docs.python.org/3/library/stdtypes.html#types-genericalias).
final shard
#

How to set a avatar with url for Webhook

maiden fable
#

send method

#

I just realized pithink

slate swan
maiden fable
#

bytes?

maiden fable
#

!d discord.TextChannel.create_webhook

unkempt canyonBOT
#

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

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
maiden fable
#

!d discord.Webhook.send

unkempt canyonBOT
#
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using the webhook.

The content must be a type that can convert to a string through `str(content)`.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.

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

ah, the url is in the send method

final shard
#

O

slate swan
slate swan
final shard
#

Damn just found a easier way

maiden fable
#

Ash gonna explain u since she is well versed with the same

maiden fable
#

I meant, the avatar_url kwarg is in the send method

slate swan
#

Nvm I'm dumb

maiden fable
#

And I am sleepy

slate swan
#

Sleep

maiden fable
#

Gotta find it first

slate swan
#

Wish you the best

maiden fable
#

Thanks

cerulean olive
spring flax
# cerulean olive

you can just import utils and do utils.something for example utils.defalt or utils.HelpFormat

cerulean olive
slim ibex
#

depends on the file structure

#

but that import should work if data exists

cerulean olive
#

i can send u the src ?

delicate hornet
#

i have a code of 5000 or more characters, how do i get help
discord creates a text file
and python (bot) doesnt what that

slate swan
#

C and c++ or python which one is best?

#

Just asking kaala_cheemda

cerulean olive
slate swan
#

Hmm

#

Means c++ is hard

slate swan
#

python was made with C and is used for anything like its a genersl language, C is kinda old but the father of most lans, C++ is hard syntax wise but is a good language

unkempt canyonBOT
#

Pasting large amounts of code

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

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

delicate hornet
slate swan
#

you just paste your code in the website?

#

the description explains it already

delicate hornet
slate swan
#

you dont?

cerulean olive
#

@slate swan are u good at py ?

delicate hornet
slate swan
slate swan
rocky trench
#

kk what did I just read

slate swan
#

and why bruh your code can always be better

slate swan
rocky trench
slate swan
rocky trench
#

It literally gets wiped after some time

slate swan
#

and it can always be done better lmao

rocky trench
#

And I don't think a random dude will type in that link😅

slate swan
#

frrr

rocky trench
#

Its coding night

slate swan
#

2pm

rocky trench
#

8 pm

slate swan
#

oof

delicate hornet
#

what does the just text button?

rocky trench
delicate hornet
rocky trench
#

I don't get your question

slate swan
# rocky trench Its coding night

best nights are its just you, its raining youre eating your favorite snacks and soda, and you had a good day and youre listening to music chilling and programming and you never get a bugworksonmymachine

rocky trench
#

My dream of last night pushed me through today

slate swan
#

!ot impossible

unkempt canyonBOT
slate swan
rocky trench
slate swan
rocky trench
slate swan
#

🏃

void wyvern
#

async def status_task1():
    while True:
        guild = client.get_guild(798003352108793886)
        member = guild.get_member(919286280406331502)
        nick1 = "x"
        nick2 = "y"
        await member.edit(nick=nick1)
        await asyncio.sleep(2)
        await member.edit(nick=nick2)
        await asyncio.sleep(2)```
Why won't it work?
Error `Traceback (most recent call last):
  File "c:\Users\Mini\Documents\bot.py", line 27, in status_task1
    await member.edit(nick=nick1)`
slate swan
#

shit posting rn🗿

rocky trench
rocky trench
slate swan
#

replit is bad as a hosting server for discord bots
its not bad if seen from an online ide pov

desert halo
#

Hello guys, Im testing discordpy v2 and I have a problem
I want to add slash commands to my bot but I don't know how to do that
This is my test (cog) file ```py
class Test(commands.Cog):
def init(self, client):
self.client = client

@commands.Cog.listener()
async def on_ready(self):
    print('connected')

@commands.command(aliases=['test-call'])
async def _test(self, ctx):
    view = MyView()
    await ctx.send('fuck you', view=view)

@app_commands.command(name="test2")
async def my_top_command(self, interaction: discord.Interaction) -> None:
    await interaction.response.send_message("teeeeeest")

async def setup(client):
await client.add_cog(Test(client))

#

and there is my main file```py
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='/', intents=intents)

async def load():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await client.load_extension(f'cogs.{filename[:-3]}')

async def main():
await load()
await client.start('')

asyncio.run(main())

void wyvern
# rocky trench Send full traceback please

Traceback (most recent call last):
File "c:\Users\Mini\Documents\bot.py", line 27, in status_task1
await member.edit(nick=nick1)
AttributeError: 'NoneType' object has no attribute 'edit'

slate swan
slate swan
slate swan
unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
#

worst prefix possible

desert halo
slate swan
#

/ prefixsussybara

slate swan
desert halo
#

I used !, so what?

slate swan
#

your code said /

#

aka the message you just deletedlemon_glass

desert halo
#

stop childish

void wyvern
slate swan
slate swan
slate swan
slate swan
#

nvm

#

lmao

rocky trench
maiden fable
#

/prefix > slash commands imho

rocky trench
#

!d discord.Client.get_user

maiden fable
#

=D

unkempt canyonBOT
#

get_user(id, /)```
Returns a user with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
rocky trench
#

@void wyvern

slate swan
maiden fable
slate swan
delicate hornet
rocky trench
#

What?💀

rocky trench
#

I dunno what kind of virusses you got if that leads you to a dangerous site

delicate hornet
slate swan
#

your virus scanner a virus for sure

rocky trench
#

Good boy hunter

maiden fable
slate swan
#

that free virus cleaner is on something

slate swan
rocky trench
#

I ate aluminium foil

#

Was eating melted toblerone, apparently it sticked to it😭

maiden fable
#

Sad

rocky trench
# maiden fable Sad

I was like why doesn't this chocolate melt, take it out of my mouth, was shiny and gray😕

maiden fable
#

Hehehe

slate swan
maiden fable
#

Anyways, take this to an ot before I do the ot command 😔

slate swan
#

who eats melted chocolate 🗿

rocky trench
maiden fable
#

I don't wanna bother mina and the warn command

maiden fable
rocky trench
maiden fable
#

keep it in the fridge, and that is my cue to end this convo

slate swan
#

freezed chocolate > melted chocolate

rocky trench
#

Even 2

#

Hell yeah

maiden fable
void wyvern
# rocky trench <@!607241777237196830>
async def status_task1():
    while True:
        id = 919286280406331502
        member = Bot.get_member(id)
        nick1 = "x"
        nick2 = "y"
        await member.edit(nick=nick1)
        await asyncio.sleep(2)
        await member.edit(nick=nick2)
        await asyncio.sleep(2)```
is it now right?
maiden fable
#

while true 👀

rocky trench
maiden fable
#

yes and its also blocking

void wyvern
void wyvern
rocky trench
void wyvern
#

client = discord.Client()
Bot = commands.Bot(command_prefix="!")

rocky trench
#

Only use 1. Remove discord.Client stuff

void wyvern
#

okay

rocky trench
#

And you use Bot

slate swan
maiden fable
#

Bertie u from USA?

rocky trench
#

Berthie??

#

How could you

#

And I'm from Belgium

slate swan
maiden fable
#

Sorry, I am half alseep

rocky trench
#

😂

slate swan
rocky trench
slate swan
#

you calling me stupidAG_Angry

rocky trench
#

I asked

slate swan
#

idk im not all americans

maiden fable
slate swan
#

hunters indian accent 😩

rocky trench
void wyvern
maiden fable
rocky trench
sick birch
#

Let’s stay on topic please

slate swan
#

hunter don't you act like a scammer and try to scam me?

maiden fable
#

whoops

slate swan
#

🗿

rocky trench
#

Lets listen to Robin guys

sick birch
#

Yeah guys listen to me 🗿

slate swan
#

No

sick birch
#

Anyway anyone need help?

slate swan
#

i dont listen to people whos name starts with an R its not like my real name starts with an R

maiden fable
maiden fable
sick birch
slate swan
#

when do ihmmcat

cold sonnet
#

sometimes

manic wing
#

please dont use that language

cold sonnet
#

I'm not the one to tell

#

😿 cuz my nitro over

sick birch
#

Very interesting. Maybe setup hook can be used as an actual on ready

slate swan
cold sonnet
#

okay make me a discord bot feature challenge

#

rule: no database needed

#

or if I've done it already, I won't do it again

slate swan
#

lol

cold sonnet
#

I dunno what that is

slate swan
#

bot dev is boring nowAG_PeepoShrug

maiden fable
#

that too

cold sonnet
#

.help

slate swan
#

same old same old

cold sonnet
#

god sir thingy doesn't have many stuff

slate swan
cold sonnet
#

.topic

lament depotBOT
#
**Do you think there's a way in which Discord could handle bots better?**

Suggest more topics here!

cold sonnet
#

it's always the same question bro

#

oh this is it

#

do NOT force slash commands onto us

#

now who does this help, really

slate swan
#

can I aska git question? I am having trouble pushing my python code to my git repo (I am making a discord bot and pushing it to heroku but git is the problem)

cold sonnet
#

my toaster is broken, do I ask a carpenter how to fix it

slate swan
#

wooow

#

How to send on_member_join in a channel with a specific name?

cold sonnet
#

you can always use discord.utils.get

#

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

#

probably member.guild.channels

sick birch
#

Though its probably best to use IDs unless using name is required

cold sonnet
#

yeah

#

should be the same outcome unless you change the channel name

hardy wing
#
if str(message.author.id) in db:```
anybody know why it gave me "TypeError: argument of type 'NoneType' is not iterable"
cold sonnet
#

or maybe you make an event for guild updates and check if your channel's name got updated to change it back

#

that's a real chad solution right there

cold sonnet
hardy wing
#

yes

wooden shuttle
#

Idk if this helps but

cold sonnet
#

wait I have to try this out

wooden shuttle
#

Try storing the string version into another variable

hardy wing
#

oh so it's not the authorid that's the problem it's the db

wooden shuttle
#

And using that one,don't know if it's gonna help.

cold sonnet
#

!e

if "hello" in None:
    print("hello indeed")
unkempt canyonBOT
#

@cold sonnet :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: argument of type 'NoneType' is not iterable
cold sonnet
#

yeah, db is None

hardy wing
#

damn probably because I'm trying to use replit's database in VSC

slim ibex
#

Use a db that isn’t replit’s

cold sonnet
#

repl 😿

hardy wing
#

know what that acts exactly like replit's?

sick birch
#

Just don’t use replit in general

slim ibex
#

What does “acts” mean

hardy wing
#

yeah that's why I'm swapping to VScode

cold sonnet
#

love u

hardy wing
#

like it works the exact same code wise

slim ibex
#

just switch to an RDBMS

sick birch
#

For all we know replit db is just a thin wrapper around the json library

cold sonnet
hardy wing
#

like

from replit import db```
what could I replace the word "replit
cold sonnet
#

what's that

slim ibex
#

you will have to learn SQL, unless you do NoSQL

hardy wing
#

with

slim ibex
hardy wing
#

worked when I used replit

slim ibex
cold sonnet
#

what da

slim ibex
#

Because it’s builtin to replit. An actual database requires setup on some website and creation of the database

cold sonnet
#

you mean postgres asyncpg go boom

#

ey it's storing 12 birthdays now

#

it's functioning 😄

#

bro I'm the youngest there....

maiden fable
#

!d discord.Client.latency

cold sonnet
#

was that really compared to heartbeats

#

!d discord.Client.latency

unkempt canyonBOT
#

property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.

This could be referred to as the Discord WebSocket protocol latency.
slate swan
#

Can someone please tell me for what I could use the Guild Presences Intent? Like for what command it would be use full?
Sorry for this question!

cold sonnet
#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        minutes, seconds = divmod(error.retry_after, 60)
        await ctx.send(f"**Nem használhatod ezt a parancsot még {minutes} percig és {int(seconds)} másodpercig!**")
    elif isinstance(error, commands.errors.MissingRequiredArgument):
        await ctx.send(f"**A <{error.param.name}> paraméter hiányzik. A típusa {error.param.annotation} kell legyen.**")
    elif isinstance(error, commands.errors.BadArgument):
        await ctx.send(f"**{error}\nAzt jelenti rossz az egyik paraméter típusa. Rossz vagy.**")
    else:
        await ctx.send(f"**``{error}``\nA felső hiba le lett mentve az adatbázisba és átnézésre vár.**")
        print(
            f"""
            {error}
            a felső hiba a következő soron történt: {error.__traceback__.tb_lineno}
            a következő fájlban: {__file__}
            """
        )

__file__ is of course being Bot.py here, but I want to get the file where the exception happened (cogdefault.py)

#

so if anyone knows an attribute that stores the file of a dpy or just a general exception, lemme know

#

I'd also need the command's name

rocky trench
#

is it allowed to create a public bot called find Bertie's girlfriend?

#

ask people to send submissions with age and name and genus and get a list of people looking for a bf

#

idea from @slate swan

slate swan
#

bro that wasnt me

rocky trench
slate swan
rocky trench
#

make it send into a channel in my dc

cold sonnet
#

maybe disnake has better exceptions

slate swan
#

ok

cold sonnet
#

never fucking mind

slate swan
#

thats base exception

#

for the wrapper

cold sonnet
#

k but I need one that contains the command that raised it

#

lemme look at what the decorator does

#

of a command

slate swan
#

a command would probably raise a custom one and not base

#

base is for all exceptions so they can subclass them

hushed galleon
cold sonnet
#

let me check

#

wait a damn minute though

#

we all ignored

#

ctx

#

and I just realised this after not knowing what command should be in your example

hushed galleon
#

oh yeah i didnt mention you'd get command from ctx

vale sierra
#

hello, how can i do to delete the message's of the bot (example = the bot @jaunty folio and this message is deleted)

slate swan
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
hushed galleon
#

do you want the message to be deleted with a certain delay after it was sent? if so there's the delete_after= kwarg in the .send() method

vale sierra
slate swan
cold sonnet
#

difference between command.callback.module and command.module

pliant gulch
#

The callback is your user defined function, the module would be your file you created

hushed galleon
#

yeah what they said

vale sierra
cold sonnet
#

nah I don't need that

#

I need the cog file

#

but command has a _callback too Danny has to stop

rocky trench
#

is it allowed to create a public bot called find Bertie's girlfriend?
ask people to send submissions with age and name and genus and get a list of people looking for a bf

slate swan
slate swan
pliant gulch
unkempt canyonBOT
#

inspect.getfile(object)```
Return the name of the (text or binary) file in which an object was defined. This will fail with a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") if the object is a built-in module, class, or function.
pliant gulch
#

Just pass your Cog to this

cold sonnet
#

a következő fájlban: cogs.cogdefault 👍🏿

#

for ctx.command.callback.module

rocky trench
#

is it allowed to create a public bot called find Bertie's girlfriend?
ask people to send submissions with age and name and genus and get a list of people looking for a bf

pliant gulch
#

Genus lmao

vale sierra
rocky trench
#

heh?

pliant gulch
# pliant gulch Genus lmao

Either way, perhaps it is fine. But if you take user data you must secure it properly, otherwise depending on country etc you'd be in violation of privacy laws

#

There are some dating bots that alredy exist

rocky trench
#

Please use a translator Patapouf

vale sierra
rocky trench
#

tu veux quoi?

hushed galleon
cold sonnet
#

🙂

vale sierra
rocky trench
#

await ctx.send('qfsqfqs', delete_after = time)

slate swan
vale sierra
hushed galleon
#

they said they wanted the bot's message deleted

rocky trench
#

I dont get anything of that

vale sierra
#

srry for my bad english but here is la france

slim ibex
#

🗿

cold sonnet
#

so bot feature challenge

pliant ocean
#

can anyone help with this traceback

surreal wadi
#

Where is the bot token on the developer portal? I knew where it was but it seems to have been changed and now I can't find it

cold sonnet
#

probably bot.msg if wanting to transfer the message between two commands

#

this is a global solution so it's not gonna be able to work with two messages

torn sail
surreal wadi
#

ah okay

cold sonnet
#

json

#

isn't a database

hoary cargo
cold sonnet
#

haha....

hoary cargo
#

imagine using sqlite or bad stuff like this damn

slate swan
#

does motor require dnspython?

#

does anyone know how to fix this

cold sonnet
#

y'all keep forgetting what this channel's for

cold sonnet
cold sonnet
torn sail
#

It’s new

full lily
#

Ah i see

lyric tusk
#

code:

@nextcord.slash_command(name = "help", description= "U can see the commands of the bot", guild_ids=[testserverid])
    async def help(self, interaction: nextcord.Interaction):
        em = nextcord.Embed(title = "**Help**", description="**Use ``e![Command]`` to use a command**", colour=0xa62019)
        em.set_thumbnail(url="https")   
        em.add_field(name = "**Commands**", value = "``Eth`` ``Matic`` ``Meme``", inline=False)
        em.set_footer(text=f'Requested by - {ctx.author}', icon_url=ctx.author.avatar.url)
        await interaction.response.send_message(embed = em)`

what can i replase ctx with in the slash commands in the ctx.author

slim ibex
#

interaction.author

full lily
#

interaction.message.author?

gleaming sonnet
#

.

jade tartan
#

I have alot of errors for my log.py file can someone help me

gleaming sonnet
#

..

#

...

full lily
gleaming sonnet
lyric tusk
# slim ibex `interaction.author`

error: discord bot\cogs\help.py", line 26, in help
em.set_footer(text=f'Requested by - {interaction.author}', icon_url=interaction.author.avatar.url)
AttributeError: 'Interaction' object has no attribute 'author'

hushed galleon
#

interaction.user is how dpy originally implemented it, and it seems nextcord has kept that attribute

jade tartan
full lily
cold sonnet
full lily
#

I wonder if if not self.bot.is_ready(): is False, so it's never defined

#

do the other events work?

jade tartan
#

async def on_member_update(self, before, after): define it there?

full lily
#

I mean i guess you could but that's not practical

jade tartan
jade tartan
full lily
#

a bad approach

jade tartan
#

ok so what should i do?

hushed galleon
#

i would suggest a property that gets the channel for you

#

e.g. py @property def discord_bots(self): return self.bot.get_channel(343944376055103488)

full lily
#

oh that'd be handy

jade tartan
#

Am confused is this error coming from line 83 from on_member_update

#
    await self.log_channel.send(embed=embed)
AttributeError: 'Log' object has no attribute 'log_channel'```
hushed galleon
#

if your cog gets reloaded after the bot already started, then on_ready won't fire until your bot reconnects, so an on_ready listener isnt the best place to assign log_channel

jade tartan
#

So remove the on_ready listener?

hushed galleon
#

yea, and use a property for log_channel

jade tartan
#
    async def on_ready(self):
            self.log_channel = self.client.get_channel(886063553122021417)
            print("Working!")
        ``` Is this alright?
full lily
#

what did you change there?

jade tartan
#

Ohh you want to remove the whole on_ready listener?

hushed galleon
#

if you need an explanation on what a property is, its basically a method that's used as if it were an attribute ```py
class Employee:
def init(self, first, last):
self.first = first
self.last = last

@property
def full_name(self):
    return f'{self.first} {self.last}'

e = Employee('John', 'Doe')
e.full_name
'John Doe'``` in your case you could use a property to get the channel dynamically, that way you don't have to worry about making sure the bot's connected beforehand or having to copy-paste the get_channel in each event

jade tartan
slate swan
#

this code works ig but it gives me an error

hushed galleon
#

you should make sure those events only work in the guild(s) you want it to in case you add the bot to a server that doesnt have a #general channel

slate swan
hushed galleon
#

ideally you'd just compare the guild's ID instead of name

#

if you have developer mode enabled in Settings > Advanced, you can right click the server icon and Copy ID, then use that in your if-statement

#

e.g. py if member.guild.id == 267624335836053506: # member is in the python discord

slate swan
#

is it fine to do something like dis yml disnake asyncio tornado motor pymongo==3.12.3 dnspython