#discord-bots

1 messages Β· Page 516 of 1

final iron
#

wdym it moves onto the next command?

#

Like if you remove this code the error will reappear in another command?

#

@crystal cliff How many lines is your code btw?

dapper cobalt
#

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

dapper cobalt
#

And also, what's the error you get?

manic wing
#

where is the discord api

reef shell
oblique adder
#

can i put gif in set thumbnail ?

reef shell
#

yes

oblique adder
#

thx

final iron
#

You could use hastebin

patent lark
#

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

patent lark
#

yes

reef shell
#

you can't use emojis in embed title, author and footer iirc

#

you can

#

<:emoji_name:id>

#

and an a before first colon if it’s animated

#

it should work fine
There is another way

#

get the emoji using get_emoji()

#

!d discord.ext.commands.Bot.get_emoji

unkempt canyonBOT
reef shell
#

Make sure your bot has access to that emoji

#

show code?

#

I see no emojis there

hasty iron
#

why are you casting a string to a string

reef shell
#

You don’t need to cast something to strings which is already a string

hasty iron
#

!f-string

unkempt canyonBOT
#

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

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

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

dense walrus
#

I am using discord.py 2.0 and when getting Member.avatar_url I got None, did they change it in 2.0?

jade jolt
#

member.avatar.url iirc

dense walrus
#

I get member.avatar as None

reef shell
#

You need members intent

#

Your bot*

#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

New in version 1.5...
dense walrus
#

Yeah its already on

reef shell
#

in code and developer portal too?

dense walrus
#

maybe its because the user avatar is the default discord one?

dense walrus
reef shell
dense walrus
#

Yeah let me test it πŸ˜„

#

yeah that's the case, thanks! @reef shell

reef shell
#

np

flint forum
#
channel = bot.get_channel('894061275053707264')
    role = discord.utils.get(member.server.roles, name="Superior")
    while True:
        reaction = await bot.wait_for_reaction(emoji=":person_running:", message=message)
        await bot.add_roles(reaction.message.author, role)
#

error, Member has no attribute to server.roles

reef shell
#

member.roles

lyric moat
#

im new to visual studios how i code python in vs cause i been working it from day and it would not work

final iron
#

Then start writing

vestal lily
#

i alrdy downloaded youtube_dl in terminal but it keeps saying that

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)
vestal lily
#

damn

dapper cobalt
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a β€œserver” in the official Discord UI.

x == y Checks if two guilds are equal.

x != y Checks if two guilds are not equal.

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
slate swan
#

how does the logging module work in cogs?

patent lark
#

so outdated

boreal ravine
visual island
#

member.display_name

#

you need Member instance anyway not User

#

sure

somber musk
#

im finally done my private music bot πŸ˜„

zinc reef
#

Indeed, it must respect roles hierarchy. And server owners are at the very top

unkempt hawk
#

How can add a bot to only one channel? It shouldn't listen to on_message() on any channels except one

spring flax
maiden fable
#

Or u can add an if statement at the top

patent lark
unkempt hawk
#

Why would I want to listen to every message if it should only deal with 1 channel's?

unkempt hawk
patent lark
#

it is. lets say you want the bot to say something back to a user, but only if its in a specific channel

@bot.event
async def on_message(message):
  await bot.process_commands(message)
  if message.channel.id != YOUR CHANNEL ID:
    return
  else:
    await message.channel.send("Hello")```
#

this would be fine, and is only responding to one channel

#

no issues here.

unkempt hawk
#

But it still has to process every single message even if only 1 of a million messages is in that one channel, if that sounds efficient to you then your standards are probably rather low

maiden fable
patent lark
#

thank you, hunter.

maiden fable
#

Yea, so u want the owner to set the permissions manually even if, instead u can do that through code, right?

unkempt hawk
#

I did it with permissions and on_message only triggers for messages in channels, exactly what I needed

patent lark
#

sounds kind of ridiculous to me lol.

maiden fable
unkempt hawk
#

Yeah it is indeed a lot of work to add a bot to a single channel

patent lark
#

i would much rather get my needs of having one channel being responded to with one line of code, rather than manually setting permissions to encounter it. it seems so unnecessary.

maiden fable
pliant gulch
#

How would you mess with the internals to even achieve this

maiden fable
pliant gulch
#

You somehow pop a message out of thin air if it's only in one channel???

maiden fable
#

Using internals*

pliant gulch
#

You need to listen to every message lol that's just not how it works

#

If you are that worried about performance maybe python isn't the language you want

unkempt hawk
maiden fable
#

Well, then as Andy said, if u r worried about performance, then use another language

unkempt hawk
pliant gulch
#

I was not responding to your problem

spare lark
#

can anyone help me with this
whenever i use role.color i get the hex value of color but i dont want that instead of that i want color name so can anyone tell me how to get that
also when i use role.permissions i get the output
<Permissions value=1945627743>
instead of this i want to get output like this
Administrator, Manage Server, Manage Roles, Manage Channels, Manage Messages, Manage Webhooks, Manage Nicknames, Manage Emojis, Kick Members, Ban Members, Mention Everyone

so how should i get this

pliant gulch
#

I was responding to hunters thought of messing with internals to achieve this

#

Which just won't work lol you can't pop a message out of thin air if it's inside of a specific channel

maiden fable
pliant gulch
#

No he wouldn't need an if statement if he limited the bots permissions

maiden fable
#

Yea

#

They are two different suggestions

#

I was just continuing my suggestion of if statement

unkempt hawk
pliant gulch
spare lark
maiden fable
maiden fable
pliant gulch
#

No your just adding a useless call which makes for less performance

unkempt hawk
#

Making an empty return for 99.9% of the requests doesn't sound efficient to me

maiden fable
#

🀷

spare lark
#

when i use role.permissions i get the output
<Permissions value=1945627743>
instead of this i want to get output like this
Administrator, Manage Server, Manage Roles, Manage Channels, Manage Messages, Manage Webhooks, Manage Nicknames, Manage Emojis, Kick Members, Ban Members, Mention Everyone

spare lark
#

you told about role colour

maiden fable
#

No....?

#

That was for permissions

#

dict(role.permissions)

spare lark
#

thats my bad sorry for inconvienence

maiden fable
#

It's fine

spare lark
#

but what i do about role color

maiden fable
#

What?

spare lark
#

cause im getting output in hex code

maiden fable
#

Is that a problem?

spare lark
#

im using role.color
its giving me output in hex code

maiden fable
#

Yea

#

That's what it should

spare lark
#

but i want output by name of role colour

maiden fable
#

You can't

spare lark
#

like it should give output like black blue

maiden fable
#

Reason- There are a thousands shades of a single color, so the code doesn't know which shade u call as red lol

#

For u its different, for me it's different

spare lark
#

but mee6 give output like this

odd walrus
#

I am making a script where when detected for a keyword in discord messages it will print keyword found
So i made it to be

user_messages = (message.content)
if "ABC" in user_message:
   print("abc") 

so when i type in chat ABC it will print abc
but when i send a webhook in embed with the word ABC it does nothing any chance i gotta change anything?

maiden fable
spare lark
#

nothing

maiden fable
#

!d discord.Message.embeds it returns a list of discord.Embed objects

unkempt canyonBOT
maiden fable
#

U gotta check the description, field values and stuff haha

soft radish
#

how can u remove a role again?

#

@maiden fable

#

sorry for ping kek

maiden fable
#

It's fine

maiden fable
unkempt canyonBOT
#

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

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

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

or fetch a user

slate swan
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.
maiden fable
unkempt canyonBOT
maiden fable
#

Also User != Member

grand garden
#

@Footgamer006#132

#

@Footgamer006#1327

slate swan
#

Lmao

#

Also ur "about me" is wrong kurama's dead

visual island
#

naruto has too many episodes breh

slate swan
#

Watched both one piece and Naruto

#

Finished op in 2 months

#

Took me too long because I had school 🀧

dim cedar
#

guys

#

i needed a little help

#
@commands.has_permissions(administrator=True)
async def configure_ticket(ctx, msg: discord.Message=None, category: discord.CategoryChannel=None):```
#

