#discord-bots

1 messages · Page 733 of 1

slate swan
green bluff
#

thats why i copied the code from this onto that

slate swan
#

What do you actually want?

green bluff
#

the profile picture

#

onto the embed

boreal ravine
slate swan
#

Like this?

green bluff
#

yup

#

thats better

slate swan
#

Then you need to set the embed author

#

!d discord.Embed.set_author

unkempt canyonBOT
#

set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
boreal ravine
slate swan
green bluff
#

url?

slate swan
#

You don't need it

boreal ravine
#

how do you install something from pypi but forget what pypi is??

slate swan
#

May you stop? It's irrelevant.

boreal ravine
#

of course it is, I just asked where they installed it from and they acted like they didn't know

slate swan
#

They know how, but not from where. Not everyone knows PyPi is where libraries are taken from.

green bluff
#

@slate swan

slate swan
#

You're missing the embed.

#

And you need to specify name=

#

And you can remove url=Embed.Empty,

green bluff
#

no the embed is there

#

@slate swan

slate swan
#

?

green bluff
#

wdym im missing embed

slate swan
#

It's embed.set_author

vast gale
vast gale
slate swan
#

Not needed

green bluff
#

1 more error

slate swan
#

Which is?

vast gale
# slate swan Not needed

it is. Look at their code, they're in the init of the embed definition. set colour needs to be moved out of the embed init call and act on the embed

#

problem is you can't see where the last paran is for the embed init call

slate swan
#

The code got pasted above, that's just the small addition of set_author.

#

Which is the only thing needed.

#

So no, no need to send the entire code again with just one line of changements you can clearly see.

green bluff
#

yea i think its not that part of the code thats effected

slate swan
#

You need to read the JSON file content.

green bluff
#

the error is in suggest

slate swan
#

Well, you don't need to send pictures of that; you can show the error you get.

green bluff
#

lol sorry

green bluff
#

why arent the errors underlined in red

slate swan
#

Just replace .txt with .json, it doesn't really matter as long as you keep the JSON structure inside the file.

slate swan
green bluff
#

OMGGGG I AM BLIND

#

ok what do i do there

tawdry perch
#

What is the error?

slate swan
#

Well, now you'd need to send the code of the entire command.

#

As the screenshot doesn't help at all in this case.

green bluff
#

embed.set_author(name=f'{ctx.author}s Suggestion.'}, icon_url=member.avatar_url)

slate swan
#

The entire command.

#

Oh well

green bluff
#

@client.command()
@commands.cooldown(1, 600, commands.BucketType.user)
async def suggest(ctx, *, reason=None):
if reason == None:
await ctx.reply("Pls enter a suggest")
else:
embed = discord.Embed(title=f"Suggestion sent by: {ctx.author}",
description=f"Reason of suggestion : {reason}",
colour=discord.Colour.orange())
embed.set_author(name=f'{ctx.author}s Suggestion.'}, icon_url=member.avatar_url)
channel = client.get_channel(910048935257718794)
await channel.send(embed=embed)

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
#

Here it is:

#

Remove that

#

quick question, do i have to use FFmpegPCMAudio when trying to play an mp3 file that is saved on my computer locally?

green bluff
#

i dont understand

#

what did i do there

#

that i should fix

slate swan
#

how do I make custom responses for options in the dropdown menu command these are codes I tried using if command but didnt worked correctly

    async def callback(self, interaction: disnake.MessageInteraction):
        await interaction.response.send_message('yo')


class DropdownView(disnake.ui.View):
    def __init__(self):
        super().__init__()
        self.add_item(Dropdown())```
slate swan
green bluff
#

member is now highlighted in yellow

#

member.avatar_url

slate swan
#

Because you haven't defined it

green bluff
#

yes i did it is icon_url

slate swan
#

Replace with ctx.author

slate swan
slate swan
slate swan
green bluff
#

bot is not responding

#

it would say it in my channel modlogs but i didnt recieve a suggestion

#

no errors

slate swan
#

And in the cmd?

green bluff
#

nothing

#

terminal right'

slate swan
#

Yeah - what's your code now?

green bluff
#

@client.command()
@commands.cooldown(1, 600, commands.BucketType.user)
async def suggest(ctx, *, reason=None):
if reason == None:
await ctx.reply("Pls enter a suggest")
else:
embed = discord.Embed(title=f"Suggestion sent by: {ctx.author}",
description=f"Reason of suggestion : {reason}",
colour=discord.Colour.orange())
embed.set_author(name=f'{ctx.author}s Suggestion.', icon_url={ctx.author}.avatar_url)
channel = client.get_channel(910048935257718794)
await channel.send(embed=embed)

slate swan
#

!code use this please

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.

green bluff
#

what is that letter

#

'

boreal ravine
#

hm

green bluff
#
@commands.cooldown(1, 600, commands.BucketType.user)
async def suggest(ctx, *, reason=None):
  if reason == None:
    await ctx.reply("Pls enter a suggest")
  else:
    embed = discord.Embed(title=f"Suggestion sent by: {ctx.author}",
    description=f"Reason of suggestion : {reason}",
    colour=discord.Colour.orange())
    embed.set_author(name=f'{ctx.author}s Suggestion.', icon_url={ctx.author}.avatar_url)
    channel = client.get_channel(910048935257718794)
    await channel.send(embed=embed)```
