#discord-bots
1 messages · Page 733 of 1
thats why i copied the code from this onto that
What do you actually want?
I said where not how he installed it
Like this?
It takes from pypi in case you don't know, but sure
Then you need to set the embed author
!d discord.Embed.set_author
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.
name -> "User Left"
icon_url -> Avatar
url?
You don't need it
how do you install something from pypi but forget what pypi is??
May you stop? It's irrelevant.
of course it is, I just asked where they installed it from and they acted like they didn't know
They know how, but not from where. Not everyone knows PyPi is where libraries are taken from.
You're missing the embed.
And you need to specify name=
And you can remove url=Embed.Empty,
?
wdym im missing embed
It's embed.set_author
set_author is underlined because you aren't acting on anything
can you paste your code instead of a screenshot?
Not needed
1 more error
Which is?
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
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.
yea i think its not that part of the code thats effected
You need to read the JSON file content.
Well, you don't need to send pictures of that; you can show the error you get.
lol sorry
why arent the errors underlined in red
Just replace .txt with .json, it doesn't really matter as long as you keep the JSON structure inside the file.
Show the error you get in the command prompt.
What is the error?
Well, now you'd need to send the code of the entire command.
As the screenshot doesn't help at all in this case.
embed.set_author(name=f'{ctx.author}s Suggestion.'}, icon_url=member.avatar_url)
@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)
!code
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.
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?
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())```
Remove the underlined character
Yes
Because you haven't defined it
yes i did it is icon_url
Replace with ctx.author
How would i download FFmpegAudio on a virtual machine?
There are many tutorial for that you can find on the Internet.
ok thanks
Defining means
mmeber = ...
you never did that
bot is not responding
it would say it in my channel modlogs but i didnt recieve a suggestion
no errors
And in the cmd?
Yeah - what's your code now?
@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)
!code use this please
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.
hm
@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)```
TYSM also i understood everythingthanks for the info

why
if reason is None
Comparisons to singletons like None should always be done with is or is not, never the equality operators
changed it thanks
if not reason would be true even for reason = 0 , or reason = False , right?
shh
If you want to remove an else you can simply do
if not reason:
return await ctx.reply(...)
embed = discord.Embed(...)
[...]
🔪 why not just deal with required arguments with on_command_error

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())
examples/views/dropdown.py line 29
await interaction.response.send_message(f'Your favourite colour is {self.values[0]}')```
As you an see, it uses self.values[0] to get the dropdown value you clicked.
remove the ,
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.
!paste or this if it's too long
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.
no its clear from the code he gave
!e
a = 1,
b = 2
@visual island :warning: Your eval job has completed with return code 0.
[No output]
It's a list.
oh
tuple*
List
what
!e
x = [1, 2, 3]
print(type(x))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'list'>
!e
a = 1,
print(a)
@visual island :white_check_mark: Your eval job has completed with return code 0.
(1,)
List :)
tuple :)
A list of button objects :D
@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
As I said ^
https://github.com/Rapptz/discord.py/blob/master/examples/views/confirm.py here you can see how buttons work.
okay..
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.
its a thing in discord_components
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
yeah I totally agree, it exists in master branch and better to use forks instead of external libs
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
thats where dicts come into place 
but you can do this
!e
list_ = [
{
"a":1,
"b":2,
"c":3
}
]
print(list_)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
[{'a': 1, 'b': 2, 'c': 3}]
pretty sure a dictionary won't work in a method where it needs a list of Components 👍
Wdym by auto responder
can there be aliases with 2 words?
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)
It returns discord.ChannelType
its called on message event
!d discord.ChannelType
class discord.ChannelType```
Specifies the type of channel.
@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
this is the problem, thanks!
great
well, i enabled the intents but it still isnt working
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
.
what do you mean?
use a bot variable
the if statement u used is not true
!botvar
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!
Is ok I’ll check it out
what do you think i should do than?