this my cmd

#

and this is what it is gonna output

#

i just wanna make an ugrade that in my cmd there would also be a scope of giving a channel type name

#
@commands.has_permissions(administrator=True)
async def configure_ticket(ctx, x, msg: discord.Message=None, category: discord.CategoryChannel=None):```
#

ticket_channel = await category.create_text_channel(f"{x}-help-discusion-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)

#

but here it shows x is not defined help please

slate swan
dim cedar
#

i wanna add this into the channel name

slate swan
#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

x != y Checks if two channels are not equal.

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
dim cedar
#

like if x is technical problems channel name will also start with technical problems

slate swan
#

Yea but you dont have define x for do that

dim cedar
#

how

#

pls tell me

#

or fix my code

#

it is a small one

dim cedar
#

someone?

#

please

slate swan
#

Give me an example when someone executes this command

#

Like
!configure_ticket etc etc etc

dim cedar
slate swan
dim cedar
#

=configure_ticket technical-problems 894185593674821653 760497345644986380

#

this a cmd

slate swan
#

You have a variable and you have not set it. You probably do not know what you want to do.

dim cedar
#

this create a ticket message

#

and when i react to the ticket

#

it will open a channel

heavy radish
#

Can I have emojis on embed title?

slate swan
heavy radish
#

F

slate swan
#

Same infield names

dim cedar
#

it will open a channel named technical-problems-help-discussion-(reactor)

slate swan
#
@bot.command()
@commands.has_permissions(administrator=True)
async def configure_ticket(ctx, *x, msg: discord.Message=None, category: discord.CategoryChannel=None):
ticket_channel = await category.create_text_channel(f"{x}-help-discusion-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)
dim cedar
#

understand?

#

@slate swan

dim cedar
#

what is *

dim cedar
#

and just saying my ticket_channel variable is above the cmd

slate swan
#

!pastebin

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.

undone lodge
#

mmm

slate swan
#

Let me see your code

unkempt canyonBOT
#

Hey @dim cedar!

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

dim cedar
#
@bot.event
async def on_ready():
    async with aiofiles.open("ticket_configs.txt", mode="a") as temp:
        pass

    async with aiofiles.open("ticket_configs.txt", mode="r") as file:
        lines = await file.readlines()
        for line in lines:
            data = line.split(" ")
            bot.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]

    print(f"{bot.user.name} is in the game.")

@bot.event
async def on_raw_reaction_add(payload):
    if payload.member.id != bot.user.id and str(payload.emoji) == u"\U0001F3AB":
        msg_id, channel_id, category_id = bot.ticket_configs[payload.guild_id]

        if payload.message_id == msg_id:
            guild = bot.get_guild(payload.guild_id)

            for category in guild.categories:
                if category.id == category_id:
                    break

            channel = guild.get_channel(channel_id)

            ticket_channel = await category.create_text_channel(f"{x}-help-discusion-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)
            
            await ticket_channel.set_permissions(payload.member, read_messages=True, send_messages=True)

            message = await channel.fetch_message(msg_id)
            await message.remove_reaction(payload.emoji, payload.member)

            await ticket_channel.send(f"{payload.member.mention} Thank you for creating a ticket! Use **'-close'** to close your ticket.")

            try:
                await bot.wait_for("message", check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close", timeout=3600)

            except asyncio.TimeoutError:
                await ticket_channel.delete()

            else:
                await ticket_channel.delete()```
undone lodge
#

my god

