#discord-bots

1 messages · Page 434 of 1

ocean hawk
#

Hello. How to get the user id of someone who used a slash command on bot like this? message.reference is None on slash commands

slate swan
#

You mean to get it from the other bot? I don't think you can if reference is none rooThink

ocean hawk
#

i have a bot that blacklists bot commands from specific roles/users on specific channels. it worked perfectly until the slash commands that for some reason has reference=None

#

is there anymore a way to externally know who used the bot command to which the bot (dynobot in this case) replied to?

vocal plover
#

you cant get that info, i believe

#

though discord has plans on their api docs repo to improve command permissions for server owners, so it shouldnt be an issue that much longer

dapper cobalt
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.update "discord.Permissions.update").
vestal owl
dapper cobalt
#

create_channel can take permissions kwarg. You can for example do:

await ctx.guild.create_channel(permissions=discord.Permissions(send_messages=False, read_messages=True))
vestal owl
#

I had to do .attach_files()

dapper cobalt
ocean hawk
vocal plover
#

oh yeah that should be accesible i agree

#

but im fairly sure its an api limitation yeah

floral crypt
#

Need some help

#

how can i make the name of a channel being created be different each time?

#

example

#

support#0001 and support#0002

minor totem
#

If you have a SQL database use a Sequence

acoustic jetty
#

! help

high flame
#

i need ideas while learning FastAPI

vale narwhal
#

Is there any search module on python? Like i want to automatically search the username of the user that leaves the server (if there is any message send by specific user and the user has left the server then ban the user)

#

I would appreciate if there's anyone give me an example code ig?

dapper cobalt
vale narwhal
rare saddle
#

Why isn't the channel deleted when I press the second button?

dapper cobalt
#

If you mean search for messages sent by a specific user then you can use the discord.TextChannel.history. It can take a check kwarg.

vale narwhal
#

Sesrch the matching message

dapper cobalt
#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/stable/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

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

Examples

Usage...
vale narwhal
#

Ah

#

I'm new to this and trying to make automatic Freeloader detect commands so..
I'll try my best ig

rare saddle
vale narwhal
#

Also

#

How to check if user has left the server

dapper cobalt
dapper cobalt
unkempt canyonBOT
#

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

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

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

Alr ty

dapper cobalt
#

No problem.

rare saddle
rare saddle
dapper cobalt
#

Send the code instead of a screenshot.

#

!paste if the code is too big.

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.

maiden fable
#

Yo @visual island, the package I was talking about has been released on pypi. It's still WiP as application commands are been coded. They should be ready in a few days!)

#

!pypi disnake

unkempt canyonBOT
dapper cobalt
dapper cobalt
dapper cobalt
maiden fable
#

WiP --> Work in Progress

rare saddle
dapper cobalt
#

Ah, gotcha.

dapper cobalt
rare saddle
dapper cobalt
rare saddle
dapper cobalt
rare saddle
quartz epoch
#

Hello can Someone help me by a Python discord bot the bot should do if a person comes in a channel that the bot a sound plays pls help and dm me

dapper cobalt
quartz epoch
#

Pls help

kindred epoch
#

Is there a way I can check if a commands cooldown is finished?

glacial mesa
#

please help mee

rare saddle
glacial mesa
#

how can a bot play music

dapper cobalt
glacial mesa
maiden fable
#

Lemme get it

kindred epoch
#

Ahh

#

Ye i get it

maiden fable
#

!d discord.ext.commands.Command.is_on_cooldown

rare saddle
unkempt canyonBOT
kindred epoch
#

Returns a bool?

maiden fable
#

There

#

Yes

kindred epoch
#

Ok

dapper cobalt
rare saddle
dapper cobalt
#

Then most likely the event does not get triggered at all.

glacial mesa
#

can anyone help

#

@client.commands()
TypeError: 'set' object is not callable

#

pls

dapper cobalt
maiden fable
#

client.command()

#

Not commands()

#

commands is a set (sort of a list) of commands

dapper cobalt
#

Don't pass anything just @on_click() then print the custom_id.

pale turtle
#

Maybe with edpy

dapper cobalt
#
@on_click()
async def on_con_button(inter):
  print(inter.custom_id)
maiden fable
#

Yups

rare saddle
stark bobcat
#

hoi

brittle stag
#

What is the code to start a Discord Bot?

dapper cobalt
maiden fable
stark bobcat
stark bobcat
dapper cobalt
# rare saddle

inter.component.custom_id? I didn't do this in a while so I'm just looking at the docs.

maiden fable
stark bobcat
maiden fable
#

Lol

stark bobcat
#

lol kejujoget

ionic wadi
#
async def review(ctx, sterren=None, prompt=None):
    if sterren is None:
        return await ctx.send("!review <1/5> <feedback>")
    if prompt is None:
        return await ctx.send("!review <1/5> <feedback>")
    await ctx.channel.send("Hartelijk dank voor je feedback! Mocht er iets mis zijn kan je altijd contact op nemen!")
    prompt = ctx.message.content
    embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
    embed.add_field(name="Sterren:", value=sterren, inline=False)
    embed.add_field(name="Opmerking:", value=prompt, inline=False)
    embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
    channel = bot.get_channel(881094340087283722)
    await channel.send(embed=embed)```
rare saddle
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.

slate swan
#

someone knows how do i open a file package in replit?

dapper cobalt
ionic wadi
maiden fable
slate swan
#

idk what u mean

#

i wanna edit something from a package file

slate swan
#

they have one?

maiden fable
slate swan
rare saddle
slate swan
#

do u know?

maiden fable
#

Monkeypatching means editing the package files locally @slate swan

dapper cobalt
slate swan
maiden fable
slate swan
#

is it possible to have a subcommand and a normal command with the same name?

maiden fable
#

No

dapper cobalt
maiden fable
#

99%, nope

dapper cobalt
slate swan
#

!code

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.

rare saddle
clever pelican
#

ERROR:

FileNotFoundError: [WinError 3] The system cannot find the path specified: './cogs'```
> **CODE:**
```py
@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

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

Can someone pleasee tell me what's wrong with the code?

dapper cobalt
clever pelican
#

I have

dapper cobalt
#

Ah yes, one second. It should be os.listdir(r"cogs"), not os.listdir('./cogs').

clever pelican
#

Strange, still doesn't work

#

The same error

#
@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir(r"cogs"):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')```
glacial mesa
#

How to add ffmeg?

#

ffmpeg was not found

clever pelican
#
pip install ffmpeg ```
#

I guess

#

And

#
import ffmpeg```
#