slate swan
#

{ctx.author}.avatar_url

#

You're not using an f-string, remove the {}

green bluff
#

TYSM also i understood everythingthanks for the info

slate swan
green bluff
#

why

visual island
#

if reason is None

visual island
# green bluff why

Comparisons to singletons like None should always be done with is or is not, never the equality operators

green bluff
#

changed it thanks

slate swan
#

if not reason would be true even for reason = 0 , or reason = False , right?

visual island
#

yes

#

works with reason = [], reason = "" and everything that's Falsy

velvet tinsel
#

Caeden did if … == True

#

It was kind of funny lol

visual island
#

shh

slate swan
velvet tinsel
#

😳

#

You didn’t see that

slate swan
#

🔪 why not just deal with required arguments with on_command_error

velvet tinsel
slate swan
#

Well then you need to name your arguments decently, which is barely my case.

#

Example:

s := session.New(*sessionUsername, *sessionPassword)
#

Could be better than just s

#

:v well it saves from lot of harcoding

#

how do I make custom responses to each option in my dropdown menu using disnake library?

    async def callback(self, interaction: disnake.MessageInteraction):
 #if something.........
        await interaction.response.send_message('yo')


class DropdownView(disnake.ui.View):
    def __init__(self):
        super().__init__()
        self.add_item(Dropdown())
unkempt canyonBOT
#

examples/views/dropdown.py line 29

await interaction.response.send_message(f'Your favourite colour is {self.values[0]}')```
slate swan
#

As you an see, it uses self.values[0] to get the dropdown value you clicked.

visual island
#

remove the ,

slate swan
#

We'd need more code though.

#

Share more code, below and above.

#

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

slate swan
#

!paste or this if it's too long

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.

visual island
slate swan
#

No, it could be a list.

#

As you can see now :)

visual island
#

!e

a = 1,
b = 2
unkempt canyonBOT
#

@visual island :warning: Your eval job has completed with return code 0.

[No output]
slate swan
#

It's a list.

visual island
#

oh

slate swan
#

Remove the x = part

#

Just keep the Button(...), Button(...), Button(...)

visual island
slate swan
#

List

visual island
#

what

slate swan
#

!e
x = [1, 2, 3]
print(type(x))

unkempt canyonBOT
#

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

<class 'list'>
visual island
#

!e
a = 1,
print(a)

unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

(1,)
slate swan
#

List :)

visual island
#

tuple :)

slate swan
#

A list of button objects :D

visual island
#

oh

#

that

#

but

#

!e

list = [
  a = 1,
  b = 2,
  c = 3
]
```you cant do this
unkempt canyonBOT
#

@visual island :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     a = 1,
003 |       ^
004 | SyntaxError: invalid syntax
slate swan
visual island
slate swan
#

You don't use wait_for, you use view.wait().

#

So please take a look at the example, thanks.

#

As I said, the example shows how to use buttons properly.

#

Look at the code by yourself and you will understand it better.

visual island
slate swan
#

It is, should not be used though.

#

Not really useful to use discord_components for buttons, dropdowns etc. They are already in discord.py 2.0

visual island
#

yeah I totally agree, it exists in master branch and better to use forks instead of external libs

slate swan
#

i was never able to found the correct documentation for that library

#

Which library?

#

discord_comps

#

nvm , its was the slash command library

#

It changed name so many times

#

And now it's almost an entire library

#

Not really an add-on anymore

#

is a big confusion for people who used it with og discord.py

#

I'd rather use a completely different library or a discord.py fork than using libraries that let's you add something to the original discord.py library.

#

guys

#

can u say me how could I

#

make a auto responder bot

#

?????????

#

@slate swan

#

@slate swan

slate swan
#

but you can do this

#

!e

list_ = [
  {
  "a":1,
  "b":2,
  "c":3
  }
]
print(list_)
unkempt canyonBOT
#

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

[{'a': 1, 'b': 2, 'c': 3}]
slate swan
#

pretty sure a dictionary won't work in a method where it needs a list of Components 👍

slate swan
haughty quartz
#

can there be aliases with 2 words?

humble granite
#

Yo, I want to list every channel's chosen type.
my code:

for i in guildchannels:
  print(i.type)            # this works; returns me text,category or voice
  if i.type=="text":       # this doesnt work
    print(i) 
visual island
#

It returns discord.ChannelType

slow fog
visual island
#

!d discord.ChannelType

unkempt canyonBOT
slate swan
#
@bot.event
async def on_message(message):
    slangs = ["shi"]
    for word in slangs:
        if word in message.content:
            await message.delete()

why isnt it working?

#

there is no error in the console

#

message intents ill assume

#