Is it difficult to migrate from discord.py to nextcord.py ?
I heard that discord.py is discontinued
I'd recommend to use disnake.
You just need to replace all discord to disnake for everything,.
Example: discord.Embed -> disnake.Embed
which one is better ? performance wise
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.
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
Stars don't mean anything, you should never make up an opinion based on them. disnake get more, and fast, updates and its developers are much more performant.
i dont get reply on email
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.
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
In Python, it's True
if message.content.startswith(prefix + 'changeprefix' + newprefix):
await message.channel.send('Changed the prefix to' + newprefix)
prefix = str(newprefix)```
Also u can do if rightbutton:
how can I make it so that when i type .changeprefix / it changes the prefix to /
!d discord.ext.commands.Bot.get_prefix
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.
huh
await view.wait() why isnt this working?
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)```
I have the discord library installed...?
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
do you have the right interpreter selected?
say my bot dms someone, is it possible for it to grab the channel's id or recipients?
yor meant to have discord.py lib installed not discord
do pip3 install discord.py or pip install discord.py
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...
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
but why
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
do you get an error
nope
is the bot appearing as online
yes
Do you have message intents on?
!intents
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.
i think you turn it on in the discord dev portal
ok i'll try this first
anyone knows? i just looked at the results online and it seems like non of them edit old messages
its working but i don;t want to use prefix , i just want that it listen to every message that contain happy birthday
but its still unable to send welcome message
Then use an on_message event
^
I wanna make a bot like owo
can I get some help
maybe try edit with message ID
?
Not sure
this is ephemeral
can I get some basic codes
it isn't gonna save if newprefix is just a variable containing a string if you restart your IDE
wym
i know how to get the id, but i dont know how to use it in the code to edit it 
We don't spoonfeed
I want to make a bot like owo
can anyone say me what modules and what codes I need to write
you can fetch the message and then edit it
How do I check if a role on a guild is a bot-only role?
msg = ctx.guild.get_message(...) #get methods get stuff from the cache you have better luck fetching it though
await msg.edit(...)
ill check
basically check for the bots role?
and how?
he’s asking you
how can I check in which servers my bot is in
I want a stats command
anyone can help?
!d discord.ext.commands.Bot.guilds returns all the servers ur bot is in
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
@humble granite bot_has_role()
If I want to make an embed generator, like the user can make the fields himself, what's the best way to do it?
uhh don’t think you can do that
https://discordpy.readthedocs.io/en/latest/api.html#discord.Role.is_integration <== this checks if the role is managed by discord
Thannks
what command wil I write?
with decorator?
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
trying to figure that out, what am i supposed the put in the ()'s? the first one is the message id and the 2nd is the content?
so how will i write that
just like how you do any other command
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
kk
just wait for a message and then use the attachments attribute on the message object from your wait_for and then use the url attribute on that
Is there any way of having more then 3 fields inline on a discord embed?
Not that I know of.
msg = await bot.wait_for(...)
var = msg.attachments[0].url
``` ^
^
SyntaxError: invalid syntax```
error @slim ibex
you can’t just put discord.Guild
you cant set/use an attribute of something in a parameter
then>
it has to be connected to a parameter
how pls send example
guild: discord.Guild
Anyone know if its possible to have more then 3 fields inline on a discord embed? 😄
^^^^^^
SyntaxError: invalid syntax```
Only if you are using cogs
@slim ibex
guild.guild?
bro I can't really understand
I don’t think it is
just say it to me with example
async def stats(ctx, guild: discord.Guild)
and after that?
property guilds: List[discord.guild.Guild] this?
to be honest, you should know what else you need to Create a stats command for your bot
sheesh
me nub
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()
I have just started it
ur not gonna write it for him?? wth
what are you making
No, then he won’t learn
a simple bot
sarcasm bro
simple but u can’t do it?
did you read docs of discordpy
say it rn
not fully
You need to fetch all the guilds your bot is in along with all the members and put that into a message
"not fully" means how much?
that’s all I will say
and what will be the code for that?
lol
monke moment
umm
lemme think
I cant
@slim ibex help
pls
💀

pls
say me bro 
say me
@slim ibex
did anyone use mongodb for custom prefix?
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.
I can't yet understand
What do u not understand?
scroll up
uh

name of all guilds?
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
I wanna make a command if I use that command it can show me the name of alll guilds
yeah
@slate swan
^^
how are u making a whole bot if u dk how to write this simple thing
I want a full example buddy I am beginner
I made the bot with ban kick and responder commands
why this make my bot doesnt answer all cmd?, im making custom prefix with mongodb
hence why nobody gave him the full answer yet
decorators?
why are you running it in sync
wait wht?
it should be async
yeah
bruh dpy is an async lib why are u using sync
also, why mongodb
async def
use sqlite or postgres/mysql
use that
mongo = bad
why? because i dont like it




just use motor if you want to mongodb
hey guys
help me
i dont know what im doing rn
im not gonna bash you, but you seem to be overcomplicating your code here. what is your intent
I am here since last 10 mins ig
not using intent at all
thats not what
the getprefix function takes bot as the first argument
lol
so i have this code py for i in perms.keys(): overwrite = discord.PermissionOverwrite() overwrite.(i) = perms.get(i)
you already got your ans. above
is anyone gonna help me?
yea, but im need the message
;-;
your issue?
weird
eh wait

you would be getting both
^^^
that nobody is writing his code for him
scroll up
no
why?
so the user inputs a dict of perms, and it loops through the keys and sets the permissions of a role to the perm key.
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
Is there any way to have more then 3 fields inline on an embed with discord.py
!d discord.ext.commands.Bot.guilds
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
my discord's laggy
uh wait , so first it was bot, message right because im saving it by guild id
then what the bot for?, it shown not acessed
I used it but I don't know how to use it
yeah , do you get any errors tho?
he's confused how to show all the items of a list 😐
(not mine)
async def get_prefix(bot, message):
guild = message.guild
# you can do something here with the guild obj, open a file and return something different per guild
default_prefix, custom_prefix = '.', '>'
return [default_prefix, custom_prefix]
learning mongodb takes 3hours and now i need to change
Is there any way to have more then 3 fields inline on an embed with discord.py??
async def stats(ctx, guild: discord.Guild):```
use sqlalchemy if its sql, i dont know much about mongo
iske baad kya likhna hai @slate swan
why are you even using guild parameter
those anybody know how to fix it?
blinds said
are u watching a tutorial? @slate swan
nope
so go watch one
"Bot is not in a vc"
but it is
so u know what type hinting is but u don't know how to show items of a list??
its connected
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
I made a new year resolution I am not gonna watch tutorials they r just shit
error says something else
ya
i dont understand wym
u r not indian?
are u crazy? why do that when others can write it for you
I meant what I have to write after that
i am , but still
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:)
I'm confused if that's sarcasm or not but I'm guessing it is lol
hehe
intents enabled?
!intents Enable the members intent and keep your code
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.
bruh r u triggering me?
hm , commands.Bot is basically your bot object , you gotta use the .guilds object to get the list of all servers ,
next you would be looping through all the guilds and use .name property on them
i thought i enabled let me double check
no idea
Make sure you enabled in developer portal and code.
!ytdl
its only for me
ah, i’m not enabling in code that’s why. thanks so much!
why?
No problem
Because of that @slate swan
its a local file
No
atleast seems like that to me , song.mp3
Look the code closely.
oh
ytdl.download()
nvm
nvm then , im high
bruh all of it just went above my brain
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
if a message has a video attached, I can get it by message.attachments right?
@slate swan is this right?
Why intents
@slate swan bruh can't u help me writing that code
pls..............
no