dim cedar
#
@bot.command()
@commands.has_permissions(administrator=True)
async def configure_ticket(ctx, *x, msg: discord.Message=None, category: discord.CategoryChannel=None):
    
    if msg is None or category is None:
        await ctx.channel.send("Failed to configure the ticket as an argument was not given or was invalid.")
        return

    bot.ticket_configs[ctx.guild.id] = [msg.id, msg.channel.id, category.id] # this resets the configuration

    async with aiofiles.open("ticket_configs.txt", mode="r") as file:
        data = await file.readlines()

    async with aiofiles.open("ticket_configs.txt", mode="w") as file:
        await file.write(f"{ctx.guild.id} {msg.id} {msg.channel.id} {category.id}\n")

        for line in data:
            if int(line.split(" ")[0]) != ctx.guild.id:
                await file.write(line)
                
    await msg.add_reaction(u"\U0001F3AB")
    await ctx.channel.send("Succesfully configured the ticket system.")```
undone lodge
#

ticket code ?

dim cedar
#

this a full tickt system

dim cedar
undone lodge
slate swan
#

This part?

dim cedar
# slate swan This part?
         ticket_channel = await category.create_text_channel(f"{x}-help-discusion-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)
            
            await ticket_channel.set_permissions(payload.member, read_messages=True, send_messages=True)

            message = await channel.fetch_message(msg_id)
            await message.remove_reaction(payload.emoji, payload.member)

            await ticket_channel.send(f"{payload.member.mention} Thank you for creating a ticket! Use **'-close'** to close your ticket.")

            try:
                await bot.wait_for("message", check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close", timeout=3600)

            except asyncio.TimeoutError:
                await ticket_channel.delete()

            else:
                await ticket_channel.delete()

@bot.command()
@commands.has_permissions(administrator=True)
async def configure_ticket(ctx, *x, msg: discord.Message=None, category: discord.CategoryChannel=None):
    ```
slate swan
#

...

dim cedar
#

u will find the cmd at last

#

and the ticket channel variable at 1st

dim cedar
slate swan
dim cedar
#

?

vernal tapir
#

.

dim cedar
high pollen
#

Hi I need help

#
@client.command()
async def test(ctx):
    embed2 = Embed("DON'T KNOW THE RULES?", "NO PROBLEM USE ``--rules`` TO VIEW THE RULES")
    await ctx.send(embed2)

Code

#

out put

<discord.embeds.Embed object at 0x00000228622C65E0>
visual island
#

embed=embed2

high pollen
#

oh

#

ty

#

super silly mistake

slate swan
dim cedar
#

my problem?

dusk pumice
slate swan
#

But cant add text like that, must define it, in title or description.

hoary gust
#

help

slate swan
high pollen
valid galleon
#

how do i make it so that when my bot joins a server, its role is at the top of the heirarchy?

high pollen
# slate swan Embed(title="", description="")

Embed is a function

    embed = discord.Embed(title = Title, description = Description, colour = discord.Color.orange())
    embed.timestamp = datetime.datetime.utcnow()
    embed.set_footer(text = "Bot by 09𝔀π”₯𝔬𝔰𝔱𝔯𝔦𝔑𝔒𝔯#9678")
    return embed```
slate swan
#

O.o

hoary gust
#

someone help

high pollen
slate swan
#

Why all this for a simple embed lol

hoary gust
high pollen
#

so makes it easy

#

this is just a part of it

slate swan
#

You know!

gloomy quest
#

I need help

#

H E L P

#

PLS

sick birch
#

your indents are messed up

ocean leaf
gloomy quest
#

o h

gloomy quest
gloomy quest
#
async def prefix(ctx, prefix):
  with open('prefixes.json', 'r') as f:
      prefixes = json.load(f)
    prefixes[str(ctx.guild.id)] = prefix

    with open('prefixes.json', 'w') as f:
      json.dump(prefixes, f, indent=4)
  await ctx.send(f"Prefix changed to {prefix}.")```
sick birch
#

prefixes part

#

line 53

gloomy quest
#

so what should it be like

sick birch
#

i'm not going to spoonfeed you

ocean leaf
slate swan
unkempt canyonBOT
#

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

Creates a public thread from this message.