oh yes could be

#

or your if statement does not quality

#

what was the message u sent

slate swan
#

great

#

well, i enabled the intents but it still isnt working

dusk trout
#

Hello there guys so I have coded a little something and basically I have something test=defined to something . Is there any way I can make a command that when executed redefines test . Something like .rtest test2 which badically redefines test to tes2. Is that possible

slate swan
slate swan
slate swan
slate swan
unkempt canyonBOT
#

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

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

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

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

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

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

dusk trout
#

Is ok I’ll check it out

slate swan
cold sonnet
oblique adder
slate swan
#

I'd recommend to use disnake.

#

You just need to replace all discord to disnake for everything,.
Example: discord.Embed -> disnake.Embed

oblique adder
#

which one is better ? performance wise

slate swan
#

disnake is much more used and preferred by users, performance wise you'd need to make tests and analyze them yourself as nobody has done it before.

oblique adder
#

both of them is a fork of discord.py and both look great. nextcord got more stars on github have more contributor and used by so I might try that first. Thanks anyway

slate swan
regal leaf
#

i dont get reply on email

slate swan
#

Had some server issues, here is my answer shortened:

Yes I pay for my domains, I pay them on Namecheap.
Yes you can get domains for free, on Freenom, but I don't recommend it as they can remove your domain at any moment, unlike paid domains.

lapis breach
#

hey trying to learn pyhton by myself and idk why this isnt working it problably isnt written that wait but idk how cuz as i said i was just starting out

lapis breach
#

oh...

#

ohhhhhh ye i see

solar anchor
#
    if message.content.startswith(prefix + 'changeprefix' + newprefix):
        await message.channel.send('Changed the prefix to' + newprefix)
        prefix = str(newprefix)```
maiden fable
#

Also u can do if rightbutton:

solar anchor
#

how can I make it so that when i type .changeprefix / it changes the prefix to /

maiden fable
unkempt canyonBOT
#

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

Retrieves the prefix the bot is listening to with the message as a context.
solar anchor
#

huh

lapis breach
#

await view.wait() why isnt this working?

solar anchor
#

i dont use "bot"

#
import discord
import os
import math
import random

from discord import user
from discord import client
from discord.ext import commands

prefix = '.'

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return
        

    if client.user.mentioned_in(message):
        embedVar = discord.Embed(title="**Settings for this server**", description="", color=0x004AEB)
        embedVar.add_field(name="Info:", value='The prefix is set to: ' + '``' + prefix + '`` \n \n Type ``.commands`` for the list of commands', inline=False)
        #embedVar.add_field(name="Field2", value="hi2", inline=False)
        await message.channel.send(embed=embedVar)

    if message.content.startswith(prefix + 'commands'):
        await message.channel.send('__Comming Soon!__') #commands
    

    if message.content.startswith(prefix + 'changeprefix' + newprefix):
        await message.channel.send('Changed the prefix to' + newprefix)
        #prefix = str(newprefix)```
slate swan
#

I have the discord library installed...?

    from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
slim ibex
#

do you have the right interpreter selected?

slate swan
#

say my bot dms someone, is it possible for it to grab the channel's id or recipients?

brave flint
#

is there any way to get guild id for custom prefixes?

#

i saved prefixes by guild id

shadow wraith
#

do pip3 install discord.py or pip install discord.py

desert crest
#

hey, can anyone help me rq?
so basically what I'm trying to do is add a command that edits an old message the bot sent. my issue is that I made reaction role message but didn't think about changing it in the future, I want to keep all the reactions but just edit the original message

#

I've seen some results online but most of them are different from each other and I want to use the safest way...

pallid marsh
#

is there a way to detect when a user joins a discord server? I’m using on_member_join(member) but it does nothing. there’s no error code. i even tried to print to the console when it ran but that didn’t work either. i’m using discord.py

slate swan
#

bot is unable to send dms

#

i don’t think that’s the problem @slate swan

#
# bot.py
import os

import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user.name} has connected to Discord!')

@client.event
async def on_member_join(member):
    await member.create_dm()
    await member.dm_channel.send(
        f'Hi {member.name}, welcome to my Discord server!'
    )

client.run(TOKEN)```
#

if u look above another person jaden is using what you are

#

the issue is not only with dms its also with commands

#

its not responding at all

#

just listening to the active ports

#

where are the commands?

#

wait

#

here it is

#
@client.event
async def on_message(message):
    if 'happy birthday' in message.content.lower():
        await message.channel.send('Happy Birthday! 🎈🎉')```
#

its not responding with happy birthday

pallid marsh
slate swan
#

nope

pallid marsh
#

is the bot appearing as online

slate swan
#

yes

final iron
slate swan
#

message intents ? is that a setting idk bout this

#

or a script

final iron
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

pallid marsh
#

i think you turn it on in the discord dev portal

slate swan
#

ok i'll try this first

desert crest
slate swan
#

but its still unable to send welcome message

slate swan
#

ok

#

wait thats what i am using above

slate swan
#