@glacial mesa

glacial mesa
#

let me try :)

clever pelican
#

Sure

maiden fable
#

No lol

glacial mesa
#

then?

#

@maiden fable after that?

#

what shud i download?

fallow sage
#

Anyone found any good dpy forks?

maiden fable
#

It's still WiP, but will be out soon

brittle stag
#

@dapper cobalt Where can i learn development?

maiden fable
dapper cobalt
#

!resources if you want to learn Python specifically.

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

hoary gust
#

@maiden fable isin't there a single module to just make a simple webpage nothing more just one page

unkempt canyonBOT
#

A simple framework for building complex web applications.

vale wing
#

@clever pelican

hoary gust
#

Asking for frontend@maiden fable

clever pelican
#

Yes?

maiden fable
#

Ah idk. U gotta use HTML

hoary gust
#

Not a single module in python to make a webpage lol

vale wing
#

Uh why did it send

#

Don't mind me it was accident

#

Do you get any errors still?

clever pelican
#

Yes

glacial mesa
vale wing
#

Same error?

vale wing
rare saddle
#

How to avoid sending a message after each button click

floral crypt
#

how to mention

vale wing
#

Mention what?

clever pelican
vale wing
#

user.mention

floral crypt
#

people

#

or roles

#

and how do i define user

#

id?

vale wing
#

Usually those objects have .mention attribute

#

What exactly do you want to define

floral crypt
#

the user

vale wing
#

If it is possible, show your code please

vale wing
#

bot.get_user(id)

clever pelican
floral crypt
#
admin_normal = guild.get_role(749603000208719872)
        msg_id = 881867819912953886
        if payload.message_id == msg_id:
            if str(payload.emoji) == ':soyfonSoporte:':
                overwrites = {
                    guild.default_role: discord.PermissionOverwrite(view_channel=False),
                    payload.member: discord.PermissionOverwrite(view_channel=True),
                    admin_normal: discord.PermissionOverwrite(view_channel=True)
                }
                canal_soporte = await guild.create_text_channel(f'soporte-#{member.id}', overwrites=overwrites)
                embed_soporte = discord.Embed(title='Ticket de Soporte', description='Informanos de tu problema y pronto te responderemos.', color=0xb522ba)
                await canal_soporte.send('')
vale wing
#

@clever pelican could you show your files hierarchy?

clever pelican
#

Sure

slate swan
#

can anyone tell me how to send a message to user, if the user does not have a role for that command
i have done this

@bot.command(hidden=True)
@commands.has_role('ServerBotMaintainer')
try:
     code here
except discord.ext.commands.errors.MissingRole:
    def norole(msg):
        await msg.send('You do not have the role to run this command')

does not work

vale wing
#

And the code you showed was in main.py right?

clever pelican
#

Yes

floral crypt
#

How to notify mods when a channel has been created

vale wing
#

@floral crypt you can either get mention like this: @vale wing or f'{user.mention}' but you will need to define user like I showed before

floral crypt
#

Okay

vale wing
slate swan
vale wing
vale wing
#

Message does not have send attribute afaik

#

You can use ctx.send or channel.send

fervent dust
#

TypeError: on_member_join() missing 1 required positional argument: 'member'

slate swan
#

in short
what is want is when the user does not have that role
my idle console gives me the error discord.ext.commands.errors.MissingRole
i want to tell that user tell that he/she does not have that role

clever pelican
vale wing
#

This is not the code I meant

floral crypt
#

how to double line on fstring?

glacial mesa
#

i downloaded it but still this is coming

vale wing
#

I need the error from os.listdir('cogs')

vale wing
loud crane
#

I came across something wired in python today

can someone explain me why python dose this

#

!e

list1 = [[0]*5]*5
list1[3][3] = 1
print(list1)

unkempt canyonBOT
#

@loud crane :white_check_mark: Your eval job has completed with return code 0.

[[0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0]]
glacial mesa
loud crane
#

i was expecting 1 only at 3,3

clever pelican
vale wing
slate swan
#

nobody uses this channel for what it is....

vale wing
#

The module is not what you need

vale wing
vale wing
slate swan
vale wing
#

\n is new string, \ is ignoring new string in code

slate swan
#

if the check returns False, that code won't process there

high flame
#

they are the same

vale wing
#

If that's what you meant

high flame
#

try cogs/

glacial mesa
clever pelican
#

Same error

vale wing
#
f'some long \
string'```
Will result into ```some long string```
And
```py
f'some long \n string'```
will result into
```some long
string```
slate swan
#
@bot.command()
@commands.has_role('ServerBotMaintainer')
async def test(ctx):
    #code here

@test.error
async def test_error(ctx, error):
    if isinstance(error, discord.SomeError):
    #code here

@slate swan

#

this is how you handle a checkfailure

#

oo i'll try it ty

vale wing
#

I am not sure if that's right way but it works for me this way and I have been told this several times

#

@clever pelican wait, I will try to create similar code to yours and run it

clever pelican
#

Ok

glacial mesa
vale wing
#

@clever pelican are you running your code from main.py folder or from upper layer?

glacial mesa
vale wing
vale wing
#

Together with main bot file

slate swan
ionic wadi
#
async def review(ctx, sterren=None, prompt=None):
    if sterren is None:
        return await ctx.send("!review <1/5> <feedback>")
    if prompt is None:
        return await ctx.send("!review <1/5> <feedback>")
    await ctx.channel.send("Hartelijk dank voor je feedback! Mocht er iets mis zijn kan je altijd contact op nemen!")
    embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
    embed.add_field(name="Sterren:", value=sterren, inline=False)
    embed.add_field(name="Opmerking:", value=prompt, inline=False)
    embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
    channel = bot.get_channel(881094340087283722)
    await channel.send(embed=embed)```

I want the prompt(variable) to be all messages after the sterren variable but It currently outputs only one word.
(Sterren means stars and prompt Is my basic solution for feedback btw)
But currently Its like !review  5 Test testcc
and It only outputs Test
slate swan
#

you use a star for that

#

async def command(ctx, stuff, *, stuff2)

#

stuff2 will return everything that was passed in after stuff in a string

#

however, by using the star like this:
async def command(ctx, stuff, *stuff2)
stuff2 will return everything that was passed in after stuff in a list

vale wing
#

@clever pelican this is what I made, extensions loading alright worked

