#discord-bots
1 messages Β· Page 568 of 1
aiosqlite*
lol, which one do I choose
there is sqlite3
lol
There's also postgresql
Help
mongo db easiest
@commands.command(aliases=['search'])
async def google(self, ctx:nextcord.ext.commands.Context, *, query: str):
await ctx.send(f'Google Result for: `{query}`', view=Google(query))```
yes but it is not so easy and quick
ty
its commands.Context
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\jason\chad\cogs\info.py", line 247, in google
await ctx.send(f'Google Result for: `{query}`', view=Google(query))
File "C:\Users\jason\chad\venv\lib\site-packages\discord_slash\dpy_overrides.py", line 323, in send_override
return await send(channel, *args, **kwargs)
TypeError: send() got an unexpected keyword argument 'view'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jason\chad\bot.py", line 66, in on_message
await bot.process_commands(message=message)
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\ext\commands\bot.py", line 1032, in process_commands
await self.invoke(ctx)
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\ext\commands\bot.py", line 999, in invoke
await ctx.command.dispatch_error(ctx, exc)
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\ext\commands\core.py", line 520, in dispatch_error
await injected(cog, ctx, error)
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\ext\commands\core.py", line 154, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\jason\chad\cogs\info.py", line 556, in google_error
raise error
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\ext\commands\bot.py", line 995, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\jason\chad\venv\lib\site-packages\nextcord\ext\commands\core.py", line 895, in invoke
await injected(*ctx.args, **ctx.kwargs)```
no?
Nextcord ππ
lol
cmon whats the problem?
use tinydb
No wonder you got an error
xD its a json file
unoficcial 3rd party of dpy...
xD
dont be rude and try to help me?
Can someone give me the code of members intents or the python bot command of intents
how did u fix it?
same error its just a library problem
I would but idk, never used nextcord to that extent
Fork*
I didn't, the code wasn't mind I was helping someone
fix?
read the pins
that's how they are, get used to it π¦
Idk?
Thx
lol
it isnt because of nextcord
its because of the lib he's using
cuz discord slash?
yes
discord_components?
File "C:\Users\jason\chad\venv\lib\site-packages\discord_slash\dpy_overrides.py", line 323, in send_override
return await send(channel, *args, **kwargs)
TypeError: send() got an unexpected keyword argument 'view'
chad π³
btw how do you make slash commands to the bot instead?
how do uk chad
use a fork that has slash commands
Depends on what lib you're using
lol
im using the discord lib?
bruh i just migrated everything to nextcord
There's more than 1
If it's dpy, they don't have it
iirc nextcord's slash commands are still in beta
You could use a 3rd party lib, but that could mess with dpy's internals, like they always did
So you'd be better off by using a fork
How do we update things in that
And by far the best and most promising and mature fork is disnake
I have the
MASTER
version π
shit lib
Master doesn't have it, Danny never added slashes to dpy
google tinydb
i did
i hv an idea
im asking how do we update things in tinydb
who's danny?
What if i use discord slash buttons......
ok tinydb.update
dpy owner
π
That's a very shit lib
The owner of dpy
What? Wasn't that the ponzzk something idk
idk why it's in pins then
Β―\_(γ)_/Β―
!unpin shit lib
You are not allowed to use that command here. Please use the #bot-commands channel instead.
what? lol
rapzzz something
Who that
idk i cant remember his name
That's Danny
yeah Rapptz lol
ponzzk
aka danny 
π
ππ
π π
you know it! π
RoboDanny 
**i am trying to make an afk cog ** with very limited knowledge of python
the screenshot shows what i have in mongodb
what i want to do is:
on_message
if someone mention you
bot check if mention.id in member (on database)
check AFK (on database)
send message: user is afk with {reason}
if member texts
bot check if author.id in member (on database)
set AFK to false (on database)
can anyone help please?
how do i read database, any docs would help too.
Got caught in 4k fam
afk cog
nono i was just joking
Object

