#discord-bots

1 messages · Page 740 of 1

oblique adder
#

Thank you

slate swan
unique tendon
#

How to make this loop

slate swan
#

Use tasks loop

unique tendon
#

@slate swan can u help

#

Idk how to use tasks

rustic kayak
#

got this while searching up on google

slate swan
rustic kayak
#

noice

fervent shard
#
@bot.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, member: discord.Member, *, reason=None):
    if member == ctx.author:
        em = discord.Embed(
            description=f"**you** cannot `mute` yourself", colour=discord.Colour.red()
        )
        await ctx.send(embed=em)
 
    else:
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="muted")
        x = get_role(883538063496708116)
        x1 = get_role(883705723572342855)
        x2 = get_role(910023978607857684)
        x3 = get_role(888220698680647710)
        x4 = get_role(888253795535056926)
        x5 = get_role(811491773188800552)
        x6 = get_role(811491879853621260)
        await member.remove_roles(x, x1, x2, x3, x4, x5, x6)

    em1 = discord.Embed(
                description=f"{member.mention} has been `muted` for **{reason}**",
                colour=discord.Colour.green(),
            )

    em2 = discord.Embed(
            description=f"**you** have been `muted` for **{reason}**", colour=0
        )
    await ctx.send(embed=em1)
    await member.send(embed=em2)
    list_of_muted_members.append(member)
    print(list_of_muted_members)```
its not sending the embed nor give the muted role when i use the command.
#

free hosting service with replit: uptime robot + a simple code to type in replit.

slate swan
#

thats not a bot hosting service

fervent shard
slate swan
#

the bot restarts at every 30minutes-1 hrs , rip cache

fervent shard
slate swan
#

arguable topic , but replit is bad for hosting anyways

#

its an ide , not a host

fervent shard
#

heroku < replit

slate swan
#

Both are equally bad.

fervent shard
slate swan
#

No, both are equally bad.

#

You shouldn't use any of these, as simple as that.

stable berry
#

Can anyone pls help me with buttons i still don't know how to add them

slate swan
stable berry
slate swan
#

What library do you use?

#

It's a basic question you should know the answer ^^

heavy folio
#

using commands.Greedy, if a member isnt found how do i get it to raise MemberNotFound
for some reason when i didnt specify a valid member it'll still work

slim ibex
#

you can use a try except block

#

Where in the except, you specifically look for the MemberNotFound

#

or you can use the raise keyword

dreamy sluice
#

Is there a way I can make the bot find the message_id of the message the author replied to?

For example, A replies to B's message with the bot's command in the message's content. Now, how do I find the message ID of B's message (which A replied to)?

slate swan
#

Returns an object of this type

#

!d discord.MessageReference

unkempt canyonBOT
#

class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)```
Represents a reference to a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.5.

Changed in version 1.6: This class can now be constructed by users.
dreamy sluice
slate swan
#

Use .reference on the message object.

dreamy sluice
#

So, it leads to the message which the author replied to?

#

@slate swan

slate swan
dreamy sluice
#

Ohh, so it just returns a message object.

slate swan
#

Then you have multiple attributes to use.

slate swan
#

discord.Message != discord.MessageReference

dreamy sluice
#

I see.

slate swan
#

Click on it and you will see yourself.

dreamy sluice
#

Mkay

#

Ok new issue, how do I convert a message id back to a message object.

#

@slate swan Can you help?

slate swan
#

!d discord.TextChannel.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
dreamy sluice
#

I see.

heavy folio
#

because of how the converter works i think

#

thats why even when member is not found it doesnt raise the error for me

vale wing
#

Could you show your code?

slim ibex
#

no CommandInvokeError?

dreamy sluice
#

Is this correct?

vale wing
#

Seems valid but msgId is not following naming conventions

heavy folio
#

!d discord.ext.commands.Greedy

unkempt canyonBOT
#

class discord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
dreamy sluice
slate swan
#

s n e k

heavy folio
#

"most input errors are silently discarded"

vale wing
#

@heavy folio could you show how you typehint your args in command?

heavy folio
#
    async def _command(self, ctx, member: commands.Greedy[discord.Member]):
        ...
vale wing
#

Um

heavy folio
#

wait

vale wing
#

And where is the argument you typehint lol? Typo?

heavy folio
#

i dont have my pc rn lol

#

yeah typo

slim ibex
#

why didn’t you type hint a member argument

#

oh there it is

heavy folio
#

i did i said its a typo

dreamy sluice
heavy folio
#

if i didnt a syntax error will be raised

#

wait not syntax error the uh

vale wing
#

I mean if there's anything following Greedy argument with default value, it might prevent it from raising error like

async def command(..., member: Greedy[Member], num: int = 0)```
heavy folio
#

nope i dont have snything after that

dreamy sluice
slate swan
#

You need to use it on a discord.TextChannel object.

vale wing
#

Is your argument typehinted with Greedy the last one?

dreamy sluice
heavy folio
#

wdym

slate swan
#

Which you eventually don't have, so you need to use channel = bot.get_channel(id) and then use on that variable the fetch_message method.

vale wing
slate swan
#

And as I said, click the link to know more about MessageReference since it's not a Message object and therefore doesn't have a id attribute.

heavy folio
#

nope

vale wing
#

I guess it's possible to avoid typehinting it with greedy, you could just use list of arguments

async def cmd(ctx, member: discord.Member, *roles: discord.Role)```
@heavy folio
vale wing
#

Greedy is needed when you want to like insert the list of arguments inside