yes
pls............
your "await ctx.guild.unban(user)"
is one space foward.
did i need to class it on main.py?
nah , that was just an example why it needs bot
just let the bot arg stay there even if u dont use it
bro whats your issue
bro im working with this error 2 hours straight
stop begging people to write and spoon feed you code
whats the error
ill spoon feed him if it shuts him up
not responding
what if I pay them?
LOL true
ill do it for sure then 😄
chanhe your functions argument first py def function(message) -> py def function(bot , message)
greedy
nah wait maybe ur onto something
doneee
I am just 14 I can't really pay u
why are you in a server about programming, if you dont want to learn.
I wanna do that
How can I check if a discord.User has the Online status?
ok, tell me whats your issue
for the getprefix function right , now try running it
I wanna make a stats command for my bot
which I am unable to do
ok 2 mins of builds
;-;
it could be bout my mongodb too
ahh

users dont have a status , members do
!d discord.Member.status
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.
ok, can you be more specific.
what’s the d prefix for?
docs
ty
its actually a command alias
sorry for not being technical
I just want that if I send +stats The bot must give me the list in which it is in....
he is correct in saying its a prefix
stats on what???
still not showing anything
! is the bot's prefix d is a command.
every time the bot is joined to a server add the servers name to a list and then send that list when the bot recieves +stats
I just want the list of servers in whch my bot is in
any errors in console?
clear
await ctx.send(client.guilds)
well tbh if you want a actual list of names:
server_obj = client.guilds
names = []
for x in server_obj
names.append(guild.name)
await ctx.send(names)
How do I check if message.attachments is a video, not an image?
could’ve watched a yt tutorial in the time you’ve been asking
@slate swan ignore those yaml
I just have 20mb data network left
!d discord.Attachment.content_type
The attachment’s media type
New in version 1.7.
google then
can you try printing data
done
intents = discord.Intents(members=True)
client = discord.Client(intents=intents)``` is this correct?
nothing shown
thnx
and...what's the content type of a video?
do you think this is bout the database?
didn't got answer on stackoverfow
just "video"
so , the db does not return anything , the prefix is set to ?
you know this is a bad implementation, right?
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.
you know why it fails, right?
i think yes
error @slate swan
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
no it doesnt respond the setted prefix and when i mention nothing happend
please don't fetch from a DB whenever you need a prefix, you can't go any worse
so custom prefix is a bad idea?
no, your implementation is just bad
oh ok
ever heard of a botvar?
nope
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
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
^^ this function is sync, which is good
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"
give me a sec, i will literally write it for you lol.
ok" i wanna make it more listed too
thnx buddy only u r generous here others r trolling me ;-;
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
?
Noice!
just check your errors...
also Givaways?
any special role?
@slate swan if u complete the code just dm it to me
No errors.
Oh ** my keyboard sucks
any error handlers?
i cant think that far
you'll have to
your db lib also isn't async
No
try to only create the voice channel
i think i need to change to motor
chances are, maybe it's already there
idk, I don't use mongo or whatever it is
intents = discord.Intents(members=True)
client = discord.Client(intents=intents)``` is this correct i’m using discord.py
no
you're only enabling the member intents that way, not the others
yeh ikr
@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
so what should I do?
just check where the code goes, simple debugging mate
damn my discord just lagged
from discord.ext import commands
TOKEN = ""
client = commands.Bot(command_prefix=".")
@client.command(name="test")
async def test(ctx):
activeservers = client.guilds
names = []
for guild in activeservers:
names.append(guild.name)
await ctx.send(names)
client.run(TOKEN)
intents = discord.Intents.default()
intents.members = True
Works... but only the category doesnt creating.
as you see in the code i send there is only categories all the categories creating other than the "Voice" category
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.
no comment
maybe there's already one OR that's a default one idk
That's faster too
Nope
just paste your code in https://mypastebin.com/
I'll check it out
I would have did that since it's shorter to write too
!paste
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.
either way, he has his code now
or that
you're overwriting your command with your function, do you realize that? they have the same name 🧠
and why don't you be smart and just put it in 1 function?
I did pip install discord already how to fix this?
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
Ah? explain
delete line 4 and line 9
put line 10-34 in function on line 3
these lines are based on what you sent me
restart vs code if you opened it before installing dpy
ah
Why line four?
from __init__ import simple
please read what I type, will you?
Same error still
Please help mEE
Im importing the function from another file..
i think u py -m pip it
I did pip install discord
its pip install discord.py
read what I type, then I'll help
Do it in vsc
Already installed it says
it's the same discord or discord.py
Yeah that is the same
I know. i read this. Im doing this cause its more cleaner
weird
go settings then type venv
Settings of? vsc?
then try py -m pip install discordpy to got venv file
ok, what did I tell you to do?
yea
Did
this
like this?
HOw to edit a message on button click without getting the This interaction failed error
and just copy to there
please help me
for me its work
Ah
paste the file dir
Can I set a video for embed.set_image?
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
get it from py -m pip install discord.py
help
XD i just get that problem yesterday
do you actually know what you're doing?
Ah okay
I know dyp that is not the problem for me
you can't
yeah I want the names of the guild in which my bot is
Never MInd i think i got it
Well. it works now, so how can i make it work from importing it?
any workaround?
I have reset my pc like 1 week ago and forgot all the python stuff
just remove the guild parameter and you're done
it save some mb lol
Alright, but I am in the settings with venv now yeah.
what did you change?
What you said
show me the new code
I am here now
videos on discord can only be sent by uploads or links, not supported in rich embeds
holy shi
What?
not like thatttt
Oh sorry
u need to type on the...
terminal then powershell
yeah finally after an hour with the help of @slim ibex @slate swan @slate swan @potent spear I got my code done
I don't get what you are trying to tell me sorry.
u click terminal then choose powershell, then type py -m pip install discord.py
lovely, and now one last thing
when you create a category, the function returns the category object
so you can store that as a variable
you know what to do with this info?
ooooh
it will shown a error that lib arl downloaded and show the filepath
thnx guys @potent spear @honest shoal @slim ibex @slate swan @slate swan
just copy those filepath and put it there
What filepath?
From my project folder?
thoseeee /D
Ah i guess, idrk english and google translate is bad
bruhhhhhhhhhhhhhhh
I just don't understand what you are telling me
my bot is done now it's time to make token account joiner
I'll show you
instead of
await guild.create_....
categ = discord.utils...
you can be smart and do
categ = await guild.create...```
token account joiner?
wth is this
selfbotting!?
yeah I will enter the tokens and the server link it will get the acc get joinede
nope
;-;
That is self botting
with
categ = await guild.create...
I can make like 5 categories at the same time?
its self botting
lmfao I will not do that then
I thought its not the hell it
but its a holy shit
np
not really at the same time, you just save yourself a line because you can get the category object instantly returned after creating it
thnx for the advise
Ok thx
is self botting illegal?
not "illegal" per say, but yes it's against ToS
^
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Command' object is not subscriptable WHAt hell is this?
Lets see the code
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?
here is the code
start using an async wrappe for that db asap
that's not the issue you're facing tho
How do I fix this,
your parameter typehint is completely wrong, you silly
I don't understand?
I speak english tho
Which line bro
you should know what a parameter is
ok
will do, but do you know why it might not be inserting?
I guess you might have to commit too?
I don't work with mongo or whatever it is
you should really check out documentation man
there's more wrong with his code, found out later
first install the library
always check out documentation PLS
.
you have module not found error, ofc
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
import discordpy
i seen on youtube
its import discord
oh thanks @near sedge
if it still gives you errors double check its actually installed using pip
Is there any way to have more then 3 fields inline on an embed with discord.py??
I don't think so. It's a discord thing
@maiden fable Okay, thought so just thought id ask 🙂
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)```
Why don't you try it?
i have
Hmm I get the problem
U r muting first, and then seeing if the author is muting himself
Its that you're using camelCase
that's just you fucking up indents
!indents
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
Language
calm down?
Yea
fucking or messing things up, same thing
nah
so do i indent or unindent
Any help?
Indent
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).
await view.wait() why wont that work?
I smell Lucas 
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'disnake.ui.view' has no attribute 'wait' this is the error
U need a View class instance
anyone know how to make a custom help command?
view != View
like
!custom-help
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
!help <command_name>```
See the link (:
its from google tho
Okay?
nvm my fault
Bad One
lmao
i prefer to use ID's
Everyone does
User ID's don't change while usernames can
why does lucas even bother to teach people to use their usernames?! what if it contains invalid chars?
¯_(ツ)_/¯
Yeah, best is to follow the tutorial in its entirety if you don't know what the code even does.
Because his tutorials are known to be the worst you will ever find on YouTube.
i just used it many times earlier and forgot to use it rn
like those really insecure people that constantly change their usernames
why lucas? why?
I have my username since 2015 
and the comments section of the vids just disgusts me
well I dont know him I follow "Code With Swastik"
yeah
he least made me learn a lil of python
client = discord.Client() i think
hey love your bio! It just, pops in (get it?)
ik thanks
I made it for myself and it also helps me out
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
I guess an event, if there are some for buttons
just set timeout to None
any alternative ?
no
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
I don't really think so, as long as the users know
I'll make a disclosure
Also, how bad would it be to have synchronous code running in my discord bot?
Can I make a bot where it assigns a role across multiple discord servers
but if someone click on the button first time the next time it wont work right ?
because it have finish waiting
too bad
if you can't find an async wrapper, you can always run_in_executor
what should I use to make it work after the first click
run_in_executor?
google about it
it will
!d asyncio.loop.run_in_executor
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:
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 ?
Could I have a quick code example?
Actually never mind
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)
wait wait wait
why not use bot.users?
!d discord.Client.users
property users: List[discord.user.User]```
Returns a list of all the users the bot can see.
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
for role in guild.roles:
if len(role.members) == 0:
await role.delete()
also check your intents
the problem is, most of the roles get displayed as having 0 members in them
the members intent has to be done on the discord developer page, correct/
How do I invite my bot?
yea
go to discord dev portal, OAuth2 and url generator
@maiden fableoh, when i do the intents, do I have to enable the intent on the discord developer portal and in the code?
Yes
It doesn't work
!intents will help u better (:
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.
Or bot permision calculator, u put the bot id and copy the link
i always do that xd
it is now working, I didn't have ```py
intent = discord.Intents.all()
client = discord.Client(intents=intent)
I don't understand
When I have 2 channels here in replit, it only functions one, anyone knows why is that? If you do pls tell me
isn't this good
A small calculator that generates Discord OAuth invite links
How to mention someone like this?
in client id put the application id, and select the permissions you want
member.mention
yes, i just didn't know that I need the intents enabled on the developer portal and in the code.
ah now u know (:
pls answer guys im worried
just member.mention or "{member.name}#{member.discriminator} (idk what u exactly want)
It says
you have to ask better questions to get better answers
channels?
files* just help pls why wont it not function the other one
did u put the bot id?
Yes ofcourse
can u just help im new
some ppl have 100 files and it doesnt mess up
I just want to mention someone in a embed
i have 2 and it wont function one, if i try remove one and try the other
the other works fine
Instead of this
in author you cant
this id?
str(member) will show what you want
yea
^
that is the same as the bot ID in 99.9% of cases
yes but the but isnt in any server
soooo?
Yes
i dont know what i said bro XD, sorry
haha its fine
did it like this?
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.
No
I selected everything
but then I tried it with just administrator
Yes but he wants it xd
and it still doesn't work
Your bot is using too much memory (512 mb).
All you can do is make your bot use less memory, depending on the feature it has. Or simply stop using Heroku because as you can see it's very limited.
i dont know why, sorry
how u can add the bot with the dev portal?
what are the ways to use less memory?
Register only needed intents and remove resource intensive features.
hmmm so making bot.group commands will help to reduce memory usage?
Note that, the more your bot joins servers, the more it will use memory.
soo I guess its switching time
I'll just write it, if you really want me to
Very simple
is there any free hosting platforms for discord bots?
Go to your developer dashboard.
GCP and AWS (1 year trial)
K, go on please
Hahaha
Yo thx man
No problem 
@slate swan By the way, love your username 😂

yes plss
How do i make my bot run commands
you have to understand the concept of commands first, because you obviously don't
the documentation has examples
will you link me there?
so u write it from replit or give me code?
google has links too 😉
I don't use replit, it sucks too
breh
!d discord.ext.commands.command
@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.
if you give them these links, they'll never know how to find them without going to discord first
gimme code then?
nah, I'll tell you what you're missing, I don't spoonfeed
https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html is actually better for a guide on how to create commands