You must have [`create_public_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_public_threads "discord.Permissions.create_public_threads") in order to create a public thread from a message.

The channel this message belongs in must be a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel").

New in version 2.0.
sick birch
#

unindent so it matches

ocean leaf
sick birch
#

or indent depending on your purpose

gloomy quest
#

ok

ocean leaf
#

so dpy officially allows to create threads

#

hmm i thought i have to use forked versions

gloomy quest
# sick birch or indent depending on your purpose
async def prefix(ctx, prefix):
  with open('prefixes.json', 'r') as f:
      prefixes = json.load(f)
      prefixes[str(ctx.guild.id)] = prefix

      with open('prefixes.json', 'w') as f:
        json.dump(prefixes, f, indent=4)
  await ctx.send(f"Prefix changed to {prefix}.")```??
#

this?

hoary gust
#

@gloomy quest indian?

sick birch
ocean leaf
#

i'm making a help command in which anyone can ask for help regarding any langs.

gloomy quest
sick birch
#

also not sure how well it works considering you open it with read only mode, and open it for writing within

hoary gust
#

just asking

ocean leaf
#

how is my idea?

gloomy quest
#

but it didnt change the prefix

sick birch
#

you probably shouldn't be using json for prefixes anyway

gloomy quest
#

o h

sick birch
#

a database

#

preferable postgres

gloomy quest
#

oh

slate swan
fading harness
#

hi how can i check that a user has permission or not?

warm flame
#

does anyone know how to fix this?

sick birch
#

you'll have to do str() on the int

warm flame
#

okk

warm flame
#

so i cant do this?

sick birch
fading harness
#

with if

sick birch
sick birch
warm flame
#

what does this mean?

#

im getting this error now

dapper cobalt
#

It's expecting an int and not a str. Though, you gave it a str which is "job".

warm flame
#

but the json requires a string...

dapper cobalt
#

Try user[str(user.id)]["job"].

warm flame
warm flame
dapper cobalt
unkempt canyonBOT
#

@dapper cobalt :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | KeyError: 0
dapper cobalt
#

Ah, didn't do it correctly.

warm flame
#

but it works with the other components

dapper cobalt
#

Could you please show me the whole code?

warm flame
dapper cobalt
#

No, I meant this particular command.

warm flame
#

the json file?

#

i dont know where the problem is coming from

unkempt hawk
#

How can I move my commands to a separate commands.py file, and import them all to main.py? For example, main.py:

client = commands.Bot(command_prefix="!", case_insensitive=True)

@client.command()
async def hello(ctx):
    await ctx.reply("Hello!")

@client.command()
async def bye(ctx):
    await ctx.reply("Bye!")

if __name__ == "__main__":
    client.run(var.DISCORD_MARTINBOT_TOKEN)

I'd like to move those commands to commands.py and then use them in the bot in main.py

unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

vocal plover
light night
#

pithink hmm

undone lodge
#

!e

unkempt canyonBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code
block. Code can be re-evaluated by editing the original message within 10 seconds and
clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an
issue with it!*

manic wing
#

!d discord.ext.commands.Cog

undone lodge
unkempt canyonBOT
#

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

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

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

I'm failing to understand why chat has just been filled with either pointless or not very useful content

undone lodge
#

!e

shit = print
shit("just shit")
unkempt canyonBOT
#

@undone lodge :white_check_mark: Your eval job has completed with return code 0.

just shit
undone lodge
unkempt hawk
#

I don't really understand that

undone lodge
#

what about doing loop shipit

unkempt hawk
#

(I hate classes)

vocal plover
#

hm i might have a better thing for you to read 1 sec

undone lodge
#

!e

loop = True 
if True:
    print("looooop")
unkempt canyonBOT
#

@undone lodge :white_check_mark: Your eval job has completed with return code 0.

looooop
vocal plover
#

Please can you stop

undone lodge
#

while*

undone lodge
vocal plover
#

yes

undone lodge
#

kk

vocal plover
unkempt hawk
#

Do I create the class in commands.py?

vocal plover
#

yes

unkempt hawk
#

And then import that class in main.py?

vocal plover
#

no

#

read the article, it explains it

unkempt hawk
#

But classes giving me headaches lol

steep estuary
#

why the bot is doing dm to itself

slate swan
#

you just load the extension using load_extension , you cog would have setup function which will do it

steep estuary
#
welcomeEmbed.add_field(name=f"Member Number", value=f"#{member.guild.member_count}", inline=True)
            user = member
            await channel.send(embed=welcomeEmbed)
            await user.send(f"We Are So Excited to have you on {member.guild.name}")
#

it is doing dm to itself :/

slate swan
#

what's the member variable?

steep estuary
slate swan
#

Hy i need some help

#

πŸ™ƒ

warm flame
#

guys how can i add a button?

dapper cobalt
dapper cobalt
slate swan
dapper cobalt
unkempt canyonBOT
dapper cobalt
reef shell
#

!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.
reef shell
#

and It's pretty good

warm flame
#

ive been thinking the same thing

dapper cobalt
boreal ravine
dapper cobalt
unkempt hawk
# dapper cobalt You can use cogs. You may have a look at this repository, it has examples and ex...

I'm trying so far I have

from discord.ext import commands

bot = commands.Bot(command_prefix="!", case_insensitive=True)


class Commands(commands.Cog):

    @commands.command()
    async def hello(self, ctx: commands.Context):
        await ctx.reply("Hello!")

    @commands.command()
    async def bye(self, ctx: commands.Context):
        await ctx.reply("Bye!")

    def __init__(self, bot: commands.Bot):
        self.bot = bot

But then how do I import that in the main script?

boreal ravine
dapper cobalt
#

But I'm afraid of the version not being stable.

slate swan
#

No ones helping πŸ˜’πŸ˜’

dapper cobalt
boreal ravine
dapper cobalt
slate swan
#

Okies

#

Thanks

boreal ravine
unkempt hawk
#

Gotcha, and now what?

#

What do I import?

slate swan
#

@dapper cobalt can u give link of documentation ur talking about

reef shell
dapper cobalt
#

@unkempt hawk are you making classes in the main file? If so, you're defeating the purpose of cogs.

slate swan
#

@unkempt hawk hey listen shard up yr bot it's easy and it will also make fast

boreal ravine
reef shell
slate swan
#

@reef shell thanks πŸ™ƒπŸ™ƒπŸ™ƒ

reef shell
hybrid fjord
#

is there an event where a user joins a voice channel?

boreal ravine
unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
reef shell
#

I'm not talking about forks

hybrid fjord
#

thanks

unkempt hawk
reef shell
#

fyi

boreal ravine
spare lark
#

list(dict(role.permissions).items())
by using above code im getting the permission a role in list but they are not in order i mean that i want permissions in the decreasing order of priviledges like

Administrator, Manage Server, Manage Roles, Manage Channels, Manage Messages, Manage Webhooks, Manage Nicknames, Manage Emojis, Kick Members, Ban Members, Mention Everyon

how should i get this output

dapper cobalt
reef shell
unkempt hawk
slate swan
#

@boreal ravine hm

visual island
unkempt hawk
#

I didn't have bot defined yet btw

#

Only client

dapper cobalt
unkempt hawk
#

I did but I don't understand it

#

I hate classes

warm flame
#

what does the row arguement take?

dapper cobalt
unkempt hawk
reef shell
reef shell
#

it takes the row number

dapper cobalt
#

It should be named bot and not client, though.

#

It does work, but it's preferable to make your bot instance named bot.

unkempt hawk
#

Aren't you supposed to use @client.event etc.?

#

The tutorial I was following used client

reef shell
#

Bad naming Convention

dapper cobalt
#

It depends on what you defined your bot's instance as.

unkempt hawk
#

My client is client = Client() I don't have a bot yet

warm flame
dapper cobalt
reef shell
#

You don’t need to specify it if you are gonna have only one row

dapper cobalt
#

!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.
warm flame
reef shell
#

And a row can have max. 5 buttons

unkempt hawk
dapper cobalt
#

That's why YouTube tutorials are bad.

#

Don't follow them.

reef shell
unkempt hawk
#

Neither was a YT one lol

reef shell
warm flame
dapper cobalt
#

What kind of tutorial?

reef shell
#

Follow this one

unkempt hawk
#

Whatever google threw up for python discord tutorial

dapper cobalt
#

Even worse.

warm flame
dapper cobalt
#

Tutorials in general are mostly bad.

reef shell
warm flame
#

oh wait

reef shell
#

is it dpy?

warm flame
#
        await ctx.reply(
            embed=em,
            components=[
                Button(label="Back", ),
                Button(label= "Next", )
            ]
        )
``` yes
reef shell
#

I don’t think so

dapper cobalt
#

Try appending that list in another one. It should work iirc.

warm flame
dapper cobalt
#

components=[[Button(..), Button(..)]]

warm flame
#

isnt it the same thing but in an another array?

dapper cobalt
#

Yes.

#

That's what I said at first.

reef shell
# warm flame why would i be here then?

i'm not familiar with this type of defining buttons,
You should subclass discord.ui.View and use button decorator so you can use that button's callback easily

warm flame
#

nvm it works

#

how tf is putting it in another array works?

dapper cobalt
#

If you give it a list in a list, it will loop through the outer list, and join the inside list.

#

There's a Discord limitation; hence why you can't have more than 5 buttons in one row iirc.

reef shell
#

are you sure you are using dpy v2.0 and not a fork?@warm flame

warm flame
#

yes im sure im using dpy 2.0

reef shell
#

never knew components is a kwarg of reply()

#

I checked and it is not

#

lmao

unkempt hawk
#

Why does on_message print the message but the cog command doesn't fire? If I comment out the on_message it works

@bot.event
async def on_message(message):
    print(f"{message.channel} - {message.author}: {message.content}")


# Load Commands

bot.load_extension("commands")


if __name__ == "__main__":
    bot.run(var.DISCORD_MARTINBOT_TOKEN)
#

Can I not have both for a message?

slate swan
#

await client.process_commands(message)

#

after the print

unkempt hawk
#

Oh ty

reef shell
#

!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/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/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/master/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/master/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/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
warm flame
#

guys how can i edit alrdy sent embeds?

unkempt hawk
warm flame
#

can i just store ctx.send in a variable then edit it or smth

unkempt hawk
warm flame
boreal ravine
#

yes

dapper cobalt
warm flame
#

so python has something common with other languages, epic

boreal ravine
reef shell
#

it should be await bot.proc.....

maiden fable
slate swan
#

ah bot

maiden fable
#

bot

#

Cz its bot.event haha

unkempt hawk
#

I'm confused as hell on whether to use client or bot, half the people are saying client is bad but the other half tells me to use client instead of bot

slate swan
#

so it would be

await bot.process_commands(message)```#
unkempt hawk
#

Ye I got it

maiden fable
slate swan
maiden fable
#

Haha it's fine

unkempt hawk
maiden fable
unkempt hawk
#

Commands and normal events like on_message

maiden fable
#

Bot has both

slate swan
maiden fable
reef shell
#

Client is for beginner yert

#

Yeah ik

unkempt hawk
#

Got it

maiden fable
reef shell
#

bruh

maiden fable
#

Most of the ppl (if I am correct), start with Client

#

Well, I can be wrong also 🀷

dapper cobalt
maiden fable
#

djs devs didn't add an extension cz they wanted to keep things simple for themselves lmao

soft galleon
#

heyo, what ways do you guys know i can make the bot prefix case unsensitive? for example dank memer i can do PLS, pLs, pLS. and pls

hasty iron
#

if you say Client is bad, that means Bot is also bad

maiden fable
#

client = commands.Bot()

hasty iron
#

oh

maiden fable
#

If I understand him correctly, that's what he means lol

maiden fable
dapper cobalt
#

No.

maiden fable
#

....?

#

That's for commands lol. Not for prefixes

hasty iron
#

use regex like a chad

soft galleon
#

no

dapper cobalt
#

!d discord.ext.commands.Bot.case_insensitive

unkempt canyonBOT
#

Whether the commands should be case insensitive. Defaults to False. This attribute does not carry over to groups. You must set it to every group if you require group commands to be case insensitive as well.

soft galleon
#

thats for commands, not prefixes

maiden fable
#

Bruh

maiden fable
slate swan
#

Isnt that only for the commands. Eg $apple. $AppLe

soft galleon
#

but thanks for trying to help :)