I wanna make a bot like owo

#

can I get some help

slate swan
#

?

#

Not sure

slate swan
#

can I get some basic codes

boreal ravine
slate swan
desert crest
boreal ravine
slate swan
#

can anyone say me what modules and what codes I need to write

boreal ravine
humble granite
#

How do I check if a role on a guild is a bot-only role?

boreal ravine
desert crest
#

ill check

slim ibex
humble granite
slate swan
#

he’s asking you

#

how can I check in which servers my bot is in

#

I want a stats command

#

anyone can help?

boreal ravine
unkempt canyonBOT
slim ibex
#

@humble granite bot_has_role()

spring flax
#

If I want to make an embed generator, like the user can make the fields himself, what's the best way to do it?

slim ibex
#

uhh don’t think you can do that

humble granite
#

Thannks

slate swan
#

with decorator?

slim ibex
#

you need a decorator to say something is a command In the first place

#

The Guilds thing is a function

#

that you use in the command

desert crest
slate swan
slim ibex
#

just like how you do any other command

spring flax
#

Also, how can I, using a wait_for, wait for the user to send an image, and use that image to set it as embed.thumbnail

slate swan
boreal ravine
polar ice
#

Is there any way of having more then 3 fields inline on a discord embed?

slim ibex
#

Not that I know of.

boreal ravine
slate swan
#
                                ^
SyntaxError: invalid syntax```
slate swan
slim ibex
#

you can’t just put discord.Guild

boreal ravine
slate swan
slim ibex
#

it has to be connected to a parameter

slate swan
slim ibex
#

guild: discord.Guild

slate swan
#

k wait

#

watch a oop tutorial

polar ice
#

Anyone know if its possible to have more then 3 fields inline on a discord embed? 😄

slate swan
#
             ^^^^^^
SyntaxError: invalid syntax```
slim ibex
slate swan
#

guild.guild?

slim ibex
#

lmao what

#

I said guild: discord.Guild

slate swan
slate swan
#

just say it to me with example

slim ibex
#

async def stats(ctx, guild: discord.Guild)

slate swan
#

property guilds: List[discord.guild.Guild] this?

slim ibex
#

to be honest, you should know what else you need to Create a stats command for your bot

honest shoal
#

sheesh

honest vessel
#

can anyone explain?

Deleted 4 message(s)
We gonna try delete 2 messages from Zero&Ones#2436.
Deleted 1 message(s)

If i tell it to purge 5 it purge 4, sometimes less even, and u can see when 2 it purge 1....

    @commands.command(aliases=["dm", "purge"])
    async def delete_message(self, ctx, member:disnake.User, num_of_msg=1):
        def is_me(m):
            return m.author == member
        await ctx.send("We gonna try delete **{}** messages from {}.".format(num_of_msg, member), delete_after=10)
    
        deleted = await ctx.channel.purge(limit=num_of_msg, check=is_me)
        await ctx.channel.send(f'Deleted {len(deleted)} message(s)', delete_after=20)
        await ctx.message.delete()
slate swan
#

I have just started it

slate swan
slate swan
#

now what?

#

;-;

honest shoal
slim ibex
slate swan
slate swan
slim ibex
#

ik

#

lmao

slate swan
slate swan
#

lmao

honest shoal
slate swan
#

say it rn

slate swan
slim ibex
honest shoal
slim ibex
#

that’s all I will say

slate swan
#

lol

honest shoal
#

monke moment

slate swan
#

umm

#

lemme think

#

I cant

#

@slim ibex help

#

pls

#

💀

#

pls

#

say me bro RC_say_what

#

say me

#

@slim ibex

brave flint
#

did anyone use mongodb for custom prefix?

slate swan
#

help me

#

!d discord.guild.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
#

I can't yet understand

quick gust
#

What do u not understand?

slate swan
brave flint
#

uh

slate swan
#

hm

#

what do you even want to do? display the servers your bot is in?

honest shoal
honest shoal
quick gust
#

bot.guilds returns a list of all the guilds your bot is in, u can just use simple .join() or use len() if u wanna display the number of servers

slate swan
#

I wanna make a command if I use that command it can show me the name of alll guilds

slate swan
honest shoal
#

^^

slate swan
#

how are u making a whole bot if u dk how to write this simple thing

slate swan
quick gust
#

so u are asking to get spoonfed code

#

?

slate swan
brave flint
#

why this make my bot doesnt answer all cmd?, im making custom prefix with mongodb

slate swan
brave flint
slate swan
#

it should be async

slate swan
quick gust
slate swan
#

also, why mongodb

#

async def

#

use sqlite or postgres/mysql

#

use that

#

mongo = bad

#

why? because i dont like it

slate swan
slate swan
#

just use motor if you want to mongodb

#

hey guys

#

help me

brave flint
#

i dont know what im doing rn

slate swan
#

I am here since last 10 mins ig

slate swan
#

thats not what

slate swan
#

lol

quaint epoch
#

