#discord-bots
1 messages · Page 437 of 1
Yes sorry me on mobile it is hard to type
Why in a json file?
store message ids in a list in the file then get the length of the list
Idk maybe do better
Storing in json is bad if you open and close it on every message. Consider using a db
Huh?
ask @slate swan He/She knows better
Idk how to use a db ðŸ˜
Then learn?
Ok
well, i think i will, cant really do anything
For learning sql: https://sqlbolt.com/
General choices for SQL databases:
sqlite- a liteweight SQL variant, single file, no server. Lacks some features
postgresql - Standard-weight SQL server, very capable, good sql lib.
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
I don't know anything better. Anyone will know about their issue will help them. Also He 🙂
i see....
ty, but where do i put the bots token for it to connect?
bot.run("token here")
the bot instance you just made have a run method, you need to use that and make sure to use it at the last of everything since it's a blocking call
commands.bot is a module and its Bot_instance.command() not the class
ty guys :D
Hey @heavy belfry!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
D:
this is the code```import discord
from discord.ext.commands import bot
from discord.ext import commands
bot = commands.Bot(command_prefix="!", help_command=None, intents=discord.Intents.all())
@bot.command('$ping')
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
what are some ways i could create a custom help command?
I assume you mean pycache? If yes, it's the cache file where your compiled code is stored during the runtime.
You don't need to take care of that much. If you're uploading your code on git repo, make a .gitignore and add those files with correct syntax in the file, and it'll not be uploaded on git
https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96 Have a look at this gist
i cant post the error its too big.....
!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.pydis.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.
ty
I'm new to python
Remove
from discord.ext.commands import botsince it can interfere with your main bot instance, maybe... Alsoimport discordisn't used, so you can remove that too.
You don't needhelp_command=Noneunless you need to disable your help command, which I don't think you want. I may be wrong.
You don't need to set prefix in@bot.command(...). You already set the prefix in the Bot constructor, no need to do that again and just write command name
ty
ty, if i want that ping thing to appear when i type $ping what do i need to write in the @bot.command('')?
In @bot.command(...), you always need to just name the main command, like ping without $, to set $ as the prefix, set the command_prefix equal to $
also its comming up with errors in my bot.run('') i cant paste because its too big and the ctrl + s seems to do nothing..
ahhh, ty
You added the token in it?
sure did
Try to paste the error, can't guess what's the issue without any traceback 
the error is too big.. can i send it to you privatly?
Okay
@heavy belfry You enabled intents in the constructor but it's not enabled on your dev portal. Enable them from discord developer portal.
Also have a look at https://vcokltfre.dev/, a pretty good tutorial and guide on dpy
It has everything mentioned about basics of dpy, also about intents ^
when you say dev portal do you mean in the creator part of discord? cause i have that enabled allready...
what you sent, i had already done that, either im big dum and have missed something or.. well idk
No idea then, error says you have not ¯_(ツ)_/¯
O, i copied and pasted what was on the website and that didnt come with any errors!
I just saw that you can post a private message in a channel - visible for only one user. How to do that?
I am trying to make a server info command and i have one embed field with total members but i cant find a way to calculate the total bots and humans. I can only find the total members but I want to include total bots and humans
What examples can I see that requires presence intents
Guys does anyone know any good alternatives to discord.py as a Python discord API wrapper?
!pypi disnake
A python wrapper for Discord API forked from discord.py.
releasing soon, but the features are amazing 😄
@maiden fable will it have completely different functions to dpy?
Do try excepts work with command cooldowns?
okay
how can i make my bot run even if my pc is off ?
Host it on a vps
and is it possible to do that
how
Use a vps
discord.py is weird
Why?
any free vps's ?
heroku
can anyone help me use the bot token regex to make a piece of code to delete a message if it contains a token please
idk, im just complaining lol. trying to learn it but im a dumb fuck 
?
Heroku is free
ok
could u share the link ?
please
just search up heroku
@bot.command()
async def code908(ctx):
embed = discord.Embed(
description=f"""**Ranks**
**#1 @Owner / Founder / CEO **
**#2 @Co Owner / CFO **
**#3 @Developer **
**#4 @Admin **
**#6 @Staff **
**#7 @Helper **
**#8 @[HR] Member **
**#9 @[V] Elite **
**#10 @[IV] Advanced **
**#11 @[III] Intermediate **
**#12 @[II] Novice **
**#13 @[I] Member **
**All ranks have different perks, Premium / Premium + / Premium ++ Are limited ranks, they are earned as rewards for events and staff spotting out active people, thank you.**"""
colour=0x3D9AF2)
await ctx.send(embed=embed)``` what's wrong with this?
The python bot already has this and it is open source.
!source
although there is no regex that works 100%
@bot.command()
async def code908(ctx):
embed = discord.Embed(
description=f"""**Ranks**
**#1 @Owner / Founder / CEO **
**#2 @Co Owner / CFO **
**#3 @Developer **
**#4 @Admin **
**#6 @Staff **
**#7 @Helper **
**#8 @[HR] Member **
**#9 @[V] Elite **
**#10 @[IV] Advanced **
**#11 @[III] Intermediate **
**#12 @[II] Novice **
**#13 @[I] Member **
**All ranks have different perks, Premium / Premium + / Premium ++ Are limited ranks, they are earned as rewards for events and staff spotting out active people, thank you.**"""
colour=0x3D9AF2)```What's wrong here?
It still does not exist.
No comma after kwarg
tak?
da-no?
I don't understand
struggling to find the file for it
I still don't understand
@cloud dawn
why is your font so large
lol
if serverstats['Antispam'] is True: get rid of is, why is it even there
i want create py bot on danbot but i cant. help me please. what i should
get rid of is True as a matter of fact, you don't need them
@slate swan don't invite me to your servers
We are not going to go trough the steps of you implementing copied code.
Hello, I was wondering how I could do the following:
If I have the bot on more than one server and I only want it to send welcome messages, goodbye to a specific server, how could I do it?
That is, it only sends those messages if someone joins a specific server that the bot sends a welcome message if it gets on that specific server, not on another that is the bot
I do not know if I explained well
ik but i dont know where is bot code
So you also want us to provide the code?
yes
so you want all joins and leaves to be logged in one server?
how to combine bot token and my process
Exactly, no in all servers the bot is in, only in one of the all servers
I think i get you, you can make this easily using a database.
i made a fork of discord.py and have i seet it up but do not how do i import it
fghj
well first of all get the channel(s) that you want the bot to log them in, and create on_member_join and the event thats called when a member leaves (can't remember what it's called)
Like i've said we're not going to help you to implement copied code.
im looking for commands too, like got no ideas
Ah I see
have a go at making a morse code translator
already have it, but the bot send this message when anyone joins to any server on is my bot, and i only want this happen in serverid
@elfin pewter what are you trying to do?
already done it before, but i deleted it
@marsh depot explain ur issue
@hoary gust
You have member.guild.id
Hello, I was wondering how I could do the following:
If I have the bot on more than one server and I only want it to send welcome messages, goodbye to a specific server, how could I do it?
That is, it only sends those messages if someone joins a specific server that the bot sends a welcome message if it gets on that specific server, not on another that is the bot
I do not know if I explained well
@marsh depot fetch the id and get the channel and send it
Fetch the guild
Then get the channel u want it to send msges in
Try to get it first.
fetch is an api call, using get would be better
@cloud dawn ofc we need to fetch the guild first
@marsh depot just make a list and save ur guild id in it
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/container/bot.py", line 36, in on_message
users = json.load(f)
File "/usr/local/lib/python3.9/json/init.py", line 293, in load
return loads(fp.read(),
File "/usr/local/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
async def on_member_join(member):
with open('users.json', 'r')as f:
users = json.load(f)
await update_data(users, member)
with open('users.json', 'w') as f:
json.dump(users, f)
channel = bot.get_channel(881094340087283722)
embed=discord.Embed(title=f"Welkom {member.name}", description=f"Bedankt voor het joinen van {member.guild.name}!", colour = random.choice(colors)) # F-Strings!
embed.set_thumbnail(url=member.avatar_url) # Set the embed's thumbnail to the member's avatar image!
await channel.send(embed=embed)
@bot.event
async def on_message(message):
with open('users.json', 'r')as f:
users = json.load(f)
await update_data(users, message.author)
await add_experience(users, message.author, 5)
await level_up(users, message.author, message.channel)
with open('users.json', 'w') as f:
json.dump(users, f)
async def update_data(users, user):
if not user.id in users:
users[user.id] = {}
users[user.id]['experience'] = 0
users[user.id]['level'] = 0
async def add_experience(users, user, exp):
users[user.id]['experience'] += exp
async def level_up(users, user, channel):
experience = users[user.id]['experience']
lvl_start = users[user.id]['level']
lvl_end = int(experience ** (1/4))
if lvl_start < lvl_end:
await bot.send_message(channel, '{} is een level omhoog, en is nu level {}'.format(user.mention, lvl_end))
users[user.id]['level'] = lvl_end ```
No maybe not
or just get_guild
better would be to check if it is not true
@wary ravine yep
!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.
I have the codeblocks, but I had * in the code so discord changed it
get_... > fetch_...
best fetch/get system is ```py
guild = bot.get_guild(2347234792347) or await bot.fetch_guild(23432423432)
Fetch api call
Its because of the mathematics
if you had the codeblocks properly then discord wouldn't change it
Did you wrote this yourself?
im "noob" in put the bot config in diferents discord servers, im trying to make this first time
how can i apply this to my code, maybe put
guildserver = bot.get_guild(818910383908585535) or await bot.fetch_guild(818910383908585535)
if member.guild.id = guildserver:
do stuff
else
return
¿?
A part of It Is tutorial yes
I litterally use the codeblocks that the bot gave me and It doesnt change so
can be an api call sometimes 
if member.guild.id == 818910383908585535:
...
else:
return
``` this suffices for single guild
but okay
okay im gonna try it
ty
Better than not getting any info imo
when someone connects to the my server nothing happens!
code:
import discord
from discord.ext import commands
from datetime import datetime
from discord import Game
client = commands.Bot(command_prefix=".")
@client.event
async def on_ready():
print("Bot is ready!")
@client.event
async def on_member_join(member):
channel = client.get_channel(id=882282531276345416)
embed = discord.Embed(title=f"{member.mention}", description="Test")
embed.set_author(name="New member")
embed.set_footer(text="footer text")
await channel.send(embed=embed)
client.run('TOKEN')
We all pretty much don't use json and advice everyone to not use it. So json questions will likely will not get answered here.
Do we got an error?
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x000001805D299EE0>
Traceback (most recent call last):
File "D:\python\lib\asyncio\proactor_events.py", line 116, in del
File "D:\python\lib\asyncio\proactor_events.py", line 108, in close
File "D:\python\lib\asyncio\base_events.py", line 746, in call_soon
File "D:\python\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed
this
This is a new one
i'm sure we can yes
what?
color
Replace # with 0x so 0xFFC0CB not in a string
replace # with 0x
try restarting your bot again
I'm guessing its possible to find the amount of emoji's a server has by looping through a list I just need some help with it because im terrible with looping through lists and arrays
i made a fork of discord.py and have i seet it up but do not how do i import it how do i
what's the problem?
Don't know is this the whole error?
yes
enable intents in the dev portal
You need to download it and also working with d.py is already advanced and touching the bare API is even more advanced so know what you are doing.
i have it download
@cloud dawn all good , ty for your help
is enabled!