ionic wadi
shell wing
#
, case_insensitive=True
``` some says that it causes performance loss
slate swan
#

?

shell wing
#

like ? i dont get it

slate swan
#

show the code

ionic wadi
#

!codeblock

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.

stoic whale
#

how to make a button independent for each person, I have a problem that when someone presses the button no one else can do it until the other person finishes the cycle

ionic wadi
#
async def review(ctx, sterren=None, *, msg2=None):
    if sterren is None:
        return await ctx.send("!review <1/5> <feedback>")
    if msg2 is None:
        prompt="Geen feedback gegeven"
    if sterren == "1":  
        await ctx.channel.send("Hartelijk dank voor je feedback! We vinden het jammer dat je niet tevreden bent! Je mag altijd contact opnemen met support .")
        embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
        embed.add_field(name="Sterren:", value=":star:", inline=False)
        embed.add_field(name="Opmerking:", value=msg2, inline=False)
        embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
        channel = bot.get_channel(881094340087283722)
        await channel.send(embed=embed)
        return
    if sterren == "2":
        await ctx.channel.send("Hartelijk dank voor je opmerking! Toch is ier iets mis? Als er iets mis is met product of je niet tevreden bent kan je contact opnemen!")
        embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
        embed.add_field(name="Sterren:", value=":star: :star:", inline=False)
        embed.add_field(name="Opmerking:", value=msg2, inline=False)
        embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
        channel = bot.get_channel(881094340087283722)
        await channel.send(embed=embed)
        return
    if sterren == "3":
        await ctx.channel.send("Hartelijk dank voor je feedback! Het is nog niet perfect, maar alsnog bedankt!")
        embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
        embed.add_field(name="Sterren:", value=":star: :star: :star", inline=False)
        embed.add_field(name="Opmerking:", value=msg2, inline=False)
        embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
        channel = bot.get_channel(881094340087283722)
        await channel.send(embed=embed)
        return
    if sterren == "4":
        await ctx.channel.send("Hartelijk dank voor je feedback! We zijn blij dat je tevreden bent!")
        embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
        embed.add_field(name="Sterren:", value=":star: :star: :star: :star:", inline=False)
        embed.add_field(name="Opmerking:", value=msg2, inline=False)
        embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
        channel = bot.get_channel(881094340087283722)
        await channel.send(embed=embed)
        return
    if sterren == "4":
        await ctx.channel.send("Hartelijk dank voor je feedback! We zijn blij dat je helemaal tevreden bent!")
        embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
        embed.add_field(name="Sterren:", value=":star: :star: :star: :star :star:", inline=False)
        embed.add_field(name="Opmerking:", value=msg2, inline=False)
        embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
        channel = bot.get_channel(881094340087283722)
        await channel.send(embed=embed)```
vale wing
#

Performance loss maybe by running .lower() lmao, I am not sure how commands processing works

clever pelican
vale wing
#

Sure

slate swan
#

oh heck

ionic wadi
#

Its really crappy on discord lemme put It on the code copypaste site

#

!largecode

shell wing
slate swan
#

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

slate swan
#

im experimenting with a module that implements drop down menus into dpy, i am stuck on a problem that is i need to append to a list a changing amount of times but its not a string or an integer i need to append something else as shown belowpy msg = await ctx.send( "**Tickets!**", components=[ Select( placeholder="Select A Ticket!", options=[ SelectOption(label="a", value="a"), SelectOption(label="b", value="b"), ], custom_id="select1", ) ], ) as you can see, i need to append SelectOption(label="a", value="a"), anyway i can do it with a for loop?

ionic wadi
vale wing
slate swan
#

no output?

shell wing
ionic wadi
#

I get no error on my panel and no output in the server

slate swan
#

weird

#

it seems correct

ionic wadi
#

Yeah thats what I though thoo lol

stoic whale
#

how to make a button independent for each person?, I have a problem that when someone presses the button no one else can do it until the other person finishes the cycle

ionic wadi
#

too*

slate swan
slate swan
#

?

#

do you have an eh?

#

Python noob

ionic wadi
#

Dpy Isnt getting updated no more

slate swan
ionic wadi
slate swan
#

error handler

ionic wadi
#

Not really

#

I can get one

slate swan
#

don't

ionic wadi
#

Ok

slate swan
#

I ask these because I would've wanted you to disable it

#

I'm new to discord.py, so should I try to learn discord.js instead?

glacial mesa
#

can anyone tell what feature i can add to my bot (no music please idk how to do it)

ionic wadi
#

But normally it would, the last variable would like put the left overs In the last one\

glacial mesa
slate swan
#

djs has more features

#

and will probably continue getting updates

ionic wadi
#

Dpy doesnt support slash commands lol

slate swan
#

based on how discord gets updated

#

idk what's good about slash commands lol

ionic wadi
#

Discord wants all verified bots running on only slash commands

#

In like 2 months estimated

slate swan
#

but for example:
djs has voice receiving

night crater
slate swan
#

almost 2 months

night crater
slate swan
#

I've won, but at what cost

stoic whale
#

how to make a button independent for each person?, I have a problem that when someone presses the button no one else can do it until the other person finishes the cycle

rare edge
maiden fable
#

I am also making one haha

#

Ofc with a friend

#

That's fine. U can always contribute to the library I am making (:

#

I am also contributing. The community is friendly asf

#

Surprisingly, nope

#

It's a WiP

#

That's what I'mma use

dapper cobalt
ionic wadi
#

https://paste.pythondiscord.com/upagujosob.py

Does anyone know why this code gets no output nor error?

And how do i get msg2 to get all left overs In the command so like If the text is !review 5 Test and double test.

Sterren would get 5
and msg2 would get test and double test

dapper cobalt
maiden fable
#

Nope, I am maintaining that only

dapper cobalt
unkempt canyonBOT
maiden fable
#

Yups

#

Not in the basic code like commands and stuff

dapper cobalt
#

Nope. He said it will have the same syntax.

maiden fable
#

Only in advanced things like slash commands, context commands and Buttons

#

Haha!

dapper cobalt
#

EQ is going to save us, lmao.

maiden fable
#

Yes

#

Sure he will!

dapper cobalt
#

He already updated the logo and the name.

maiden fable
#

Yea

#

It also has a non toxic community, just like this Python Server has!

#

Hmm

slate swan
dapper cobalt
unkempt canyonBOT
dapper cobalt
#

It's gonna be so good.

rare edge
#

Is it just API or API and websocket?

maiden fable
slate swan
rare edge
#

That doesn’t answer the question

dapper cobalt
maiden fable
maiden fable
slate swan
maiden fable
#

It also has some advanced features like guild.humans to make yr life easier

dapper cobalt
unkempt canyonBOT
rare edge
maiden fable
unkempt canyonBOT
#