so i have this code py for i in perms.keys(): overwrite = discord.PermissionOverwrite() overwrite.(i) = perms.get(i)

slate swan
#

intent as in what is your goal.

#
def get_prefix(bot , message):
   ...
honest shoal
slate swan
#

is anyone gonna help me?

slate swan
#

which I don't know

brave flint
slate swan
#

;-;

slate swan
honest shoal
#

weird

brave flint
#

eh wait

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
quaint epoch
slate swan
# brave flint yea, but im need the message

im pretty sure i have a bot i made in like 2018 with customizable prefixs, i can try to find it to you if thats your goal. but what your writing right now seems extremely overcomplicated

polar ice
#

Is there any way to have more then 3 fields inline on an embed with discord.py

slate swan
unkempt canyonBOT
slate swan
brave flint
#

then what the bot for?, it shown not acessed

slate swan
slate swan
quick gust
slate swan
brave flint
#

learning mongodb takes 3hours and now i need to change

polar ice
#

Is there any way to have more then 3 fields inline on an embed with discord.py??

slate swan
#
async def stats(ctx, guild: discord.Guild):```
#

use sqlalchemy if its sql, i dont know much about mongo

slate swan
honest shoal
echo bridge
#

those anybody know how to fix it?

slate swan
quick gust
#

are u watching a tutorial? @slate swan

echo bridge
#

so go watch one

honest shoal
echo bridge
#

but it is

quick gust
# slate swan nope

so u know what type hinting is but u don't know how to show items of a list??

echo bridge
#

its connected

slate swan
# brave flint then what the bot for?, it shown not acessed

its because , the actual way discord.py deals with it is ```py

class MyBot(commands.Bot):
def get_prefix(self , message):
....
``` so basically it takes self which is a bot object as the first argument

keeping that in mind , you'll have to keep it even if you dont use that , not acessed means u didnt use it

slate swan
honest shoal
slate swan
slate swan
slate swan
slate swan
#

i am , but still

pallid marsh
#

anyone know how to alert a bot when a user joins the server? everything i’ve read doesn’t work. on_member_join(member) doesn’t give an error but the code doesn’t run at all. please help i’ve been stuck on this for a while:)

quick gust
slate swan
#

hehe

slate swan
unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
slate swan
echo bridge
pallid marsh
slate swan
slate swan
honest shoal
echo bridge
#

its only for me

pallid marsh
slate swan
slate swan
slate swan
#

No

#

atleast seems like that to me , song.mp3

#

Look the code closely.

#

oh

#

ytdl.download()

honest shoal
#

nvm

slate swan
#

nvm then , im high

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.

spring flax
#

if a message has a video attached, I can get it by message.attachments right?

pallid marsh
#

@slate swan is this right?

slate swan
#

Why intents

#

@slate swan bruh can't u help me writing that code

#

pls..............

#

no

slate swan
#

pls............

slate swan
slate swan
#

just let the bot arg stay there even if u dont use it

brave flint
#

ok

#

so did i need to change my code?

slate swan
#

pls tell me the code bruh I get my lappy just for few minutes

#

@slate swan

slate swan
brave flint
slate swan
#

stop begging people to write and spoon feed you code

slate swan
slate swan
brave flint
slate swan
slate swan
brave flint
slate swan
slate swan
slate swan
slate swan
slate swan
#

I am just 14 I can't really pay u

#

why are you in a server about programming, if you dont want to learn.

honest lintel
#

How can I check if a discord.User has the Online status?

slate swan
#

ok, tell me whats your issue

slate swan
slate swan
#

which I am unable to do

brave flint
slate swan
#

;-;

brave flint
#

it could be bout my mongodb too

honest shoal
#

ahh

slate swan
slate swan
#

!d discord.Member.status

unkempt canyonBOT
#

property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
slate swan
slate swan
slate swan
#

ty

#

its actually a command alias

#

sorry for not being technical

slate swan
slate swan
brave flint
slate swan
pallid marsh
slate swan
slate swan
brave flint
#

clear

slate swan
#

in text pls

slate swan
spring flax
#

How do I check if message.attachments is a video, not an image?

slate swan
brave flint
#

@slate swan ignore those yaml

slate swan
honest shoal
unkempt canyonBOT
slate swan
slate swan
brave flint
pallid marsh
#
intents = discord.Intents(members=True)
client = discord.Client(intents=intents)``` is this correct?
brave flint
#

nothing shown

spring flax
brave flint
#

do you think this is bout the database?

slate swan
honest shoal
spring flax
#

oh okay

#

thanks

slate swan
potent spear
slate swan
#
Traceback (most recent call last):
  File "D:\Python\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: guild is a required argument that is missing.
potent spear
#

you know why it fails, right?

brave flint
slate swan
# slate swan didn't got answer on stackoverfow

look somewhere else then, cant believe you’ve just sat in here for over half an hour asking for that one line when if u just looked for yourself you’d have found it. Researching is a skill u ought to learn

brave flint
potent spear
brave flint
potent spear
brave flint
#

oh ok

potent spear
#

