#discord-bots
1 messages · Page 651 of 1
playlist function meaning?
guys what is the syntax for muting channels using this servers python bot?
*hushing channels
smth like when we enter spotify playlist link,bot play music
!play [spotify playlist link]
ah
^
!source hush
Silence the current channel for duration minutes or forever.
Someone?...
Lol the project is for a discord bot
And technically i could ask anywhere, it is a python problem, doesn't have any categories
its for a db right?
It is a function which is called and return a TypeError, it is not relationed to what i'm doing
hm
well it is not like that the function returns TypeError, the call of the function returns a TypeError which is different lol
I have the same script used to another project and it works fine
anti spam
so, give an example?
Doesn't discord already have an anti-spam?
or i could use slow-mode?
also some of these might be helpful, + anti raid
.bm
if you send eg 5 messages in 10 seconds you get muted
hmmm interesting
okay
whats the function of role for
how do i dm ppl using my bot?
!d discord.Member.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
I don't actually remember, I think it was smth I just added there to test stuff. let me see
okay
Why a mistake?
so useless just make a func called role and check if the role isnt in the members roles if it isnt add it, if it is in the members roles remove it
having 2 commands for this is kinda dumb
1 is for removing and second one is or adding, I don't want to mess too much with the old code
¯\_(ツ)_/¯
for some reason when someone sends a message to server 1 more of the logging gets added, I have been trying to find it but no luck so far. I have searched every file so many times.. it is getting annoying.
I'm so good that I don't even remember when i added that ;-;
?
Just saying, because I was bored and the chat was not too active
i use commas and TRIED to log all the messages in a csv, but every character was separated by a comma and everything was rainbow
so i don't go anywhere near to csv reading/parsing
weird
yeah, how can anyone fuck up that bad?
Do people not get tired of creating bots, like every new bot is the same
I do, but after doing some API stuff it was nice to get back of making few commands
shudders reddit api
meaning?
I was making my own API
i ALWAYS got 429s, or 500s when i requested json data
what api
🤷
😬
lemonapi (kinda done, missing a commit)/chatapp (under development)
How do I make my bot detect if it's already in a voice channel?
i don't try and scrape data off of reddit anymore
both of them are in github
maybe voicestate? idk
!d discord.VoiceClient
class discord.VoiceClient```
Represents a Discord voice connection.
You do not create these, you typically get them from e.g. [`VoiceChannel.connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceChannel.connect "discord.VoiceChannel.connect").
Warning
In order to use PCM based AudioSources, you must have the opus library installed on your system and loaded through [`opus.load_opus()`](https://discordpy.readthedocs.io/en/master/api.html#discord.opus.load_opus "discord.opus.load_opus"). Otherwise, your AudioSources must be opus encoded (e.g. using [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/master/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio")) or the library will not be able to transmit audio.
^^ dont think thats accurate tho
wdym?
like, server mute every one or an entire role in a vc
Why do i get AttributeError: module 'discord.guild' has no attribute 'default_role'?
channel.set_permissions(discord.guild.default_role, send_messages=False)
use the guild instance, ctx.guild
maybe you didn't do py from discord import Guild
i can't use ctx, its event on_reaction_add
Then do py Guild.default_role
thanks!
do reaction.message.guild then??
https://mystb.in/ColoredAdequatePrisoner.python
this displays the same rank for me and 2 others
that is #1
no errors
bruh, you dont use the class
Posting the question again
or maybe in the params usepy async def hi(ctx, guild : Guild)
Huh?
shit i forgot to include ctx
oh, lol. don't know about this. Thanks!
Still wrong
yeah.. dont use the class, use what I said
Ur giving me headache
idk
Uk python?
Hey please help me!
yeah, that's what i used when i needed to make a warn command, well, except using member-
I searched up synonyms for warn
discord.member.Member?
I am getting mad
why you ping me for that?
What's discord.member.Member?
member:discord.Member
It's wrong tbh
don't both do the same thing?
No
no
There's nothin as discord.member.Member
huh, they did for me
Discord!! 
@quaint epoch learn python plz
Yes so?
bro then my python is having a seizure
There's nothin as discord.member.Member
that's wrong
then why does it show up?
there is technically
BRUH U SRS RN?
Umm there is...
discord.member.Member means the Member class in member file in discord directory...
Why discord.Member works is because in the init file located in discord, Member object is imported so that you don't need to write whole path again and again
idk
WHATTTT
there is also this, they did the same things for me
discord = folder, member = file name, Member = class name 🤦♀️
I meant for his need...

Both are SAME things... Why to make an argument over it lol
yeah
DO U KNOW VSC? OR WHICHEVER ID UR USING ?
but why is there discord.member.Member then?
wtf chill bruh
if there is discord.Member
discord.member and discord.Member are diff
because there is
idk, but it's wrong
I am having a headache
because reasons
discord is the directory name where all the files are located
member is the file name and Member is the class present in that file...
ofc they are, discord.member is the dir, Member is the class name
what dont you get
Please read my message again carefully
okay
#discord/member.py
class Member:
...
``` smh
well both of them work
just write discord.Member and it will work
^^
Bruh
I have no words
me too
it doesn't matter i'm going to abuse the power of my bot and warn ppl for no reason
..
can someone help me send a dm?
I looked at the python api faq and just switched their code so it used my own user id instead but I keep getting an error.
Why are we still here..
await member.send()
You must search what and how __init__ files work. That might clear your confusion
Anyways what was the main issue lol?
Still ur warn cmd is wrong
fetch the user
Cuz u r not storing the warna
just stop
method.send()
the user is not found
..
it's my own user id
@boreal ravine @slate swan
check if it's written correctly
?
Which permissions do i need to change if i want to change Permissions to write for everyone role in guild?
currently i get this error: discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
Um i did py member = discord.Member(# int here) await member.send(content=(stuff to send))
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
just enter a valid user
here ^
Kinda feel like this is copied, but you should know your own code and what it does and how to manipulate it
No it's not
admin ig
member = discord.Member(# int here)
await member.send(content=(stuff to send))```
Fetch the member
there is alot of ways u can improve that code lmao
if you wanna grab a member you have to use fetch_member or get_member
I wrote my own code with my own rank card! And leaderboard cmd is not copied not is everything
you kinda look like you dont know what it does, plus it has comments for some reason ¯\_(ツ)_/¯
That doesn't give me.a solution
haha jokes on you i enabled members intent and admin but i can't fetch members because I HAVEN'T ENABLED MEMBERS INTENT APPARENTLY
k
Yes so is writing comments bad?
Dude I'm lazy to read 582 lines of code without even knowing what's erroring... Can you please spot the line where you did the "displaying the rank" feature?
Search for intents
It has comments cuz I used pillow and I had to create the bar and all
guys i have a problem help me please
if you wrote it, you'll know how to solve it don't you?
.
!d discord.ext.commands.Bot use this
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
oh this one?
false ?
yes
false.. what?
no its true
it keeps saying my syntax is wrong for some reason
did you do py client = discord.ext.commands.Bot(command_prefix='prefixhere')
im not sure why
For me and 2 more.ppl it shows rank as #1 it's in line 505 ig
how so ? its just the name of the object , has nothing to do with what u name it
no, read the class u used
If there's no error and I tried multiple things and cudnt solve it then?
what's the error?
I mean where you declared your "client" thing, use commands.Bot instead of discord.Client
No need to declare both
Using 2 variables?
Bruh, learn OOP. 🙂
just Bot will work fine
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 70, in on_ready
member = discord.Member(646136875282595871)
TypeError: __init__() takes 1 positional argument but 2 were given
other way around
what are you doing bro
discord.Member.fetch_member(id) then
discord.Member is the class
You don't create discord.Member classes manually
you need an instance
bruh
How to make sure that the buttons do not stop working until the bot is restarted?
Library - dislash
bot.get_user(id) if you ahve intents, await bot.fetch_user(id) if you don't
stop
you clearly don't know what you're doing
embed.set_footer(text="NOTICE: Please be patient, our staff will assist as soon as they are available.")
embed.set_thumbnail(url=logo_url)
msg = await ctx.send(embed=embed,components=[Button(label="Open Ticket", custom_id="ticket", style=ButtonStyle.green)])
Hello sorry for the newb question. im just looking into buttons for the first time. Ive created a button but how do i then detect when its been clicked?
im using discord-components
i was using dpy 2.0 but i got recommended this. Cant seem to get either of them working 😦
why is it on the on_ready function?
..anyone?
I just put it there to see if it would work. I'll have it run when someone sends a specific message when I can get it to work
i did mine in a command
- You don't create discord.Member instances like that. Use what others told you, like get_* and fetch_*
- Are you using replit? Yes it syntax errors randomly like that. Try to use something else
on_message if u don't want it to be a command and if u want it to be a cmd then @client.command()
Ca- can u help 🥺?
@bot.command()*, never name your variable client if you have a commands.Bot instance
be consistent
Huh? Why?
?
@prisma spoke ^
dude aliases aren't tuples they are lists im not sure if they were using stuff like () instead of []
they can be tuples though
because consistency, and naming it client when your bot is a commands.Bot instance is just confusing
@slate swan
they work with either since it doesn't have to to be mutable
tuples aren't so different, they're still iterables, but immutable and faster
No tbh.. but ok.. what does discord.client do?..
That's the displaying command. I mean the logic where you get it done
yes | discord.Client doesn't have the commands framework
everything that doesnt do commands
client = discord.Client() # CORRECT
bot = discord.Client() # WRONG
client = commands.Bot() # WRONG
bot = commands.Bot() # CORRECT
don't you mean client = discord.Client() is wrong
Below that there must be a line as 'result=cursor.fetchone()'
Then rank=
no its right
oh
just the variable naming is wrong
srry
Like?
How to set this send permission rule timed? I want to set send_messages to False after 15 minutes for example
my code:
await channel.set_permissions(reaction.message.guild.default_role, send_messages=True)
i only came here for command ideas 🚎
i just said it? sending messages, adding roles, events etc
🤔 asyncio.sleep
Hm but u can also do like
abcde = commands.Bot()
yes
go for a cycle and do import asyncio then convert on google how much is 15 minutes into seconds
you can, but just because you can doesn't mean you should
..
then do ```py
blahblahblahblah
await asyncio.sleep(...)
blahblahblahblah
Umm I guess it's the logic and sql ur using to create ranks... I'm pretty dumb with sql so ig I won't be able to help
@prisma spoke
Ooh
Same for u?
imagine using ellipsis in an argument
what
@boreal ravine
idk maybe asyncio.sleep
i think it'll be bad if i sleep in on_reaction_add event
Why two.variables?
@quaint epoch ^
Remove client=discord.Client
i dont know sql ¯\_(ツ)_/¯
I mean you could just use Loop.call_later()
wait what , why are you using both bot and client lmao
ohhhhh
And people.say that json isn't a db use a db.. but no one can help when we use.. thats why I hate dbs...
didnt know that sorry :
you already said you hate dbs

But what to do... I can't quit fr using it either
idk
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
im only here for command ideas
its pretty enjoyable tbh
honestly use mongo its like json but easier
Can u help?
oh yeah , sure
Mongo is shit
whats wrong ?
i never said i wanna learn it though
why is it shit
@slate swan
stop pinging people
Hating dbs cause there is less support for it is interesting reason lol... Anyways for sql consider #databases... Also I'm not sure is your problem really related to sql or not.
whatever = commands.Bot(command_prefix=)```
this is why you got banned from tcr 🤦♀️
i dont mind getting pinged , i offered help
Did but didn't get an answer
He only said ffa
well , based on my knowledge i dont think you've declared a state to check where id = x, just give me the part where u think you've got an error on , the code is too long
try being more formal instead of sending a mb with 500 lines
And fhey won't unban md either wow
Look at.line 595
505*
Why a mistake?
505
Rank=
Result=
There's nothing as continue
you were kinda a skid lol ¯\_(ツ)_/¯
I was not am..
I know it's just funny
but you had the dpy logo and an empty html tag as your profile picture, kinda obvious
Huh? When?
well it was logged in chat logs but i guess i just delete them at the end of the day because it looks unorganized
I never had dpy logo and html tags as my pfp
It practically dead anyway
R u talkn bout <>.py? O
then I was mistaken for the wrong person, but I asked u basic python questions but u didn't know how point still stands
@prisma spoke
- Check if the users you were testing with have same xp or not...
- Try to print rank getting outputted from the db. The issue might be in creating rank card too.. who knows
Huh? When? U never asked me any such questions?
They dont have the same
When I printed the rank it got printed as same
How will the issue be in generating the card?
I even printed the result and it gave as a tupe with value 0
Idk. Your rank card create function is already cursed. So I just assumed so
It's not cursed.. I just didn't have a way cuz the texts wud be different so had to do with if elses
Make a general function and then use if else.. No?
I tried all this then came for help
The texts were different
Are
Nevermind there are still ways you can shorten your code but it's not the real issue
Yes.. I need help with the issue..
Anyone else?
Vscode with github theme
wtf is lirc
what database are you using ?
oh
If I remember correct lol
uh i'm confused on something , so i've got a blacklist command that blacklists words that cannot be snipped nor sent , like they get deleted but i've got it running like this
@tasks.loop(seconds=5)
async def my_loop(self):
x = await self.bot.db.fetch("SELECT blacklisted FROM blacklist")
lst = ' '.join(words["blacklisted"] for words in x)
lst = list(lst.split(' '))
self.blacklisted_stuff = lst
@commands.command(aliases=['s'])
async def snipe(self,ctx):
if self.message is None: return await ctx.send('there are no deleted messages')
embed = discord.Embed()
embed = discord.Embed(title=" ",description=f"{self.message}")
embed.set_author(name=self.author.name,icon_url=self.author.avatar_url)
embed.set_thumbnail(url=self.author.avatar_url)
embed.set_footer(text=f'requested by {ctx.author.name}',icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)
```and this
```py
@commands.Cog.listener()
async def on_message(self,message) -> None :
if message.author.bot: return
msg = message.content.lower()
new_string = "".join(c for c in msg if c.isalpha() or c == " ")
lastest_string = new_string.split()
x,y = set(lastest_string) ,set(self.blacklisted_stuff)
if x & y:
await message.delete()
await message.author.send(embed=discord.Embed(title=f"you've sent a blacklisted word in {message.guild.name}",description=f"Blacklisted word : {x & y}"))```
but i'm making my bot public but theres one thing i'm confused about , how would i make my task update for each guild . and i thought someone here must know another way thats better , so i was asking if there is a way to do so ?
sniping is against tos
How to trigger custom guild roles?
you cant get the content of a deleted message
they are never meant to be accessed.
man just send where it says its against tos and i'm not going to have this anymore
nah people just said
Or can be accessed only by moderators
okay then , when you get a trusted source , tell me its against tos
alrite
dude said you cant get content of deleted messages when there are logs
can you elaborate ?
It's not against tos... but... it's just bad practice and people don't like it often
bad practice ?
lmao how is making a command bad practice smh
please i'm not here to argue
Can I see where it says that?
Yeah you don't want your deleted message gets sniped by someone random in chat
it isnt just ignore them for
dont send them in the first place ?
and either ways it would be on logs so why bother
just clear bs tbh
Discord doesn't store deleted messages
^
Design your database to store blacklisted words for every guild instead of just one, and run the tasks accordingly
Imagine getting confused when to use bracket and semicolon
I hate npm not writing JS
I have this role(check screenshot).
And i want to trigger all users that have this role, with if statement.
for example:
if '<@&693935970030059521>' in user.roles:
return
@slate swan ^ Make a column with guild ids as input and store each guild's blacklisted works and run tasks
Why just npm in particular?
if 693935970030059521 in [role.id for role in user.roles]: return
tryna install a module since 3 days but ducking nothing
thanks! i can just type ROLE ID with digits? like you did
The ID for the role.
Uhh ic, anyways good luck for your next try... Also what module if you don't mind?
or if 693935970030059521 in map(lambda m:m.id, user.roles): return
nodegui
@manic wing Help my bot stopped working.
Read your error
I am.
It's clearly mentioned there
Have you considered reading the error?
yeah, replit hosts a lot of bots and sometimes they get ratelimited
what are you confused at?
Is it possible to move it to VSC?
well yeah if you keep your computer online 24/7
vsc is an editor-
What's the best host?
I would say a cheap vps
buy a cheap one acc to ur requirements
Even tho I'm using a free host atm
Me kinda free too-
I have 500mb free storage and 65%of cpu which is more than enough for my bot
Why if you click on the button in the menu from different servers, then channels with reports will be created only on one server, and not where you clicked the button
nice
@final iron
In shell typed kill 1 and it worked.
doesn't oracle provide decent free servers?
I heard about it but not sure
guys, please tell me what is the problem? i did everything right, but when i enter the command it doesn't work
um idk
if you dont know, dont say. this server wouldnt be very helpful if everyone came and said 'idk'
any errors? you typed in .purge?
no i mean i have to check
my code
and i was also playing a game so i would've died
What to do if a bot takes a category from the first document for all reports
no errors
it looks fine to me
Did you restart your bot after adding command?
is the bot online?
maybe you need to do @commands.has_permissions(manage_messages=True)?
no.
....
thanks for help
Smh that isnt necessary for running a generally mods only command
really?
in fact, it makes it less likely to work.
i've done that too many times
i just write code, don't test it, add a check then the next day i panic when it returns an error or doesn't work
oof, incase if your command doesnt work adding a check decorator would make it less likely to work
Thats a bad practice, every command should be tested ,-,
yes
I swear handling 3 DMs at a single time each doing a different thing is a real pain
been there done that
and yes it sucks
How to mention guild role by ID in message? ID of my role: 693935970030059521
<@&id> iirc
ah, ok
if i simpy code it with:
await channel.send('ping role - <@&id>')
it'll ping?
Yes
thanks
is it possible to compress a 250 mb vid to 8mb?
!ot
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
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.
k
what will str(error.param).split(':')[0] do?
what is error
making an IDE is hard
I'm still on the menu
does anyone know what the function is that turns mentions into plaintext, but not the id, the actual name and discriminator
any help
You can do that by casting a Member or User object to a string
i got a question
``` works, i mean it counts from 1 to 10000
but when i try
```for i in range(9999999999999999, 0):
its not working?
class range(stop)``````py
class range(start, stop[, step])```
The arguments to the range constructor must be integers (either built-in [`int`](https://docs.python.org/3/library/functions.html#int "int") or any object that implements the `__index__` special method). If the *step* argument is omitted, it defaults to `1`. If the *start* argument is omitted, it defaults to `0`. If *step* is zero, [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") is raised.
For a positive *step*, the contents of a range `r` are determined by the formula `r[i] = start + step*i` where `i >= 0` and `r[i] < stop`.
For a negative *step*, the contents of the range are still determined by the formula `r[i] = start + step*i`, but the constraints are `i >= 0` and `r[i] > stop`.
first arg is the start then stop
i swear there is a function that just process the text and does it
and step is by default 1
i just cant find what its called
yea
!d discord.Message.clean_content
No documentation found for the requested symbol.
!d discord.ext.commands.Context.clean_prefix
property clean_prefix: str```
The cleaned up invoke prefix. i.e. mentions are `@name` instead of `<@id>`.
New in version 2.0.
This?
9999999, 0, -1
ohhh
for i in range(99999999999, 5, -1):
await message.channel.send(i)```
so it should be like that?
damn u do be ratelimited
yeah i know i am gonna be
bruh
thanks
its not working when i open it
I'm not on right now but it is possible to make a command that uses Instagram to get and show the latest post on someones account
!pypi instagram
Use this ig
😩😩😩
Or use aiohttp and send raw requests who knows
there's no docs 😩
clean_content was what i wanted thanks
cool
Oh 😩
Or for raw or deep docs: https://developers.facebook.com/docs/instagram-basic-display-api
Or use reddit instead :D
They need someone's insta acc data in particular ig
And reddit has some nice data in it, made me left reddit since I saw it 
!pypi instaloader
reddit works with aiohttp and has an active stack overflow solution so this is ezier
ik that , what about the task part smh
Greetings all
How can i give permission to write in channel to a user in on_reaction_add event?
my code:
@bot.event
async def on_reaction_add(reaction, user):
channel = bot.get_channel(916255565896892426)
await channel.set_permissions(user, send_messages=True)
Add_role I think
Greetings, dear
Smh sorry, I've a bad habit
Wdym
i want to give permission to write, to specific user
To write what?
How would i be able to have a command thats like -instagram (no im just gonna do it without the thing u showed me cuz i give up) but like -instagram set "link" then have it send a message to a channel saying Hey go like this post or something like that
i just need help doing the link
and the specific channel to send
in text-chat
Assign them a role with the suitable perms
Please help lmao
when I kick someone to print in logs that I kicked ("member" has been kicked). how can i make that ```py
@client.command()
@commands.has_permissions(kick_members = True)
async def kick(ctx, member : discord.Member, *, reason = None):
await member.kick(reason = reason)
await ctx.channel.send(f'{member.mention} has been kicked by {ctx.message.author.mention} for reason of: {reason}!')
print(f"")
this has nothing do to with helping you but why do you have it do print(f"")
ignor the last line
ok
Just get the required channel and send the info there
!d discord.ext.commands.Bot.get_channel
@client.command()
async def online(ctx):
online = ("https://caprihotel.nl/api/online")
await ctx.reply(f":yes: there are ... {online} online!")
I am testing something with a certain Link I would like the bot to send the amount of the number of users online but it just sends the link how do I fix this?
get_channel(id, /)```
Returns a channel or thread with the given ID.
@upbeat otter
You need to fetch the data from the link using either requests or preferably aiohttp
You want it to print or send a message in a channel?
Like this?
Just print member.name kicked by {ctx.author} for reason bla blah
yes in a sense, however that url doesnt work?
Yep yep
What im doing wrong here? I want to give role when user reacted
@bot.event
async def on_reaction_add(reaction, user):
guild_role = discord.utils.get(reaction.message.guild.roles, name="wannaplay")
await user.add_roles(guild_role)
what error does it provide?
no errors
jump into my dms ill set up a test bot we can work on?
Try doing, reaction.guilld.roles
i think i found solution, in stackoverflow
should work either way tbh
also why not just do await reaction.guild.get_role(id)

the thing you posted should work
it just did for me ```py
@bot.event
async def on_reaction_add(reaction:discord.Reaction, user:discord.User):
guild_role = discord.utils.get(reaction.guild.roles, name="wannaplay")
try:
await user.add_roles(guild_role)
except Exception as e:
print(e)
just make sure you are actually getting a role
does anyone have any tutorials for me talking about how to make a web scrap using discord.py? send on dm, pls
ah, find solution. event can't get old messages
AttributeError: 'Reaction' object has no attribute 'guild'
Web scrapping with dpy?
yes
That's not how you make a web scraper
mb
@bot.event
async def on_reaction_add(reaction:discord.Reaction, user:discord.User):
guild_role = discord.utils.get(reaction.message.guild.roles, name="wannaplay")
try:
await user.add_roles(guild_role)
except Exception as e:
print(e)
Dpy is a library intended for creating discord bots
^^
but... is there no way i can pull information from some website and put it as a variable for the bot?
@client.command()
async def tester(ctx):
url = f'https://caprihotel.nl/api/{online}'
async with ctx.typing():
async with aiohttp.request("GET", url, headers={}) as a:
embed = discord.Embed(
title=f"Users online {online}",colour=ctx.author.colour,timestamp=datetime.utcnow(),)
await ctx.send(embed=embed)
Idk if this is correct but it is not working?
yes you can, if it has an api just make a request or go ahead and scrape it, but you have to do it separately using different packages not using dpy
do you asking if it's not working
you havent defined {online}, which is?
The amount of users online
mhm... ty dude
cant tell if that is sarcastic
The link is the goes to the amount of users
and explain what is https://caprihotel.nl/ since if you acvtually click on it... you get a access denial
it is an online game if you use https://caprihotel.nl/api/online then you can see the amount of users online i would like to make a command when you use that in your discord you can see the amount of users
it wasn't supposed to be lul
thats what i get, where are you in the world
ah okay
where are you in the world, netherlands?
yes
how can i define that {online} ?
im doing it now give me a minute
NO SPOONFEEDING
smh im bored ill do it as i please
You can also explain it, then I learn something and I know how to do it myself next time :)
You should actually explain rather than straight away giving away the code
well the website is actually stupid and doesnt allow requests, it asks "to turn on javascript"
and cloudflare stops you at an instant
<p data-translate="turn_on_cookies" style="color:#bd2426;">Please enable Cookies and reload the page.</p>
There's only one thing left to do, right? I just have to define {online} right? but how 
well, you dont actually need to define online
the url, where you put https://caprihotel.nl/api/online this is to send a request to the url and expect a response back
How to send programming styled text in discord.py?
Like this:
lorem ipsum
await ctx.send("text` here")
ah, thanks! how about bold text?
and to recieve a response with apis, you would usually take in their json, which is for aiohttp ```py
await a.json()
or ```await a.text() or await a.content()```
thanks!
Oké so what should i need to do?
well, at this moment in time, it should usually send a response back however, cloudflare blocks you and requests for you to turn on cookies
so i dont know where i can go from here so yeah
o ok no problem
Discord uses markdown, look online about that for text styling
whats wrong? i copied the check= from docs just to see how it works but apparently it doesn't work
await ctx.send("testing", components=[Button(label="Button number one", custom_id="btn")])
interaction = await client.wait_for("button_click", check=lambda inter: inter.custom_id == "btn")
await ctx.send('nice interaction')
is discord certified moderator in public flags ?
hello all
public...flags?
i dont understand...
no... How can i activate?
I think he's asking a question
ah
or maybe not idk sounds like a question
yes
maybe it's an error but I dont see public flags to do with your code
there we go. So you want to check if it has verified mod?
Correct
https://stackoverflow.com/questions/66951118/discord-py-showing-user-badges#:~:text=You could do str(user,the%20badges%20an%20user%20has maybe this
wait thats hypesquad
@slate swan maybe that's what you're looking for
@client.command()
async def tester(ctx):
async with ctx.typing():
async with urllib.request.urlopen("https://caprihotel.nl/api/online") as url:
data = url.read()
print(f"{data}")
hmm did that work for you?
no
Any reason why you're not using aiohttp?
How do I get an members message history?
because i always get this returned
here is the code
Hey do any of you guys know how to make a streaming bot
!play YoutubeLink
then it will stream the videi
can you do that.
Bots can't steam video, so no
can anyone help me?
Is it ok if I put a useless piece of code in my github ;-;
errr...on_message event
Use aiohttp
this is not asynchronous
It will block your code
?
like
"""
def foo():
print("foo")
"""
You need text channel history
So
!rank
Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.
for i in range(len(my_list)):
do_something(my_list[i])
The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:
for item in my_list:
do_something(item)
Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.
channel = await ctx.guild.get_channel(ID)
history = await channel.history(limit=100).flatten() # flattens, returns a list of messages
@quaint epoch
.bm
!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...
You can pass a check in that method where it checks it only returns the members messages, you want for
ah finally
another helper
I don't have to teach beginners what SyntaxErrors are anymore
or IndexError
or ValueError
or TypeError
or the NoneType thing
whatever that is
or any other error tbh
🙂 thank you
still typing? ok
messages = []
channel = ctx.guild.get_channel(ID)
member = ctx.guild.get_member(ID)
async for message in channel.history(limit=100):
if message.author == member:
await messages.append(message)
You would want something like this
.bm
no
it's wrong
messages = []
channel = ctx.guild.get_channel(ID)
member = ctx.guild.get_member(ID)
async for message in channel.history(limit=100):
if message.author == member:
await messages.append(message)
you forgot a tab
T_T
Basically what's happening here is I am looping through each message in the channels history and checking the if there is a message in the channel with the member that want to check for, if there is, it will append the messages list
I am on a mobile device
that explains
also
remember, .history() method is an API call
So don't make very large queries
You can get ratelimited
That would return the author aka the member object of who invoked the command
They want the author of the message
alright
can't you also put the author in a dict?
and add values to the key whenever the same author sends it?
It wouldn't make it faster or more efficient
And it's more to code it
Lists are good enough
I wouldn't recommend it either
I tried that once
total mistake
broken af
maybe it's because of the reddit API or what idk
!pypi reddit
!pypi PRAW
!pypi asyncpraw
hurrr
how can u send a message to a specific channel
is there any way i can make the bot click on some item within a website?
Can you not have 2 on_raw_reaction_add events in 2 different files?
how do i get the current guild id?
discord.on_raw_reaction_remove(payload)```
Called when a message has a reaction removed. Unlike [`on_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_remove "discord.on_reaction_remove"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
what do you mean
like i want to find the id of the guild that the bot is currently in
fetch/get, anything works
i don't want to manually enter the current guild id, i want tot bot to get it
how to do that?
guild = ctx.guild?
thanks!
hey, anyone know how i can disable embeds on messages that my bot sends
???
Because when my bot sends a link
and embed appears with it
how do i disable that?
disable embeds in the channel settings?
no, just for the message
Then, I don't believe so
If anyone can get back to me on this, I'd appreciate it, it's not removing the roles when the reaction is removed, the code is listed below:
@commands.Cog.listener()
async def on_raw_reaction_remove(self, payload):
latency = round(self.bot.latency * 1000)
messageID = 916814759360335872
if messageID == payload.message_id:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '🥶':
member = payload.member
mrole1 = discord.utils.get(guild.roles, id=916548833641627679)
await member.remove_roles(mrole1)
emoji = payload.emoji.name
if emoji == '🥱':
member = payload.member
mrole2 = discord.utils.get(guild.roles, id=916548881943240724)
await member.remove_roles(mrole2)
well then does anyone know how to set messages flags in await ctx.send('message')?
what?
Anyone know why my slash commands don’t show up when my bot joins a new server
what lib
Disnake
show your commands.Bot line
show me the line where you defined bot
It doesn’t have test guilds
It has prefix=“!” And case insensitive=True
I’m not at pc rn
why are you comparing an emojis name with a emoji
And the bot works in 4/8 servers
does it show the commands in any other servers?
!
How do u add applications.command to the scope
same way you add the bot scope
get the id and send
i kinda forgot how though lol
get_channel
how can i check if a catigory exists
B = discord.utils.get(ctx.guild.channels, name="Terminations")
await ctx.channel.edit(category=B)
if B is None:```
i need to check if the category by the name 'terminations' exists or not
var = client.get_channel(int(channelid))
without channel id, just name
wasnt replying to u
ah
Thanks it worked
anyone
get_channel
Maybe? Idk
I have a simple question how would I get my bot to put a blank space after a message without sending two messages
Like letting the bot press the enter key inside of one message
category, not channel
Oh yeah thanks I forgot about that I haven't used Python in a while
but ive never heard of get_category so
Thank you
Not sure then
get_channel works for categories too
wait when I do that it prints the /n.
my codes is
await member.send( str(message.author) + " told me to tell you that:" + "/n" + " ".join(sentence[2:len(sentence)]))
np
Does anyone know how I can check if a message has an attachment?
does anyone know how to send files?
is it py await ctx.send(file='file.txt')
or what?
dont think so
cuz u cant just send a file that isnt opened or whatever I dont think
otherwise it will just return the file name
what if i open the file likepy with open('file.txt', 'r') as file: await ctx.send(file=file)?
file.read() id think
so, await ctx.send(file=file.read())?
I edited it, would it work then?
try it!
im not like professional python guy ive only been doing this for a few weeks
How to make the buttons work until the bot is restarted?
Library - dislash
in cogs
idk if it has it, but commands.Bot(command_prefix="!", reload=False)
maybe? not sure
anyone know how to display only the names of the guilds when I use like bot.guilds
I believe embeds have a file kwarg
They actually don't
async defines a coroutine, rather than a normal python function
await waits for a couroutine to finish, and get the result
Both are very important components of asynchronous programming
You'll find it in other languages too, for example, JavaScript's promises
An asynchronous function that doesn't block
It's sort of a fire the function, do something else, come back and get the result
hello, ive made a button for a ticket system. everything seems to be working as it should but is there another way i can make it so the button is always responsive not just after when you type the command?
response = await client.wait_for("button_click", check=lambda i: i.component.id in button_ids and i.author.id == ctx.author.id and i.message.id == interaction.id, timeout=None) # You can change the timeout
if response.custom_id == 'open_ticket':
await response.respond(type=6)
print(f"{ctx.author.name} has just opened a ticket")
ticket_channel = client.get_channel(ctx)
await ticket_system(ctx.author.id, ticket_channel, 1)```
This is what i have at the bottom of the command. but once i restart the bot i then need to re-do the command instead of it always being active
Rather than in normal python, it fires the function, waits on it to finish, and then does something else, sort of like a queue
Not sure about these third party libraries, but in vanilla d.py you can accomplish this using add_view
A very very simplified version, yes
No problem, it took me a while to understand the whole thing haha
So I defined mytest and all words are in a text file.
I put them in a tuple like mytest = tuple(mytest)
I want to check to see if a member's nickname has the word(s) in the file.
So I did if after.display_name in (mytest):
So now when I put it like just the word in my name it works. But when I add
hi before or after the word in the file it doesn't do stuff that I wanted it to do below which is rename
Please ping on reply
i got something like that when i run my bot i just dowload mudle i dont even add the modle to the code of my bot or somethin
cuz i dont know
yeah
Basically it says you can't have nextcord and discord.py at the same time
you'll have to uninstall one of them
either do
pip3 uninstall discord.py to uninstall discord.py
or do
pip3 uninstall nextcord to uninstall nextcord
oh
???
is that using dpy 2.0 or ext libs
Why are you trying to see if the emojis name is equal to a emoji
what is the name of the owner of this discord mark it please
why
@worthy wagon you cant compare an emoji name with an emoji object
You can make it persistent (always usable) but you have to subclass discord.ui.View so you'd need to use a discord.py fork in order to do this.
Or just use discord.py...
¯_(ツ)_/¯
without the fourth line my code works but with the third line, it dosen't. Not even error.
how do i get a list of members in my guild?
guild.members
thanks!
or if u wanna use the current guild, then ctx.guild.members
alright
uh, did what you said but it only returned info on me?
because u r the only one in the guild?
no there are 15 other ppl in my server
ctx.guild.members shd work
worked for me
!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.
Show me the full output
How do i add roles to members automatically by my bot?
Why do you have two bot variables
i don't use the 2nd
!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/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
idk why i added the 2nd lol
Then remove it.
[<Member id=909639627374202890 name='HRLO77 test bot' discriminator='9637' bot=True nick=None guild=<Guild id=885170029824450580 name='R8A' shard_id=None chunked=False member_count=15>>]
that is the full output
so why is it not giving all of the members?
shit it only returned ITSELF, not me
try asking in discord.gg/dpy I'm kinda out of ideas why this is not working
Let's see the code
he did ctx.guild.members
i even setup the intents
why is ctx underlined?
because it is spelling mistake or smth
and client
o
Do i need this role = guild.get_role(832120561848156180) as well when trying to add different roles?
to members
or just the await
yes, thats for getting roles though
ok
why is client a var that holds your bot instance and ur bot var is discord.Client() ?!?!?@,@@
i don't use the bot var idk why i made it
consider renaming ur client to bot as well lol
already asked earlier, dont bring this up again pls 🙏
damn that sucks
Google Definition: Python pickle module is used for serializing and de-serializing a Python object structure. Any object in Python can be pickled so that it can be saved on disk. What pickle does is that it “serializes” the object first before writing it to file. Pickling is a way to convert a python object (list, dict, etc.)
Basically It's good for orginization among other stuff similar to that
pls anyone?
yes sorry
grammar mistake
It will make you code much neater.
But I'm sure it has other uses as well.
yeah, lol
odd name I guess
Your welcome my man!
:D
please
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = await (await client.fetch_channel(885464532959526913)).send(f'Welcome to server **{member.mention}**.')
role = guild.get_role(832120561848156180)
role = guild.get_role(862632463615262730)
role = guild.get_role(849093239285743647)
role = guild.get_role(853980922243711007)
role = guild.get_role(851020933053546537)
role = guild.get_role(856124625482547250)
role = guild.get_role(862630645658681364)
role = guild.get_role(862629105019519006)
role = guild.get_role(862662802161795072)
role = guild.get_role(862662586024853504)
role = guild.get_role(851021143040327680)
role = guild.get_role(856123770020692040)
role = guild.get_role(856123532747472916)
role = guild.get_role(862667562634051614)
role = guild.get_role(852477636961108008)
role = guild.get_role(862669289353904158)
role = guild.get_role(862670413632634930)
role = guild.get_role(862670842735624233)
await member.add_roles(role)
print(f"{member.name} has joined the server")```
what is it?
Right?
without the fourth line my code works but with the fourth line, it dosen't. Not even error.
Useful when you want to store objects inside a database or json as a primitive
oh I see
i just replaced _ with " "
For example if you wanted to store your bot instance in a json file, you’d pickle it
what?
Hello
not here
grammar sorry
Invisible?
oh np
maybe get rid of the ('_')
but what is this program used for?
that will help me better understand your problem
does it have to do with Web Hooks?
oh dear lord
plz
all the variables are named role is that intentional?
for this
can you please help me?
yeah but what is this program for
Also if I can't help go to Stackoverflow
this program just gets a message from a server and splits the content at " " then replaces "_" with " "
oh I think I know your problem
the concatenation goes to an empty string
maybe instead of that empty string put some form of information
hey guys i found the mistake in my code, i did Intents=intents instead of intents=intents :/
because there is no point of concatinating 2 strings
might have spelled that wrong
The only other thing I can think of is maybe use a Table (the square brackets) instead of the ones you are currently using
Sorry if I wasn't much help.
how do i check if a member is an admin?
Theirs a check decorator to check perms
not intentional, but someone told me that this is correct becuz i thought that it can be mentioned with role id within multiple of them
not that, like in the code
i know how to do that
Dont really know never done it before
i believe that this is the correct one. role = get(member.guild.roles, name='•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•')
Change The Variable names then it might work
maybe
lol