maiden fable
#

isn't that what I said

slate swan
#

Yea but...

maiden fable
dapper cobalt
#

Oh, right.

maiden fable
#

easy way

dapper cobalt
#

Didn't read it well.

#

9 AM and I haven't had a minute of sleep.

unkempt hawk
#

Same here, been up for almost 48h, I blame discord.py

high flame
#

command_prefix=[...]

warm flame
#

guys how can i check if a button is pressed or not?

maiden fable
solar pike
#

code for mentioning a user

warm flame
#

no

solar pike
#

like pinging him

maiden fable
maiden fable
solar pike
warm flame
#

ive been following a decumentary but it doesnt seem to be working

#

tried a yt vid, still aint working

maiden fable
#

Sorry bro. Never used that lib. Please use dpy 2.0

warm flame
#

i am using dpy 2.0 tho

high flame
maiden fable
unkempt canyonBOT
#

property mention: str```
Returns a string that allows you to mention the given user.
maiden fable
warm flame
high flame
maiden fable
maiden fable
high flame
warm flame
high flame
#

oh

warm flame
#

is that the one u talking abt?

high flame
#

no no

warm flame
#

do i have to use that?

high flame
#

oh wait

#

that's wrong maybe

#

you've imported it and didn't use it

#

you use a 3rd lib instead

warm flame
#

what am i suppose to use?

reef shell
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
warm flame
reef shell
#

I told you earlier

#

The timeout for the view

#

eg. buttons and dropdowns

warm flame
#

liek this?

reef shell
maiden fable
#

Not the correct case, but yes

warm flame
reef shell
#

i don't follow tutuorials

warm flame
#

ive been trying to figure it out myself

reef shell
#

i follow docs

warm flame
#

but then i gave up

warm flame
reef shell
#

wait, you never knew that? cring

soft galleon
#

yeah

reef shell
unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

warm flame
#

oh this one

reef shell
#

gtg for shower, bye

dawn vine
#

how do i make it so that it sends a message every 90 seconds or so

reef shell
unkempt canyonBOT
#

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

oh ok thanks

#

waht do i put in loop?

reef shell
#

Your task

dawn vine
#

oh ok

#

thanks so much!

reef shell
#

like sending messages

#

In your case

dawn vine
#

yea

#

i want to irritate ppl

reef shell
#

lmao

dawn vine
#

File "C:/Users/Admin/PycharmProjects/Code/Python/MY_bot/main.py", line 27
discord.ext.tasks.loop(*, seconds=0, minutes=1, hours=0, time=0, count=None, reconnect=True, loop='F.C.P.D reporting partrol 5 check on general' )
^
SyntaxError: invalid syntax

#

?

reef shell
#

so you literally copied the code from docs?

dawn vine
#

uh yes

#

cause i didnt learn this

#

in any tutorials

reef shell
#

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

dawn vine
#
yes
reef shell
dawn vine
#
    discord.ext.tasks.loop(*, seconds=0, minutes=1, hours=0, time=0, count=None, reconnect=True, loop='F.C.P.D reporting partrol 5 check on general' )
                            ^
SyntaxError: invalid syntax
reef shell
#

This is a decorator to be used for async fuctions

dawn vine
#

ok

#

but whats the error

#

the *

#

?

reef shell
#

the error is you are not doing it in the way it meant to be

dawn vine
#

yea but how is meant to be xD

reef shell
#
@tasks.loop(seconds=60)
async def activity_change_(): 
users = sum(g.member_count for g in bot.guilds)
await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name=f"ethelp | {users} users")) 

There you go, a quick example i copied from my code

dawn vine
#

oh ok

#

thanks!!

#

what is count supposed to be?

reef shell
#

the indentations got f up

#

Nvm

reef shell
dawn vine
#

what is for infinite?

reef shell
#

don't mention

#

The keyword

dawn vine
#

k

#

thanks

reef shell
#

It defaults to loop forever

#

and please consider reading the docs

dawn vine
#
discord.ext.tasks.loop( seconds=60 , reconnect=True, loop='F.C.P.D reporting partrol 5 check on general' )
AttributeError: module 'discord' has no attribute 'ext'
weary gorge
#

Could u help me mr. sherlock?

reef shell
dawn vine
#

yea

reef shell
#

so why are you using it like before lol

weary gorge
#

i've run into an issue with reaction roles

reef shell
weary gorge
#

thanku

#

this is the command line

#

@bot.command(name="selfrole")
async def self_role(ctx):
await ctx.send("ANSWER")

questions = ["Enter Message: ", "Enter Emojis: ", "Enter Roles: ", "Enter Channel: "]
answers = []

def check(user):
    return user.author == ctx.author and user.channel == ctx.channel

for question in questions:
    await ctx.send(question)

    try:
        msg = await bot.wait_for('message', timeout=120.0, check=check)
    except asyncio.TimeoutError:
        await ctx.send("Type Faster Nerd")
        return
    else:
        answers.append(msg.content)

emojis = answers[1].split(" ")
roles = answers[2].split(" ")
c_id = int(answers[3][2:-1])
channel = bot.get_channel(c_id)

bot_msg = await channel.send(answers[0])

with open("selfrole.json", "r") as f:
    self_roles = json.load(f)

self_roles[str(bot_msg.id)] = {}
self_roles[str(bot_msg.id)]["emojis"] = emojis
self_roles[str(bot_msg.id)]["roles"] = roles

with open("selfrole.json", "w") as f:
    json.dump(self_roles, f)

for emoji in emojis:
    await bot_msg.add_reaction(emoji)
#

then this is the error: Ignoring exception in command selfrole:
Traceback (most recent call last):
File "C:\Users\glent\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 85, in wrapped

#

well, part of it

sacred folio
#

Hey guys, im trying to get all the people that have reacted on a message. I tried using await getmsg.reactions[0].users().flatten() but it seems it only gets the latest one

solar pike
#

how do i add embed in this code

dawn vine
#

umm it saying something wrong in my client.run

solar pike
#

nvm got it

dawn vine
#

why it not working

slate swan
#

That's not how loop works

dawn vine
#

ok thanks

reef shell
# dawn vine

So you chose to not follow docs or the example I've shown youharold

dawn vine
#

LMAO im sorry i dont understand without indents

#

i tried to follow but i didnt understand

reef shell
#

i'm on mobile so indentations got f up nvm

dawn vine
#
@tasks.loop(seconds=5.0, count=5)
async def slow_count():
    await message.channel.send('This is F.C.P.D partrolling general partrols 5 and 6 are killing beluga')
hoary gust
#

someone tell me why is this happening discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: edit() takes 1 positional argument but 2 were given

dawn vine
#

ok

#

thanks

reef shell
#

but you need something else to start the loop

hoary gust
#
        info = await ctx.send("Please send the embed message title in 1 minute")

await info.edit("Timeout")

dawn vine
reef shell
#

Wait a sec

#
from discord.ext import tasks

@tasks.loop(seconds=5)
async def my_loop():
    print('Hello World')

my_loop.start()β€Š
dawn vine
#

do i have to install tasks?

hoary gust
#

@reef shell can u help me a bit

reef shell
#

no

#

You need to import

reef shell
hoary gust
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: edit() takes 1 positional argument but 2 were given

hasty iron
#

edit takes only kwargs

hoary gust
#

why th is this happening

reef shell
#

Only 1 pos. arg

hasty iron
#

?

#

do you know what kwargs is

#

keyword arguments

dawn vine
#
await message.channel.send('This is F.C.P.D partrolling general partrols 5 and 6 are killing beluga')
#

its saying message is unresolved

hasty iron
#

define it

dawn vine
#

but it is defined it other ones

hasty iron
#

!scope

unkempt canyonBOT
#

Scoping Rules

A scope defines the visibility of a name within a block, where a block is a piece of python code executed as a unit. For simplicity, this would be a module, a function body, and a class definition. A name refers to text bound to an object.

For more information about names, see !tags names

A module is the source code file itself, and encompasses all blocks defined within it. Therefore if a variable is defined at the module level (top-level code block), it is a global variable and can be accessed anywhere in the module as long as the block in which it's referenced is executed after it was defined.

Alternatively if a variable is defined within a function block for example, it is a local variable. It is not accessible at the module level, as that would be outside its scope. This is the purpose of the return statement, as it hands an object back to the scope of its caller. Conversely if a function was defined inside the previously mentioned block, it would have access to that variable, because it is within the first function's scope.

>>> def outer():
...     foo = 'bar'     # local variable to outer
...     def inner():
...         print(foo)  # has access to foo from scope of outer
...     return inner    # brings inner to scope of caller
...
>>> inner = outer()  # get inner function
>>> inner()  # prints variable foo without issue
bar

Official Documentation
1. Program structure, name binding and resolution
2. global statement
3. nonlocal statement

hasty iron
#

if you define a variable inside a function, you cant access it somewhere else

dawn vine
#

but i didnt have to do that before?

hasty iron
#

?

dawn vine
#

oh nvm

#

i fixed sorry to bother

vale narwhal
#
@bot.event
async def on_member_unban(member):
   if member == "SIN#2981":
      await member.ban(reason="Alt")
   else:
      pass

i got this errror

2021-10-04T08:21:54.846539+00:00 app[worker.1]:     await coro(*args, **kwargs)
2021-10-04T08:21:54.846567+00:00 app[worker.1]: TypeError: on_member_unban() takes 1 positional argument but 2 were given
#

Am i doing anything wrong?

rough ledge
vale narwhal
#

guild, user?

rough ledge
#

Yes

vale narwhal
#

Alright ty

#

If i want to check then use user right?

rough ledge
#

Yes

vale narwhal
#

and can i use it with await ban

#
@bot.event
async def on_member_unban(guild, user):
   if user == "739767836850913302":
      await user.ban(reason="Alt")
   else:
      pass

weird...

rough ledge
#

if member == "SIN#2981"
I'm not sure if this would work
I assume it would be if f'{user.name}#{user.discriminator} == "SIN#2981"'

vale narwhal
#

hmmm

vagrant brook
#

str(user) works

rough ledge
#

If you want to check the id
if user.id == 1234

vale narwhal
#

Alright

placid skiff
vale narwhal
#

also how do i ban em thought

#

user.ban?

rough ledge
#

Use Guild.ban, because User doesnt have ban()

placid skiff
vale narwhal
#

It's an event

placid skiff
#

It s the same lol

#

Just use that member: Member

#

The code will try to convert the string member into a Member object

vagrant brook
#

uhh

slate swan
#

You don't understand the question at all

placid skiff
#

If it cannot then will simply raise an error

slate swan
#

Again, they're trying to ban a user through an event and not with any type of command

#

So what you're giving is pretty much useless and helpless

placid skiff
#

The member converter work anyway :_:

#

Let s say

async def on_member_unabn(guild, user: Member):
    If  user.name == wathever_the_name_is:
       await guild.ban(user)
slate swan
#

guild.ban is really outdated ;-;

placid skiff
#

The on_member_unban event gives a guild and a user as parameter, that user can be converted into a member and be used as a member object

#

So it no metter what user is, if is an id, the nickname or the discriminator. Is a member object and can be used as a regular member

orchid raptor
#

Hi, I use ctx.reply in my commands instead of ctx.send and it works.
But something can happen that for whatever reason the message is deleted and an error
HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In message_reference: Unknown message
Sending, I want the ctx.send process to be done if something like this happens.
And this is possible with try and excpet, but to use this in any of my commands is really useless and a waste of time.
please help

slate swan
#

hello
I am trying to make a discord music bot play any1 sound file when a single command is use
there are the codes

@bot.command()
async def fast(ctx: commands.Context):
    voice_channel: discord.VoiceChannel = ctx.author.voice.channel
    print(voice_channel.name)
    vc = await voice_channel.connect()
    vc.play(discord.FFmpegPCMAudio("file 1" or "ffile2"))
    while vc.is_playing():
        await asyncio.sleep(.1)
    await vc.disconnect()

there aren't working

#

anyway to fix?

hasty iron
#

Member.ban is an alias to it

placid skiff
slate swan
hasty iron
placid skiff
hasty iron
#

you aren’t converting anything

#

you’re just doing a regular typehint

#

nothing more, nothing less

slate swan
slate swan
hasty iron
#

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

Equivalent to Guild.ban().

hasty iron
#

how is Guild.ban outdated

slate swan
#

Not alias of

#

how to use embed in cogs ?

hasty iron
#

it does the same thing

#

and it’s better because you dont need a Member object

slate swan
slate swan
hasty iron
#

?

#

oh right

slate swan
#

User asking for help is not even here anymore

hasty iron
#

why does that matter

slate swan
#

➿

hasty iron
#

im just saying that you dont need a Member object with Guild.ban, you can pass in any snowflake

#

which makes it better

slate swan
#

➿

#

Ok

orchid raptor
orchid raptor
hasty iron
# slate swan Not alias of

    async def ban(
        self,
        *,
        delete_message_days: Literal[0, 1, 2, 3, 4, 5, 6, 7] = 1,
        reason: Optional[str] = None,
    ) -> None:
        """|coro|

        Bans this member. Equivalent to :meth:`Guild.ban`.
        """
        await self.guild.ban(self, reason=reason, delete_message_days=delete_message_days)
``` basically an alias
slate swan
vale narwhal
#
@bot.event
async def on_member_unban(guild, user):
   if user.id == 739767836850913302:
      await guild.ban(user, reason="Alt")
   else:
      pass