Hey @lone flume!

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

dapper cobalt
#

!past

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.

maiden fable
slate swan
maiden fable
rare edge
slate swan
maiden fable
maiden fable
rare edge
#

Errr ok

shell wing
#

does adding return after the command helps ?

maiden fable
#

No

slate swan
#

Does it have the things from d.py 2.0?

dapper cobalt
shell wing
#

alr

maiden fable
lavish frost
#

If I am assigning my client via a class, how do I set my prefix?
(Please ping me, I am not always at my computer.)

slate swan
#

Cool

maiden fable
#

If everything goes well, they should be live within this week (as EQUENOS is the only person working on them and I am working on extra/advanced features)

slate swan
#

Are you making it?

maiden fable
#

!d discord.ext.commands.Bot use this for command prefix

unkempt canyonBOT
#

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

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

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

Cool

lavish frost
#

Rip

slate swan
dapper cobalt
maiden fable
slate swan
#

Okay

rare edge
#

Or if your bot is nothing but call and response, switch over to HTTP Interactions

slate swan
#

i want to every time when sogs plays the bot will send "now playing + the song"
but with this script he send it every time , olsu when the song just added to the q and he dosent play right now.
someone knows what to do?

maiden fable
#

If u want, I can invite u to the support server so that u can have a close look at the development

slate swan
#

Yes please

maiden fable
#

At least the dev isn't waiting for dpy 2.0 like every other person so that they won't have to implement slash commands and stuff themselves haha

manic wing
maiden fable
#

Ah

#

My bad :c

#

Yea

#

U gotta get a different channel every time

#

for channel in guild.text_channels:
. . . .

hoary gust
#

!pypi anvil

unkempt canyonBOT
#

Generates new project structures from Jinja templates

maiden fable
#

Yes

#

Haha

lost fossil
#
@client.command()
async def update(ctx, *, title, msg):
    embed = discord.Embed(title=f"**{title}**", description=f"{msg}", color = 0xFFFF00)
    await ctx.send(embed=embed)
    await asyncio.sleep(0.1)
    await ctx.message.delete()

can someone help me with this?, i dont know how i can separate the title from the msg

rare saddle
#

For some reason, it does not respond to the command, if you make an error handler, if the person is not an administrator

lone flume
rare edge
#

My favorite about dpy situation is ignoring Danny talk about gateway problem and pretending lack of slash interactions is the issue

maiden fable
#

?

lost fossil
#
@client.command()
async def update(ctx, *, title, msg):
    embed = discord.Embed(title=f"**{title}**", description=f"{msg}", color = 0xFFFF00)
    await ctx.send(embed=embed)
    await asyncio.sleep(0.1)
    await ctx.message.delete()

can someone help me with this?, i dont know how i can separate the title from the msg

velvet yarrow
#
- hey I am making a discord bot and my bot has a mute command in which I am getting the unmute time with the help of now() + time delay how to find its unmute time like do I have to loop through the database every min
brisk helm
vagrant brook
stone palm
lost fossil
#
@client.command()
async def update(ctx, *, title, msg):
    embed = discord.Embed(title=f"**{title}**", description=f"{msg}", color = 0xFFFF00)
    await ctx.send(embed=embed)
    await asyncio.sleep(0.1)
    await ctx.message.delete()

can someone help me with this?, i dont know how i can separate the title from the msg

stone palm
#

!pypi disnake

unkempt canyonBOT
fickle turret
# lost fossil ```python @client.command() async def update(ctx, *, title, msg): embed = di...

you can't by this method afaik, since different arguments are identified using space in between, and using the * there will take everything and won't separate it by spaces, so there is basically no way for the function to differentiate between more than one argument after the star thingy, what I do is just pass one argument after that and using some string splitting get two arguments out of it inside the function, like using | in between the sentence.

lament mesa
#

What I do is add a client.wait_for and get the other required arguments

slate swan
#

if so, then you can do this

@client.command()
async def update(ctx, title, *, msg):
    embed = discord.Embed(description=str(msg), color = 0xFFFF00)
    await ctx.send(f"**{title}**", embed=embed)
    await asyncio.sleep(0.1)
    await ctx.message.delete()
spring flax
#

how will python know what to put for the msg arg then?

maiden fable
#

Yea

#

Everything will be consumed by title

spring flax
#

just do this

#
@client.command()
async def update(ctx, title : str, msg : str):
    embed = discord.Embed(title=title, description=msg, color = 0xFFFF00)
    await ctx.send(f"**{title}**", embed=embed)