channel.history it is then, i'm outta here thanks guys
this is even worse than #help and #help-2 
ππ
btw what is the attribute/method called to check if there is a channel named something
or no i need to iterate through every channel and see if there is a channel called logs?
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
if returns none then there is no channel with this name
You could do that too
discord.utils.get(guild.text_channels, name'hey')
returns None if not found
utils.get is just wonderful
That needs an id not a name
and that checks all the channels the bot has perms to view right?
in one guild yex
Wheres that
yes*
alright thank you
well
Dpy server
you can pass bot.get_all_channels()
You're banned from it afaik
yes I am
at .gg/dpy
I'm 99% sure you went to r. Danny's server and asked why u got banned in dpy
stalker
π
I just happened to join π
@has_permissions(manage_roles=True, )
what is it called if i want to check if the user has permissions to edit /create channels?
xD
manage_channels iirc
manage_channels
alright thanks guys
today ur a little bit more helpful heh
π
No u just didn't do anything that got on my nerves
yet
xD
imagine
u wan't me to start?
wan't
wan't
ah yes i wan't
Wan't
Wan't
kyle wan't to get unbanned from dpy
maybe here someone?
table tags:
| ID | NAME | CONTENT |
+----+-----------+----------------+
| 1 | email | bruh email |
| 2 | gmail | bruh gmail |
| 3 | morth | bruh morth |
| 4 | gmail.com | bruh gmail.com |
| 5 | nomail | bruh nomail |
SELECT tags.name
FROM tags
WHERE tags.name SMTH 'fmail'
LIMIT 3;```
I want this SMTH to be as LIKE operator but to it return:
```py
[ ['email'], ['gmail'], ['gmail.com'] ]```
Is there any way to do that?
Wrong channel
π¦
yes
Poor guy ππ
i was immature at the time π
KeyError*
π
maybe you help me there ?(
idk databases 
Idk SQL that good
lol
goes back a thelping in #help bye guys 
Bye goes back to sleep
if utils.get(ctx.guild.text_channels, name="mod-logs"):
does this return a bool btw?
No
no but the comparison would work
It returns the TextChannel object
it returns a discord.TextChannel
but it also returns None if not found so the If statement still applies
ah I see, if it doesn't return the channel it returns None right
yep
alright ty
:D
I know how to create a role, does it apply the same thing with creating a text channel?
yes
Get its id
or discord.utils.get
raise MessageNotFound(argument)
discord.ext.commands.errors.MessageNotFound: Message "10s" not found.
I don't understand?
(check my code before assuming) idk what i'm doing wrong, can someone help me?
why i am getting guild ids in my console also there is no print for that ?
Shows syntax error
how can i make a eval command that really do what i said
for example i evaluate a role code, it'll role me
how can I get the sent message ID?
maybe you can do
msg=await ctx.channel.send("Your message")
print(msg.id)```
ok ty
but no no
i want the id of the authors message
o
so you can do
print(ctx.message.id)```
give it a try
Thanks it worked, how can I DM someone?
await ctx.author.send("message")```
π
ty!!
:D
I figured out the error
but thanks for reply
I had added 1 less ')' bracket
Alr
this is a support server so you can ask here. Use #databases for help with mongo DB.
He maybe asked here cuz hes using it for his bot
its still a db question is it not?
Yes it is but is related with discord.py too
I have a question, does anyone know how to find more of the <> discord things? Ik you can do <@id>, <#id>, <t:unix time stamp:R> but are there any more and how can I find them?
How can i check for two reactions?
The β is working, but the β is not
It's not doing any errors, it's just not working
How to fetch user from id?
user = get(bot.get_all_members(), id="1234")
if user:
# found the user
else:
# Not found the user
or something like client.get_user(id)
I think i was using this before
!d bot.fetch_member
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.
oh get_user also works
change your check
and (str(reaction.emoji) == "checkmark_emoji" or str(reaction.emoji) == "X_emoji")
then use an if statement
mmm can you give me an example please
cuz i don't know wdym
Hey @inner pumice! 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 doing my discord bot in class and it seems like all ctx commands don't work. How can I fix this?
i used bot.get_user() instead
Yes, he asked how to fetch a user
Hey so I've made plenty of bots before and i set this one up just as all the other with this code: ```py
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='!', intents=discord.Intents().all(), help_command=None)
token = 'blabla'
client.run(token)```
but the deploy keeps on failing with this error and I don't know why ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ERROR: failed to build: exit status 1 ERROR: failed to build: executing lifecycle: failed with status code: 51
Any ideas?
no, I just didn't have the emoji so I typed it in
you should use the emoji
your check should pass, doesn't matter if it's a β or an β
then you can check
if str(reaction.emoji) == "β
":
#yes
else:
#no
yes, change your check then check if it's a checkmark
return user == ctx.author and (str(reaction.emoji) == "β
" or str(reaction.emoji) == ":β:")
but i want to do different things after different emojis
use an if statement
.
How do you make both of these tags?
I spoonfeeded u
return user == ctx.author and (str(reaction.emoji) == "β
" or str(reaction.emoji) == "β")
i need to use the if statement
yes
so it will look like this?
but not in the check
after the wait_for()
in the wait_for, you get every data
you can use the data right after
exactly
how do i get all the roles a person has in a server?
member.roles -> returns a list of role objects. Where member is an instance of discord.Member.
okay thank you
<Role id=903947766768750603 name='rtjt45y'> it gives me this, i want only the name
!d discord.Role.name then you do role.name
The name of the role.
ok
Thats the role object
you're gonna have to access the role's attrs to get what you want
[k.name for k in member.roles]
Imagine
roles = member.roles```
this is how i defined roles btw
ok coochie man
im different
property mention: str```
The string that allows you to mention the channel.
only gave me one role
then you only have one role
does it have role intents
nope
hm
u sure u have 4 roles
wait
@wintry kernel did u even loop
over your roles
outside
i want it in a sentence
lmfao i printed it outiside
is there a way i can print it outside and still get all roles
ye ye ik
@manic wing
jeeeeezus
holy shit
thats what the list is...the starting member.roles is the list of all the roles - you've gone and made it more difficult
a last question.. how do i remove the [] and ,
and how do i ping all the roles like it did for @everyone
print('@'.join([k.name for k in member.roles]))
how could i let the bot wait answer of a member on pm and store it into a var? (on pm)
', '.join([role.mention for role in member.roles]) iirc
await member.send('Hello!') #where member is an instance of typing.Union[discord.User, discord.Member]
message = await bot.wait_for('message', check=lambda m: isinstance(m.channel, discord.DMChannel) and m.author.id == member.id)```
what's check=lambda m: isinstance(m.channel, discord.DMChannel) ? i'm not good enough sorry
class discord.DMChannel```
Represents a Discord direct message 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 a string representation of the channel
and the check means that the on_message only reacts if it follows the checks; the on_message only triggers if the channel is an instance of discord.DMChannel, and if the message.author.id is equal to the member's id. Meaning that not everyone can just respond.
bruh
thx
embed = discord.Embed(color=discord.color.blue
do you have any questions? I prefer explaining than spoonfeeding
i can feel it
sooooo i would ask
i do not understand that m.channel
why ctx commands doesn't works in class?
hm
!d discord.Message.channel awesome - in the lambda (which is just like a one line function), it takes one argument - and that is m. You can call m whatever you want, but all m is, is the message. m is just discord.Message. You know how a def on_message(message) accepts message? So does the lambda. Maybe I shouldve renamed m to message. Also, instead of doing lambda you can do check=check and def check(message): return message.author.id == β¦ # blah blah blah
The TextChannel or Thread that the message was sent from. Could be a DMChannel or GroupChannel if itβs a private message.
pycharm moment
python moment
what ide should I use?
second question, why m.author.id == member.id instead of m.author.id == ctx.author.id? i do not know where to get that member
from discord.ext import commands
import discord
from var import *
class admin(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def test(self, ctx):
await ctx.author.send('Hello!') #where member is an instance of typing.Union[discord.User, discord.Member]
message = await bot.wait_for('message', check=lambda m: isinstance(m.channel, discord.DMChannel) and m.author.id == member.id)
so i should use commands instead of bot, but i do not know how to catch that member
personally VSC or sublime
m.author.id == ctx.author.id is literally the same
m is short of message
m.author.id == member.id checks if the author is equal to a member
But sublime is only a text editor and not an IDE
yes, but how do i get member
If we follow a channel in a server if the message in that channel deleted does it deleted automatically in our channel
i need to do for of guild.members and get the id in a var?
I just said member because it might not be ctx- just replace member with ctx.author
You need to also pass self in the function
VSC then
Like async def test(self, ctx: commands.Context, *args, **kwargs):
the bot starts, but all commands and activity status do not work
replit
just use visual studio code like a normal person 
imagine being normal
I downloaded vsc, but the bot doesn't work now
i really only use vsc for js json and html
How to check if mentioned user's top role is lower or higher than author's top role??
!d discord.Member.top_role
property top_role: Role```
Returns the memberβs highest role.
This is useful for figuring where a member stands in the role hierarchy chain.
I triedpy if user.top_role >= ctx.author.top_role: print("Nope")
That should work
when adding a field to an embed is there a way to not have a name value
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'top_role'
if you dont want a title for that field
wtf
python has no >= only > and <
Your user is not a Member object
Yes it has...
you need member intents
!e
if 10 >=10:
print(True)
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
True
i have
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.
Your user in your code is not a user object for some reason, paste the code here, let's check
ok
@slate swan
@client.command()
async def welcome(ctx, user:discord.Member=None):
if ctx.author.guild_permissions.manage_messages:
if user is None:
await ctx.reply("Woah, how can you think of welcoming no one?")
if user==ctx.author:
await ctx.reply("You cannot welcome yourself...")
elif user==ctx.author or user.top_role >= ctx.author:
await ctx.reply("Bruh, you cannot welcome someone who is already in such a high rank!")
else:
await ctx.message.delete()
for role in user.role:
if role.id==698500675306258452:
await user.remove_roles(role)
initiate_role=ctx.guild.get_role(698500328169013258)
await user.add_roles(initiate_role)
await user.send_message(f'You have been promoted in {ctx.guild.name}!')
await ctx.channel.send(str(welcome.replace("(userhere)", f"{user.mention}")))
else:
if ((datetime.now() - user.joined_at.strftime("%m/%d/%Y, %H:%M:%S")).total_seconds)<=60:
initiate_role=ctx.guild.get_role(698500328169013258)
await user.add_roles(initiate_role)
await user.send_message(f'You have been promoted in {ctx.guild.name}!')
await ctx.channel.send(str(welcome.replace("(userhere)", f"{user.mention}")))
else:
ctx.reply("That user was already in the server!")```
you need member intents
Yup
If the ide tells you that is a None object is because or you haven't pass an argument in your command or the typehinting can't convert the string you pass into an user object
I have intents
I noticed it too but it isn't the problem ππ
user is a NoneType object
intents = discord.Intents.default()
intents.members=True```
Essentially is equals to None
Start the debug
And follow up the user variable
Remove self parameter
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '>=' not supported between instances of 'Role' and 'Member'```
Self parameter is for Cogs
When I pinged the bot itself, it gave this error: raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'role'
Code
its .roles
@client.command()
async def welcome(ctx, user:discord.Member=None):
if ctx.author.guild_permissions.manage_messages:
if user is None:
await ctx.reply("Woah, how can you think of welcoming no one?")
elif user==ctx.author:
await ctx.reply("You cannot welcome yourself")
elif user.top_role >= ctx.author.top_role:
await ctx.reply("Bruh, you cannot welcome someone who is already in such a high rank")
else:
await ctx.message.delete()
for role in user.role:
if role.id==698500675306258452:
await user.remove_roles(role)
initiate_role=ctx.guild.get_role(698500328169013258)
await user.add_roles(initiate_role)
await user.send_message(f'You have been promoted in {ctx.guild.name}')
await ctx.channel.send(str(welcome.replace("(userhere)", f"{user.mention}")))
else:
if ((datetime.now() - user.joined_at.strftime("%m/%d/%Y, %H:%M:%S")).total_seconds)<=60:
await ctx.message.delete()
initiate_role=ctx.guild.get_role(698500328169013258)
await user.add_roles(initiate_role)
await user.send_message(f'You have been promoted in {ctx.guild.name}')
await ctx.channel.send(str(welcome.replace("(userhere)", f"{user.mention}")))
else:
ctx.reply("That user was already in the server")```
member.roles if you trying to get someone roles (list)
can you show me your full class?
Already fixed
ah ok π
instead let me try user.bot
In last line you miss await ctx.reply
There is no attribute named "role"
You are searching for .roles which returns you a list of roles set in this way: [(<role_tag>, role_name, role_id)] if i'm not wrong
you mean classes
cogs are subclassed classes
oh yea
The most important thing is that everything works 
π
!e
class a:
def __init__(self, bot):
self.bot=bot
def im_cool(self):
return "im cool"
print(a("kayle").im_cool())
``` π
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
im cool
slash commands doesn't works now
not in dpy
What lib are you using
Show code & error
Can I pm you with code?
so im making an on ready event with a new bot and I want it to tell me the number of the session, e.g "Session 1" then next tme "Session 2" etc.
how could I go about that
could I make something that adds to the last number mentioned
or what
i guess
any ideas of how I can go about doing this?
basically each time the console is run, it adds 1 to the last number
there must be a module or smth
to check when the console runs
store the number of bot starts in some db or a json
on every on_ready event
ok ill have a look
not used much db or json before lol
ill have to do some learning
but thanks for the idea
json easy pz , or even a txt file will for your purpose
tru
That's not the correct decorator for a class
classes dont have decorators though
Hi, if have this in my code, the commands won't work. Why and how can i solve it?
use bot.listen()
@quaint axle.listen()
add this to the end of the event: await client.process_commands(message)
then the commands will work
if you use listen()
remove one indentation
he should
because otherwise as he said commands wont work
if he uses listen, then no
well instead of changing everything to listen() then he can just use what i said
.
this is working
just at on_message
you're welcome
everything's explained on the message I answered
actually here it's better
how do I mention the channel name?
channel.mention
I want him to mention only one channel: 835236006713098304
<#id>
Create text file rename it to .env
im in vscode and i did that
i just made a file called .env directly though
No that's all you need but i still don't have an error.
bot.token(os.getenv('TOKEN'))
why dont ppl just create a file then import it from file import variable then bot.run(variable)
idk
Well?

never heard of it
heard of what
import variable
Since .env is more secure, when using environment variables you cannot accidentally commit your token to your program/repo.
cant u just
.gitignore..?
.env is a default gitignore.
did you enter the token properly
hm
Why aren't you giving us the error?
yes in the .env file i put TOKEN = 'ABC'
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
A full traceback could look like:
Traceback (most recent call last):
File "tiny", line 3, in
do_something()
File "tiny", line 2, in do_something
a = 6 / b
ZeroDivisionError: division by zero
The best way to read your traceback is bottom to top.
β’ Identify the exception raised (in this case ZeroDivisionError)
β’ Make note of the line number (in this case 2), and navigate there in your program.
β’ Try to understand why the error occurred (in this case because b is 0).
To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
it takes time to load
ill try rn
slow laptop
Oh
i'll send a ss
hm
def get_tag(self, guild_id: int, name):
def disambiguate(rows):
if rows is None or len(rows) == 0:
return 'Did not found anything.'
return '\n'.join(ro[0] for ro in rows)
t = self.bot.database.fetchall('SELECT user_id, name, descr FROM tags WHERE guild_id = %s AND name = %s',
(guild_id, name))
if len(t) == 0:
query = """SELECT tags.name
FROM tags
WHERE tags.guild_id=%s AND tags.name LIKE %s;
"""
r = self.bot.database.fetchall(query, (guild_id, name))
return disambiguate(r)
return t[0]```
always returning `Did not found anything.` if tag with `name` not exists, any way to fix?
What am i supposed to put here bc i got an errorti na valw edw gia na mhn bgazei to error
@bot.event
async def on_message(message , *, ctx):
on_message takes only 1 arg and that is message
remove * and ctx
ye ik but i have this
e=discord.Embed(title=f' :ticket: | Server : {ctx.guild.name}')
e.set_thumbnail(url=f'{ctx.guild.icon_url}')
so ? message has a guild attribute as well
^
e=discord.Embed(title=f' :ticket: | Server : {message.guild.name}')
e.set_thumbnail(url=f'{message.guild.icon_url}')
like this?
sure , but are trying to make a command?
no
logs
ohok , so yeah message.guild is the thing
how do you DM a user who reacts to a role without using ctx?
eh
it works tysm
are you using that in a listener or event?
wdym
oh
a listener
mhm , on_reaction_add takes a user arg
you can use user.send(
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesnβt require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itβs required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
would i use payload.author or payload.member
are you using the raw event?
( raw_reaction_add)
The way reactions are meant to be made.
it would be payload.member
no payload.user member does not exist
user (Union[Member, User]) β The user who added the reaction.
yeah raw
It's a union.
You have to actually load the .env first.
the env returns TOKEN value as None somehow
where did you find this so i can see the rest?
@slate swanClick on the reaction the then the lowest blue URL.
how
oh
Oh lol scrap that use member i was overlooking to remove event.
is that for v2.0?
No scrap that i was looking to remove raw event.
oh alright
In on_raw_reaction_add there's no payload.user
they already told twice
That is exactly what i said if you read a bit further.
Wait I think I should not add a ' around the word
Hey @slate swan!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
the indents-
why are you making your bot instance in the cog also?
you could have just used and in the conditions
also raw_reaction_add takes only payload as an argument
I don't know how to load a .env file now..
did you create one?
this keeps on happening
yes
it has TOKEN = "the token"?
yes
i made the env file again
yet the error happens again
is it in the same dir as your bot's file
directory u mean file?
yes
I asked, they said me to try here..
someone?
why tf
How can I get all the messages in a channel?
How can I create category with bot???
Does anyone knows it?
because it is for bot tf
Remove len I guess, also there might be no data
it has nothing to do with dpy
Len has no use afaik
not related to discord bots
why bruh? It checks if there are 0 results like bruh
idrk
It either gives smth or no.
And you alrd check it without len
bruh... anyway that didnt help
Is there anything to return?
yes
!d discord.Guild.create_category
await create_category(name, *, overwrites=..., reason=None, position=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Same as [`create_text_channel()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`CategoryChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.CategoryChannel "discord.CategoryChannel") instead.
Note
The `category` parameter is not supported in this function since categories cannot have categories.
if isinstance(error, [what to put here] ):
await ctx.send("You are not connected to any voice channel")```
can anyone tell how to send error when user is not connected to voicechannel
with discord.py

!d discord.Member.voice
property voice: Optional[discord.member.VoiceState]```
Returns the memberβs current voice state.
if none: send
How can I find a specific message sent in a text channel?
Well can't help with what ever module you use. I think I have not used it
ok
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destinationβs message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
@tough wagon try printin the rows tho
ty
I think you should learn more python before engaging in the most difficult part of discord.py
can I do no limit at all?
it will print [] i tried
But it's gonna take AGESSSSSSS
Thanksssssssssss||Happy Holloween hunter!!||
Then there is no data
That's fine
lol
... no data SELECTED
if i print all rows of db of course it will return rows
I give up
if isinstance(error, discord.member.VoiceState ):
await ctx.send("You are not connected to any voice channel")```
like this ?
I don't have time for this
(:
The reason I know all these is cz I just see the relation... You make a category in a Guild and all the create methods start with create_... Then it's all trial and error with the docs command haha
|| Same to you!!! ||
..........
no
Hmm... Okay!! Thanks :)
||Thanks!||
Why when i am using this none of the commands are working?
@bot.event
async def on_message(message):
if '>help' in message.content:
comm_lg = bot.get_channel(903980815212503091)
command_logs = bot.get_channel(903980815212503091)
await comm_lg.send(f"{message.author.mention}")
e=discord.Embed(title=f':members: | User : {message.author.name}#{message.author.discriminator}', description=f' **:ticket: | Id : {message.author.id}**', timestamp=message.created_at)
e.set_author(name=f' | {message.guild.name}', icon_url=f'{message.guild.icon_url}')
await command_logs.send(embed=e)
@command(name="bruh")
async def _bruh(ctx, *, member: discord.Member):
if member.voice is None:
await ctx.reply('this member not connected to voice channel bruh')``` @green jacinth
ok ty
umm like hey
π
cant it be in if isinstance
What does isinstance do?
ok if isinstance(member.voice, None): @green jacinth
@play.error
async def mojkardi_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send("You are on cooldown!")
if isinstance(member.voice, None):
await ctx.send("You Must JOin vc") ```
this is the one i want to add it for voice tracing
first - @play.error
@play.error maybe?
umm i edit i tlike this
no
yea
pls read my messages
then
k
this one
@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
if ctx.author.voice is None:
await ctx.reply('You are not connected to any voice channel!')
return
async def wetfart(ctx):
voice_player = await ctx.message.author.voice.channel.connect()
print("Releasing Wet Fart")
rahalog = bot.get_channel(903976956842868736)
await rahalog.send("`Releasing Wet Fart`")
await ctx.send("> Releasing Wet Fart")
voice_player.play(discord.FFmpegPCMAudio("wet-fart.mp3"))
await asyncio.sleep(3)
await ctx.voice_client.disconnect()
@wetfart.error
async def mojkardi_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send("You are on cooldown!")```
the real code
xd

@tough wagon please put it in this and forward
;-;
ctx.author is enough.
put
if ctx.author.voice is None:
await ctx.reply('You are not connected to any voice channel!')
return``` to start of command
someone pls
what exactly not working? any errors?
How can I get the content in the message when i use .history()?
if utils.get(ctx.guild.text_channels, name="mod-logs"):
channel_history = utils.get(ctx.guild.text_channels, name="mod-logs")
async for messages in channel_history.history():
print(messages)
else:
pass
this is what I have now
messages doesn't return anything about that content
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the messageβs hash.
So?
on_message stops commands. use @bot.listen() not @bot.event
Rename messages to message and do message. ...
messages.content @slate swan
message.content bro
Lol
ohhh ok ty
@pliant gulch why would there be a case where you use event not listen? Whats the difference between bot.event and bot.listen()
Breh
no errors
@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def wetfart(ctx):
if ctx.author.voice is None:
await ctx.reply('You are not connected to any voice channel!')
return
voice_player = await ctx.message.author.voice.channel.connect()
print("Releasing Wet Fart")
rahalog = bot.get_channel(903976956842868736)
await rahalog.send("`Releasing Wet Fart`")
await ctx.send("> Releasing Wet Fart")
voice_player.play(discord.FFmpegPCMAudio("wet-fart.mp3"))
await asyncio.sleep(3)
await ctx.voice_client.disconnect()
@wetfart.error
async def mojkardi_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send("You are on cooldown!")```
like this
What is the command called when u wanna check the history of a members punishments(mute, kicks, warns) etc?
okay let me try
like what do I name my command?
n...o...
That is called a database, yes.
please u put and tell
!tag learn python
-_-
u said at starting it means it -_- u must have used line no this
not what I meant, like what do i call the command to get this command ran?
That's why i told him but you spoon fed him anyways.
in async def wertfart, not outside
where?
@tough wagon see it i edit
like !incidents <member>?
or what is it called?
Here.
it is at the end now...
tell line no xd
4..
now see
I know exactly what you mean and you should not use this method to do this.
@cloud dawn if what I do is spoonfeeding then there's the only way right (send lpypls)?
yes...
no I don't think u understand, I ask for what the name of discord command should be to check a members history of punishments, like i have !kick command, !ban command, but what should I name the command to check the history of punishments, my english isnt good so idk what its called
Currently yes since he doesn't know enough python, so you can better just code it yourself lol.
please tell me only once vro -_- i am sry i dont know it so that why i am asking you so that i learn it and dont forget it next time
Yes i do understand but you are going to need a database for that since your solution is impractical and really slow.

IndentationError
yes ik it's just temporary, can u just give me the name if u know the name?
Usually that command is called infractions
learn py
okay thank you
cant u tell me once bro -_-
i may learn from it only
it will help
-_-
tabs required
you are in a function (async def wetfart(ctx):), everything in this function should be as usual code but with tab before it in every line
Like see:
not in function
do_something('yes', 'no')```
in function
```py
do_something('yes', 'no')```
this is the basic of python syntax
bruh
sir
It's not that we don't want to help, it's that at this point we would basically code it for you. And most people here are not going to do that for you.
Hey @green jacinth!
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:
Can i see the code
i just asking that can your put that if in my code it would help me man π¦ ok np
?
;-;
π
!indention
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
huh
you dont need self outside classes
I recommend reading this.
k
Most projects online are in a cog so that explains the self copy
@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def wetfart(ctx):
if ctx.author.voice is None:
await ctx.reply('You are not connected to any voice channel!')
return
voice_player = await ctx.message.author.voice.channel.connect()
print("Releasing Wet Fart")
rahalog = bot.get_channel(903976956842868736)
await rahalog.send("`Releasing Wet Fart`")
await ctx.send("> Releasing Wet Fart")
voice_player.play(discord.FFmpegPCMAudio("wet-fart.mp3"))
await asyncio.sleep(3)
await ctx.voice_client.disconnect()```
i want a bot event like this can anyone make me one
if ctx.author.voice is None:
await ctx.reply('You are not connected to any voice channel!')
return```
here is prb
the return is kinda.. odd
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
see i tell what help i want is that i want to that it shows error when a user is not is vc
@client.event
async def on_guild_join()```
i mean wehn the bot joins a server yk
then what's the problem currently?
@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def wetfart(ctx):
voice_player = await ctx.message.author.voice.channel.connect()
print("Releasing Wet Fart")
rahalog = bot.get_channel(903976956842868736)
await rahalog.send("`Releasing Wet Fart`")
await ctx.send("> Releasing Wet Fart")
voice_player.play(discord.FFmpegPCMAudio("wet-fart.mp3"))
await asyncio.sleep(3)
await ctx.voice_client.disconnect()
@wetfart.error
async def wetfart_error( ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send("You are on cooldown!")```
and i want to inplement it in this
Ikk
If you want people to create a bot for you i recommend going to fiverr
idk how to put actually
i have mine but yk recently started coding
The answer got spoonfed 10 minutes ago already.
i wanted to go with
if isinstance(error, [ liek here ]):
error coming and also it is not sending
That is good, but we are here to help not to provide whole working code. Discord.py is quite the advanced library so beforehand knowledge is pretty much mandatory.
ok
@visual island could you tell ?
If you can re-read what Master32 has send you rather than pinging other people, he has already told you the asnwer.
i saw but error is coming sir
and it is not sending that u must be conneceted to a voice channel
You can't put this error in an isinstance since it would most likely just be an attribute python error.
Hol on do i need database for shards?
ok then without it also
No.
||I just want to spoonfeed eIeIEe||
@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def wetfart(ctx):
if ctx.author.voice is None:
await ctx.reply('You are not connected to any voice channel!')
return
voice_player = await ctx.message.author.voice.channel.connect()
print("Releasing Wet Fart")
rahalog = bot.get_channel(903976956842868736)
await rahalog.send("`Releasing Wet Fart`")
await ctx.send("> Releasing Wet Fart")
voice_player.play(discord.FFmpegPCMAudio("wet-fart.mp3"))
await asyncio.sleep(3)
await ctx.voice_client.disconnect()```
||That's what i told you||
Is there something like async class?
see it gives https://paste.pythondiscord.com/dakacuvexi.sql
How do ik shard_id for each server ?
How many servers is your bot in?
AttributeError?
90
geez
I have this code:
class Interactor:
global connection, mode
# lambda m: m.content == "" and m.channel == connection
def connect(modearg):
connection_guild = bot.get_guild(interact_url)
connection = discord.utils.get(connection_guild.channels, name='api')
mode = modearg
if mode == 1:
await connection.send('--connect')
return True
else:
return False
As you know, await connection.send won't work because it's not in an async function, however I still wanna use it somehow. Any way I can get around this?
async def
when cmd is runned then it shows
channel = utils.get(ctx.guild.text_channels, name="mod-logs")
async for message in channel.history():
async for message in channel:
TypeError: 'async for' requires an object with aiter method, got TextChannel
Help?
Okay first of all, you need autoshardedbot instead of bot as the instance and you'd need atleast have around 2000 guilds in order to shard.
so I just put the class in an async function?
no, you put the function in one
async def functionName
which ic connect for you
now no error nor any reply
ohh alright
!d asyncio.create_task
asyncio.create_task(coro, *, name=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.
If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").
The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.
This function has been **added in Python 3.7**. Prior to Python 3.7, the low-level [`asyncio.ensure_future()`](https://docs.python.org/3/library/asyncio-future.html#asyncio.ensure_future "asyncio.ensure_future") function can be used instead...
ππ½
fixed it myslef -_-
what are you trying to do?
after running it 2-3 times
Cool
wait, so to access the function do I do Interactor.await connect()?

@cloud dawn -_-
trying to print the content of all messages in a specific channel
but why isn't it working
await Interactor.connect()
ty for telling about it ;-;

This is exactly what we are asking of you.
cant you just do
async for message in channel.history():
print(message.content)
```?
literally what i did, but channel.history() didn't return anything I think
limit=None
ty man for being hard with me and leting me learn it my self
it returns AsyncIterator object
fair enough, though I was wondering if there was a way to do what I'm trying to do without having to put "await" everytime I wanna call a function
what exactly does that do?
nop
damn
Still doesn't work
if utils.get(ctx.guild.text_channels, name="mod-logs"):
channel = utils.get(ctx.guild.text_channels, name="mod-logs")
async for message in channel.history(limit=None):
print(message.content)
This returns literally π nothing π
Well it might sound a bit harsh but discord.py is an advanced library not meant for beginners. Even the owner of discord.py states this.
then there is no channel names mod-logs @slate swan
try print(utils.get(ctx.guild.text_channels, name="mod-logs")) before that if
I'd disagree. Discord.py is far from advanced, I'd say it's suitable for advanced beginners
it prints mod-logs
it doesn't get the messages tho
No? Machine learning is easier than discord.py.
yea i know due to my exam i was not able to pratise and i forgot 50% things
Really? Why do so many people complain about machine learning being so difficult, when it's easier than a Discord library in Python?
do messages = await channel.history(limit=None).flatten()
and print(messages)
Because they don't learn hard parts of this lib?
What would be some of the hard parts in your opinion?
Because people are already use discord and use discord bots, whack a friendly UI in the doc page and a bunch of tutorials since Discord is pretty popular and bam.
Cogs, HelpCommand, database, Groups, basics of python, Views (2.0)
Autosharding, IPC routes, OOP, Subclassing, async programming
I've seen beginners (6 months) use cogs and groups lol
it is not so discord.py
it's python
Not really about discord.py
basically runs a coroutine without awaiting it
"Discord.py is an OOP async library"
Cogs?
it prints some information about the messages sent in the channel, it works
I've seen beginners (6 months) use cogs and groups lol
Well yeah if you put the effort and time in it, some people also learn faster than others.
is limit=None allowed anyway?
try changing it to 100 and see if it makes a difference
I guess you're right
it worked with limit=None
The thing is this library is also well documented so i wouldn't be surprised for someone to make an advanced bot in even 2 months if they spend ca 6 hours a day on it.
@bot.command(ctx, member:discord.Member=None):
async def info(ctx):
embed=discord.Embed(title="Cursex", description="Identifitcation Card", color = 0x5865f2)
embed.add_field(name="User's name:", value=f"{member.name}")
embed.add_field(name="User's tag:", value=f"{user.discriminator}")
await ctx.send(embed=embed)
``` what did i do wrong
bot.command only takes keyword arguments.
i still need help
with what
mb
i need to get the message content
!d discord.Message.content
The actual contents of the message.
I need to get the message content of this:
messages = await channel.history(limit=None).flatten()
it wont work
thats why i did a async for message in channel.history()
it is list of all messages in channels, you cannot get it's content
you can with the way I did
Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "c:/Users/Uzytkownik/Desktop/Dawid Orginalny/Python/avexy veryfi/main.py", line 39, in on_message await message.author.send(embed=embed1) File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 1013, in send channel = await self._get_channel() File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\member.py", line 299, in _get_channel ch = await self.create_dm() File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\member.py", line 142, in general return await getattr(self._user, x)(*args, **kwargs) AttributeError: 'ClientUser' object has no attribute 'create_dm' ```py
@client.event
async def on_member_join(member):
global hasloo
haslo = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
haslo2 = 5
hasloo = "".join(random.sample(haslo,haslo2))
id_channel = int(828011225292079124)
await client.get_channel(id_channel).send(f"**{member.name}, uΕΌyj komendy** `!verify (kod)`\n**TwΓ³j kod weryfikacyjny to** \n`{hasloo}`")
@client.command()
async def verifyy(ctx, kod):
global hasloo
if hasloo == kod:
print("Εmiga")
else:
print("ΕSSSSSa")``` why bot create dm?
if you want to get content of each message then:
for message in messages:
print(message.content)```
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
exactly^ ty
wont work:
messages = await channel.history(limit=None).flatten()
for message in messages:
print(message.content)
prints β nothing β
- recommend using the string import
- This error and code does not match.
full code pls
how could i make a discord bot that locks certain emojis to certain roles?
if member:
print(member.id)
if utils.get(ctx.guild.text_channels, name="mod-logs"):
print("before")
channel = utils.get(ctx.guild.text_channels, name="mod-logs")
print(channel)
messages = await channel.history(limit=None).flatten()
for message in messages:
print(message.content)
else:
print("not working")
else:
await ctx.send(":x: You need to provide a member!")
???
why bot send dm no to channel
try to learn walking docs. it is:
await ctx.author.voice.channel.connect()```
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
oh okay im sorry
what does console print? (screenshot)
471284463893086209
before
mod-logs
this and nothing else
do print(type(channel)) after defining it and print(type(message)) in for message
channel = guild.get_channel(channel_id) await channel.send("message")
doesn't work
def connect(modearg):
connection_guild = bot.get_guild(interact_url)
connection = discord.utils.get(connection_guild.channels, name='api')
mode = modearg
if mode == 1:
bot.loop.create_task(connection.send('--connect'))
return True
else:
return False
471284463893086209
before
<class 'discord.channel.TextChannel'>
<class 'discord.message.Message'>
<class 'discord.message.Message'>
!d discord.message.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the messageβs hash.
?
how u creating that embed