ever heard of a botvar?

brave flint
potent spear
#

it's like bot.guilds

#

guilds is an attribute of that instance

#

so what you actually want, is to store the prefixes as a botvar

#

and whenever you update a prefix, you update the db and the botvar

slate swan
# brave flint no it doesnt respond the setted prefix and when i mention nothing happend

well thats a lot of mixed up stuff , im not a mongodb person but you would prefer using something like thiss ```py
def get_prefix(bot , message):
if isinstance(message.channel , DMChannel): return 'default prefix'

read db

if db_has_data : return data
else : return 'default prefix'

instead of mentioning commands.when_mentioned_or there ,

bot = Bot(command_prefix = commands.when_mentioned_or(get_prefix))```

just an example , do not copy

potent spear
#

^^ this function is sync, which is good

west shuttle
#
    await guild.create_category("Welcome")
    await guild.create_category("General")
    await guild.create_category("Givaways")
    await guild.create_category("Voice")
    await guild.create_category("Staff")

All the categories are creating other the "Voice"

slate swan
brave flint
slate swan
potent spear
#

just load in all your prefixes before you start the bot
, then all you have to do is get them from the variable instead of fetching from the DB every time.
it's basically a cache

#

don't EVER fetch a prefix from a db whenever you need to check them, you can't go any worse

slate swan
#

ho ho

#

me booster now

west shuttle
potent spear
slate swan
#

@slate swan if u complete the code just dm it to me

west shuttle
potent spear
potent spear
west shuttle
potent spear
brave flint
potent spear
#

chances are, maybe it's already there

potent spear
pallid marsh
#
intents = discord.Intents(members=True)
client = discord.Client(intents=intents)``` is this correct i’m using discord.py
potent spear
brave flint
spring flax
#
@bot.event
async def on_message_delete(message):

    if message.attachments:
        if message.attachments[0].content_type == "video":
            message_url = message.attachments[0].url
            channel = bot.get_channel(825629287859617812)
            await channel.send(str(message_url))
    else:
        return 
#

Why doesn't this work? No errors

pallid marsh
potent spear
maiden fable
#

damn my discord just lagged

slate swan
potent spear
west shuttle
maiden fable
#

Why not just do names = [x.name for x in client.guilds]

#

!list-comp

unkempt canyonBOT
#

Do you ever find yourself writing something like this?

>>> squares = []
>>> for n in range(5):
...    squares.append(n ** 2)
[0, 1, 4, 9, 16]

Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:

>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]

List comprehensions also get an if statement:

>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]

For more info, see this pythonforbeginners.com post.

potent spear
maiden fable
west shuttle
#

Nope

slate swan
#

it is, but i didnt think of doing it

potent spear
maiden fable
#

I would have did that since it's shorter to write too

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.

slate swan
#

either way, he has his code now

potent spear
#

or that

potent spear
junior verge
#

I did pip install discord already how to fix this?

true moon
#

I am using discord_components and I want to edit the message on which the button was clicked but there is no option like interaction.update() and when i do msg = await ctx.send('Example') on button click await msg.edit('Yo') it gives that This interaction failed

#

please help me

potent spear
honest shoal
west shuttle
potent spear
junior verge
west shuttle
brave flint
junior verge
#

I did pip install discord

honest shoal
potent spear
west shuttle
junior verge
true moon
junior verge
#

Yeah that is the same

west shuttle
honest shoal
#

weird

brave flint
junior verge
brave flint
#

then try py -m pip install discordpy to got venv file

potent spear
brave flint
junior verge
junior verge
#

like this?

true moon
#

HOw to edit a message on button click without getting the This interaction failed error

brave flint
true moon
#

please help me

brave flint
#

for me its work

junior verge
#

Ah

brave flint
#

paste the file dir

spring flax
#

Can I set a video for embed.set_image?

slate swan
#
async def stats(ctx, guild: discord.Guild):
    names = [x.name for x in client.guilds]
    await ctx.send(names)``` code 


```Traceback (most recent call last):
  File "D:\Python\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "D:\Python\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: guild is a required argument that is missing.``` errror
brave flint
junior verge
#

Sorry @brave flint you are going a bit too quick 😛

#

I am not following it

brave flint
potent spear
junior verge
#

I know dyp that is not the problem for me

honest shoal
slate swan
true moon
#

Never MInd i think i got it

west shuttle
spring flax
junior verge
#

I have reset my pc like 1 week ago and forgot all the python stuff

potent spear
brave flint
junior verge
potent spear
west shuttle
potent spear
junior verge
#

I am here now

honest shoal
brave flint
junior verge
#

What?

brave flint
#

not like thatttt

junior verge
#

Oh sorry

brave flint
#

u need to type on the...

junior verge
brave flint
#

terminal then powershell

slate swan
#

yeah finally after an hour with the help of @slim ibex @slate swan @slate swan @potent spear I got my code done

junior verge
#

I don't get what you are trying to tell me sorry.

brave flint
#

u click terminal then choose powershell, then type py -m pip install discord.py