^ solved

slate swan
#

how to fix embed is not working

slate swan
#

It's not the embed that doesn't work

slate swan
#

Add self

hasty iron
#

bruh

boreal ravine
slate swan
#

It's 4 characters, is it that hard?

#

Add self

boreal ravine
#

lmfao eol error

slate swan
#

Literally 4 characters

slate swan
# slate swan

Dont u just need the ctx then embed.add_image(url=ctx.author.avatar_url)?

#

i am a beginner

boreal ravine
#

not add

hasty iron
slate swan
slate swan
hasty iron
#

or do you not know how to use a keyboard

slate swan
#

And adding 4-6 characters after a ( is not that hard

slate swan
slate swan
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.

slate swan
#

I am trying to make a discord music bot play any1 sound file when a single command is use
there are the codes

@bot.command()
async def fast(ctx: commands.Context):
    voice_channel: discord.VoiceChannel = ctx.author.voice.channel
    print(voice_channel.name)
    vc = await voice_channel.connect()
    vc.play(discord.FFmpegPCMAudio("file 1" or "ffile2"))
    while vc.is_playing():
        await asyncio.sleep(.1)
    await vc.disconnect()
boreal ravine
slate swan
vale narwhal
boreal ravine
#

You said

Dont u just need the ctx then embed.add_image(url=ctx.author.avatar_url)?
I correct you by saying it's embed.set_image now

#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

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

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
slate swan
#

So its set

boreal ravine
#

doesn't exist

#

yeah it's set_image

slate swan
#

Ohhh kk i forgor

umbral carbon
#

he

#

if __name__ == '__main__':
  for ext in extensions:
    client.load_extension(ext)
#

this is my code to import cogs and the cog 'codes' is running fine while the cog 'random' isnt

#

the other basic code we put in a cog is same in both but icant use commands of random cog but the codes cog commands run fine

#
from lists import *

class random(commands.Cog):
  
  def __init__(self, bot):
      self.bot = bot```
#
  bot.add_cog(random(bot))```
#

this is my code and in between those are my commads which i have tried putting same commands in both

#
discord.ext.commands.errors.CommandNotFound: Command "tt" is not found```
#

this is the error

valid niche
#

@umbral carbon could you show your full cog code?

#

so with the commands and everything?

slate swan
#

The error might come from how you've written your commands in the cog file, share the entire code

valid niche
#

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

valid niche
#

if it's too long to paste use this

slate swan
#

And why do you use bot in cogs but client in the main file Think

valid niche
#

oh also that class random is going to be VERY annoying when you want to use the random module

umbral carbon
#

yes

#

i changed to randomcom

#

doesnt work still

#

wait a sec

valid niche
#

share the cog code with us

slate swan
#

Since your other cog is loading, the issue is in the random cog. Share this file

valid niche
#

paste the code in that pasting service linked above and give us the link

umbral carbon
#

pasted the cog too

slate swan
#

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.

valid niche
#

which is exactly explained in the instructions

umbral carbon
#

i use replit

slate swan
#

Indentation is not correct

valid niche
#

that, and that YTDL at the top

#

!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)
valid niche
#

!indents

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

umbral carbon
#

mostly it shows it isnt corect

valid niche
umbral carbon
#

my bad i'll check it, im kind of new lemon_sentimental

slate swan
#

Commands should be indented at the same level as the __init__ function

umbral carbon
#

ohhh

umbral carbon
#

alright ty

slate swan
umbral carbon
#

okayss

#

hey it worked

#

thanks a lot, it was a very silly mistake

slate swan
#

Hello why am I getting || on timestamp?

#

I want only 1 |

#

emb.set_footer(text = f"Bumped by {ctx.author}", icon_url = ctx.author.avatar_url)
emb.timestamp = datetime.utcnow()

glass sail
#

Hello!
I had a question about Discord.py.
I want my bot to respond only when I write a number and a dot next to it.
Example: 20. hello (the number here is 20 and the text here is hello)
It should get both the inputs (the number and text).
Should I do this with the on_message function (if so, how?) or with any other method?
Thanks!

valid niche
#

you have on_message and you have wait_for

valid niche
slate swan
#

When you add a footer and timestamp, there's an automatic | on phone to separate them

#

And on computer I believe it's β€’ that separates them

waxen granite
#

Is it possible to get the member who created a channel?

slate swan
#

Yes, by checking the audit logs

waxen granite
#

Any other way?

slate swan
#

Nope

supple sentinel
#

Hey guys, i want to create a bot that within its features creates a "profile" for everyone who sends a message in the server. These "Profiles" would work like variables, holding infomation that can change about each person. How would i go about doing this?

slate swan
#

Use a database to store the required information

valid niche
supple sentinel
#

Ah, thank you very much PepeHappy

slate swan
#

@valid niche @slate swan

emb.timestamp = datetime.datetime.utcnow()
emb.set_thumbnail(url=ctx.guild.icon_url)
emb.set_footer(text = f"Bumped by {ctx.author}", icon_url = ctx.author.avatar_url)
await ctx.send(embed = emb)

#

We help you fix issues you face, not code one for you

#

Halp pls

#

How to make the default || to |

#

@cedar smelt

slate swan
#

This is how Discord works

#

You can't change anything about it

#

If it shows as || and you haven't added an extra | by yourself, then it's Discord that decided it

slate swan
#

See, there's only one...

#

But how?

#

I don't see ||

slate swan
#

As I said........

#

What should I add here?

#

It's DISCORD that chose it to be like that

#

You CAN'T change what Discord made default

#

If you add a footer text AND timestamp, it will be separated using |

#

And this is how it is and you CAN'T do ANYTHING about it

slate swan
#

Can you read please?

#

Read what

#

Whatever

#

Maybe read what users send

#

Thank you!

#

:)

#

...

#

It now shows |

slate swan
#

Anyways, thanks again

slate swan
boreal ravine
#

whats a permissions argument

plucky shoal
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
plucky shoal
#

You can use this this

boreal ravine
#

a check?

#

that isnt an arg

plucky shoal
#

I understood him as he was trying to check the permissions

#

Am I wrong?

boreal ravine
#

command args?

plucky shoal
#

You can see all possible args here

#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
plucky shoal
#

Check in the link this

boreal ravine
#

u dont need perms

#

to add args to a command

#

blank image?

#

wait nvm

#

just add it manually?

#

there isnt something like that in dpy lol

slate swan
#

How to ise token bucket

keen talon
lilac latch
#

Can I use multiple images in the same embed??

steep estuary
#

how i can know if someone voted my bot ?

lilac latch
#

Or whatever site you are using

steep estuary
#

on_dbl_vote?

lilac latch
steep estuary
#
@bot.event
async def on_dbl_vote(data):
    print(data)
    user = data["user"]
    voteEmbed = discord.Embed(title="Voted!", description=f"{user} Just Voted for {bot.user.mention}",color=embedTheme)
    voteEmbed.add_field(name=f"Voter ID", value=f"{user.id}", inline=False)
    voteAnnounce = bot.get_channel(892260693846401054)
    await user.send(f"Thanks For Voting {bot.user.mention} !! You Can get Rewards in Our Official Server")
    await voteAnnounce.send(embed=voteEmbed)
#

this is my code but not working :/

lilac latch
#

It doesn't work like that my friend

#

1 min

steep estuary
#

why ?

#

take 2 min :/

#

oops srry

lilac latch
steep estuary
#

i just google it

#

it shown me that

#

i imported dbl

#
import dblpy
boreal ravine
#

thats a thing?

steep estuary
#

i saw docs

#

it was there

lilac latch
slate swan
#

Can I? If yes, how can I convert my discord bot to apk so that I can run it on my other phone (without using termux/pydroid3)

steep estuary
#

but also if someone vote dank memer than it gives coins to the user