#

If it goes for last just use list of arguments

slate swan
# dreamy sluice Mkay

You can try, message.reference.cached_message.id to directly get the ID of the message, but if the message is not cached, it won't work.

dreamy sluice
pseudo lake
#

in memory

dreamy sluice
#

Ok thanks

heavy folio
#

oh

pliant gulch
#

Why can't you just use MessageReference.message_id?

fervent shard
#

could someone indent/unindent this for me?

@bot.command(pass_context = True)
@commands.has_permissions(manage_messages=True)
async def unmute(ctx, member: discord.Member, reason=None):
      mutedRole = discord.utils.get(ctx.guild.roles, name="☁️ | muted")

      embed=discord.Embed(description=f"{member.mention} has been `unmuted` for **{reason}**", colour=discord.Colour.green())
      em1=discord.Embed(description=f"**{member.mention}**, you have been `unmuted` for **{reason}**", colour=0)
      await ctx.send(embed=embed)
      await member.remove_roles(mutedRole)
      await member.send(embed=em1)
    else:
      if member == ctx.author:
      em2=discord.Embed(description=f"**you** cannot `unmute` yourself", colour=discord.Colour.red())
      await ctx.send(embed=em2)```
vale wing
#

Why can't you do it by yourself?

slate swan
#

!indents Will help you

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

vale wing
#

Also why is there else coming out from nowhere

strong shale
vale wing
#

Because she's using old library ig

fervent shard
vale wing
#

It is only available in forks

fervent shard
#

thank you

vale wing
fervent shard
fervent shard
strong shale
#

hmm

sullen pewter
#

Error: name 'bot' is not defined

unkempt canyonBOT
#

Hey @sullen pewter!

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

#

Hey @sullen pewter!

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

sullen pewter
#

@bot.command(name='hack')
async def hacker_man(ctx, member: discord.Member):
ran_sleep = random.uniform(1.75, 2.25)
email, password = login_generator(member.display_name)
friends = random.randint(0, 1)
_dm = random_dm()
common_word = random_common_word()
member_disc = str(member.discriminator)
random_port = random.randint(1123, 8686)
random_subnet = random.choice(('192.168.0.', '192.168.1.', '192.168.2.'))
random_ip = random.randint(0, 254)

msg = await ctx.send(f'Hacking {member.display_name} now...')

await asyncio.sleep(ran_sleep)
await msg.edit('Finding discord login...(2fa bypassed)')
await asyncio.sleep(ran_sleep)
await msg.edit(f'Found login info...\n**Email**: {email}\n**Password**: {password}')
await asyncio.sleep(ran_sleep)
await msg.edit(f'Fetching DMs with closest friends (if there are any friends at all)...')
await asyncio.sleep(ran_sleep)
if friends == 0:
    await msg.edit(f'No DMs found.')
else:
unkempt canyonBOT
#

Hey @sullen pewter!

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

sullen pewter
#

await msg.edit(f'DMs found...\nLast DM: "{_dm}"')
await asyncio.sleep(ran_sleep)
await msg.edit('Finding most common word...')
await asyncio.sleep(ran_sleep)
await msg.edit(f'Most common word = "{common_word}"')
await asyncio.sleep(ran_sleep)
await msg.edit(f'Injecting trojan virus into member discriminator: #{member_disc}')
await asyncio.sleep(ran_sleep)
await msg.edit('Setting up Epic Store account...')
await asyncio.sleep(ran_sleep)
await msg.edit('Hacking Epic Store account...')
await asyncio.sleep(ran_sleep)
await msg.edit('Finding IP address')
await asyncio.sleep(ran_sleep)
await msg.edit(f'IP Address Found!\nIP address: {random_subnet}{random_ip}:{random_port}')
await asyncio.sleep(ran_sleep)
await msg.edit('Reporting account to Discord for breaking TOS...')
await asyncio.sleep(ran_sleep)
await msg.edit('Hacking medical records...')
await asyncio.sleep(ran_sleep)
await msg.edit('Selling member's data to the Governement...')
await asyncio.sleep(ran_sleep)
await msg.edit(f'Finished hacking {member.display_name}!')
await ctx.send('The totally real and dangerous hack is complete.')

#

yes

sullen pewter
#

no

#

whats cog

final iron
#

Can you send the entire file?

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

sullen pewter
#

k

final iron
#

Put it in there

sullen pewter
#

done

final iron
#

You called your bot constructor client

#

So either change that or change the command decorator

#

There is also a spelling mistake on your cleint.run("") line

slate swan
#

Also just an outside tip: you could put all those different messages inside a list and iterate through it to shorten your code.

final iron
#

It should be client.run("")

#

With your fingers

sullen pewter
#

the @bot.command?

final iron
#

Yes

#

bot is undefined

sullen pewter
#

what should I change it for?

final iron
#

@client.command

sullen pewter
#

ok

#

ty

oblique adder
#

can I send 2 embed in 1 message ? in webhook I can

final iron
oblique adder
#

so im here to ask

#

I send embed as an array

tender estuary
#

I never would have imagined in my entire life that I would ever use replit

#

Turns out I need to use it to host my bot.. heroku is just shit I couldn't keep using it

tender estuary
pseudo lake
#

altho all of them are just bad. not sure about epik host

quaint epoch
pale turtle
quick gust
maiden fable
#

Starting dpy 2.0 iirc

solar anchor
#

can someone help me install UI path?

maiden fable
solar anchor
#

yes

vale wing
#

Ui path?

#

What is that

solar anchor
maiden fable
#

Ah

#

It's discord.ui

vale wing
#

It's called a package or smth not path lol

maiden fable
#

!d discord.ui.button

unkempt canyonBOT
#

discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
solar anchor
#

okay but how can i install it?

vale wing
#

@solar anchor you want dpy 2.0?

solar anchor
#

what?

maiden fable
vale wing
solar anchor
#

i just use python

maiden fable
#

!d discord.version

unkempt canyonBOT
#

discord.__version__```
A string representation of the version. e.g. `'1.0.0rc1'`. This is based off of [**PEP 440**](https://www.python.org/dev/peps/pep-0440).
vale wing
#

@solar anchor you know how to install packages right?

solar anchor
#

ppl give me the thing to type yes

vale wing
#

It's pip install -U git+https://github.com/Rapptz/discord.py if you want dpy 2.0 that has support of buttons

solar anchor
#

i did that but it didnt work

vale wing
#

Tho you'd better use fork like disnake

vale wing
solar anchor
#

terminal and

vale wing
#

Cmd?

solar anchor
#

ye

vale wing
#

Ok that's alright, did you get any errors?

solar anchor
#

yes imma send

#

ill delete cuz my name lol

#

just tell me if ur done

vale wing
#

It's installed?

#

There are no errors

solar anchor
#

well ya thats what i thought but

#

still this

severe rampart
#

never heard of ui

vale wing
#

ui is subpackage

severe rampart
#

from discord.ext

vale wing
#

You can't import it

#

I mean it's not a package at all

solar anchor
#

thats why i type from

#

right?

vale wing
#

You should use

from discord.ui import ... something```
slate swan
#

isnt it discord.ui?

solar anchor
slate swan
#

It is

#

not documented , but its discord.ui

solar anchor
#

i see

slate swan
#

It's discord.ui

#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
solar anchor
slate swan
#

^^

solar anchor
#

like this?

vale wing
#

Yes

#

It is imported now

solar anchor
#

how do i do it with menus?

vale wing
#

Check the docs out

#

I think it's like

#

Selection?

solar anchor
#

ill read it

slate swan
#

я один русский?)..

solar anchor
#

thanks for help already tho

vale wing
#

!d discord.ui.Select

unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Select.values "discord.ui.Select.values").

New in version 2.0.
vale wing
slate swan
slate swan
#

Take a look at the examples here @solar anchor

#

@vale wing@slate swan, it's an English only server

#

!rule 4

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

vale wing
#

We will go to dms dw

slate swan
#

Don't worry, just saying ^^

#

okaynya

solar anchor
#

any knows how to fix this?

pseudo lake
#

whats menus.MenuPage?

solar anchor
#

no clue

#

i copied this part

pseudo lake
#

why are you inheriting it then lmao

vale wing
#

M bro

#

Look for definition of it

pseudo lake
vale wing
#

In the code

solar anchor
#

it should be a built in function

pseudo lake
#

it isnt

vale wing
#

It's not

solar anchor
#

then it should be a package

vale wing
#

@solar anchor if you are browsing source code from github on pc you can just click it and look for definition

solar anchor
#

i copied it a some days ago

solar anchor
#

no

vale wing
#

Check out that

pseudo lake
#

its not inheriting it

unkempt canyonBOT
#

examples/views/dropdown.py line 9

class Dropdown(discord.ui.Select):```
#

examples/views/dropdown.py line 32

class DropdownView(discord.ui.View):```
vale wing
#

Python bot has very nice functions

solar anchor
#

yeah

slate swan
#

discord.ext.menus does exist.

#

You just need to install it

python -m pip install -U git+https://github.com/Rapptz/discord-ext-menus
#

Then you can use

from discord.ext import menus
unique tendon
#

does anyone have a code i could use for an “embed” command where the bot repeats what i said but in an embed

vale wing
#

Have you tried to make something by yourself?

unique tendon
#

Or atleast help pls

#

Idk much about coding just need help making a simple bot for my server

vale wing
#

You should learn some, nobody here will make full code for you

unique tendon
#

ok ig

slate swan
#

!d discord.Embed , you'd be using this

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
vale wing
#

I can recommend you some tutorials if you would like to

unique tendon
#

I got it

#

Thanks

spring flax
#

when a custom check like

def something:
  def predicate(ctx):
   #code
return commands.check(predicate)

when the above fails, what's the error to handle?
is it commands.CheckFailure

slate swan
#

Yes

#

any solutions?

spring flax
# slate swan Yes

oh i thought it raised commands.MissingPermissions i see thank you

slate swan
#

Error says all

slate swan
gleaming torrent
#

So there’s one thing I don’t understand

slate swan
#

how to remove nextcord?

#

pip3 uninstall nextcord

gleaming torrent
#

What are shards? For discord bots. I don’t get it.

#

And what are they used for?

slate swan
#

ok

slate swan
slate swan
weary mirage
#

this might not be the best place to ask, but I'm making this bot thats using sqlite3. It's gonna be used to hold money, but just for some game I play. How can I make a thing to track its usage history?

crimson idol
weary mirage
#

yee its a discord bot

lime vector
#

Ask me questions

cloud dawn
weary mirage
#

yus

crimson idol
#

Is it a discord-based game or..

weary mirage
#

its Minecraft lol

#

they pay the player and so the shopkeeper opens their account

cloud dawn
weary mirage
#

wouldn't I need to create new rows for every transaction?

#

or could I join them into one row

cloud dawn
weary mirage
#

how would I join with the user id o.o;

cloud dawn
#

Maby some kind of dynamic function to log it to that table.

vale wing
#

Personally I would make a function that would operate with user's currency and log the transaction at the same time

cloud dawn
#

Best is to also make a transaction type to know what is what.

cloud dawn
vale wing
#

Not really

weary mirage
#

this sounds kind of complicated o.o

cloud dawn
weary mirage
#

I'm already somewhat familiar with sqlite3, but I don't know that much

vale wing
#

SQL code?

weary mirage
#

sqlite3

crimson idol
#

I'd say something like

# code

Or something similar to that for the function

cloud dawn
vale wing
#

1 query to update user data and 1 to log transaction? Too much effort? Maybe you mean something else?

cloud dawn
#

Eliminate repetitive code.

vale wing
#

I mean maybe it's possible to combinate them into one query

cloud dawn
crimson idol
pseudo lake
vale wing
#

Ofc I wouldn't

cloud dawn
vale wing
#

Bruh what I suggested was combinate 2 actions into function and you are doing all this...

weary mirage
#

me over here not understanding anything

vale wing
#

@weary mirage you should probably ask in #databases maybe they suggest better option involving sqlite's tools

weary mirage
#

oh aight

crimson idol
cloud dawn
#

I have my own wrapper for SQL based syntax anyways so i'd only really have to add one function to log everything.

vale wing
weary mirage
#

alright, thank you

polar ice
#

Hey, can someone help me fetch the guild_id from a custom function??

#

my function gets called on_ready

potent spear
#

I've not seen any code, no idea what you're trying to do

quaint epoch
#
(await ctx.guild.fetch_member(member_id)).mention``` would mention the member, right?
quaint epoch
#

my on_ready func looks like this, it says in every server it's in that it's logged in and it sends every member a verification code.

#

but i commented out bc im the nerdy annnoying kid in school that like pushups too much and pinging everyone isn't very good and everyone hates me for it

#

so yeah

hoary cargo
#

uh, this tells everything you need to know

quaint epoch
hoary cargo
#

wtf you have 200+ imports or what

quaint epoch
#

NAH

#

srry caps

#

since it's a mod bot i added a lot of perm overwrites

hoary cargo
quaint epoch
#

that's why i commented it out

#

hm

quaint epoch
#

i removed the commented out code

#

but there's still a command to manually send a code to a member

#

to check if they're a bot

#

spam bot

#

ig

#

wow i really don't know why i made this

#

this is just gathering dust

oblique adder
hoary cargo
quaint epoch
#

obvi not

final iron
#

How would I see how many members my bot is watching over in total?

quaint epoch
final iron
#

Wait I may of got it

hoary cargo
#

first of all you need the members intent

final iron
#

Yeah I got it

quaint epoch
# final iron Yup
members = 0
for server in bot.guilds:
  members += server.member_count
#

idk if that works

final iron
#

bot.users returns a list of member objects

#

Or something

hoary cargo
quaint epoch
#

you loop through the server and add all the members from the server to a variable

#

lemme try it myself

#

it worked

#

it worked perfectly

#

what do you mean?

maiden fable
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

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. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
maiden fable
slate swan
#

I don't think I've ever seen it being used in other libraries's docs

maiden fable
#

It just indicates that u shouldn't use these classes in your code and they are only meant for documentary purposes

cold sonnet
#

just every class

#

you shouldn't use main classes of dpy in code

maiden fable
#

Like every class which has a send method sunglasses the abc.Messageable class

maiden fable
hoary cargo
quaint epoch
#

no

hoary cargo
#

yes

cold sonnet
hoary cargo
#

lmao

cold sonnet
#

base classes

quaint epoch
#

the total amount of people IN ALL of the servers the bot is in

slate swan
maiden fable
slate swan
#

member_count doesnt

maiden fable
#

@slate swan

hoary cargo
maiden fable
maiden fable
#

!d discord.Guild.member_count

unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

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

It needs

slate swan
#

ow

maiden fable
#

Lol

slate swan
#

nvm then

maiden fable
#

Anyways I'mma just get some sleep since my arm is already sore since morning thanks to the vaccination sadcat AP_catCrying

quaint epoch
#

oh yeah this is going get ot

#

!ot

unkempt canyonBOT
autumn bone
#

Hello everyone,
Can someone help me ? I want all channel from a specific category, it's possible ?

tacit token
#

hello guys, anybody help me? My problem is so dumb. I try make buttons, but it not in 1 line

opal skiff
#

how can i send a pillow object?

tacit token
#

wait a minute

#

1 line in all button

final iron
#

Which library are you using?

tacit token
#

discord_components

#

so?

slim dagger
#

Traceback (most recent call last):
File "C:\Users\unitt\Downloads\4214141241421.py", line 1, in <module>
from discord.ext import commands
ModuleNotFoundError: No module named 'discord'
[Finished in 0.1s with exit code 1]

#

anyone know this traceback? never gotten it before

final iron
#

Also verify your interpreter is correct

plain shadow
#

idk for me it worked when it happened

slim dagger
slim dagger
tacit token
#

pip install discord

plain shadow
slim dagger
#

is there a new version of python?

plain shadow
#
git clone https://github.com/Rapptz/discord.py
cd discord.py
python3 -m pip install -U .[voice]
plain shadow
slim dagger
#

lmfao that explains it

#

im using 3.3 rn

plain shadow
#

that's not a problem

#

it shouldn't influence it

slim dagger
#

weird

#

im still gonna get the new one anyways

visual yarrow
#

@plain shadow The command here is called !docs

plain shadow
#

ohhh right sorry i forgot i'm not in the dpy server

#

thank you!

honest shoal
#

do context menu commands work for mobile users?

upbeat otter
#

this......isnt the right channel?

slim dagger
tacit token
obsidian relic
#

Can anyone say me how to make a discord bot online whit python?

upbeat otter
upbeat otter
#

btw, docs

obsidian relic
#

where

obsidian relic
upbeat otter
obsidian relic
#

I want put a bot online

#

how

#

and with Python

#

just help me to do that

#

@upbeat otter

upbeat otter
#

no comment

obsidian relic
#

...

upbeat otter
#

cant even understand your question properly welp

slim dagger
#

my virtual environment is set, obviously i have discord.py updated, i updated everything and im still having this problem

slate swan
#

Well that's good that you got this error since you shouldn't use requests

pastel cobalt
slate swan
#

i have a questionpithink

#

The module requests should never be used.

pastel cobalt
slate swan
pastel cobalt
slate swan
#

If you don't use the correct way to make web requests don't make others to the same mistakes.

slim dagger
#

what modules do you use then?

slim dagger
#

if you don't mind me asking

quick gust
#

a non-blocking one like aiohttp

slate swan
slate swan
#

aiohttp

slate swan
# quick gust ask

ok so to mention a member its member.mention because its a attr but in the source code its a function how does it work do since a function needs to be called with () and if i call it without it, it will just print the memory locationpithink

slim dagger
#

just want to make sure

slate swan
quick gust
slate swan
slate swan
unkempt canyonBOT
#

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

1641837109.4104993
dire folio
#

Uhm so all my commands stopped working does anyone know a possible reason

slate swan
slate swan
#

See this ^

#
@property
    def mention(self) -> str:
        """:class:`str`: Returns a string that allows you to mention the member."""
        if self.nick:
            return f"<@!{self._user.id}>"
        return f"<@{self._user.id}>"

thats how you mention a member but its a function how so its done .mention and not .mention() since its a function?

dire folio
slate swan
slate swan
slate swan
indigo karma
#

Hey! I am trying to make a bot and i need to a ban/kick functionality to my bot

slate swan
#

!d discord.Member.ban

unkempt canyonBOT
#

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

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

!d discord.Member.kick

unkempt canyonBOT
#

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

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

the coros ^

indigo karma
#
if message.content.startswith("$kick"):
    async def kick(ctx, member : discord.Member, *,   reason= None):
      await member.kick(reason = None)

Ik this is too wrong but is there any way that i could modify this

slate swan
#

modify it by how?

#

and yes thats wrong

#

use the command handler

#

not on_message events

#

and your spaces are really off

indigo karma
slate swan
#

yea

#

okimii will guide u , hes a god

indigo karma
#

Oh nice!

slate swan
slate swan
#

!d discord.ext.commands.Bot

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/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

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

this ^

indigo karma
#

I don't think so

slate swan
#

may i see your code?

indigo karma
#

I'm currently too noob at this

slate swan
#

ic

indigo karma
#

should I send you my repo?

velvet tinsel
#

hi Okimii

#

Because you’re online lemme nerd ou- jk jk

velvet tinsel
indigo karma
#

sent!

velvet tinsel
#

What’s wrong

slate swan
velvet tinsel
#

Ah

#

So you’re using message.startswith?

indigo karma
#

yep

velvet tinsel
#

not good

#

!d discord.ext.commands.Bot || exists for a reason

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/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

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

ive answered you alreadypithink

velvet tinsel
#

use commands.Bot

velvet tinsel
indigo karma
#

alrighty...i'll give it a try

slate swan
velvet tinsel
#

Okimii

slate swan
#

thats me

velvet tinsel
#

Will it be said if I need out in one of the ot channels

slate swan
#

everywhere I go , I see disnake

velvet tinsel
slate swan
#

grumpchib Let Disnake take over

velvet tinsel
#

Disnake rules the world now

slate swan
#

yes

#

disnake on top👑

velvet tinsel
#

We must hail disnake

slate swan
#

yes

velvet tinsel
#

I like the fact that you type fast

#

Unlike the others who type at 10 WPM

#

I send them something they reply after 10 fucking minutes

#

And all they say is “hi”

slate swan
#

130wpm go brrrr

#

I can feel the pain

velvet tinsel
#

Yeah

#

Lol😳

velvet tinsel
#

mwahahhahaha I’m now unstoppable

slate swan
#

I can do 90 ez , never tested recently

#

Typing games got me through a lot of boring classes lmaoo

velvet tinsel
#

I bet I can get 100

#

What do you use

slate swan
#

i can do 10cps🚶

#

Monkeytype

slate swan
slate swan
velvet tinsel
#

I'll try

slate swan
slate swan
velvet tinsel
#

85 WPM

#

eh

#

I can do better than that

#

I'm not even touch-typing

slate swan
#

Idk how to properly type and the fastest I've done is 135 lol. I use one finger on my right hand and 4 on my left

#

Horrible at texting tho 💀

cedar plank
#

hey how i make the bot unban everyone

#

unban all

velvet tinsel
#

uh

slate swan
cedar plank
velvet tinsel
#

lol

#

I love cats

#

I'm making a website dedicated to cats ❤️

#

ignore doge-net

#

my computer is broken

#

idk why

slate swan
#
async for member in bans():
    await member.unban()

would that work ?

velvet tinsel
#

okimii have you downloaded splitgate yet

slate swan
#

probably not

velvet tinsel
#

😠

velvet tinsel
#

do it

slate swan
velvet tinsel
#

please 😩

#

I'm all alone

#

don't worry I'm not a sweat

slate swan
#

almost got banned from the dpy server cuz i mentioned disnakepithink

quick gust
unkempt canyonBOT
hoary cargo
slate swan
hoary cargo
#

PopcornPepe you should've dmed the name then peeposhrug their rules idk

#

AShmm is someone using Hata from here or disnake/pycord for an honest opinion

pseudo cradle
#

Can you make more commands as trigger for one action?

slate swan
#

i mostly use disnake

pseudo cradle
#

Like "!test1" and "!test2" will output "test"

#

So if I say !test1 it will say test and if I say !test2 it will also say test

#

Without creating 2 separated commands

slate swan
#

just use on msg and wait for those 2 msgs

#
if message.content.startswith("!test1" or "!test2"):
    ...
pseudo cradle
#

Oh ok

slate swan
#

!or

unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
karmic totem
#

Does anyone know a good artificial intelligence API

honest shoal
karmic totem
#

like clever

honest shoal
#

hmmm

karmic totem
#

funny

#

whatever

hoary cargo
slate swan
#
@bot.command(aliases=["test2"])
#

dont know why that wasnt my first option

round robin
#

this just gives me a syntax error. what am i doing wrong? ```py

r = requests.post(config["sync_check_url"], data = data)
except requests.ConnectionError:
    await ctx.send("@round robin,@wet relic, Auth server is down. Please try again later.")```
slate swan
#

request isnt async btw

round robin
#

is that why it cant work?

#

how do i make it not async when still doing the same thing

slate swan
#

!blocking

unkempt canyonBOT
#

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

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

import discord

# Bunch of bot code

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

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

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

slate swan
#

use aiohttp

round robin
#

i need it to wait for the response from the website

#

does it always wait anyway before it continues if its not async

slate swan
#

have you read what was in the embed?

round robin
#

some of it

#

i was asking as i was still reading

slate swan
#

tl;dr when you do a request with the request lib the bot will not do anything until the request is done since its a sync lib you will need a async web request lib like aiohttp

round robin
#

is there a way to get around that

#

by using functions that arent async

#

so i can still use the requests module

slate swan
#

nope

round robin
#

would it make the function async

slate swan
#

aiohttp is very similiar

round robin
#

ok

slate swan
#

!pypi aiohttp

unkempt canyonBOT
round robin
#

ill take a look at it

left raptor
#

does the python script have to be running for the bot to work?

left raptor
#

is there a way to have it run continuously?

round robin
#

u can run it on a vps

slate swan
#

if you dont run the file which runs the bot it wont do anything

round robin
#

then its not on ur pc but its on another computer somewhere else

slate swan
#

you can self host or use a vps

left raptor
#

but you need to buy the server space, discord won't provide it?

round robin
#

well basicly same thing

slate swan
round robin
#

for a simple discord.py bot u shouldnt need more then 200mb of ram and u can get those pretty cheap still

#

i recomend sparked host for discord bots

#

they have decent prices

#

or pebble host also does discord bots i think

slate swan
#

digital ocean is good

round robin
#

do they do bot hosting

slate swan
#

it gives you 1gb of ram iirc for 5usd a month

round robin
#

thats not that good

slate swan
#

very overkill

slate swan
round robin
#

and 4 cores

slate swan
#

not sure who they are

round robin
#

their ddos protection isnt great but u probably wont be using it as a public vps

slate swan
round robin
#

ya kinda

#

i got ddosed on it but it was like 5gb/s and it held up good enough

slate swan
#

still not very good of a option

round robin
#

i didnt notice anything untill they emailed me lol

#

they probably wont be running the bot on a vps they will be sharing with

#

so its probably fine to get it for their use case

dire folio
#

i have this:

while t != timer:
        try:
            guess = await client.wait_for('message', check=is_correct, timeout=timer)
        except asyncio.TimeoutError:
            await ctx.send('Time has ran out!')
        
        if guess.content == answer:
            await ctx.send('Well done! You are correct!')
            break
        
        elif guess.content != answer:
            await ctx.send('Your punctuation or spelling was incorrect. Try again!')

but it only looks for a message once and not repeatedly

pearl cove
#

Guys, what extension do you use to make discord bot in Python?

round robin
#

nextcord, pycord, dissnake

#

any work

#

i dont recomend discord.py anymore because its not supported

velvet tinsel
velvet tinsel
#

nothing from stopping you

#

but yeah it is unsupported

#

I'd go with disnake.

round robin
#

didnt say u couldnt use it

dire folio
dire folio
#

this is the command

@client.command(aliases=['tr'])
@commands.has_role('Owner')
async def typeracer(ctx):
    timer = random.randint(4,7)
    answer = 'A test sentence!'
    userid = ctx.author.id
    t=0

    def is_correct(ctx):
        return ctx.author.id == userid

    send = '``'
    send+= answer
    send += '``'
    await ctx.send(f'You have {timer} seconds')
    await ctx.send(f'Type this sentence:\n{send}')

    while t != timer:
        try:
            guess = await client.wait_for('message', check=is_correct, timeout=timer)
        except asyncio.TimeoutError:
            await ctx.send('Time has ran out!')
        
        if guess.content == answer:
            await ctx.send('Well done! You are correct!')
            break
        
        elif guess.content != answer:
            await ctx.send('Your punctuation or spelling was incorrect. Try again!')
dire folio
#

i want it to check messages until the timeout

slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

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

it has the timeout kwarg

dire folio
#

confusion

slate swan
#

you want it to wait for a msg until a certain time?

dire folio
#

basically i want it so if the guess is wrong it will continue to wait for messages

#

currently it only waits for the first message

slate swan
#

what you need to do is check if the message content actually equals the answer string

#

otherwise it just waits for the first message sent in any channel

slate swan
slate swan
#

and no your wrong

#

hes waiting for any msg if its wrong it sends a msg that its wrong if its right it continues the action

#

here's the problem with that:
wait_for will return the first event that meets the check criteria

#

so if he's not testing for the correct message.content in the check function it will just return for one single message and none that come after

#
check = lambda check: if message.content == "msg"
#

that just checks for that msg only

#

but as said on msg alone checks for any msg you would have to do a check for that msg

pearl cove
round robin
#

ok

hoary cargo
round robin
#

(i dont care its not async) will else fire even if its not able to connect? py if r.text == "1": role = bot.get_role(config["user_role"]) await bot.add_roles(ctx.author, role) else: await ctx.send("You are not registered on https://karen.pics/ .")

hoary cargo
#

zz

slate swan
slate swan
unkempt canyonBOT
hoary cargo
round robin
slate swan
#

¯_(ツ)_/¯

#

in this case you should've been matching against the correct string he defined earlier:

check = lambda check: if message.content == answer
#

there isn't a list of strings it should match against, it's just one

slate swan
round robin
#

i want cirtian ids

#

not cirtian permissions

hoary cargo
#

probably his bot is just for his server

slate swan
dire folio
#

sorry wrong thing sent

slate swan
#

so if answer is a string it would wait for that str

slate swan
slate swan
slate swan
slate swan
#

use a function in this case

#
def check(msg):
    if msg.content == answer and msg.author.id == user_id:
        return
dire folio
slate swan
dire folio
#

nope

SyntaxError: 'await' outside async function
slate swan
#

ig set a var value and send the var ig

#

im just confused rn with lambda and im having a headache

wary zenith
#

how do i fix this

#

and what exactly causes me to exceed ratelimit

slate swan
#

What library do you recommend?

wary zenith
#

???

slate swan
wary zenith
#

discord.py still works fine, but if you need to you can use pycord

slate swan
#

Yes

#

I would like to try Nextcord

hoary cargo
#

Hmm disnake too or hikaru

slate swan
#

Okay

wary zenith
untold token
#

If you want to use a fork with stable and updated features, use disnake / nextcord

hoary cargo
#

It might be from the host if you use one

jade tartan
#

Hi my host isnt logging me to my discord or is not authorizing to login it says

#

Do you know how to fix it?

manic wing
#

redirect_uri pithink

green bluff
#

how to make a bots message that the author can only view

#

bot sends a message

#

only author can view it

final iron
green bluff
#

whats an ephermal kwarg

tidal hawk
#

google

final iron
#

Not through

#

But in response

#

So you can't do it with your everyday command

round robin
#

does guild.members contain offline members? ex if i use py for member in ctx.guild.members: print(member) will that print offline members too?

round robin
#

normaly u cant get offline members with a member fetch

#

at least with selfbots u cant

#

i wasnt sure with normal bots

final iron
#

heh

#

Looks like someone made a self bot

round robin
#

i didnt

#

on bot making threads people always talk about fetching members and they couldnt find out how to fetch offline users i think

final iron
#

It should work

#

Worked for me

round robin
#

ok

left crater
#

how would i make the bot send a dm to a certain person

#

this is my code

#
async def on_message(message):
  user = client.get_user(12345678)
  if user_message.lower() == 'dm':
        await message.user.send("stuff")```
green bluff
#

i still dont get ephermal kwargs

jade tartan
#

What redirect url do i need to make it work?

green bluff
#

@left crater why client.event

#

i mean its gonna be much easier for client.command

left crater
#

hmm ok

green bluff
#

@left crater

#

u could do that

left crater
#

ok

green bluff
#

like !hello @awdawd

#

it dms them hi

quaint epoch
#

how do you check if a message replying?

final iron
unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

final iron
#

If no message is mentioned it will return None

green bluff
#

@final iron i still cant figure ephermal kwargs

final iron
green bluff
#

really

#

only in an interaction

final iron
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

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. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
green bluff
#

can it be like !hello and it sends back an ephermal kwarg

final iron
#

No ephermal kwarg

green bluff
#

oh okay

pliant gulch
#

You only get ephemeral messages with interaction responses

green bluff
#

so like a clikc

#

so it wont return an ephermal message if i do !hello

#

like u cant make it return one

final iron
#

No

green bluff
#

oh

final iron
#

I need command ideas

#

I'm running out

green bluff
#

r u making a bot?

final iron
#

Oh, I haven't even made moderation commands yet

final iron
green bluff
#

also heres another idea, giveaways

#

after u make moderation commands u can work on that

tidal hawk
#

How many messages can a bot iterate through in channel's history?

#

There must be some kind of limit

final iron
tidal hawk
#

i guess

manic wing
#

i think its like 1000 a minute or smthin

#

dont quote me on that

tidal hawk
#

okeei

wary zenith
#

you should probably use the commands portion of discord.py tho

#

in that it would be more like:

#
@client.command()
async def dm(ctx):
  dm = await ctx.author.create_dm()
  await dm.send("stuff")```
#

@left crater

final iron
#

No need to create the dm

#

just await ctx.author.send()

wary zenith
#

i tried that in my program and it didnt work so i just made the dm

slate swan
#

I'm very stupid (

hard trail
#

I've been having trouble putting in the code. So I've created a "bad word" restriction and it works the way I want it too but however I want to have exceptions for example MODS can say the words but the Members cannot. (I had a bit of help from a youtube video).

#
async def on_message(msg):
  for word in bad_words:
    if word in msg.content:
      await msg.delete()
    
  await bot.process_commands(msg)
  if msg.author.has_permissions.manage_messages:```
#

How far I got

#

So if the msg.author has the manage_messages permissions I want it to ignore them

#

Ping me when you can help

slate swan
#

Any help ? (Python version : 3.9.9 / Hosted on Pterodactyl)

#

P.S. : Ping me if you can help :>

hoary cargo
slate swan
left crater
#

i want to send it to a certain user by using their discord id

wary zenith
#

then to who?

#

ok then add a discord.Member param to the function

left crater
#

i want to do a slight bit of trolling on my friend

wary zenith
#

kinda like this python async def dm(ctx, member: discord.Member.id): dm = await member.create_dm() await dm.send("stuff")

#

this should work i think

left crater
#

ok

wary zenith
#

you would use it like (prefix)dm (discord user's id)

left crater
#

do i just add an if then function before dm.send

wary zenith
#

nope

#

if then doesnt exist anyway

#

its if elif else

tidal hawk
#

so does discord.Member.id convert the param into member object?

left crater
#

like if user_message.lower() == "dm"

wary zenith
#

yes

tidal hawk
#

didn't know that notations work like that

wary zenith
#

it just tells us what class the thing belongs to

#

or in this case is supposed to belong to

quaint epoch
#

could you do this?py @bot.command() async def kick(ctx): Member = await ctx.guild.fetch_member(ctx.message.reference.author_id) await Member.kick(reason='Bye bye')

#

by finding the person that sent message that you replied to, and kick them?

tidal hawk
#

kicks the ctx.author?

quaint epoch
wary zenith
#

nvm i suck

quaint epoch
#

the author of the message that you replied to

wary zenith
#

@left crater are you ok with just using discord.Member class and then using the code to generate the id

slate swan
#
@client.command(aliases=['dm'])
@commands.has_permissions(administrator=True)
async def mp(ctx, user: discord.User, *, value):
    await user.send(f"{value}")
    print("Message sent")```
#

You can use that

wary zenith
#

or you can listen to this pro

slate swan
#

👀

wary zenith
quaint epoch
wary zenith
#

yes i think

slate swan
#

You can use it I think

quaint epoch
#

at least that's what i do

left crater
#

but what would i have to type in order for it dm

#

like for example !dm

slate swan
#

!dm <user> [message]

wary zenith
#

!dm (members discord name and his gamertag) (your message)

slate swan
#

Oops

left crater
#

ok ill try it

#

File "C:\Users\nick\PycharmProjects\pythonProject\main.py", line 91, in <module>
@client.command(aliases=['dm'])
AttributeError: 'Client' object has no attribute 'command'

slate swan
#

client

wary zenith
#

discord.ext.commands.Bot()

slate swan
#

like @botname.command

wary zenith
#

you defined client as discord.Client() right

#

but you gotta do discord.ext.commands.Bot() to do this one

#

and define your command prefix

slate swan
#
@mp.error
async def mp_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You can use that command, you don’t have the perms !")
    await ctx.message.delete()```

Error message if you don’t have perms
wary zenith
#

as a kwarg of your client

wary zenith
wary zenith
#

something like python @mp.error async def mp_error(ctx, error): if isinstance(error, commands.MissingPermissions): await ctx.send("You can use that command, you don’t have the perms !") await asyncio.wait(3) await ctx.message.delete()

slate swan
#
import discord
from discord.ext import commands

client = commands.Bot(command_prefix='+', help_command=None)

token = "TOKEN_HERE"

@client.event
async def on_ready():
    print("Bot is ready!")
    await client.change_presence(status=discord.Status.online,
                                 activity=discord.Game("+help"))


@client.command(aliases=['dm'])
@commands.has_permissions(administrator=True)
async def mp(ctx, user: discord.User, *, value):
    await user.send(f"{value}")
    print("Message sent")

@mp.error
async def mp_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You can use that command, you don’t have the perms !")
    await ctx.message.delete()
#

Here it is

#

change the command_prefix to your bot prefix

final iron
#

Me when spoon feeding

slate swan
left crater
#

also where do u learn the discord library

slate swan
#

wiki

final iron
left crater
#

skill

slate swan
#

not skill

#

skill is when you subclass Bot like me and others

#

and that bot constructor why that bad naming smh

#

thats like naming a lemon an apple

#

and dont change your presence on ready smh use the kwargs for it

hard trail
#

I keep on getting an attribute error

async def on_message(msg):
  guild = msg.guild 
  if msg.author.permissions.manage_messages:
            # does nothing (skips)
            ...
  else:
   for word in bad_words:
    if word in msg.content:
      await msg.delete()
    
  await bot.process_commands(msg)```
#

Everytime the event is triggered this shows up in the console

slate swan
#

i dont think the member class has that attr

#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
slate swan
green bluff
#

can i make /commands

slate swan
#

no

green bluff
#

why

#

discord says u can

#

and mee6 can

slate swan
#

dpy doesnt have slash commands

green bluff
#

oh

#

bruh

slate swan