Usage (saying that the command prefix is ?:

?update "put your title here" "put your description here"```
#

this is to have more than one word for the title and description both

slate swan
glossy edge
#

Haven't been completely on board but ppl say that discord is going to mandate slash commands, is that the case?

slate swan
#

yes

#

i think it's only going to be mandatory on bots in over 75 guilds

shell wing
#

right now i have slow.txt in no folder i was thinking to adding it in a folder.. what will be the changes in opening it ??

glossy edge
#

Oh damn, do you happen to have the detailed article? would be interested to see their TOS

slate swan
glossy edge
#

ty

rare edge
vocal plover
#

No it doesnt

glossy edge
#

Where do you guys get the info from? I haven't been able to keep up

rare edge
vocal plover
#

Since a lot of bots will still need the gateway it makes no sense to remove interactions from it

waxen tangle
#

anyone able to tell me why cmds wont work? i have the await client.process_commands(message) line ```py
@client.event
async def on_message(message):
if message.author.bot:
return

if 'modded' in message.content.lower():
await message.channel.send('This is blah blah blah')
return

await client.process_commands(message)```

rare edge
echo lagoon
#

heyo, needed help making threads that work with discord py. . .
something like running ffmpeg while handling real time output (waiting to capture errors or success + file paths) and my bots completely frozen lol
(well, like ffmpeg, running esrgan upscaler -- takes a while to run for some images)

vocal plover
#

because it works crap for a lot of people

rare edge
vocal plover
#

Not everyone has even close to the knowledge required to set stuff up well over HTTP

rare edge
vocal plover
#

I'm not gonna argue with you if you make this sort of stupid point

#

"Its not their problem" is never a good argument

echo lagoon
waxen tangle
#

hmm

rare edge
vocal plover
#

not if you already have a gateway connection open

rare edge
#

because even if your bot doesn't have on_message intent, WebSocket is more expensive then just HTTP calls

#

since you have to bi directional open connection that must be pinged and tracked

echo lagoon
#

wait, whats going to happen to word filters then?

rare edge
echo lagoon
#

;-; welp,

rare edge
#

Obviously, if your bot is small, you can keep doing it over just normal messages since you can have message intent but I expect that to become more restrictive in the future regardless of bot size

willow vine
#

Hey, I'm kinda new, can someone teach me how to use cogs

rare edge
#

So if your bot is simple call and response, I would switch to slash commands and while doing it, I'd consider looking to do it over HTTP instead of WebSocket because I could see a world where Slash Commands are only available over HTTP

echo lagoon
slate swan
#

wat

#

you do this in the setup function of every cog

willow vine
slate swan
#

and cogs are usually in different files

#

so this doesn't add up

willow vine
#

and load it

echo lagoon
slate swan
#

why

#

that literally ruins the point

willow vine
#

suppose i want to make logger(member events like join, leave, edit) message events like(edit and delete)

slate swan
cloud dawn
willow vine
#

so that can be in one py file and import it to main file, i heard cogs is the way to do it, can someone explain how to do ti

slate swan
#

I suggest reading the docs first

#

then asking what you don't understand

echo lagoon
# slate swan why

welp, i dunno, guess i wanted to use cogs back then without understanding them, so i just added it

slate swan
#

there were also several stackoverflow questions about that

cloud dawn
#

If you just use the docs and read it, at some point you don't even need the docs anymore since you already know what you will need py_guido

slate swan
#

practice makes perfect... I guess

echo lagoon
slate swan
#

2.0 docs?

#

never heard of em

#

probably

cloud dawn
# willow vine oh okay

You can still ask questions if you don't know what i mean, since i'm pretty sure you still don't get it.

cloud dawn
slate swan
#

literally everyone has the same code there

#

with that for loop

#

I don't, cuz I'm stupid and I don't wanna complicate it too far

cloud dawn
#

This is my cog loading part ```py
for extension in c.BOT_EXTENSIONS:
try:
print(extension)
bot.load_extension(extension)
except Exception as e:
print(e)

slate swan
#

uh

willow vine
#

https://youtu.be/vQw8cFfZPx0
i dont understand why this person defined 2 commands for loading and unloading when he made the for loop

In this video, we learn about cogs and how to implement them in a discord bot.

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

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

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

▶ Play video
slate swan
#

they check over all files in a folder

cloud dawn
slate swan
#

if file.endswith(".py"):
bot.load_extension(file)

#

something like this

fleet oracle
#

Hello, can someone help me on the subject of cogs? everything works, but I wanted to know how I can add subdirectories and read all the files in those folders

cloud dawn
#

You can do this with basic bots but if you are going to include more advanced options like __init__ & __main__ it also tries to load those extensions.

waxen tangle
#

anyone know what my problem is? i also have import random and from random import choice ```py
@client.event
async def on_message(message):
if message.author.bot:
return

if 'modded' in message.content.lower():
random = ["vkjsjbv", "eeee", "lololol"]
await message.channel.send(f"{random.choice(random)}")

await client.process_commands(message)this is my errorIgnoring exception in on_message
Traceback (most recent call last):
File "C:\Users\jamie\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\jamie\OneDrive\Documents\BreadProject\main.py", line 64, in on_message
await message.channel.send(f"{random.choice(random)}")
AttributeError: 'list' object has no attribute 'choice'```

dim oriole
#

is it possible to set the about me page of a bot?

slate swan
#

random.choice...

cloud dawn
slate swan
#

wait bru

#

you can't name a variable random

cloud dawn
dim oriole
#

thx

gritty flame
#

@waxen tangle name variable something else

slate swan
#

don't name variables the same as keywords

waxen tangle
#

ooooh

waxen tangle
gritty flame
#

py_guido <-- just relized he is python ceo/owner

slate swan
#

and

#

you don't need an f string there

lavish venture
cloud dawn
waxen tangle
#

Got it thanks! what way can i do it tho so it responds randomly and not everytime, i have thrown some empty lists in and it works but i do get erros in terminal

slate swan
#

I'd choose a random number between 1-10

#

for example, if the random number is 8, it sends something

#

then it's 1/10 chance it sends something

lavish venture
minor kestrel
#

How can I send ephemeral messages with my discord bot?

slate swan
#

spoonfeed

cloud dawn
#

I don't even know what "ephemeral" means lol

minor kestrel
waxen tangle
# slate swan then it's 1/10 chance it sends something

somt like this ```py
@client.event
async def on_message(message):
if message.author.bot:
return

llll = random.randint(1,10)
if 'modded' in message.content.lower():
llll = random.randint(1,10)
if llll == 8:
await message.channel.send('This is the 2019 modded war modpack')
else:
pass

minor kestrel
#

those message that use the bots to respond you slash commands

slate swan
#

I translated it to hungarian

cloud dawn
slate swan
#

it was like:
the lifetime of a certain bug

#

little do I know, that bug lives for 2 weeks

cloud dawn
#

My language translated it to "quick"

slate swan
#

but yeah

cloud dawn
oblique herald
#

guys where is the link for dpy is going away

#

they shud rly pin this

#

pls

slate swan
#

should I pin it for u?

oblique herald
slate swan
cloud dawn
#

I'll ask Scragly to pin it later when he is on.

slate swan
#

I think praw's client id and secret are not meant to be leaked*

#

I don't think this is our stuff

cloud dawn
#

No idea but that i do know is that you need to reset your client secret.

static patio
#

oh wait nvm

slate swan
#

nah, I'm hecking him rn

#

jk

#

I don't even know how that works

cloud dawn
#

Worst you can do is get him banned from the api

slate swan
#

Also the issue is praw.reddit is a module not an object, but idk what is correct

slate swan
#

enough of a crime

static patio
#

😂

cloud dawn
#

Well it's not a crime but it's a bit rude.

static patio
#

what does module not callable mean anyways?

cloud dawn
slate swan
#

!e

import random
random() 
static patio
#

well how do i fix it?

hasty iron
#

dont call it

static patio
#

im preety new to python sorry wtf

cloud dawn
slate swan
#

the id of the author is equal to a role object?

#

in your code

cloud dawn
#

Not yet but in python 3.10 there is going to be a match/case system that cleans this up. Also you can't take control of the owners role but people lower than that cannot "add upper role than you have" anyways so that's a bit extra extra.

bitter depot
bitter depot
#

I'm sure he has his reasons

cloud dawn
#

For now yes, but like i've said the "You can't control the owner role" and people lower than that cannot even use it. Only owners can so that's imo a bit much.

#

When 3.10 is released you can implement it. You can also experiment with it now over at #878694948810137621 the bot has python 3.10 beta.

static patio
hasty iron
static patio
#

so i should import praw.reddit?

hasty iron
#

what

#

its praw.Reddit, not praw.reddit

cloud dawn
#

Noooo, look into it you will get it :)
Syntax is indeed a bit off but when the IDE assigns the colors it will be doable.
Also the fact that match/case will be way faster than elif's.

static patio
vocal plover
static patio
#

im dumb

static patio
cloud dawn
vocal plover
hoary gust
#

Guys I want to store one embed and whenever a command is executed then my bot will send that embed but what should I use to store that 1 embed

hoary gust
#

@tawdry perch no I want to save a embed I made

#

Only me

slate swan
#

does anybody know how to open a file with a varible because when i a sign it to a variable it opens by itself so i want it to only open with a variable for my discord bot

cloud dawn
hoary gust
#

I mean I want to store that embed until I change it

#

And the time could be 1 min or 1 day or even a month maybe

cloud dawn
slate swan
hoary gust
#

@cloud dawn is it possible to change that embed using command

static patio
#

now how to fix this

cloud dawn
static patio
#

oh ok

#

type error nvm

cloud dawn
hoary gust
#

@cloud dawn Yes

#

U r correct

slate swan
#

it just opens by itself

cloud dawn
maiden fable
#

or

hoary gust
#

So what should I use to store that embed

maiden fable
#

!pypi aiofiles

unkempt canyonBOT
slate swan
cloud dawn
cloud dawn
cloud dawn
hoary gust
hasty iron
#

and doing for word in f works too

cloud dawn
hoary gust
cloud dawn
#

Depends on where this code is

dim wing
#

How can i link my bot to my website?

cloud dawn
dim wing
#

Nope to send informations

cloud dawn
slate swan
hoary gust
#

@cloud dawn can u gimme a example what u tried to say

dim wing
cloud dawn
#

I can't really see a problem either. How are you using this?

cloud dawn
dim wing
#

I was thinking about making an api

cloud dawn
cloud dawn
hoary gust
#

@cloud dawn any docs for this or any stackoverflow link?

dim wing
hoary gust
#

Anything will be fine

lament mesa
cloud dawn
#

@hoary gust @dim wing , Not really since this combines multiple skills. For both it is combining different sources with each other i'm speaking from experience and how i would tackle this problem.

You can search on the web and maby someone has done this already but 50/50 of the times the thing you have in your own head is unique.

lament mesa
cloud dawn
#

For Cursed Wolf i would recommend looking into OOP programming since that allows you to use variables and save them over multiple functions (commands).

And for Baptiste i'd do something that you are most comfortable doing with. Going with an API is more work than just checking the file and using a DB but using an API or IPC routes is significantly faster.

hoary gust
#

Are jsons fast?

lament mesa
dim wing
lament mesa
cloud dawn
lament mesa
hoary gust
#

@cloud dawn OOPS ARE FAST?

lament mesa
#

?

#

OOP is a concept

hoary gust
#

I don't know about OOP

#

New to OOP

cloud dawn
hoary gust
#

Ok

#

Lemme search on google

dim wing
cloud dawn
# hoary gust Ok

In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.

Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...

▶ Play video
hoary gust
#

@dim wing I would like to know about that too cause I am also learnin about api route etc

dim wing
#

Yeah i think it's very interesting and fun (i hope so) concepts

lament mesa
dim wing
cloud dawn
lament mesa
#

I dont want to confuse you but classes and functions are also objects

cloud dawn
hoary gust
#

Amd what do u mean by db, I mean what u want to say

lament mesa
#

Database

hoary gust
#

And*

cloud dawn
#

Since you need to code in 3 different files and connect them by also using 2 programs at the same time and linking them.

hoary gust
lament mesa
hoary gust
#

Ok I got it

cloud dawn
#

databases are meant to store text, ints and objects.

#

So no pictures or files etc.

hoary gust
#

@cloud dawn I ultimately wanted to say what is the use of it in IPC and ROUTING else I know what db and it's work is

lament mesa
#

You shouldnt use a db if you are going to store pictures

dim wing
#

So to pass files, IPC routes are the best?

hoary gust
#

@lament mesa I don't think it's even possible

lament mesa
#

It is

#

but it is not ideal

cloud dawn
hoary gust
#

What but how using base64

cloud dawn
lament mesa
cloud dawn
#

2mb in a DB is alot that is like 50k user data.

lament mesa
#

Store a file as a file.

cloud dawn
#

Just for fun load a 2mb json file

#

I'll see you back in 45 min

hoary gust
#

Bye bud

cloud dawn
#

It was more that that takes 45 min lol

#

Unfortunately i do have to go :/

#

There will prob be someone here to help!

#

Thanks, if not i will be same time here tomorrow again.

spring flax
#

@tawdry perch whats the error

#

manage_channels

dim wing
#

it's okay

slate swan
#

create_instant_invite

willow vine
#

@cloud dawn so basically in this code i don't get why hels made the load and unload commands when he's got a for loop to load the files

spring flax
#

this is a command? or event

#

why do you need to get the channels?

#
for channel in ctx.guild.channels:
  await channel.set_permissions..
#

keep in mind ratelimits too btw

#

full traceback?

#

is this 2.0

#

dpy v2

#

then i guess use_slash_commands=False is not valid because it does not have that yet

pliant gulch
#

No lastest has use_slash_commands as well

#

!d discord.Permissions.use_slash_commands

unkempt canyonBOT
willow vine
#

why do we use @commands.Cog.listener() instead of @bot.event in cogs

ruby tinsel
#

Hi I need help

@commands.has_any_role("(👑) Owner","(⌛️) Administrator","(🎧) Manager","(🔧) Developer")
async def balance(ctx, user: discord.Member=None):
  if not user:
    user = ctx.author
  await open_account(user)

  users = await get_bank_data()
  user = user

  


  wallet_amount = users[str(user.id)]["wallet"]
  bank_amount = users[str(user.id)]["bank"]
  total_amount = bank_amount + wallet_amount
  
  

  embed = discord.Embed(title= f"{user}'s Balance", color = discord.Colour.blurple())
  embed.add_field(name = "Wallet :money_with_wings:", value=f"{wallet_amount:,}", inline= False)
  embed.add_field(name = "Bank :bank:", value=f"{bank_amount:,}", inline= False)
  embed.add_field(name = "Total Balance :moneybag:", value=f"{total_amount:,}", inline= False)

  await ctx.send(embed=embed)

def moneypurge(money):
    money = str(money)
    nmoney = ""
    if money.endswith("000000000000000"):
        nmoney = money[:-15] + "Q"
    elif money.endswith("000000000000"):
        nmoney = money[:-12] + "T"
    elif money.endswith("000000000"):
        nmoney = money[:-9] + "B"
    elif money.endswith("000000"):
        nmoney = money[:-6] + "M"
    elif money.endswith("000"):
        nmoney = money[:-3] + "K"
    else:
        nmoney = money```

/balance is my command but I made this deg moneypurge how can I add this behind my numbers in /balance?
willow vine
#

why though

#

whats the difference

pliant gulch
#

Take a look at the documentation for set_permissions it has examples of what to pass

#

!d discord.abc.GuildChannel.set_permissions

unkempt canyonBOT
#

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

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

You must have the `manage_roles` permission to use this...
pliant gulch
#

Yes

ionic wadi
#

Ignoring exception in command mute:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/container/bot.py", line 109, in mute
await member.add_roles(mutedRole)
File "/home/container/.local/lib/python3.9/site-packages/discord/member.py", line 777, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'

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

Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'

async def unmute(ctx, member: discord.Member):
    mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
    await member.remove_roles(mutedRole)
    await member.send(f" U bent geunmute van: {ctx.guild.name}")
    embed = discord.Embed(title="Unmute :speaker: ", description=f" Ik heb {member.mention} geunmute",colour=discord.Colour.light_gray())
    await ctx.send(embed=embed)
    
@bot.command()
async def mute(ctx, member: discord.Member):
    mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
    await member.add_roles(mutedRole)
    await member.send(f" U bent gemute in: {ctx.guild.name}")
    embed = discord.Embed(title="Mute :muite: ", description=f" Ik heb {member.mention} gemute",colour=discord.Colour.light_gray())
    await ctx.send(embed=embed)```
vocal shoal
#

hi guys... i want to make an auto moderation bot, the "banned" words are stored in a json file (the bot is for only one server), now here i am a bit confused. is this the right way to check if any message has one of these words?

@commands.Cog.listener()
    async def on_message(self, message):
        data = utils.jjson.read_json("words")

        if message.author.bot:
            return

        if any(word in message.content for word in data['blacklistedWords']) and not message.content.startswith(self.client.defaultPrefix):
            if message.author.bot or message.author.id == self.client.owner_id:
                return
            await message.delete()
            await message.channel.send(f"{message.author.mention} you can't send this here")

        await self.client.process_commands(message)
jagged hamlet
#

why is PyCharm doing this?

gritty flame
vocal shoal
# vocal shoal hi guys... i want to make an auto moderation bot, the "banned" words are stored ...

also this is how i add a word to the json file

    @commands.command(description="Add a word to blacklist", aliases=['aw'], usage='<word>')
    @commands.has_guild_permissions(administrator=True)
    async def addWord(self, ctx, *, word:str = None):
        data = utils.jjson.read_json("words")

        if word is None:
            return await ctx.send("Please specify a word to blacklist.")

        if word in data['blacklistedWords']:
            return await ctx.send(f"`{word}` is already blacklisted.")
            
        utils.jjson.write_json(data, "words")
        await ctx.send(f"Added {word} to blacklist")
full lily
#

When the bot starts and when you add a new word

#

Rather than every time there's a message

vocal shoal
#

thanks

pine lava
#

is there a way to save all of the messages in a channel (as in like modmail) with a .txt file?

sacred cargo
#

i need help

#

i want a song to download to a folder, but it doesnt even when i try to make it download to the folder

#
queue_path_2 = "/home/pi/asbeta/Queue
        subprocess.call(f"youtube-dl --extract-audio --audio-format mp3 -o {queue_path_2}" + (str("song")) + ".mp3 " + f'"ytsearch:{url}"', shell=True)
full lily
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

don't curse antiswear man

#

How can I fix this error?

TypeError: argument of type 'NoneType' is not iterable```
austere herald
#

🚎

ionic wadi
#

File "/home/container/bot.py", line 101, in mute
await bot.add_roles(member, role)
AttributeError: 'Bot' object has no attribute 'add_roles'

How do I then add a role?

maiden fable
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
slate swan
#

I set the topic channel to Bypassed though.

#

Oh okay

#

It is possible it's checking any other channel too, so having some check is good

#

Okay

#

Uh.. It's for User319183

#
@bot.command()
async def hello(ctx):
    """Says world"""
    author = ctx.message.author
    print(str(author) + " used ?hello")                                                           
await ctx.send("world")
    if not author in usedhello:
        usedhello[str(author)] = 1                                                            else:
        usedhello[str(author)] += 1
    await ctx.send(str(author)+" used ?hello "+str(usedhello[str(author)])+" times!") 

Last line always prints "(username) used ?hello 1 Times how to fix

stark flicker
#

How do I get 22.58

kindred epoch
stark flicker
#

no

kindred epoch
#

make the bot type it

stark flicker
#

omg

stark flicker
#

how do I get 22.58

#

using split and indextaion

kindred epoch
#

idk

#

"how do i get 22.58"

#

how would i know how to get it without code?

fervent dust
#

AttributeError: 'NoneType' object has no attribute 'mention'

#
embed.description = f"**Sunucu Ad**: {guild.name}\n**Sunucu ID**: {guild.id}\n**Sunucu Kurucusu**: {guild.owner.mention} ({guild.owner_id})\n**Üye Sayısı**: {guild.member_count}"```
prisma wedge
#
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg):
    logsChannel = client.get_channel(809483574398812160)
    user = member.mention
    embed = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    await logsChannel.send(embed=embed2)
    await member.send(f'You have been warned in {server_name} for **{arg}**!')
    message = await ctx.send(embed=embed)
    await message.add_reaction('☑️')```
#

says arg is a required argument thats missing

kindred epoch
prisma wedge
#

what do i do

kindred epoch
prisma wedge
#

Bruh

#

this is a help server

kindred epoch
prisma wedge
#

IK PYTHON

stark flicker
prisma wedge
stark flicker
#

send problem

prisma wedge
#

i did

kindred epoch
prisma wedge
#

above

#

bro sasuke

hasty iron
#

make the arg argument optional

fervent dust
#

maybe

hasty iron
#

Guild.owner can be None

#

use owner_id instead

stark flicker
fervent dust
#

owner.mention} and ({.owner_id

#

like this

stark flicker
#

Where you define warn then add the if statement under async def

prisma wedge
#

nope didnt work

#

i added arg = None underneath

stark flicker
#

:**

floral crypt
#

Can i make a command inside on_raw_add_reaction?

covert palm
#

Guys

#

I need help

floral crypt
#

ok

#

go

covert palm
#

How do I make a command that will do something by deafult when no arg is passed

#

and will do something else when 1 arg is passed

lost lagoon
#

Whats the difference between Client.Command and Client.Event

prisma wedge
#

it doesnt work @stark flicker

slate swan
prisma wedge
#
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg):
    logsChannel = client.get_channel(809483574398812160)
    user = member.mention
    embed = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    await logsChannel.send(embed=embed2)
    await member.send(f'You have been warned in {server_name} for **{arg}**!')
    message = await ctx.send(embed=embed)
    await message.add_reaction('☑️')```
#

says arg is a missing requirement

slate swan
#

U didn't change ur code

prisma wedge
#

i did

slate swan
#

In ur arg param put arg = None

prisma wedge
#
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg):
    if arg == None:
       arg = None
    logsChannel = client.get_channel
    (809483574398812160)
    user = member.mention
    embed = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    await logsChannel.send(embed=embed2)
    await member.send(f'You have been warned in {server_name} for **{arg}**!')
    message = await ctx.send(embed=embed)
    await message.add_reaction('☑️')```
slate swan
#

U only added the if statement

#

U need to put the default value to None

stark python
#

Hey sorry to bother the topic you're in right now, but can someone help me? My code isnt working to the basics, client command isnt working and nobody knows why

slate swan
stark python
#

yes!

slate swan
#

Do u have the process_commands at the end of it?

stark python
#

no : s

slate swan
#

!d discord.ext.commands.Bot.process_commands

unkempt canyonBOT
#

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

This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.

By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.

This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
slate swan
#

Put that at the bottom of your on_message func

#

Restart and it should work

prisma wedge
#

it isnt working

slate swan
#

What's not working

#

Hello, i want to send a validation message with a reaction in DM
My function:

@bot.command()
async def dm(ctx):
    msg = await ctx.author.send("Bonjour et bienvenue dans notre entreprise!")
    await msg.add_reaction(":white_check_mark:")

    def check(reaction, user):
        reaction.message.id == msg.id

    reaction, user = await bot.wait_for("reaction_add", check=check)
    print("test")
    await ctx.author.send("Thanks")```
And it don't work
prisma wedge
#
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg = None):
    if arg == None:
       arg = None
    logsChannel = client.get_channel
    (809483574398812160)
    user = member.mention
    embed = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
    embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
    embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
    embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
    
    await logsChannel.send(embed=embed2)
    await member.send(f'You have been warned in {server_name} for **{arg}**!')
    message = await ctx.send(embed=embed)
    await message.add_reaction('☑️')```
slate swan
#

What's the issue now

prisma wedge
#
AttributeError: 'function' object has no attribute 'send'```
slate swan
#

I believe it's reaction.message_id @slate swan

prisma wedge
#

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: AttributeError: 'function' object has no attribute 'send'```
brave geyser
#

Hey. How can I cancel other methods that are on await

brave geyser
#

I want a command, that blocks every new message if the mode is enabled
can someone help out

prisma wedge
#

yes

#
  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: AttributeError: 'function' object has no attribute 'send'
172.18.0.1 - - [30/Aug/2021 20:26:03] "HEAD / HTTP/1.1" 200 -
Ignoring exception in command warn:
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 1036, in warn
    await logsChannel.send(embed=embed2)
AttributeError: 'function' object has no attribute 'send'```
#

sorry this is

stark python
#

I also have an error when putting the await process commands

#

Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\simao\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "d:\Documentos\code\main.py", line 18, in on_ready
await process_commands(message)
NameError: name 'process_commands' is not defined

slate swan
#

Or client instead of bot, depending on what you have

prisma wedge
#

Kraots can u solve my problem

slate swan
#

what is the problem ?

slate swan
brave geyser
#

I want a command like !stop
and if its enabled I want any other command that is written in the time the mode is enabled to be blocked

slate swan
stark python
prisma wedge
#
    await logsChannel.send(embed=embed2)
AttributeError: 'function' object has no attribute 'send'```
slate swan
slate swan
slate swan
slate swan
stark python
#

i might've confused on message with ready

prisma wedge
#

OH

stoic whale
#

is there a way to set cooldown to a button?

kindred epoch
slate swan
kindred epoch
slate swan
stark python
#

yes im sorry

#

still learning, on the youtube tutorials they just do this and won't really explain

slate swan
stark python
kindred epoch
#

dont follow yt tutorials

stark python
#

can you give me a tip on where to learn it?

slate swan
#

ha year, ok

stark python
#

might as well ask already

#

does it explain how to make the bot join the channels?

kindred epoch
#

no

slate swan
#

Np

kindred epoch
#

it tells you the basics of making a discord bot

stark python
#

ill check it out now, thanks!

slate swan
stark python
#

but yeah im coming back because

#

its already not replying to the hello world

slate swan
#

wouldn't it reply to !hello

stark python
#

yes, that

slate swan
#

or whatever your prefix is

stark python
#

ok

#

if i run it just with that line of code

#

it replies

#

but my code is probably already very twisted, ill start over

slate swan
#

you could just delete the name parameter

#

and name your function hello

#

keep it simple

stark python
#

so just client.command()

slate swan
#

yeah

#

next line can just be
async def hello(ctx):

stark python
#

worked!

#

so after def is what the command will be called

slate swan
#

yeah

#

@client.command() has an aliases kwarg

stark python
#

i see, ill keep following this tutorial to get the hang of it

slate swan
#

if you want your command to have multiple names

#

and I saw you put something in on_ready

#

well- don't do that

#

a print is enough

stark python
#

I have no clue what it does honestly, i tried following those yt vids and got way to overwhelmed

#

so when on_ready just print that its on

slate swan
#

on_ready triggers once the bot is ready for commands and stuff

#

but it happens multiple times

#

and randomly

#

so with loading cogs in on_ready, you will get an error like everyday that you already have loaded them

#

and I'm not sure you have cogs

stark python
slate swan
#

yeah, that's enough

stark python
#

this is the beginning of something great

#

i hope ahsdahadh

slate swan
#

but why are people leaving a space there

#

between print and the brackets

stark python
slate swan
#

that's not how you call a function

hasty iron
#

i think it works regardless

stark python
#

it works, just cleared it rn

slate swan
#

some IDEs throw error cuz of that space

hasty iron
#

!e ```py
print ("h")

unkempt canyonBOT
#

@hasty iron :white_check_mark: Your eval job has completed with return code 0.

h
stark python
#

how do you guys send code like that?

hasty iron
#

!code

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.