potent spear
junior verge
#

ooooh

brave flint
#

it will shown a error that lib arl downloaded and show the filepath

slate swan
#

thnx guys @potent spear @honest shoal @slim ibex @slate swan @slate swan

brave flint
junior verge
#

From my project folder?

brave flint
west shuttle
brave flint
junior verge
#

I just don't understand what you are telling me

slate swan
#

my bot is done now it's time to make token account joiner

potent spear
final iron
honest shoal
#

selfbotting!?

slate swan
slate swan
rugged marsh
#

;-;

west shuttle
slate swan
#

I thought its not the hell it

#

but its a holy shit

#

np

potent spear
slate swan
#

thnx for the advise

slate swan
quick gust
honest shoal
#

^

true moon
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Command' object is not subscriptable WHAt hell is this?

near sedge
#

can anyone help me with something regarding mongodb?

profile = {
            "userId":ctx.message.author.id,
            "userTag":ctx.message.author,
            "balance":0
        }
collection.insert(profile)

it was able to insert it before i added balance, but now it doesn't anyone know why?

true moon
#

here is the code

potent spear
junior verge
#

How do I fix this,

potent spear
true moon
potent spear
true moon
potent spear
true moon
#

ok

near sedge
potent spear
#

you should really check out documentation man

true moon
#

wait.custom_id

#

bruh

#

if wait == 'rock'

#

it should be wait.custom_id

potent spear
#

there's more wrong with his code, found out later

kind wasp
#

anyone knows the Discord import

#

?

potent spear
#

always check out documentation PLS

kind wasp
#

but

#

whats the import

potent spear
kind wasp
#

i'm having issues

#

im using this

potent spear
#

you have module not found error, ofc

true moon
#

and if you trying edit the message onButtonCLick then you should use wait.edit_origin otherwise it will give This interaction failed error in discord

kind wasp
#
import discordpy
potent spear
#

you've never looked at the docs in your life, right?

#

start doing so

kind wasp
#

i seen on youtube

near sedge
kind wasp
#

oh thanks @near sedge

near sedge
#

if it still gives you errors double check its actually installed using pip

polar ice
#

Is there any way to have more then 3 fields inline on an embed with discord.py??

maiden fable
polar ice
#

@maiden fable Okay, thought so just thought id ask 🙂

fervent shard
#

could someone check if this is right?

@bot.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, member:discord.Member, *, reason=None):
      guild = ctx.guild
      mutedRole = discord.utils.get(guild.roles, name="muted")    
      await member.add_roles(mutedRole, reason=reason)
        
      if member == ctx.author:
       em=discord.Embed(description=f"**you* cannot `mute` yourself", colour=discord.Colour.red())
      await ctx.send(embed=em)

      else:
      em=discord.Embed(description=f"{member.mention} has been `muted` for **{reason}**", colour=discord.Colour.green())
      await ctx.send(embed=em)

      em=discord.Embed(description=f"**you** have been `muted` for **{reason}**", colour=0)                 
      await ctx.send(embed=em)
      await member.send(embed=em2)
      list_of_muted_members.append(member)
      print(list_of_muted_members)

@bot.command()
@commands.has_permissions(kick_members=True)
async def unmute(ctx, member: discord.Member, reason=None):

  if member == ctx.author:
    em=discord.Embed(description=f"**you* cannot `unmute` yourself", colour=discord.Colour.red())
    await ctx.send(embed=em)
  
  else:
    em2 = discord.Embed(description=f"{member.mention} has been `unmuted` for  **{reason}**", colour=discord.Colour.green())
    em3 = discord.Embed(description=f"**you** have been `unmuted` for  **{reason}**", colour=0)
      mutedRole = discord.utils.get(ctx.guild.roles, name="muted")
      await member.remove_roles(mutedRole)
      await member.send(embed=em3)
      await ctx.send(embed=em2)```
fervent shard
maiden fable
#

Hmm I get the problem

#

U r muting first, and then seeing if the author is muting himself

final iron
#

Its that you're using camelCase

potent spear
#

that's just you fucking up indents

final iron
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

maiden fable
fervent shard
maiden fable
#

Yea

potent spear
#

fucking or messing things up, same thing

fervent shard
fervent shard
slate swan
#

Any help?

final iron
slate swan
# slate swan Any help?

You're following the same tutorial as 90% of the people I see.
When executing the command you need to do !unban Username#0001 (no mention, no ID).

lapis breach
#

await view.wait() why wont that work?

maiden fable
lapis breach
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'disnake.ui.view' has no attribute 'wait' this is the error

maiden fable
#

U need a View class instance

quaint epoch
#

anyone know how to make a custom help command?

maiden fable
#

view != View

quaint epoch
#

like

maiden fable
unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

quaint epoch
#
!help <command_name>```
maiden fable
#