Now also in your code.
but you didn't apply it in your code.
but i do not know what to change so i can imprt echodiscord and not discord
Then you can just import it, like i said it is way beyond advanced so i recommend not touching it.
Then what should i do?
!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.
well whan i do the name it will not work
You can just do ```py
import discord as echodiscord
the name of it is echo-discord.py
I don't understand so you only want to change the name?
just want to import it

Thanks! I was in the middle of a r6 game.
Hey @void fox! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
I'm trying to list the amount of roles a server but its only listing 2 instead of 60 . This is the code
amount_of_roles = 0
for member in ctx.guild.members:
for role in member.roles:
amount_of_roles += 1
why cant i just do import echodiscord
ive been working on this for like 4 days and i cant give up now
I have no idea what you have changed and what you are doing.
What's going wrong?
i changed the token but it still doesn't work!
and i get a error:RuntimeError: Event loop is closed
i am just trying to import my lib did not change anthing
no
!paste Can you copy the whole thing into here?
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.pydis.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.
delete the lock file and hope for the best
k sure
Hey @slate swan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
its too big
what's the problem?
amount_of_roles = len([role for role in ctx.guild.roles])
Yes, because you're trying to send the whole thing as a txt file
Hey @slate swan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
!paste
paste has already been spammed
!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.pydis.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.
!paste
per channel cooldown
Where are you running this?
Did you apply intents?
yes
ahrhr someoneee helpppp
This has nothing to do with intents, you wouldn't get that error from that
pycharm!
ahrhrhr pleaseeeee send the tracebaaaaaaaacck
We still have no codee
Wait what Python version is this? Because that is indeed a very odd error 😅
That is true but i've seen his code and he needed intents anyways for it to work so atleast he won't get that error after this.
TypeError: 'Lock' object is not iterable
2021-08-31T18:35:25.339381+00:00 app[worker.1]: Unclosed client session
2021-08-31T18:35:25.339382+00:00 app[worker.1]: client_session: <aiohttp.client.ClientSession object at 0x7f0b768e6550>
2021-08-31T18:35:25.499954+00:00 heroku[worker.1]: Process exited with status 1
2021-08-31T18:35:25.610673+00:00 heroku[worker.1]: State changed from up to crashed
thats the end one
Is there anyway I can change that to show the amount of emoji's in the server?
python 3.9
That's also what i said i've never seen it.
Hey, I'm new to this server, and um you have to have a verified account to add bots to your own server right?
I want the whole thing, visit the site and hit Ctrl + V then Save and copy the link here
I am not sure, is it not working?
Like, it is not 2.0?
I can't visit that
amount_of_emojis = len([emoji for emoji in ctx.guild.emojis])
can i dm u now?
Correct, It wont work! My account is verified and it still wont work.
No, please don't
kayy.
2021-08-31T18:35:25.300497+00:00 app[worker.1]: await super().send(data)
2021-08-31T18:35:25.300505+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/websockets/protocol.py", line 371, in send
2021-08-31T18:35:25.300682+00:00 app[worker.1]: yield from self.write_frame(opcode, data)
2021-08-31T18:35:25.300691+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/websockets/protocol.py", line 740, in write_frame
2021-08-31T18:35:25.300906+00:00 app[worker.1]: with (yield from self._drain_lock):
2021-08-31T18:35:25.300938+00:00 app[worker.1]: TypeError: 'Lock' object is not iterable
2021-08-31T18:35:25.339381+00:00 app[worker.1]: Unclosed client session
2021-08-31T18:35:25.339382+00:00 app[worker.1]: client_session: <aiohttp.client.ClientSession object at 0x7f0b768e6550>
2021-08-31T18:35:25.499954+00:00 heroku[worker.1]: Process exited with status 1
2021-08-31T18:35:25.610673+00:00 heroku[worker.1]: State changed from up to crashed
thts the whole error
finalllyyyyy
I still cant make bots! Anoying
That's still not all of it
I don't think I follow, what happens when you try to?
it is mate, last time i ran the whole thing like 3 times so it all added up but thisi s the original output
i can't 😩
No it isn't, in your picture here I can see more https://cdn.discordapp.com/attachments/343944376055103488/882333217489846282/unknown.png
bluenix is now surrounded by dum idiots 🤣
okay one min
Are you sure that is all of the output? I am thinking that there may be an error above it
Traceback (most recent call last):
File "D:\python\lib\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "D:\python\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\discord\main.py", line 31, in <module>
client.run('za2l0l9VScNUMaHkIQisyASQAnsBy2Ul')
File "D:\python\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "D:\python\lib\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "D:\python\lib\site-packages\discord\client.py", line 665, in start
await self.login(*args, bot=bot)
File "D:\python\lib\site-packages\discord\client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "D:\python\lib\site-packages\discord\http.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000020BCFCC9DC0>
Traceback (most recent call last):
File "D:\python\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "D:\python\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "D:\python\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "D:\python\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Process finished with exit code 1
You leaked your token again, but this is great
CHANGE YOUR TOKEN IMMEDIATELY
Guys someone suggest me a command
Self-mute
@minor totem wth
You tell me, why doesn't it work in the first place?
Lol
i made a fork of discord.py how do i cahnge the import from discord to echodiscord
🤣🤣
"NameError: name 'music' is not defined"
import discord
from discord.ext import commands
cogs = [music]
client = commands.Bot(command_prefix='!', intents = discord.Intents.all())
for i in range(len(cogs)):
cogs[i].setup(client)
client.run("TOKEN")
Are you having issues doing this? It should just be changing them
Someone suggest me a command
well the name of the fork is echo-discord.py but will not work
evaluation command or poker night command.
Oh wait, yeah you already changed it haha. The error you get is because it is wrong in the first place, go to the Developer dashboard and grab the new one
@cloud dawn what are this commands?
I'm trying to get the owner of a guild with ctx.guild.ownerbut its returning a None value
eval is the code to run python inside discord and poker night is just absolute genius.
It's owner_id
Ok and any other suggestion?
temp mute using a database and datetime objects.
So sorry for not responding we are all good! Have a good rest of your day!!!!
I'm going to try to create poker night, seems fun.
Oh awesome, have fun! 🤗
Anything more?? 😅
You don't 'create' poker night you just generate the URL using routes of the bare API.
No like, I'm going to create a poker bot from scratch.
Hey, is it possible to start a Discord Bot via a Webpanel? Like pressing a button on the website and then it starts the bot
Remake your bot constructor the be a child instance of commands.Bot and have it construct it using setup, async wait_until_complete and super()
Yes but the website does have to be online ofc :)
Yea i know that. We or I just want to start the Bot remotely.
Do you know how it works with the website thingy?
You need to search discord poker night since you don't know what i mean.. i think.
You'd need to use sub processing.
!eval
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code
block. Code can be re-evaluated by editing the original message within 10 seconds and
clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an
issue with it!*
!eval source
Unable to convert '!eval' to valid command, tag, or Cog.
!source eval
Run Python code and get the results.
Is there a tutorial for starting a bot via a website?
I know what you mean, but, I'm doing something different. The poker night sparked a idea.
Sorry, couldn't help myself. This is pretty custom so you'd need to make it yourself unfortunately.
Oh okay, gl!
Because i searched for a tutorial but i couldnt find one. Im just to stupid to find out how to start a discord bot via website
Do you even have a website up inside a python framework?
I recommend quart
not yet, we have one with php/js but we could not find a way to do it there so i was asking here how to do it in py
You could run it with PHP although i don't have any experience in that.
So like i said: "This is pretty custom so you'd need to make it yourself unfortunately.".
So we can help a bit but you first need an actual site running first.
AWS
I will try to make a Small Website and then u can help me
All mysql DB's are paid.
@cloud dawn but why?
Uhhh, cz they wanna earn profit.....?
Sure but not today (my time) since i gotta go to school tomorrow so i'm gonna go in like 10 min
so i clicked on generation and copy and pasted! I don’t know how it could have happened, I haven’t tried it yet
no prob
That and database is one of the most expensive thing to run.
Developing = investing, if you are not willing to invest you can't have the nice toys.
Any online SQL db that is free to run for a period of time like mongo?
None that i know of, but hey i do everything on local host.
I will have to keep my pc on for 24*7 and I can't do that
I'm assuming you are still coding your bot
So it's not even finished why would you want to run it then?
@cloud dawn my bot is lacking speed with mongo I want to Increase that speed
mongo is faster than mysql

MySQL is the fastest right?
postgresql is the fastest.
Well gl guys i'm gonna sleep.
that ) is looking rather green
Now i'm gonna sleep
You missed an "
wdym discord bot via website
We want to start a discord bot via a button on our website
@commands.command(brief="gives you the digits of pi that Python knows")
async def pi(self, ctx):
await ctx.send(math.pi)
@commands.command(brief="reverses text")
async def reverse(self,ctx,*,args=None):
if args:
reversed = args[::-1]
await ctx.send(content = f"{reversed}", allowed_mentions=discord.AllowedMentions.none())
if args is None:
await ctx.send("Try sending actual to reverse")```
how would i make these into non cog form
this should be with js but idk about python 
no problem, i think we already got it
if there's a way to run shell commands with js you can try and run the python file
you need to learn classes ngl
I got it nvm
This grey line
how put this in embed
the same way you do it here
Thanks
I'm trying to display the time a guild was created using guild.created_at but its showing down to the milliseconds. I don't know how to format the time and its not allowing me to splice off the numbers so could I have some help?
Really all I need to know is either how to splice the result or how to format the time
use datetime.timedelta
How would I implement that?
if ctx.channel.id not in limitedChannels:
if commandInvoker != self.ownerid:
await ctx.channel.send(f"{commandInvoker.mention}, this command isn't allowed here.")
raise commands.CommandError('The command is limited.')```
i am trying if the commandInvoker is owner it should pass it
but it still raises error
guild.created_at returns the timestamp of the guild creation in UTC
so, to get the datetime object do:
from datetime import datetime
guild_creation_date = datetime.utcfromtimestamp(guild.created_at)
print(guild_creation_date) # incase you dont like the format change it using .strftime (google)
pls help guys
is the commandInvoker variable an id or a user object? if its a user object get the id using .id
Throws the error TypeError: an integer is required (got type datetime.datetime)
send me your code
created_at = datetime.utcfromtimestamp(ctx.guild.created_at)
Then I just have an f string
Sending created_at
replace commandInvoker by commandInvokerId
use .strftime
Oh i get it, the docs werent clear about the behavior of created_at, turns out it already returns a datetime.datetime object so you can just do this:
await ctx.send(ctx.guild.created_at) # Again if you dont like the format use .strftime
In discord.py, does anyone happen to know if VoiceChannel.voice_states is guaranteed to be at least as up-to-date as VoiceChannel.members? I don't think the documentation is entirely clear about this.
It seems that if you start the bot when there are people already in a voice-channel, that VoiceChannel.voice_states will contain those members, and VoiceChannel.members will not.
VoiceChannel.members is basically the list of member objects of IDs you get from the key of the mapping of VoiceChannel.voice_states.
Bot's internal cache is prepared after the startup but I guess API only returns the ID and their voice states with the channel data, and not the whole Member object, so dpy just try to form those objects using the stored cache.
Basically you need voice_state intents to receive the low level .voice_states, and if you also have member intents to cache the members, you can also get the list of complete member objects using .members.
But from docs it seems like voice_states can guarantee accuracy
The API does not need to return the member data from the channel
As the guild is cached as well as its properties, i.e memebers
Oh then it's like when you don't request or have member data coz of missing intents?
Just for whatever reason seems like member isn't cached anyhow since voice_states and members both use the same method except members also uses get_member
Then voice_states might be the function to use when you don't have member privileged intents..
how to add role to ctx.author
so i wanna purge a user messages how do i add that to the command
``` 
you could check if its him then add
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
!d discord.TextChannel.purge has a check= kwarg, pass the valid check in it
await purge(*, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own (unless you are a user account). The [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Internally, this employs a different number of strategies depending on the conditions met such as if a bulk delete is possible or if the account is a user bot or not.
Examples
Deleting bot’s messages
for ctx author
^ @sour basalt
idk
i'm using this 
@bot.command()
async def clear(ctx, amount:int):
await ctx.channel.purge(limit=amount+1)
await ctx.send(f'{amount} messages was purged from <#{ctx.channel.id}>')
Well, having access to voice states itself is a separate intent
Add a check func to return true when your user is one you need @slate swan
Members are cached by member intents, right? If voice is present, you'll receive VoiceState which you're getting in the low level method voice_states, but for members, you need to have members intent to cache members
No I don't think this would work without the voice state intents, you can try and see if it does
Yes it won't work. You need to have Voice state intent for voice_states to work, and for members to work, you also need to have members intent along with voice state
around=None, oldest_first=False, bulk=True what are those
and the limit means the max they can do ?
I must have mistaken what you said, as I thought you were saying that member voice states does not require voice state intents
Heya
How do I add character limits for words
like
eeeeeeeeeeeeeee
to prevent that?
These are args passed to history(. . . )
Nah I meant ^. I messed up wording a bit 
oh alright
Anyone knows how to fix that?
Um you can check it's len()?
Alright
how i can change voice channel user limit?
!d discord.VoiceChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
There is a user_limit kwarg that accepts integers.
Enable tracemalloc to get the object allocation traceback
Did you await it?
await voice_channel.edit(user_limit=10)
!paste Can you show full traceback please?
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.pydis.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.
Oh right I see. So it's because guild.get_member returns None at first (unless you have the member intent turned on)?
Yes, all the get_* methods use cache to get data. If you're missing any particular intent, it's data is never cached and always returns None
So, to explain why the bot was able to get the member if they joined the voice-channel after the bot was started (but not before), presumably the 'voice state update' event contains a member object in its payload, which the bot can add to its cache?
Just checking my understanding.
I'm not sure if bot can get the member once after they join since I never worked with voice. But yes, the voice_state_update event contains the member id whose state is changed as the key and VoiceState object as the corresponding value, like the payload described in https://discord.com/developers/docs/resources/voice#voice-state-object
Yes I think bots cache those members returned in event update unless you've set MemberCacheFlags.voice = False.
Right, thanks for the help!

Ok. Last time I will ask something here
I need to know how to parse a message AND DM the author of the message, knowing that on_message method only can have as argument the message
How can i do this?
@bot.command()
async def codep(ctx):
embed = discord.Embed(
description=f"React below for the roles"
colour=0x3D9AF2)
await ctx.send(embed=embed)``` Why is this an invalid syntax?
@trail flower
@rancid inlet
Looks like you are missing a comma between your embed arguments
Probably shouldn’t ping people, someone will help when they can
They are volunteers that use their free time to help
bruh its not a job
helo
can you make a bot disconnect people from voice channels
msg_id = 881859325063200841
canal_sugerencias = guild.get_channel(881858899379118080)
mensaje_sugerencias = canal_sugerencias.get_partial_message(881859325063200841)
if payload.message_id == msg_id:
if str(payload.emoji) == ':soyfonSugerencia:':
await payload.member.send('EnvÃa tu sugerencia, recuerda que todas las sugerencias deben ser serias, en caso contrario podrás ser sancionado, muchas gracias. Escribe `cancelar` para salir.')
await mensaje_sugerencias.remove_reaction(':soyfonSugerencia:', payload.member)
def check(m):
return m.channel.id == payload.member.id and m.author == payload.member
message1 = await bot.wait_for('message', check=check)
if message1.content.lower() == 'cancelar':
await payload.member.send('Sugerencia cancelada.')
return
else:
with open("sugerencias.txt") as read_file:
executed = int(read_file.readline().strip())
titulo_sugerencia = f'Sugerencia #{executed}'
executed += 1
descripcion_sugerencia = message1.content
embed_sugerencia = discord.Embed(title=titulo_sugerencia, description=descripcion_sugerencia, color=0xb522ba)
embed_sugerencia.set_footer(text=payload.member, icon_url=payload.member.avatar_url)
await canal_sugerencias.send(embed=embed_sugerencia)
await payload.member.send('Sugerencia enviada.')
with open("sugerencias.txt") as write_file:
write_file.write(str(executed))
write_file.close()```
the embed is not being sent
just make it so it dose
now
can you make a bot disconnect people from voice channels
and if i message1.content = 'cancelar' then its not printing what it should
what
maybe
cool
dyk how to move a member
@brittle remnant await member.edit(voice_channel = None)
dont do voice_channel
works for me @brittle remnant
r u talking to me
16
nah its alright just move on
i was j jk
k
keep getting a syntax error saying somthings wrong with the a in await in my code any idea why it looked good to me
@client.command()
async def random(ctx, number = random.randint(1000, 9999)
await ctx.send("The number is ", number)
Error
yes
Ah yes, good error
@client.command()
async def dropdown(ctx):
await ctx.send('testing for help command',
components=[
Select(placeholder='Select Something!', options=[SelectOption(label='A', value='a'), SelectOption(label='B', value='b')])
]
)
interaction = await client.wait_for("select_option", check=Lambda i: i.component[0].value=="a")
await interaction.respond(content=f"You clicked the 'A' value!")```
File "main.py", line 1043
interaction = await client.wait_for("select_option", check=Lambda i: i.component[0].value=="a")
^
SyntaxError: invalid syntax```
error
read the error again
and idek why you have that check
you want the user to click the a and not the b?
python is case sensitive so lambda and not Lambda
You forgot an await
Embed not being zent
And if message1.contwnt is cancelar
Not sending sugerencia cancelada
I think its something of the check
`--- Help ---
info
Commands
.help
Opens the help page, where information about the bot is stored along with all of the commands.
.play
Starts a game of Rock, Paper, Scissors, Shoot.`
^
how can i send a message like the one above through a bot?
def check(m):
return m.channel.id == payload.member.id and m.author == payload.member
Is this ok for a dm
Check if m.guild is None and the author matches
Okay
when i go to run this code it says "expected an indented block" how do i fix this
becuase you have open if before command
if ......:
pass
i have this code
@client.command()
async def selectmenu(ctx):
await ctx.send("Pick one of the buttons.", components = [Select(placeholder="Select One Of The Values", options=[SelectOption(label="A", value="A"), SelectOption(label="B", value="B")])])
interaction = await client.wait_for("select_option", check = lambda i: i.component[0].value == "A")
await interaction.respond(content = f"You have selected `{interaction.component[0].label}`")
interactionb = await client.wait_for("select_option", check = lambda i: i.component[1].value == "B")
await interactionb.respond(content = f"You have selected `{interactionb.component[1].label}`")```
result = condition(*args)
File "main.py", line 1040, in <lambda>
interaction = await client.wait_for("select_option", check = lambda i: i.component[0].value == "A")
TypeError: 'Select' object is not subscriptable
The above exception was the direct cause of the following exception:```
and this error
ok so now its saying " 'Client' object has no attribute 'command' "
Are you using discord.Client or using one of the bot classes from the commands extension?
Show me where client is defined
discord.Embed btw
instead of client = Client() do this
from discord.ext import commands
client = commands.Bot(command_prefix="-")```
How do i get a discord bot to join a call
A private call or a voice channel?
Voice channel
!d discord.VoiceClient.connect
await connect(*, reconnect, timeout)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
An abstract method called when the client initiates the connection request.
When a connection is requested initially, the library calls the constructor under `__init__` and then calls [`connect()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.connect "discord.VoiceClient.connect"). If [`connect()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.connect "discord.VoiceClient.connect") fails at some point then [`disconnect()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.disconnect "discord.VoiceClient.disconnect") is called.
Within this method, to start the voice connection flow it is recommended to use [`Guild.change_voice_state()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.change_voice_state "discord.Guild.change_voice_state") to start the flow. After which, [`on_voice_server_update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.on_voice_server_update "discord.VoiceClient.on_voice_server_update") and [`on_voice_state_update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_voice_state_update "discord.on_voice_state_update") will be called. The order that these two are called is unspecified.
I think that should work.
Thanks
No problem.
Hey how do you assign a color when creating a role?
await ctx.guild.create_role(name=color, color="0x" + colorhex[1:])
this is what im doing but its not right
colorhex is this
#ffffff
@uncut harness :white_check_mark: Your eval job has completed with return code 0.
Hello?
!d set role color
class set([iterable])``````py
class frozenset([iterable])```
Return a new set or frozenset object whose elements are taken from *iterable*. The elements of a set must be [hashable](https://docs.python.org/3.10/glossary.html#term-hashable). To represent sets of sets, the inner sets must be [`frozenset`](https://docs.python.org/3.10/library/stdtypes.html#frozenset "frozenset") objects. If *iterable* is not specified, a new empty set is returned.
Sets can be created by several means:
• Use a comma-separated list of elements within braces: `{'jack', 'sjoerd'}`
• Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}`
• Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])`...
is there an equivalent of break for if
no
but you can do like
if True:
print("hi")
raise
print("won't be printed")
how can i make a bot that sends a announcement message in each existing channel with discord.py
did anyone here switch to hikari yet ._.
if u use dislash for slash commands how long would it take to load the slash commands?
how do I make a status for my bot?
You mean activity?
yeah
@client.event
async def on_ready():
print('client is online')
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=str(len(client.guilds)) + ' servers | ' + str(len(set(client.get_all_members()))) + "My Prefix Is G, Gcommands"))
this is it but for some reason its adds "1"
channel=dormant.channels[x]
await channel.move(category=avaliable)
await channel.send(embed=avaliableEmbed)
await asyncio.sleep(0.2)
Im getting a textChannel does not have move attribute error
but
!d discord.TextChannel.move
await move(**kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A rich interface to help move a channel relative to other channels.
If exact position movement is required, [`edit()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel.edit "discord.TextChannel.edit") should be used instead.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to do this.
Note
Voice channels will always be sorted below text channels. This is a Discord limitation...
it is?
why put activity in the on ready?
so I can see just in case
if its working since I make changes to it daily
It takes 1 hour to register all slash commands In all guilds, if you add the guid id's in the guild_ids parameter then it's instant
how can you make a bot send the same message to all existing channels with discord.py?
discord.py won't work or won't be continued anymore?
I'm using google translator *
i think it still works it just wont be updated
Wdym all existing channels
in the future surely it wont work, but currently still works
all the channels in the server i want the bot to send the same message to all of the channels
ratelimit, be careful
for announcements and stuff
how im still learning
Everyone role exists
yeah i know
Announcement channel exists
is it even worth it if i make my commands that work with prefix ?
i know i just want to do that because some people in my server dont see those channels cuz their busy or something
huh? commands.Bot should have command_prefix
What do you think?
dude message_content is gonna get removed for bot's 😢
Anyone would write a would that is a command and the bot for some reason sends something
Slash commands exists
And thats what discord wants us to do so
yeah but i'm asking if i still should make commands with prefix or not
No way out
what
bruh, you haven't read the news
Use a for loop and use guild.text_channels to get all the channels
I swear this the worse time to verify your bot cuz like its gonna come in like 5-6 months
yeah
i don't want to verify my bot either
Welp, I already sent the application
Hope it does not get striked for inorganic growth
Well, I think I'll be fine
Slash commands sucks
I want to create a command that shows images off certain subreddits
I'm guessing I would use the Reddit api
But I've never used it and I have no idea how to get started
There is a library named async praw which is a wrapper for the reddit api
How's the documentation for it?
!pypi async praw
That
awawit channel.edit(category=newcategory)
how do i get my discord bot to retreive the number of members in my server
It should be easy to create a rps game.
how do i get my discord bot to retreive the number of members in my server
len(ctx.guild.members) I believe.
ctx.guild.member_count works too
Ahh yes, I just wrote what came to mind.
can anyone tell how to keep my server 24x7 online even if my pc is offline from scratch
i have absolutely no idea i need someone to tell me step by step
use a vps
don't use heroku 😶
then wat do i do
use aws
is it free
replit
I'm having an issue importing a module that I just installed
I know this is for discord bots but the module does have something to do with discord bots
And I don't think its worth taking up a help channel just for this
I'm trying to import the module but its just not showing up
Is it possible I installed it in the wrong directory?
umm how ?
itll shutdown if the bot isnt actively doing anything
U can use uptimerobot
i saw a vid about replit only thing the code isnt working
can u help me in dms ?
i used a webserver to keep it up
Search in youtube
i tried it dosent work
what is wrong with this ?```from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return 'Hello,yep I am still here'
def run():
app.run(host ='0.0.0.0',port=3108)
def keep_alive():
t = Thread(target=run)
t.start()```
pls tell whats wrong
I don't see anything wrong but is it even appropriate to ask about Flask in #discord-bots
any new python library to fill the void left by discord.py
post code and error
probably not for awhile I bet someone will fork the project and update it
its not an error i just want to change a few things and i couldnt find anything on it
Sure what do you need help with
@client.command(pass_context=True)
async def register(ctx, member: discord.Member, nick):
await member.edit(nick=nick)
await ctx.send(f'You have registered as {member.mention} ')
so basically with this, u have to do this command
=register @mighty crater nick
and if theres a space in the nick you have to use "".
i want to make it you can just type =register nick
and even if nick has a space in it, u dont have to use ""
@slate phoenix
async def register(ctx, member:discord.Member, *, nick```
^ I can’t type fast enough
Using * it will include all text after pinging the member
oh yeah thanks! i was wondering what it was lol
from discord.ext import commands
prefix = "?"
bot = commands.Bot(command_prefix=prefix)
@bot.event
async def on_ready(message):
await message.channel.send('Hello!')
channel = bot.get_channel(882470225877024821)
await channel.send("hi")
@bot.event
async def on_message(message):
print("The message's content was", message.content)
await bot.process_commands(message)
@bot.command()
async def ping(ctx):
latency = bot.latency # Included in the Discord.py library
await ctx.send(latency)
How can It so it sends a message to a channel every 10 seconds
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
How would I send the guilds name that a member is joining
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
for channel in member.guild.channels:
if str(channel) == "join-leave":
embed = discord.Embed(color=0xff0000)
embed.add_field(name="Welcome", value=f"{member} has joined {}", inline=False)
embed.set_thumbnail(url=f'{member.avatar_url}')
await channel.send(embed=embed)
Converting to "int" failed for parameter "pep_number".
!d discord.ext.commands.Bot.get_guild
get_guild(id)```
Returns a guild with the given ID.
Would I make a variable with the guilds id?
member.guild.name
and on_member_join just needs member, you don't have to add member: discord.Member
The code would work if a bot joined the server right
I'm just inviting and kicking a bot to test it
You cant use await outside async function unless you are using ipython
you want to send the message if a member joins right? If so, then yes it should work even for a bot.
Alr
So uh the code isn't working
I'm getting no error message
It just doesn't send the message
Because you don't have a error handler.
Is this gonna be for a lot of servers or just one?
I think you can do if channel.name = "join-leave":
Do I keep the for loop?
Yeah because you still have to cycle through the channels.
author = ctx.message.author
if author.voice.channel == None:
await ctx.send("You must be in a voice channel")
return``` mmm it doesnt give me errors but it doesnt work so
Nope its still not working
if ctx.author.voice is None:
#do stuff```
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
for channel in member.guild.channels:
if str(channel) == "join-leave":
break``` try this then send the embed outside the for loop, also, do you have intents on?
on_member_join for the member who joins a guild i dont think it will work for channels? idk tbh
He's trying to get the channel then send the message
Did the code work for you?
I do not have intents on because I didn't think I needed them
You need intents.
u need them
How would I get them
Really? It worked for me.
ig i have another error?
Do you have intents on?
ye
intents = discord.Intents.all()
client = commands.Bot(command_prefix=".",intents=intents)```
is it a command or on_message?
enable them on the web site and put da on ur code @final iron
!intents
nah just a command
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.
Ahh i was confused cuz I saw ctx.message.author
ctx.message.author is ctx.author :)
So I just turn on these?
I know just a extended way of doing it
Then add some stuff to my code?
ye
Sorry to interrupt, but has there been any update on sticker features getting implemented in the API
dis or
like dis
I would need all right
alr
oh alr
Yeah bro i don't know why that's not working. it should be if ctx.author.voice is None:
alr I have intents lemme test out the code
it worked thank you
Whats the point of intents anyway
i fixed the code i spelled author wrong lol das y
ahhhh lmfao
No I mean why did discord add them
for some reason? idk
Ahhh, honestly ion know lol. I just remember questioning why my events for on_member_join weren't working, then saw something about intents.
Intents are there cz discord thinks that they give u "sensitive information"
true. thats why there is intents quetions in the verification thing
why not work
So that bots don't misuse this "sensitive information"
anyone?
U need to use commands.Bot
Have patience
Also put the error in codeblock aswell
here?
yeah
No in the main bot file
Wait wait wait
Can I see yr cog file?
The one which is erroring?
hi @maiden fable 
this one
yeah
pls help
@maiden fable
ohk
Lmao
lmfao
here
Kylee gonna help u cz why not
but surely hunter will help better than me
help
Breh, I just woke up. Literally 2 min ago
ohhk
i use if on_message
if message.content.startswith('$help'):
like this
how
How did u learn discord.py?
bro?
There u go. Now u know the reason why he ain't using commands.command @vale pendant
what time is it now there?
so how do i use it
any proper ytber
10 AM (I know I fucking overslept)
everyone from youtube watches outdated videos
ohk sorry
lol pls help me
for commands.cog
Lemme give u a website
https://vcokltfre.dev/tutorial/ here i think this is pretty good to start learning discord.py
u dont have school?
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
No one gives a fuck about it lmao
ong
It's online school, so 
Why that face
Why do u think so....?
idk, you can sleep until 10 am soo....
As I said, I overslept too much. I wake up at 8 everyday
Lmao I slept at 2 or something last night, that's why I woke up at 10
@client.command()
async def guildinfo(ctx,guild):
bots = 0
users = 0
for x in guild.members:
if x.bot is True:
bots = bots + 1
if x.bot is False:
users = users + 1
static_emojis = 0
animated_emojis = 0
usable_emojis = 0
for x in guild.emojis:
if x.animated is True:
animated_emojis = animated_emojis + 1
if x.animated is False:
static_emojis = static_emojis + 1
if x.available is True:
usable_emojis = usable_emojis + 1
embed = discord.Embed(title="Guild Info:",color=random.randint(0, 16777215))
embed.add_field(name="Server Name:",value=guild.name)
embed.add_field(name="Server ID:",value=guild.id)
embed.add_field(name="Server region",value=guild.region)
embed.add_field(name="Server created at:",value=f"{guild.created_at} UTC")
embed.add_field(name="Server Owner:",value=guild.owner)
embed.add_field(name="Member Count:",value=guild.member_count)
embed.add_field(name="Users:",value=users)
embed.add_field(name="Bots:",value=bots)
embed.add_field(name="Channel Count:",value=len(guild.channels))
embed.add_field(name="Role Count:",value=len(guild.roles))
embed.set_thumbnail(url=(guild.icon_url))
embed.add_field(name="Emoji Limit:",value=guild.emoji_limit)
embed.add_field(name="Max File Size:",value=f"{guild.filesize_limit/1000000} MB")
embed.add_field(name="Shard ID:",value=guild.shard_id)
embed.add_field(name="Animated Icon",value=guild.is_icon_animated())
embed.add_field(name="Static Emojis",value=static_emojis)
embed.add_field(name="Animated Emojis",value=animated_emojis)
embed.add_field(name="Total Emojis:",value=f"{len(guild.emojis)}/{guild.emoji_limit*2}")
embed.add_field(name="Usable Emojis",value=usable_emojis)
await ctx.send(embed=embed)```
i have this
So?
Ignoring exception in command guildinfo:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 1127, in guildinfo
for x in guild.members:
AttributeError: 'str' object has no attribute 'members'
The above exception was the direct cause of the following exception:
error
im jealous 😠my parents wont let me sleep after 11 pm
what? i havw in person
that’s unlucky i sleep at like 2 or 3 am
then also u r online on discord after 12, no?
Well I got my own room, so yea. I can sleep whenever I want :D
?
um no?
Well we also have the option for offline one but as I said, no one cares
!ot
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
lemme make u more jealous 🤡 im like a bat i sleep at 11 am and i wokeup at 12 am
well i have a question
😂
Go on
how do i make a bot reply to dms
how to make a whatsapp bot
I saw that coming
like if someone dms the bot it replies with something
!d discord.Member.send
await send(content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=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/stable/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/stable/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
?
no like im surprised your school is still online
bruh
if isinstance(message.channel, discord.DMChannel):
when my parents are gone i dont sleep 
but still, if they're at home i have no choice
Well, my parents don't really mind when I sleep. They give me this much freedom at least cz.... I am gonna be 16, ig?
i feel bad for u tbh
same tbh
maybe they thought im still a kid?
😂
how old r u


14
can u liek give the code im dumb
I just gave u...
Legally you are a still child.
ye
Same

hol is there a way that u can control over 10 tokens?
in 1 code
like u can run 10 tokens
Why would you even do that
if i want 3 bots with the same code
Bot needs to be ran separately with the token
Here's someone who asked:
https://github.com/Rapptz/discord.py/issues/516
ye but like uhm you can make a list like tokens = ["token 1 ","token 2"] client.run(tokens)
how can i make my on_message event react to every message
like it shouldn't be if message.content.startswith or if "hello" in message.content
client.event
async def on_message(message):
if message.channel.id == 882257233872814133:
embed = discord.Embed(title="zxzc")
embed.add_field(name="asdasd")
await message.channel.send(embed=embed)``` i tried this but doesn't work any idea why?
Won't work
😂
you can do this
loop = asyncio.get_event_loop()
loop.create_task(bot1.start(your_args))
loop.create_task(bot2.start(more_args))
loop.run_forever()
Everything is explained here
any1?
because you have no value parameter for add_field
right.
could be something else in your code
it's still not working
maybe because there’s no error handler?
no errors
they don’t need an error handler
what’s the problem?
there’s a thing called a terminal
maybe process it..
Not about commands
That's not the Terminal as you can see
processing commands doesn’t matter with this error
nor there's any problem in terminal
go to your terminal mate
Quick confirmation, you're sending the message in the channel with the ID you're checking above right?
hmm you have any error handlers?
that should raise an error tho
No...
Comparing an int with an int doesn't raise an error..
did you end up adding that value or no?
yes i did
interesting
hmm
at this point i’d add print statements to see where your code is stopping
that's what i am doing
Here comes the professional
!d discord.VoiceChannel
class discord.VoiceChannel```
Represents a Discord guild voice 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.
i think your code is stopping before you get to your check, cause if it wasn’t, an error would have raised given that your value parameter for the embed was missing.
since this event is called on every message
whether it’s correct ID or not
yes
is that a thing?
!d discord.Intents.messages
Whether guild and direct message related events are enabled.
This is a shortcut to set or get both guild_messages and dm_messages.
This corresponds to the following events...
Specifically later it will be a privileged intent
tf i could of sworn i could use on_message without intents
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
read this
@slate swan idk, i would say the event isn’t being called.. but why or how?
idk lol i am also confused




