#discord-bots
1 messages · Page 577 of 1
don’t tell me ur using replit 😔
keep_alive maaahn 
i would say it's an online vscode
why not remove it 
just a bad way to keep your bot hosted lol
useless code should be removed, like defining something more than once when its not needed
You should not use Repl.it to host your bot.
While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:
-
The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
-
You need to run a webserver alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
-
Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
-
They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Please avoid using repl.it to host your bot. It's not worth the trouble.
See ?tag vps in #381963689470984203 if you want a list of decent hosts (there are no free hosts).
Understand, don’t memorize.
oh
so what should i use then
not heroku
vps
aws
or you could pay for hacker mode and your repl will stay online 24/7
money money money
didn't try it btw ,
AWS , if your planning to buy, still would say AWS
my friend had it , still sucks
If you really pay money, why repl, ew
i used GCP
somethin thats free?
AWS dude
alr thanks
Needs credit card
yeah that's one issue
sure but it doesn’t cost anything
And only 1st year is free
only
after that year you have to pay 10+ $ to host
if they are going to switch to a vps then why not rn?
??
your getting a year free in a good service, why pay for more?
so vps is the best choice
a raspberry pi
vps is digital ocean right ?
but for now use AWS or whatever u wish
alr arl, ty
digital ocean have vps plans
vps = virtual private server
vps is a virtual private server, which can be anything, digital ocean is one option
not really, its a site that provides the server
what i need put instead of this yellow frames ?
oh ok
async def unmutetime(self):
for key in self.blackList.keys():
guild = self.bot.get_guild(int(key))
try:
for key in self.blackList[guild].keys():
userid = key
user = self.bot.get_user(userid)
print(user)
msgid = self.blackList[str(guild.id)][key]["msgid"]
chid = self.blackList[str(guild.id)][key]["chanid"]
time = self.blackList[str(guild.id)][key]["timeleft"]
except KeyError:
print("returned")
return```
how can i get the 69494... number?
haven't really used it before
it prints returned
3rd party libs ?
2.0
no
send docs
wdym yellow frames
sorry for ping
disabled which highligted with yellow
i do
can u help with photo on the top?
what do you want to do tho
pagination
anyone
show the full dict
I mean disabled attribute is used for disabling a button, what else are you looking for instead of that
class Pages(discord.ui.View):
def __init__(self, author: int, embeds: list):
super().__init__(timeout=None)
self.embeds = embeds
self.author = author
self.embed_count = 0
@discord.ui.button(label='left',
custom_id='1',
style=discord.ButtonStyle.blurple, disabled=True)
async def back_page(self, button: discord.ui.Button, interaction: discord.Interaction):
if self.author == interaction.user.id:
self.embed_count -= 1
embed = self.embeds[self.embed_count]
if self.embed_count == 0:
self.children[0].disabled = True
self.children[2].disabled = False
embed.set_footer(text=f"Page {self.embed_count + 1} of {len(self.embeds)}")
await interaction.response.edit_message(embed=embed, view=self)
@discord.ui.button(label='right',
custom_id='2',
style=discord.ButtonStyle.blurple, disabled=False)
async def last_page(self, button: discord.ui.Button, interaction: discord.Interaction):
if self.author == interaction.user.id:
self.embed_count += 1
embed = self.embeds[self.embed_count]
self.children[0].disabled = False
if self.embed_count == (len(self.embeds) - 1):
self.children[2].disabled = True
embed.set_footer(text=f"Page {self.embed_count + 1} of {len(self.embeds)}")
await interaction.response.edit_message(embed=embed, view=self)
if u need
"824359600584523876": {
"331829647568535563": {
"timeleft": 10.0,
"msgid": 905560108916944947,
"chanid": 826871393617969233
}
}
}```, ignore the last pic. how to get this `331829647568535563` its a user id which i am tryin to get and convert back to user.mention
uh
that dict doesn't look right
@waxen granite try printing this:
check = self.blackList[str(guild.id)][key]["331829647568535563"]
async def unmutetime(self):
for key in self.blackList.keys():
guild = self.bot.get_guild(int(key))
try:
check = self.blackList[str(guild.id)][key]["331829647568535563"]
print(check)```
prints returned still
ight, remove the try\except
check = self.blackList[str(guild.id)][key]["331829647568535563"]
KeyError: '824359600584523876'```
yea theres something wrong in that dict
wdym wrong?
can i give it as member name?
what are those ids?
@sick birch following up on our convo yesterday .... when you get a minute, I'd be interested in picking your brain on extensions. I did some light reading on cogs vs extensions and it said that extensions are used in cogs, but i didn't find anything useful on how extensions would be set up that is different than cogs. I did find that extensions are useful because you can load and unload them (maybe the terms were pack and unpack, i'll have to look again). Anyways, it was cool because it allows you to keep your bot up while changing a few commands/cogs at a time.
I'd like to ask you some more questions to make sure I'm on the right track, to learn about better bot designs (I really don't like one linear file when coding larger projects - clutter annoys me), and what other resources you would recommend looking into. (I skim read the pinned messages already and know what is there in case if I need it).
If others have thoughts, then just tag me so I can find your comments easier. Thanks.
what questions do you have
https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be this is a pretty good example of how to use cogs
looking at the docs of it is also good to get more info about them
using extensions, you can hot-reload
https://stackoverflow.com/questions/53528168/how-do-i-use-cogs-with-discord-py was a helpful resource on converting things to cogs
thank you, ill look into it
yea then store it as userid or anything you like
is cogs the best way to structure a bot?
sure
i did no?
how do cogs and extensions differ?
index it as userid
!e
test = {"userid": 675414248620294154}
print(test['userid'])
@kindred epoch :white_check_mark: Your eval job has completed with return code 0.
675414248620294154
do you see what i mean
ye but@kindred epoch
i am saving them as userid because there will be multiple users
@kindred epoch i skimmed over your link.... thanks, im definitely going to be digging into this in a little. it looks really useful
multiple users in the same dict?
then make a new dict under the same guild id
and that is exactly why you use a database
ye then whats the problem
331829647568535563 and 282859044593598464 are userids
i want to fetch them
from dict
at this point, im just gonna say use a database, databases are made for this
@sick birch you prefer DM or want to keep talking in discord-bots channel? or start a help channel?
well i have to learn it from scrap, can u think of something from this only? pls
i would prefer a help channel for that
ok 1 sec
i'm playing something rn, keep it open, i'll join in later
then you'll need to index them as something to get them
yea
why didnt you just do that
if you could get the guild id then why didnt you do the same thing with user id
what does it print
i have t even in my code already...
it prints returned
its not able to do the try part
for key in self.blackList[guild].keys(): KeyError: <Guild id=824359600584523876 name='MecHaNiC Bot Support' shard_id=None chunked=True member_count=23>
send whole error
Traceback (most recent call last):
File "C:\Users\Endomorph\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "D:\Discord Bot\GitHub\ecrpgbot1v2.0\cogs\moderation.py", line 126, in unmutetime
for key in self.blackList[guild].keys():
KeyError: <Guild id=824359600584523876 name='MecHaNiC Bot Support' shard_id=None chunked=True member_count=23>```
what does this print? ```py
for key in self.blackList.keys():
guild id
824359600584523876
wait why are you indexing it by guild obj
no
How can i access the bot object inside a custom function ?
then how?
no idea honestly
How do I make embed fields? Whenever I use them, I receive this:
-'Embed' object has no attribute 'set_field'
What happened to them? Did they get removed?
its add_field
!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.
Ah the full thing is needed
Ohhh
Well, the docs command isn't for just discord.py, but for other libraries too.
!d pymongo.MongoClient
pymongo.MongoClient```
Alias for [`pymongo.mongo_client.MongoClient`](https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient "pymongo.mongo_client.MongoClient").
Yeah, I'm used to rdanny's rtfm command
Bot.get_prefix is a coroutine function that takes a message
That was an example for me
Now it says
-add_field() got an unexpected keyword argument 'title'
Is it title or something else
It takes two required kwargs, name and value
It's name.
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
!d discord.Embed.add_field
ah ok
When a user sends an inexistant command, how do I catch the error without it popping up in terminal?
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "tax" is not found```
I'm slow. Damnit.
thanks
The on_command_error event
ah alright thank you
Make an error handler and return when the error is CommandNotFound.
Shouldn't consume all errors though
This should help:
Not getting an error, but definitely should be?
Do you also have an on_command_error set up?
Please make sure to look at, and implement,** the 3 or so lines starting with 'else'** in the example below. Without this code or similar, your error handler is eating all unhandled errors. As you can imagine, this is bad when you get an unexpected error.
https://gist.github.com/EvieePy/7822af90858ef65012ea500bcecf1612
(So you know what to avoid doing)
👍
File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 1062, in change_presence
await self.ws.change_presence(activity=activity, status=status, afk=afk)
AttributeError: 'NoneType' object has no attribute 'change_presence'
anyone know what this mean
You're trying to change the presence before the bot has connected to the gateway
See the activity and status kwargs of the client constructor
!d discord.Client
class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
if user_message.upper() == 'Ratio':
await message.add_reaction('👍')
return
not working, plz help
How can this ever be true if user_message.upper() == 'Ratio':?
Lmfao
"Ratio" is upper
🤣 👌
The first letter is yeah
Ye
!e ```py
print('These are words yes'.upper())
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
THESE ARE WORDS YES
what will work then?
You can do this though
.lower or .upper wont work
if user_message.lower().capitalize() == 'Ratio':
ohh ty
But why?
AttributeError: 'str' object has no attribute 'capitalized'
remove the d
if user_message.lower() == f'*epicgamer':
embed = discord.Embed(title="epic gamer rate",
color=0xFF5733)
embed.add_field(name=f"You are a {random.randrange(100)}/100 epic gamer", value="", inline=True)
await message.channel.send(embed=embed)
return
it's not working
In embed.fields.0.value: This field is required```
value can't be empty
Uhm, is there a way I can get an emojis id?
for an animated emoji cuz i don't have nitro
Why does it say not found it is odv in the dir https://cdn.discordapp.com/attachments/727982024660615198/905602875839877190/Screen_Shot_2021-11-03_at_7.42.14_PM.png
I find it so dumb that I got ratelimited for restarting my bot twice in a couple seconds
Anyone understand reaction role embed?
replit?
if so just get a real host ez
how do i put commas there??
@client.command()
async def suggest(ctx, *, info):
em = discord.Embed(title=f'Suggested by {ctx.author}', description=f'{info}', colour=discord.Colour.red())
em.set_thumbnail(url='https://cdn.discordapp.com/emojis/652589643543609364.png?size=96')
await suchannel.send(embed=em)
is there any error
Any suggestions? Creates embed but wont assign the role
async def react(ctx, *, message,):
embed=discord.Embed(title="Reaction Roles", description="React with the corresponding emoji to get the role", color=0xff0000)
embed.set_author(name="SDN1")
embed.add_field(name=':thumbsup: ', value="Verified", inline=True)
embed.set_footer(text="SDN2")
msg = await ctx.send(embed=embed)
await msg.add_reaction(':thumbsup: ')
def check(reaction, user):
return user == ctx.user and reaction.message == msg and str(reaction.emoji) in [':thumbsup: ']
while True:
reaction, user = await Bot.wait_for("reaction_add", check=check)
if str(reaction.emoji) == ':thumbsup: ':
mrole = discord.utils.get(ctx.guild.roles, name='Verified')
await user.add_roles(Verified)
print ('gave a role to someone')```
tell me pls
!e
print(f"{1000:,}")
@kindred epoch :white_check_mark: Your eval job has completed with return code 0.
1,000
Its @bot.command() and in def check() add async as so async def check()
Still spits out the same error? AttributeError: 'str' object has no attribute 'id' @slate swan
but i'm getting it from a db can u explain more
nvm i got it thx u
in this function, you try to call the .send() method on suchannel, but suchannel isnt a thing, it does not exist in this code?
wait_for checks can't be async
Where exactly
Really?
yes
I thought they were
Makes more sense now
Wonder why async checks aren't allowed
Like your pfp
Idek why
can someone help me with a check for my wait_for("message")
I do know that wait_for creates a future and then the dispatch system will handle it but since its inside of a regular method you cannot await the check
Although I think you can use create_task
Might cause some problems though
they can't work with the current system
Is there a specific reason for that
def check(ctx):
return ctx.message.author == ctx.author
``` and then put that as my check=?
seems like it's because they aren't necessary
(ie you can call the async functions to get whatever information before you call wait_for or after, outside of the check)
interaction = await client.wait_for("button_click", check = lambda i: i.component.id in ["text", "save"])
if interaction.component.id == "text":
await interaction.send("Please insert a message")
m = await client.wait_for("message", check)
thats my thingy rn
i need help with the check at the bottom
everyone this is gonna be stupid but can anyone tell me a raid command?
No
Against tos sorry
oh srry ddint read it
!rule 8 i think
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Yea that makes sense
and also https://github.com/Rapptz/discord.py/blob/master/discord/client.py#L372-L390 (dispatch is sync and everything that calls it is in a sync method)
?
I did mention that and I feel like maybe you can check if the check is a coroutinemethod via inspect then self.loop.create_task and check if task.result() is truthy
Although just a thought Idk if it will work
i dont think that works
I cba to try ¯_(ツ)_/¯
You would need to create an event loop or set one then do it
Or you can just use don't think you can use asyncio.run hereasyncio.run
lol
am I using this wrong?
@client.command()
async def warning(ctx):
await ctx.send(f'Hey {ctx.author.display_name}How should I dispose of the evidence?!')
before you ask any weird questions it's for a security bot part of the function of removing content that infringes rules
Well its indented
wait....I have a few others that are indented it didn't affect it. hmmm or maybe it did and it picked this one up first lol
I got this after un indenting
and no im using pycharm right now.....
File "C:\Users\abrod\PycharmProjects\Discord_Bot_Phantom\discord_bot_phantom.py", line 23
await ctx.send(f'Hey {ctx.author.display_name}How should I dispose of the evidence?!')
^
IndentationError: expected an indented block after function definition on line 22
What did you unindent
I am not use to writing discords bots so I apologize if I am making a ton of newb mistakes here lol
I undented the await line
Is your client.command indented
The original bot maker is out of town this week and I am trying to go by his instructions but....lmao
Thats why i told you its indented
can someone explain to me what intents are, why are they involved in user's privacy, health
!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.
!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
it's more about computational strain rather than user privacy, though i guess it could be used for malicious purposes
can someone help me pkease
thank you lol sorry wasn't ignoring was talking to another user as well.
sure
What’s the wait_for method?
it waits for an event to be dispatched
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Everything's explained pretty well
yep, and it has examples too, if you open the page
is there an attr to display a guilds icon if the guild doesnt have an icon

no there is not
Try seeing if guild.icon is None?
Idk that just sees if there is no icon, nothing else
ok
Guilds without icons have nothing in the response JSON, so nope

Yeah but those examples dont really explain what i want my bot do to
what do you want to do?
yes
Ik it can
yeah
The first example does apply for you, maybe modify the check to check for author too.
await bot.wait_for('message', check=some_check)
just wait_for a bunch of messages lol
First let me make the command and see how it works
alright
Dm if i have a question?
My DMs are not open, no. Ask here or in .gg/dpy
even my about-me says so bc i get so many DMs from randos from the dpy server 🥴
@bot.event
async def on_member_join(member):
async with aiohttp.ClientSession() as session:
async with session.get(
f'https://some-random-api.ml/welcome/img/6/stars2?key=key&username={member.name}&discriminator={member.discriminator}&avatar={member.avatar_url}&type=join&guildName={member.guild.name}&textcolor=white&memberCount=23') as af:
if 300 > af.status >= 200:
fp = io.BytesIO(await af.read())
file = discord.File(fp, "welcome.png")
em = discord.Embed(color=0xf5ccf7)
em.set_image(url="attachment://welcome.png")
await member.send(embed=em, file=file)
await session.close()
when entering the server, the bot does not send anything
@boreal ravine
Do you have the members intents enabled?
yes
And why do you check if the status code is smaller than 300 but bigger or equals than 200
Makes no sense at all
Just check if the status is 200
And just to make sure, you've enabled the intents in the developer portal and in your code right?
Getting this error (Command raised an exception: AttributeError: module 'discord' has no attribute 'SelectOption') when trying to get drop downs to show. Using cogs.
from keep_alive import keep_alive
import os
from discord.ext import commands
from settings import *
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!!'))
for filename in os.listdir("./cogs"):
if filename.endswith(".py") and filename != "__init__.py":
bot.load_extension(f'cogs.{filename[:-3]}')
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}.')
keep_alive()
bot.run(os.getenv('TOKEN'), reconnect=True)
=============================
Menu.py:
import discord
from discord.ext import commands
class Menu(commands.Cog): # Category type is the class
def __init__(self, bot): # using self bc using class
self.bot = bot
@commands.command(brief="Provides a menu of all Bot commands")
async def menu(self, ctx):
await ctx.send(
content = 'Select an option:',
placeholder='Please select an option.',
Options = [
discord.SelectOption(label='Option 1', description='This is option 1', value='1'),
discord.SelectOption(label='Option 2', value='2'),
discord.SelectOption(label='Option 3', value='3'),
discord.SelectOption(label='Cancel', value='Cancel'),
],
custom_id='MainMenu'
)
interaction = await self.bot.wait_for('select_option', check=lambda inter: inter.custom_id == 'MainMenu' and inter.user == ctx.author)
res=interaction.values[0]
if res == 'Cancel':
await interaction.send('You have canceled your select option')
else:
await interaction.send('You have selected %s option' % (res.label))
def setup(bot):
bot.add_cog(Menu(bot))
Does the discord.SelectOption need to be coded differently in a cog?
it compiles fine, but doesn't execute the drop downs
You have not installed discord.py 2.0
$ git clone https://github.com/Rapptz/discord.py
$ cd discord.py
$ python3 -m pip install -U .[voice]
ok, ill check on my version
how cna i get member using its id?
looks like a third party library to me
bot.get_user(id)
user doesnt have att remove_roles, how can i fixthis? i am trying to remove a role from the user
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
Don't need to ask here and in a help channel, just ask in one place..
did you install it
o
Yeah, people do be impatient
Use guild.get_member() or await guild.fetch_member()
As I said, exactly what I wrote
The member is not in the bot's cache so get_member returns None. If you use
guild.get_member() or await guild.fetch_member()
It will first try to use get_member and if it returned None then it will try fetch_member which will work fine
It should not always be used though, therefore my solution
You should always try to get from cache first, and only then use the API call
ye
from googletrans==4.0.0-rc1 import Translator
i only want to import a certain version
how do i do that
this code is wrong
??
how do i correct it
do pip install module==version
module is the module name and version is the version you want it to be
what
what IDE are you using
ya replit
then thats the problem
then is there anything better i can use
a proper IDE
that return should have worked no?
to host a 24/7 discord bot
this
so what ide whould i use
a proper IDE
ok
that isnt a VPS?
is heroku
wdym
uptime robot isnt a vps
then
a VPS
its a website pinging service
Heroku
- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator. - Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case. - Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay. - Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal CPython extension functionality. (This is the reason why voice doesn't work natively on heroku.) - Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
yes a "website"
ok
help
but theres that disavantage
thats a big one
the limited amount of time
Every free hosting has disadvantages. If you want quality you need to pay, as simple as that.
Welp, please don't ask for Free Hosting Services here again haha
can we use an emoji in thumbnail in an embed?
Last night there was literally a civil war debate on Raspberry Pi vs VPS
Yes, get it's URL
I don't think so. U need to give the URL
U can't directly do :happy: or something
async def on_message(message, channel):
channel = client.get_all_channels
if message.content.startswith('hello'):
while True:
await channel.send("hello")```
how do I make it so that if I say the command word
a message gets sent in every channel
That's spamming?
no
any help with this?
if you say goodmorning
It kind of looks like one
Loop the channels
i know how to spam🙄
I guess, we should just help him Nipa. Won't be surprised when he is rate limited 😐
property text_channels: List[discord.channel.TextChannel]```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
dont know what that means
example please
for channel in ctx.guild.TextChannel:
``` not 100% sure if it's correct but you get the point
ctx.guild.channels
anyone?
oh
Will it give voice channels as well?
Why are ppl asking many questions u guys should go learn some python first
Yes
Yes, just check it's type with isinstance
I think I should be only text channel
ctx.guild.text_channels*
Why not just use ctx.guild.text_channels? Lol
What?
@cosmic frost use this
kk
Uhhhh?
async def on_message(message):
if message.content.startswith('start spam'):
while True:
await message.guild.create_text_channel("spam channel")
async def on_guild_channel_create(channel):
while True:
await channel.send(random.choice("bum do"))``` this is spamming
wouldnt have asked if i already knew
not tryna spam
Won't work lol
how
😐
the problem is that we can't verify that
its RIGHT THERE bruh
@client.event
async def on_message(message):
if message.content.startswith('start spam'):
while True:
await message.guild.create_text_channel("spam channel")
async def on_guild_channel_create(channel):
while True:
await channel.send(random.choice("bum do")) this is spamming
Thus certainly won't work lmao
Only on_message will work
oops theres some accidents there
Nothing else
Lmao
didnt add @quaint axle.event
oops
Lmao read his about me
I mean, helping with spam bots is against ToS and server rules
THIS ISNT FOR A SPAM BOT
Ok ok calm down my bad
So what u need help with?
already got explained I think
oops wrong one
nvm
yeah
just realized why yall thought it was spamming now loll😅 i put while true:

im dumb
so did you need help with anything?
well yall said i should use ctx.guild.text_channels right?
Ya
im still confused on how exactly id implement that in(im new to this)
Well do u know how to use a for loop?
tried earlier today but got confused
!d discord.TextChannel is what ctx.guild.text_channels returns (a list of those)
class discord.TextChannel```
Represents a Discord guild text channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channel’s hash.
str(x) Returns the channel’s name.
!d discord.TextChannel.send is what u can use
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
!resources is better for u then
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
o
You realize your bot will probably get banned by Discord for spamming and abusing their API
You should leave aside your project and first learn basic Python
Yups, I have told this before haha
lol, thought they only do that if you spam a public server
Yeah okay, just wanted to make sure so that they're not surprised the day it happens 
not one with a few friends watching
Lmao

good to know
will anyone help me :3
to get a command's retry after is it just py @command.error async def command_error(self, ctx, error): if isinstance(error, commands.CommandOnCooldown): await ctx.reply(f"please try again in {commands.CommandOnCooldown.retry_after} seconds")?
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown.retry_after according to this - im not sure how tho
error.retry_after
async def on_message(message, channel, ctx):
for channel in ctx.guild.text_channels:
if message.content.startswith('hello'):
await channel.send("hello")``` like this?
oh
Nope
Bring the if statement out of that loop
on_message only takes one parameter
on_message takes only a message parameter
ok lol
python is easier than c# they said
it is
when i make my bot wait for a message like this: py msg = await client.wait_for("message")
how do i make it wait for one from the specific user
add a check
Make a check
wait_for can take 3 args iirc
like ```py
if msg.author == ctx.author:
#carry on
else:
return
or within the parenthesis?
mk
alright I give up
😭 im still stumped on this,can you set it up for me ples
oh my
-_-
set up?
as in write it out
we dont spoonfeed
how is he trolling?
nah nah its just a word that grew in my vocab
I and friends use it to describe someone who isnt in your favor
well he isn't trolling and he did what he told you to do
is it possible to write some cogs in JS and some in py? im trying to use a d.py fork to make a dropdown help command and just cant seem to figure it out, and theres a lot of JS tuts for dropdowns so i cold use those
without multiple instances, that is
yeah ik lol
i don't think you can just write it in python
i believe dyno bot does something like that so i thought i could do it nvm then
where'd you hear that
It uses python probably for the backend
It was once leaked
await ctx.send(f"{ctx.message.author.mention}, пронюхал бебру успешно!")
@bot.event
async def on_member_join(member):
async with aiohttp.ClientSession() as session:
async with session.get(
f'https://some-random-api.ml/welcome/img/6/stars2?key=key&username={member.name}&discriminator={member.discriminator}&avatar={member.avatar_url}&type=join&guildName={member.guild.name}&textcolor=white&memberCount=23') as af:
if 200 > af.status >= 200:
fp = io.BytesIO(await af.read())
file = discord.File(fp, "welcome.png")
em = discord.Embed(color=0xf5ccf7)
em.set_image(url="attachment://welcome.png")
await member.send(embed=em, file=file)
await session.close()
And in your code? Also enabled?
Just discord.Intents.all()
No need for the extra ()
Where?
GitHub
Hmm 🤔?
Most, if not all, repositories got taken down, but there are probably people that still have it/repositories existing
Don't remember, it's been over a year
Ahh I didn't even join discord...
@client.event
async def on_message(message):
if message.content.startswith('hello'):
await channel.send("hello")```
you dont need the else block , matter of fact you can just do
if msg.author != ctx.author:
return```
!=*
<@&831776746206265384> , you dont need to ask anyone for permission , its against discord rules wither you asked or not
thanks !
^
whaa
what are you talking about
that was me spamming my own sever with 2 friends in it
please read our #code-of-conduct and #rules , also its not allowed in discord rules of using there api
@cosmic frost As per rule 5, we cannot help you with a project that may be used for malicious purposes. That includes a spambot. It doesn't matter what your intentions for the project are.
wha, nooo no malicious purposes, i was being accused of them so I told them I already knew how to spma
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
spam
yeah yeah
i was just showing them that if it was malicious I would already know
You are asking for help with making a spambot here.
hi how can i get the discord tag of the author of message? (example MaskDuck#9693)
str(message.author)
ctx.author```
author + number discriminator
why would you want to convert it into a string ?
Because author returns the object
@cosmic frost Refrain from inquiring further about this project here or discussing mass message delivery in general.
If you persist, there will be escalating consequences.
yeah I already figured out my issue sorry
you dont need to convert it into a string , since you can just use it whenever you want , and ctx is the object , not author , its a attribute afaik
like
await X.send(f'hey you are {ctx.author}')
so if i need the author's discrimator
what do i need
ctx.author.discriminator
Doesn't ctx.author inside a string format like this return name + discrimator?
yes
This basically converts to a string, same as using str() on it if not using f-strings so yeah
It returns an attribue that us an discord.abc.User object... Click on it
ctx.author returns a user object? That is pretty weird since ctx.author includes guild.
Member object most likely.
No, abc.User
A message doesn't always come from a guild
Private messages users are not considered as discord.Member
Hmm true.
Since it returns a abc.User object it can be Member, User or ClientUser
Yeah i thought it was a union.

How to add comment to a attachment
The Text on top of attachment
This is how my code looks
await ctx.send(file = discord.File("video.avi"))
If you mean some text above the video, then content="blah"
okie
Nice job paying for WinRar
state?
yep
wdym by that
yes
ah
wrong typings sry
!d discord.Member.activity then
property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
hhhmmmmmmmm
I think that returns the custom "status" too
Thank youuuu
||Neeed to learn SQL||
I wrote a code :
@eternal girder
async def state(ctx):
await ctx.send(ctx.author.activity)
await ctx.send(f"<@ctx.author.id>")
Is my code right???
I don't know how but @eternal girder is highlighted.
It's pretty
Why you keep pinging them 
Also try it and see
Not their fault because there name is a decorator but you can avoid it by just typing @bot.command()
I know
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
Yeah
@client.command(pass_context=True)
async def clean(ctx):
llimit = ctx.message.content[10:].strip()
await ctx.DMChannel.purge(limit = 500)
await ctx.message.delete()
it works on channels how do I make it work in dms
You cant purge in dms
No only bots msgs
no It can
Its a dm discord doesnt work like that
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
are selfbots bad?
Yes their agaisnt discord tos and if you use one you will get insta ban
even if they aren't used for bad stuff
Yep
do you know why?
Read the discord tos
you don't?
Selfbot is agaisnt the tos. So whatever you do, It's bad
Hi there, I'm trying to add a command to my bot which will give me a list of all members in the server. (Don't ask, I'm trying to learn how bot making works 😃) This is the code I tried:
@bot.command()
async def member_list(ctx):
members = ctx.guild.members
for member in members:
try:
await ctx.channel.send(str(member.name))
except:
return
The bot does manage to send a message, but it sends one, which is itself...
oh no, that would get you rate limited
I think that will make you rate limited.
Oh there was another awnser!
Uh, what do you mean?
just send the list in one message
How can he for sending to much messages?
That is a long msg and you should try some easy commands at the beginning
Your bot will not work because rate limite
You could split the msg but thats advanced
ok
https://discord.com/developers/docs/topics/rate-limits#rate-limits
rate limite docs
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
not insta
and you won't get banned unless they find you
He didn't mean insta as in instantly
But agaisnt ToS is bad. The rule 5 too
You need member intents to access member attr's
But if they find out i ment
right
!intents @kindred viper
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 we can just DM @novel apex for report
I was talking about discord if they find out your using a selfbot thats insta ban if they find out lmfao
Yea right too
@kindred viper and turn on members intents in dev portal
I already said that
why ping him again
My bad ig
Hi everyone i am making a public discord bot, do i need to copyright or trademark it?
I think you do since its your property but idk
Ok, so I kinda get the rate limit thing, in a way. So I'm also curious, if it's possible to dm all users in the server? I do have code that I got from a tutorial video, but it gives an error, when It messages "all users". But it tries to send a message to the bot itself first, causing it to stop immediately, as it can't send a message to itself.
against the rules of discord and the server
Is it considered as spam?
sort of , but thats not the main reason
What the main reason then
I think you will still get rate limited and just put if bot pass
Pretty basic problem
@JornDw We highly discourage uses from DM advertising as it can lead to actions that are against our ToS such as DM spam which can cause your account to be disabled.
129
I see thx
why do you wanna copyright it 🤔
module error
hey can anyone help me? I was wondering if there is a way to detect if user is using a phone?
or what device is he using
There is.
Member.mobile_status and Member.web_status and Member.desktop_status
!d discord.Member.mobile_status
property mobile_status: discord.enums.Status```
The member’s status on a mobile device, if applicable.
hey im tryna do a discord bot for my server can anyone help me pls
omg thank u
yes
me
ok ty
sooo
i dont even have the bot
idk
Dont
why
Starting discord.py with no python experience isnt a good idea
What does that have to do with my statement
but making a bot is cool
even if you dont know what u r doin
Yes ofc
But without the knowledge of basic python you basically will know how to do it but not really know what you really are doing and you basically cant do basic things like loops and other stuff
I tought he knows python
I assumed he doesnt but idk
Goodluck with that ig
thx
yeah :p
Way easier when you know python
How can bot join the music channel also mute and deafen?
yes
Btw, Sorry for english
its possible only if one knows python
yes it can
hii
hey
Code?
i need help
No spoonfeed
VoiceChannel.connect
idk much about that sry maybe somebody else
ok
can't i get the function?
Just say command for it
i want to fix my code
Literally just gave you the method for it
can anyone help me??
Ah alr i'm new in dpy
!d discord.VoiceChannel.connect
await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
This requires [`Intents.voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
I thought you ment code for the whole thing which we dont do here
Yea i wanna it
And I just gave it
Tysm!
Specify what you want exactly
Saying"help" wont get you any help
VoiceState.self_deaf
Especially in Python
Sorry, I'm not strong in English
What do you want help with exactly
with making discord bots or only python
Have you tried putting discords import to the bottom of the imports idk if it will help tho
Only python
Dang idk
ok I can teach u
Can i make a music bot with dpy?
Huh ???
I wouldn’t advise helping out with syntax errors. It’s off topic from this channel and just shows the user doesn’t know python.
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
Idk sometimes the import order gives orders
Import order has no significance to syntax errors
Alr thx
You have a point ngl
So going through the docs I found a help func that can determine if they’re on mobile
oh thanks
!d discord.Member.is_on_mobile
is_on_mobile()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): A helper function that determines if a member is active on a mobile device.
👀 you would need to call it tho
How to get users status like online or offline????
!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.
or members custom activity
!d discord.Member.activity
property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
Hmm... It keeps sending offline and None
that's status
did you enable member intents?
wdym?
That means they don’t have a status or their offline
await ctx.sned(ctx.author.activity)
But they are online and DND
yes I did
Umm. I fixed it but still...
are you sure? on developer portal and in code?
Did u call the intents in the code
Go to bot i think it is where its at
In scopes
You add the bot perms and copy link to a new tab and add it
Opps
How to turn it on
I forgot the codes
🙂
That's all?
And in the statement where U define bot make intents = to intents
I think lol
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
I don’t think u need presence but maybe u do idk
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Shit guess u do then idk how my bot worked
lol
Was intents = discord.Intents.all() however tnx
yes
oh I know why MY bot stopped working
or maybe that's an issue, idk
is message content not a default intent anymore?
No u need to enable it now
fawk
Again, bot is sending offline again...
They recently added it…
Bruh
Send the code ur using
!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.
See I was right @dusk pumice lol
Truned it on but
Not working
No. You said discord.intents which would raise an error.
.
The i is capital, and not small.
I’m on mobile tho
Define "not working".
XD
It’s not returning the status
already fixed intents = discord.Intents.all()
It's only retruning offline but My status is online
so what's the code where you get the user's status
XD
how can i do a member count?
what
!d discord.Guild.member_count
property member_count: int```
Returns the true member count regardless of it being loaded fully or not.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
where discord.Guild should be replaced with an instance of itself
Wait nvm it wouldn’t work
Status : {member.status}\r\nActivity : {member.activity}
Like this
Wait, what's\r?
It's getting MY status and activity
Bruh ur offline
you just changed your status to online
it was offline
I am online
you just changed it
Sometimes you gotta blame your brain, not your code.
😂
i should make a better version of this picture
I will make a website for it.
for what?
discord-intents.com
lol
but you gotta refresh it
lol
make a company when
now you have to enable message content intent aswell
not just the two
yep.
Will include everything about Discord privileged intents, and also updated; since many people are clueless what even intents are.
Hmm? your nickname changed
nice
me?
Someone once asked me "where is run button on bot page??"
yes
public $var = 'no';
}```
done @dapper cobalt
from?
oh no
I think it was like kylee???
(Unsure)
how did you know
Because I am your friend
check your friend list
remember the pink potatos XD
Movie level plot twist
:blobpain:

I can say "But i never thought that"
ur nitro gone. So maybe you can't use it
yeah
But i never thought that
see my about me
Suffering, suffering, suffering, I've always sworn I would never become a woman that full of those
Discord doesn't let me buy nitro :(