See the link (:

slate swan
quaint epoch
#

what kind of monster are you?

maiden fable
maiden fable
final iron
#

User ID's don't change while usernames can

quaint epoch
slate swan
slate swan
slate swan
quaint epoch
#

why lucas? why?

slate swan
#

I have my username since 2015 CL5_MonkaSonic

quaint epoch
#

and the comments section of the vids just disgusts me

slate swan
slate swan
#

he least made me learn a lil of python

quaint epoch
#

client = discord.Client() i think

quaint epoch
slate swan
oblique adder
#

For discord components button if I want my button to work for as long as the bot is online what should I use for interaction ? I dont think i can use bot wait for

potent spear
oblique adder
maiden fable
#

no

final iron
#

I'm going to be downloading users profile pictures and modifying them with cv2. Are there any dangers I have to be aware of?

#

i.e with code embedded in image

maiden fable
#

I don't really think so, as long as the users know

final iron
#

I'll make a disclosure

#

Also, how bad would it be to have synchronous code running in my discord bot?

tough mirage
#

Can I make a bot where it assigns a role across multiple discord servers

oblique adder
# maiden fable no

but if someone click on the button first time the next time it wont work right ?

#

because it have finish waiting

potent spear
oblique adder
potent spear
maiden fable
unkempt canyonBOT
#

awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.

The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor") instance. The default executor is used if *executor* is `None`.

Example:
oblique adder
# maiden fable it will

but if i used bot wait for and someone click on the button that mean the command have finish executed ? and the 2nd will have interation fail ?

final iron
#

Actually never mind

slate swan
#

The only roles that display members, is the roles that the bot has, why is that?```py
@client.event
async def on_ready():
guild = client.guilds
print("I'm ready")
await removeRoles(guild)

async def removeRoles(guild):
print(guild)
for i in guild:
for names in i.roles:
for l in names.members:
print(l)

maiden fable
#

why not use bot.users?

#

!d discord.Client.users

unkempt canyonBOT
#

property users: List[discord.user.User]```
Returns a list of all the users the bot can see.
slate swan
# maiden fable !d discord.Client.users

I wanted to make it where if there was an empty role it would delete it because there are many roles in this server I am in with no users assigned to the role(s)

#

and when I do client.users, it only displays the bot

maiden fable
#
for role in guild.roles:
    if len(role.members) == 0:
        await role.delete()
#

also check your intents

slate swan
slate swan
ashen aspen
#

How do I invite my bot?

maiden fable
#

yea

ashen aspen
#

Did they change the system?

#

before it was so easy

maiden fable
slate swan
#

@maiden fableoh, when i do the intents, do I have to enable the intent on the discord developer portal and in the code?

ashen aspen
#

It doesn't work

maiden fable
unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slim whale
# ashen aspen

Or bot permision calculator, u put the bot id and copy the link

#

i always do that xd

slate swan
#

it is now working, I didn't have ```py
intent = discord.Intents.all()
client = discord.Client(intents=intent)

ashen aspen
exotic kite
#

When I have 2 channels here in replit, it only functions one, anyone knows why is that? If you do pls tell me

slim whale
slate swan
#

How to mention someone like this?

slim whale
#

in client id put the application id, and select the permissions you want

potent spear
slate swan
slim whale
ashen aspen
potent spear
exotic kite
slim whale
ashen aspen
#

Yes ofcourse

exotic kite
#

some ppl have 100 files and it doesnt mess up

slate swan
exotic kite
#

i have 2 and it wont function one, if i try remove one and try the other

#

the other works fine

slate swan
#

Instead of this

slim whale
slim whale
potent spear
maiden fable
#

yea

slim whale
maiden fable
slim whale
maiden fable
ashen aspen
slim whale
maiden fable
slim whale
slate swan
#

if anyone uses heroku what is the error of r14 (memory out of range) and is there any way to fix it or ignore it?

#

No bot needs admin permissions.

ashen aspen
#

I selected everything

#

but then I tried it with just administrator

slim whale
ashen aspen
#

and it still doesn't work

slate swan
slim whale
#

how u can add the bot with the dev portal?

slate swan
#

Register only needed intents and remove resource intensive features.

slate swan
#

Note that, the more your bot joins servers, the more it will use memory.

ashen aspen
#

I appreciate you trying to help 😄

slate swan
potent spear
slate swan
#

is there any free hosting platforms for discord bots?

#

Go to your developer dashboard.

potent spear
slate swan
#

Click on the application, so your bot.

#

Click on the "Bot" tab at the left.

ashen aspen
slate swan
#

And disable this

#

Then magic happens and your link works :p

maiden fable
#

Hahaha

ashen aspen
slate swan
#

No problem KryptonBlanket

ashen aspen
#

@slate swan By the way, love your username 😂

slate swan
exotic kite
quartz summit
#

How do i make my bot run commands

potent spear
potent spear
quartz summit
exotic kite
potent spear
potent spear
maiden fable
maiden fable
unkempt canyonBOT
#

@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").

By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") using utf-8 encoding.

All checks added using the [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
potent spear
#

if you give them these links, they'll never know how to find them without going to discord first

exotic kite
potent spear
slate swan