#discord-bots
1 messages ยท Page 991 of 1
with ifttt?
https://gist.github.com/jagrosh/7606268fc9f1d3e90ce9efc79294f960 might be helpful
Imma stick with replit for now...
this is to much for me wiht no sleep
bad idea, I urge you to reconsider
replit is just so easy to use.
I host mine on a vm on my local machine
docker?
Ubuntu server
Yeah. I cant do that
why though? isn't that the point of docker, to be a lightweight VM meant for running code?
instead of running a full fledged VM i mean
Buy a raspberry pi. Heavy initial investment but pays off over time. Yours to do as you wish, free forever
Tell me where and how and I'll do it
I would have to forward my ports and stuff like that.
I jsut want a discord bot with some friends, that is all
all of our open source bots use docker, @unkempt canyon, @lament depot
Don't have to port forward a discord bot
Is it free?
FOSS
you're right
It's a tool used a lot in the industry and important to know
Foss?
As a good practice, you should always dockerize your apps when you can
I run 3 bots all small not large
free, open source
Ohhhh
Free, open source software
How do I dockerize a python discord bot with 1 main file rest in cogs
I am still having issues with bind mounts ๐ฉ
add a Dockerfile to your root containing the instructions of how docker should set up a vm to run your bot
A list of command line arguments that will install python, your bot dependencies, put all your files in the right place, and finally call python3 bot.py
Well I have no experience with docker could you make a sample file?
could be a simple shell (.sh) file right?
There are plenty of sample docker files online, let me find one for you
actually python has their own docker image
Python is an interpreted, interactive, object-oriented, open-source programming language.
https://github.com/docker/getting-started/blob/master/Dockerfile you can see an example one by the official docker team, with a bit of both python and nodejs
Can I still use oracle?
Sure you can deploy docker containers within oracle
Not sure if they have a special service for that like AWS EKS
Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with
view = HelpMenu().add_item(CogSelect(self.bot))
Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)
I use there vm software
Yeah that's fine. No problem with a vm in a vm
Hey guys
Is there a more efficient way in python to do this
users_farm = await self.bot.dbfarms.find_one({"_id": user_id})
if users_farm['plot1'] == "Empty":
style1 = discord.ButtonStyle.grey
else:
style1 = discord.ButtonStyle.green
if users_farm['plot2'] == "Empty":
style2 = discord.ButtonStyle.grey
else:
style2 = discord.ButtonStyle.green
if users_farm['plot3'] == "Empty":
style3 = discord.ButtonStyle.grey
else:
style3 = discord.ButtonStyle.green
i guess thats efficient, because u hard coded it
Okay.
I dont know how this works.
30 mnutes now and I dont know what Im doing.
Cant get a command promt or anything
but use a loop for such things
Yeah
Wondering how to do that
Like how to pass out variables with different names for each loop
users_farm = await self.bot.dbfarms.find_one({"_id": user_id})
styles = {}
for key, value in users_farm.items():
if value == 'Empty':
styles[key] = discord.ButtonStyle.grey
else:
styles[key] = discord.ButtonStyle.green
use a dict, instead of making multiple variables
@commands.command(name='mute', description='mute a user from all channels', usage='mute (user) [duration] [reason]', aliases=['timeout'])
async def mute(self, ctx, member: discord.Member, time=None, *, reason='no reason provided'):
role = discord.utils.get(ctx.guild.roles, name="muted")
if member is None:
await ctx.send("missing arguments")
if member is not None:
if member.top_role >= ctx.guild.me.top_role:
await ctx.send("i can't mute someone above my top role")
if role not in ctx.guild.roles:
perms = discord.Permissions(send_messages=False, speak=False)
await ctx.guild.create_role(name="muted", permissions=perms)
if time:
if self.convert(time) > -1:
if reason:
tempmute = self.convert(time)
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
await asyncio.sleep(tempmute)
await member.remove_roles(role)
elif not reason:
tempmute = self.convert(time)
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
await asyncio.sleep(tempmute)
await member.remove_roles(role)
elif self.convert(time) == -1:
reason = time
time = 'indefinite'
if reason:
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
elif not reason:
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
elif not time:
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
i want to make it so this works, which it doesn't currently:
if member is None:
await ctx.send("missing arguments")
if member is not None:
if member.top_role >= ctx.guild.me.top_role:
await ctx.send("i can't mute someone above my top role")
anyone that can help?
set the default value of member argument to None
right, thank you
wait so i got to run a ubuserver then the docker or does the software wrok as a vm?
@sick birch can you help me in depth like step by step?
did it and now it still doesn't work
nother question
show updated code
@commands.command(name='mute', description='mute a user from all channels', usage='mute (user) [duration] [reason]')
async def mute(self, ctx, member: discord.Member = None, time=None, *, reason='no reason provided'):
role = discord.utils.get(ctx.guild.roles, name="muted")
if member is None:
return await ctx.send("missing arguments")
if member is not None:
if member.top_role >= ctx.guild.me.top_role:
return await ctx.send("i can't kick someone above my top role")
if role not in ctx.guild.roles:
perms = discord.Permissions(send_messages=False, speak=False)
await ctx.guild.create_role(name="muted", permissions=perms)
if time:
if self.convert(time) > -1:
if reason:
tempmute = self.convert(time)
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
await asyncio.sleep(tempmute)
await member.remove_roles(role)
elif not reason:
tempmute = self.convert(time)
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
await asyncio.sleep(tempmute)
await member.remove_roles(role)
elif self.convert(time) == -1:
reason = time
time = 'indefinite'
if reason:
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
elif not reason:
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **{time}** ๐")
elif not time:
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted for **{reason}** - **indefinite** ๐")
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="exit", style=discord.ButtonStyle.red)
async def exit_button(self, ...):
# Want to tell code that we don't need to count down
message = await ctx.send(embed=embed, view=Buttons())
# How do I tell code here that if we have used the exit button, don't count anymore.
await asyncio.sleep(20)
await message.delete()
Is it possible to do slash commands or buttons without using an external library?
Buttons work with discord.py 2.0
and I think slash commands do too, but I haven't figured those out yet
dropdowns also work in 2.0
just have a flag which is either True or False, if the flag is True count else dont, when they click exit, set the flag to False
But it doesn't check again
The flag gets set to True, and it doesn't check to see if its False after the countdown has started
And I can't do a while loop, because it's a countdown
I suppose I could countdown by decreasing a value until it hits 0 lol
for every loop
if flag:
# code for couting
while flag:
await asyncio.sleep(20)
await message.delete()
break
ya that works
And then when flag is set to True it will just break it
Oh good
Here's the issue I'm running in to
@discord.ui.button(label="Exit", style=discord.ButtonStyle.red)
async def exit_button(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user != ctx.author:
return
await ctx.bot.dbfarms.update_one({"_id": user_id}, {"$set": {"has_open_farm": False}})
await message.delete()
flag = False
flag in that code is greyed out, like it's not going to update when I run that code
would it reach the flag variable in the outer scope?
self.flag, i think u want it to be global
self.flag? how come?
no, its local to exit_button
it makes it a class attribute, which means u can use that variable anywhere in the class
!e
class Foo:
def __init__(self):
self.bar = 'bar'
def method(self):
return self.bar
print(Foo().method())
using self before a variable name makes it a class attribute, which means that variable can be used anywhere in the class
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
bar
message = await ctx.send(embed=embed, view=FarmButtons(flag=flag))
How would I print FarmButtons().flag
wait can u explain what your trying to do, im not sure if i understand
It's an attribute of the instance
or probably FarmButtons().exit_button()
o = MyClass()```
`o` is an object
How do I access the FarmButtons object in here???
Bring it out to a variable
mmm
I see
It works kind of. When I click the button, it sets self.flag to be false, but it doesn't break the while loop
class Buttons(discord.ui.View):
def __init__(self, *, flag, timeout=180):
self.flag = flag
async def exit_button(self, interaction: discord.Interaction, button: discord.ui.Button):
self.flag = False
return self.flag
view = Buttons(flag=True)
message = await ctx.send(embed=embed, view=view)
while view.flag is True:
await asyncio.sleep(5)
await message.delete()
break
else:
print("Exit button was pressed.")
is there a way to just return from the entire command if the exit button is pressed??
!d disnake.Interaction
!e
class Foo:
def __init__(self):
self.bar = 'bar'
def method(self):
self.bar = False
a = Foo()
while a.bar:
print(10)
a.method()
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
10
but what if the flag changes while the while loop code is running?
Because that's currently how it works. The while loop starts and if the user presses the button during that time, it should exit the loop
it will break out, but what are you trying to do, u want to delete the message after button is pressed or something?
Yeah, and then stop counting down
just make it delete the message in the exit_button
There's a 20 second countdown until the message auto deletes when the message is sent. If the button is pressed, it should delete the message and stop the countdown.
lmao i just write hello world and press random numbers
That works, but it still counts after and I get an error because there is no message to delete
ah just that, ok
I don't want it to keep counting and then get an error if the button is pressed
I feel like it would be more efficient to stop the countdown
and i found out im in the wrong channel
Instead of handling the error so I don't get a traceback
async def exit_button(self, interaction: discord.Interaction, button: discord.ui.Button):
self.flag = False
await interaction.response.defer()
await interaction.delete_original_message()
self.stop()
view = Buttons(flag=True)
message = await ctx.send(embed=embed, view=view)
if view.flag:
await asyncio.sleep(20)
message.delete()
try this out
What changed here?
im deleting message inside the exit-BUtton function
I already make that happen
Issue is, the code reaches the flag check before the button is pressed
I need it to check for that flag all the time, so that if the button is pressed after it checks, it just cancels the countdown
oh wait we can just make the timeout be 20s instead of 180, and make it delete the button on timeout @abstract kindle
wait a miute i am already in the channel i didn't sleep for like 19 hours
just have some qucs i want to find the discord.py webside
And then handle the timeout to delete the message?
ya u can write the code to delete message in on_timeout inside the Buttons class
@abstract kindle @paper sluice can y 2, helpme
thx
any way to reset the timeout when a button is presset
or is that the default
is timeout idle for the duration or just starts upon creation
Oh it starts upon last interaction with the UI
timeout will be called when the time is passed without any interaction
lets say the timeout is 20 seconds, this means that if no one interacted with the buttons/view-items for 20 seconds, on_timeout will be called and u can stuff there
but if someone interacts with the buttons under 20 seconds, the timeout-timer resets
how to make the bot make a role in another server
Hello anyone remember me
How can my bot check if its a website? Like check if message contains https://? And if the website doesnt exist send a message?
Yea
And for the other part, u gotta send a simple GET request to the website and see the status code
@commands.command(name='volume')
async def _volume(self, ctx: commands.Context, *, volume: int):
"""Sets the volume of the player."""
if not ctx.voice_state.is_playing:
return await ctx.send('Nothing being played at the moment.')
if 0 > volume > 100:
return await ctx.send('Volume must be between 0 and 100')
ctx.voice_state.volume = volume
await ctx.send('Volume of the player set to {}%'.format(volume))```
idk what's wrong here . my command gets ignored
I want to make my discord bot send buttons but the interaction fails.
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionEventType
@bot.command()
async def button(ctx):
await ctx.send("Press Button",
components = [
Button(style=ButtonStyle.blue,
label="CLICK Me!")
]
)
rest = await bot.wait_for("button_click")
await rest.respond(type=InteractionEventType.ChannelMessagewithSource,
content="Clicked!")```
๐ dont use 3rd party libraries for components, use discord.py master branch or a fork
Stack u know ๐คทโโ๏ธ
We don't help with music bots sorry.
Hm? Its volume
A simple music bot written using discord.py rewrite and youtube_dl. - music_bot_example.py
Not convinced.
why are there brackets in the text? how can i remove them?
A very music cog i might add.
Since it violates ToS 9/10 times.
And in this case I even back traced the original gist that uses ytdl
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโs robots.txt file; (b) with YouTubeโs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
99% take music from yt
It's a grey area, but we don't help with it here, we don't call out anyone just that we won't help someone break it.
@slate swan thats what i said
Yes but in this case the gist I sended is good enough evidence right?
๐
which looks better?
# help command
@bot.command()
async def help(ctx):
em=discord.Embed(title='*help*', description='`utility , moderation`', colour=0x36393F)
await ctx.send(embed=em)
or
# help command
@bot.command()
async def help(ctx):
em=discord.Embed(title='*help*',
description='`utility , moderation`',
colour=0x36393F)
await ctx.send(embed=em)
first one
wdym
im trying to make it look as small as possible
ig
mk thanks ill use this
oh alright, thanks
you know how users can have custom rich presences? i was just wondering if bots can do the same thing?
here's an example, where the image for minecraft is shown
thats an interesting rich presence and status
indeed
lol, just the first example i could find in my friends list
but you get the point, right?
https://discord.com/developers/docs/rich-presence/how-to
u might find something here
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
i think i may have found something?
but i'm not totally sure
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
โข [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")
โข [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
that just sets the thing like playing Game
๐
it looks like you can pass them in as kwargs
Anyone knows how to add this little icon on the bottom left of an embed?
author
legend
Oh, you just pass an url to the footer?
!d discord.Embed.set_footer
set_footer(*, text=None, icon_url=None)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
@wide marlin ^^
embed = discord.Embed() # whatever is passed to the constructor
embed.set_footer(text = "example_text", icon_url = "fake_url")
await # do something with the embed
just as an example
i tried adding large_image_icon, it didnt work
lemme try a diff url ig
i thought you needed to have it created in your discord dev portal first
hence the application_id
ah ic
this is the one i attempted to do for my bot
im trying to make it work with the activity now
You cannot use assets in bot's rich presence
Discord Issue
oh, are they supposed to work?
No I meant, Discord doesn't allow it
oh, i see
Wrong words usage
@bot.command()
async def avatar(ctx, user : discord.Member = None):
if user==None:
user=ctx.author
useravatar=user.avatar_url
em=discord.Embed(
colour=0x36393F
)
em.add_field(
name=f"{user.name}'s avatar",
value=f'**[download]({user.avatar_url})**'
)
em.set_image(
url=useravatar
)
await ctx.send(embed=em)
did i overdo this?
yes
you don't need half of that if you just add an error handler somewhere
user = user or ctx.author
definitely this ^^
And then remove an indent and bring everything outside the if statement
Since that is always gonna work only if user is None, ie, you never specify someone
oh lol
also, if x == None: is functionally equivalent to if not x:
But you don't need it since or provides a more readable interface for the same thing and is also faster than an if statement
^
hunter.hunt = 'hunter' 
i got ignored as usual
not the channel for that but fine
No in case x is bool
I was in a help channel asking for help lol
Or a Sized
nice
Better practice is to use is None
Bro, stop talking bout bleeding edge cases
x cannot be bool in this case though
The only reason I would use this is cz is None is faster
this?
@bot.command()
async def avatar(ctx, user:discord.Member = None):
user=user or ctx.author
ua=user.avatar_url
em=discord.Embed(
colour=0x36393F
)
em.add_field(
name=f"{user.name}'s avatar"
value=f'**[download]({user.avatar_url})**'
)
em.set_image(
url=user.avatar
)
await ctx.send(embed=em)
But then everyone has their own opinion
or am i stupid
i said functionally for a reason, meaning in this situation it would function the same way
Yea!
ight tysm
Like fr because of vulnerabilities there might be issues also pretty sure it's against some PEP but idk which
@umbral night u on dpy 1.7 or 2.0?
1.7 i think
Ah cool it will work then
Anyways doesn't matter
ye ty
wait, what wouldn't work on 2.0?
user.avatar.url not avatar_url
Breaking change.
so, i almost have something possibly working, but i need to know how to get the ids for these images:
ah yes
rich presence?
Why do u want those?
it wants me to pass the id ยฏ_(ใ)_/ยฏ
I mean, those do not work for bots anyways
i just wanna see what error it throws, and no i'll show you what the api ref said
Sure
hello there ashley
does it mean the name of it, or some id of some kind that i dont know how to get
id is the text
Can u give the link to those docs?
hola Xenoren
are u tryna use rich presence
also large_image and stuff are the literal image names
hola amigo
ye, ok, got it
Ah, these are meant for the user's activity
yes
(Prolly)
Cannot test it since my bot has no access to Presence intent, but since member.activity returns an instance of discord.Activity, soooo
unfortunate*
Its fine, u r not in a spell bee comp
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
โข [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")
โข [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
client.change_presence() accepts discord.Activity() as a type
# avatar command
@bot.command()
async def avatar(ctx, user:discord.Member = None):
user=user or ctx.author
ua=user.avatar_url
em=discord.Embed(
colour=0x36393F
)
em.add_field(
name=f"{user.name}'s avatar",
value=f'**[download]({user.avatar_url})**'
)
em.set_image(
url=user.avatar
)
await ctx.send(embed=em)
no errors, doesn't work?
!d discord.ActivityType is an enum tho
class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
it used to work
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the clientโs presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter...
You can try, but it won't work
and that gives you this ^^
ok :/
I tried it, uhhh, long ago
you're setting the url to member's avatar (user.avatar) which returns an asset, you should use the avatar_url property instead of avatar
I don't think the ws returned any error
He is on 1.7
Ashley W
iirc you can use discord.Activity while changing presence
hm nice
"iirc"
You are on 2.0 then
discord.Game is literally a discord.Activity
hm it should work
activitytype
Okay okay my bad stop
it used to work how i had it before
like literally half an hour ago
Prolly 2 python versions
im pre sure im not on 2.0
and avatar_url is 1.7
weird
avatar.url is 2.0
ye i did _url
cool
I added this thing to my asset, when i switch tabs, it disappears 
yeah, it takes a bit but it'll work!
ah k
this is on topic, has to do with attempting to make rich presences for bots
no reason for the offtopic channel mention
rich predence for bots is possible huh?
we're trying to see if it is, because the constructor allows for passing assets through it, i think
shown here ^^
havent seen any bot with that before, goodluck though
Me: ?tag rich presence
Danny's official bot: Haha imagine having a useful feature on a bot
-Discord
in the official server of discord.py
what does that mean lol
it doesnt exist
oof
client.change_presence() can accept a discord.Activity() object which can be instantiated using the assets dictionary shown before
what?
which is what made me think there was a shot i could do it
idk
same thought, but well, rightly said, imagine a useful feature
something like that message.add_reaction("๐")
yes what with that?
uh
elaborate your answer/query
i want to add ๐ this emoji
so what i write in add_reaction()
write the name of the emoji, easy as that, or use its unicode, or copy paste the emoji from discord and paste it right into your code
already tried name ;-;
copy paste already tried
just left unicode
that im asking here
what is the unicode for ๐ emoji
doesn't add_reaction(:tada:) not work?
try add_reaction('\N:tada:')
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
see
unknown emoji
!charinfo ๐
\U0001f389: PARTY POPPER - ๐
uh
owo
thats what i needed
thanks :)
add_reaction("\N{EMOJI NAME}")```
oh ok
not used add_reaction much
cuz of buttons
ยฏ_(ใ)_/ยฏ
same.
cursed emoji
it's just the unicode version
achieved by adding a backslash in front
right
\๐
it only works with custom emojs hunter
im on phone too, slash works fine for me
this works
:๐
doesnt work with a colon
for default emojis
Okay
hello hunter, ash
# welcome message
@bot.event
async def on_member_join(member):
channel=bot.get_channel(944112299151618128)
await channel.send(f'{member.mention}, welc to saudi\n{member.guild.member_count}')
how come the member count doesnt embed
i mean
like send
!d discord.Guild.member_count
property member_count```
Returns the member count if available.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
Changed in version 2.0: Now returns an `Optional[int]`.
when a member joins, it just says welc to saudi
do you have members intents?
well you can do it with len(members) if you don't want to enable it
it will count the bot too of course
but you can remove them looping through discord.members
guild.members*
!d discord.Guild.members
property members```
A list of members that belong to this guild.
ye
Hi
You still want the members intent
you can view my website in eng know 
Cool!
@bot.command()
async def perks(ctx):
em=discord.Embed(
title='*boost & inv perks*',
colour=0x36393F
)
embed.add_field(
name='boost perks',
value='` 1x bst = custom role + rich role + pic perms \n 2x bst = ^ + lowmod + bypass gw reqs `'
)
embed.add_field(
inline=False,
name='invite perks',
value='` 5x invs = custom role + pic perms \n 10x invs = ^ + lowmod + gang role `'
)
await ctx.send(embed=em)
any clue why this doesnt work anymore?
it should?
nothing
and no errors
idk
nope it doesnt
weird, i cant see anything wrong with it
yes
no error
oh
oh
how do i fix it while keeping the error handler
alright
roll = (958979841292648459)
key = ''.join((random.choice('abcdefghijklmnopqrstuvwxyz1234567890')) for x in range(6))```
```py
@bot.event
async def on_member_join(message):
await message.send(f"reply to this message with key: ||{key}||")
m = await bot.wait_for('message',timeout=60.0)
if m.content == key :
memberr = message.author
await bot.add_roles(memberr, roll)
await message.send('Role added')
else:
await message.send('Incorrect key');```
When someone responds it doesnโt read
File "/home/me/suede/main.py", line 151, in perks
embed.add_field(
AttributeError: 'Command' object has no attribute 'add_field'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/me/suede/env/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/me/suede/env/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/me/suede/env/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'add_field'
u have a command named embed
for some reason, embed is a command, it really should never be one tho
do em
oh what
^
OHH
fast
there should be like a = discordEmbed(Title= ect
then a.add_field
bruh just add em
nice
LMAO
Maybe try use embed docs to your advantage
u can check error too?
i couldnt before, because my own error handler was stopping that
till like 3 minutes ago
oh...
roll = (958979841292648459)
key = ''.join((random.choice('abcdefghijklmnopqrstuvwxyz1234567890')) for x in range(6))```
```py
@bot.event
async def on_member_join(message):
await message.send(f"reply to this message with key: ||{key}||")
m = await bot.wait_for('message',timeout=60.0)
if m.content == key :
memberr = message.author
await bot.add_roles(memberr, roll)
await message.send('Role added')
else:
await message.send('Incorrect key');```
It wonโt read the key sent
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
Damn i should of been lurking here that was the first thing i saw
Ok thanks
My problem is bot.wait_for('message',timeout=60.0) doenst work pretty much it doenst read the message
Explain ?
Check event?
O
Add a print at the top of the function
i am making a tictactoe game when i challenge someone and if they don't respond within 30 seconds i want the game to be over. How do i do that
That means the task is not running
hm
!d discord.Client.wait_for has a timeout kwarg
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
it should be
i have ticket_logs.start()
!d discord.Role.delete @umbral night
await delete(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the role.
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.
hi guys I have a question about height and width in tkinter why these parametrs are not the same?I mean height unit is greater than width
why?
ty
@maiden fable
# deleterole command
@bot.command()
@commands.has_permissions(manage_roles=True)
async def deleterole(ctx, *, role:str=None):
guild=ctx.guild
await deleterole(
name=role,
)
await ctx.send(f'{role} was deleted')
does this make sense
no
guild.delete
or something
role: discord.Role
and then do await role.delete()
whats that called in which we hover and see the time according to timezone
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
!d discord.Guild.unab
No documentation found for the requested symbol.
!d discord.Guild.unban *
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
Hello, did you need me in specific for something?
Oh hi Seb
could u help me make ban cmd
๐
No, I can't help you with a ban command. Someone else probably can, though.
stop
i did ban alr
!d discord.Member.unban
await unban(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
just ask
Yeah agreed, not really needed to ping staff.
how bout the whole cmd and the async def paramters
see panda helped u no need of owners
we dont provide whole code sry
ok t hanks
we just help with problems
aka spoonfeeding
ctx.guild.unban?
If you got the ban cmd unban isn't that different.
yeah
ok
You can literally copy the commands and place un in front every ban
is there a way to center-align text in an embed?
No but you can have inline texts.
wow
that actually might work
inline texts?
inline field also
just chane ban to unban
You can have a blank inline field with a invisible character and then it's in the middle, kinda.
that is a big brain
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 144, in kick
msg= await ("Checking perms...")
TypeError: object str can't be used in 'await' expression
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object str can't be used in 'await' expression``` can someone help me with this?
@livid elk https://paste.pythondiscord.com/quridujolu
await ctx.send("Checking perms...")
So just wondering... does ytdl itself break YouTube TOS, or downloading music from ytdl break YouTube TOS?
It breaks ToS by downloading.
Hi
But if I were to not download, but rather just straight up steam the audio to a discord call, that wouldn't be breaking their TOS, would it?
ytdl break around 40 ToS since it has more sites than just yt
It does
You can't stream it
ok thanks
Welp, there go my hopes and dreams
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโs robots.txt file; (b) with YouTubeโs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
oh damn
Read 1 transmit = stream
didn't see the "transmit, boradcast, display" part
So... in summation, is there any way to make a music bot that doesn't infringe on somebody's TOS?
There is there are some free music sites but we don't help with anything related to music.
Since people have ruined that trust.
I saw some bots like mee6 which still do enable to listen to music in a VC, maybe you could ask about it in their discord
Wrong reply
Yeah, I was thinking of doing something like this for existing bots that have musical functionality.
https://paste.pythondiscord.com/enapimazaq here is another one?
I completely understand. I'm not asking for help or anything, I just wanted to know if it could be done at all.
You need to define the message you want to edit, for example:
msg = await ctx.send("hi")
await msg.edit("hi but edited")
Isnt it ctx.send?
for edit
No
msg
!d discord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
I have a question guys
@jade tartan
Go ahead
how i can add welocmer to my bot when i type
@bot.event
async def on_member_join(member: discord.Member):
await member.send("Welcome to the server!")
it dosent work
hmmm??????/
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
no need to define member as discord.Member its done as argument
class source(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@discord.ui.button(label='Source', style=discord.ButtonStyle.link)
async def Source(self, interaction: discord.Interaction, button: discord.ui.Button):
#open link or smth
``` How would I make my button component open a link?
u mean i dont type discord.member i only type member ?/ @olive osprey
how i can set a channel for welcomer for my bot guys????
It's a type hint
Hello
no one
opinions on a whole 2070 laptop as a server
itโs not too do with databases
TAKES money to make a chungus hoy
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
wow thanks can you help me with my error?
await msg.edit(msg, content=)?
Read tracebacks is useful
Hello okimii
its a kwarg its just content
No shit

@jade tartan await msg.edit(msg, new_content="I was unable to kick the passed member. The member may have a higher role than me, I may have crashed into a rate-limit, or an unknown error may have occured. In that case, try again.")
Okimii grumpy again
change it do edit(content=...)
i am, i didnt sleept my 8 hours because of homework
Make a ai that does your homework for you

cant
because homework takes my time
Only so just get rid of msg?
well all annotations are useless
U need to use self.add_item for link buttons
but, they can help your linter and other developers know the return types or types of arguments
Oh ok thanks, could you give any examples?
# in the init
self.add_item(Button(..., style=ButtonStyle.link, url="https://totallynotafakewebsite.com"))
How can i make it say 60 minutes instead of seconds
!d round
round(number[, ndigits])```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.
For the built-in types supporting [`round()`](https://docs.python.org/3/library/functions.html#round "round"), values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.
For a general Python object `number`, `round` delegates to `number.__round__`.
use round and do math!
I got a better one but forgot it lol
divide it by 60 to convert it to minutes and round the number so it won't be in a weird decimal form
do i need to import anything?
how sad๐
And the fun thing is, the domain name is for my project ๐คฃ
๐ญ
bro im loving it
What
..
im loving the domain
You don't even know it
I am getting a link from an API within the command, how could I pass that to the button?
just pass de parsed payload
What ๐
๐
my datetime is glitching
its showing 11 for somereason
but its not my pc time
send pics (datetime pics) ๐
Lol dw
Nvm I know what u mean now
was just wondering what the code was for your datetime to be glitching
lol
whats in this? hidden error?
timestamp=datetime.utcnow()
Define the member ๐
i just did it for showing!!!
@brisk dune yo
guys why my command dont work?
@commands.command(name="help MOD")
async def help_MOD(self, ctx: commands.Context):
await ctx.send("MOD HELP MENU:\n\nWARN MENU HELP t!warn mentionUSER reason")
error?
@slate swan huh?
yes show
how i can fix it so?
Are you manually making a help menu?
uh u can use
async def help_MOD(self, ctx: commands.Context, arg):
if arg == "Mod":
do something
nice
message commands cant have spaces in between
from datetime import datetime
datetime.now().astimezone().replace(microsecond=0).isoformat()
'2022-04-22T21:40:57+10:00'
@slate swan
wtf is this
ISO-8601 format datetime
just use pytz with datetime
!E
from datetime import datetime
datetime.now().astimezone().replace(microsecond=0).isoformat()
@slate swan :warning: Your eval job has completed with return code 0.
[No output]
!pypi pytz
uh
You would use a whole module to format time? lol
!e
from datetime import datetime
print(datetime.now().astimezone().replace(microsecond=0).isoformat())
@slate swan :white_check_mark: Your eval job has completed with return code 0.
2022-04-22T11:43:46+00:00
T11?
yeah but who uses datetime with local timezone anyways
lol i've never really had to change timezones manually since I can use utc
im using utc
i got utc+2
I got utc+0 so uhhhh
Doesn't datetime grab your own system time?
yeah
not for me
it show 11:30 smh
does glitch for me sometimes too
...
Hello ashley
I got the right time
Try using datetime.now()
I'd recommend using aiomysql, or better yet asyncpg as operations on a database server can be blocking
like 1 month ago
I'm not a fan of MySQL personally
ok
i prefer MySQL
You could also use a context manager for cursors
Blocked and reported
75% /j
lol
๐
>>> from datetime import datetime
>>> datetime.utcnow()
datetime.datetime(2022, 4, 22, 11, 49, 42, 814847)
Carrying on the datetime debate, why is it showing you 11 @slate swan? What are you using to get the time man (now I'm curious).
the thing u used above
uh huh...
aiomysql is literally MySQL but with async and await
uh wait
what are you using to host your bot?
from datetime import datetime or datetime.datetime.now()
okay
nothing ;-; self host
ye i forgot
Your internet sucks then
its wifi
Also...
Answer I found on SO regarding your situation:
I know I'm five years late, but I had the same problem tonight. In my experience, the solution to the problem was to use the aware UTC datetime:
utc_dt_aware = datetime.datetime.now(datetime.timezone.utc)
If you google "utcnow()wrong" this is the first result you get, so I thought it would be good to answer anyway.
datetime.utcnow()
This call is returning an incorrect datetime, delayed from UTC/GMT by 1 hour (check in: http://www.worldtimeserver.com/current_time_in_UTC.asp).
Is it working like it should be?...
class ImageView(discord.ui.View):
def __init__(self, file: str):
super().__init__()
self.value = None
self.add_item(discord.Button(discord.ButtonStyle.link, url=file))
``` and im getting the error ```__init__() got an unexpected keyword argument 'url'```
๐ฟ
@slate swan are you getting the utc time right?
yes
Can you show the error?
yeah plz
Imagine saying pls
That is the error, I cant show a full traceback without completely modifying my code :(
ahem ahem
PLEASE
Hm?
Can't show the traceback..? Why not?
how can i fix this
ImportError: cannot import name 'Button' from 'discord.ui' (unknown location)
im hosting my bot on replit
I have a try and an except, Iโm parsing the exception as a variable and printing it just shows that
style is a kwarg
Install dpy 2.0
i did
Just raise the error again in the except.
do pip show discord.py
Wait 5 min
@slate swan
!e ```py
try:
None.get()
except Exception as e:
raise e
2.0
thats not 2.0
>>> try:
... int('a')
... except ValueError as e:
... raise(e)
Traceback (most recent call last):
File "<pyshell#6>", line 4, in <module>
raise(e)
File "<pyshell#6>", line 2, in <module>
int('a')
ValueError: invalid literal for int() with base 10: 'a'
i think i got that
Wow
how do i install
@cloud dawn :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | File "<string>", line 2, in <module>
004 | AttributeError: 'NoneType' object has no attribute 'get'
@bot.command(name="question")
async def question(message):
redditsub = await reddit.subreddit('AskReddit')
for post in redditsub.random_rising(limit=1):
await message.channel.send(post.title)
Gives out this:
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'ListingGenerator' object is not iterable
What's going on?
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
Im pretty sure this guy also comed yesterday
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'url'
``` here is the traceback ๐ฟ
Code

paths reveled
look at praw's issues and find your error, there will be a solution for it
class ImageView(discord.ui.View):
def __init__(self, file: str):
super().__init__()
self.value = None
self.add_item(discord.Button(discord.ButtonStyle.link, url=file))
``` code ```Traceback (most recent call last):
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'url'``` traceback]
Since when does add_item have an url kwarg
since now ig
ive tried looking at asyncpraws docs, doesnt seem to register errors there
I read the example of url buttons and this is what it said
you're using praw..
class Google(discord.ui.View):
def __init__(self, query: str):
super().__init__()
# we need to quote the query string to make a valid url. Discord will raise an error if it isn't valid.
query = quote_plus(query)
url = f'https://www.google.com/search?q={query}'
# Link buttons cannot be made with the decorator
# Therefore we have to manually create one.
# We add the quoted url to the button, and add the button to the view.
self.add_item(discord.ui.Button(label='Click Here', url=url))
this is the example
it doesn't, look at what hes passing in add_item
so thats the problem? trying to use praw functions in asyncpraw?
discord.ui.button oh damn ๐ญ
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given```
class ImageView(discord.ui.View):
def __init__(self, file: str):
super().__init__()
self.value = None
self.add_item(discord.ui.Button(discord.ButtonStyle.link, url=file))```
๐คจ
is there another way to make bot pick random except
randint.random?
Just make a normal button and pass the link button style
!d random.choice
random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
its random.randint
secrets module (/s)
can la typo
allready tried that and someone pointed me towards .add_item
Where is this someone?
damn your username and you typing...
difference between is and are
difference between my attention span and yours
..
๐
For some reason I keep thinking your pfp is a planet with a blue flaming mohawk...
Huh
what ๐
what?
LMAO sparked discussion
Your must be off your shit rn god damn
@slate swan's profile pic looks like a planet with a mohawk when you zoom out enough
Nope, not... "off my s***"
censoring your messages is fitting tbh
๐
turned out that was the problem
How the hec
I tried zoom
I don't have 20/20 vision and am mildly colour-blind if that helps :)
wait 2020 vision means 20/20 and not the year???
Nobody has 20/20 vision who uses discord ๐คทโโ๏ธ ๐คทโโ๏ธ
Nah I got 2023 beta version vision ๐
does someone know how to execute action of reacting on message in command?
on_reaction 
LMAO
thx i am kinda new to the discord.py
what ๐ฅด
๐ vip acces
#discord-bots message
ah its still there
๐ฅ
awaiting on reply ๐ญ
Hi
it didnt work 
Code
are you sure this is causing that, i dont see anything wrong here
check the message i repllied to
style=ButtonStyle...
visible confusion
Enable tramloc
ah right
I forgot the error
style is kwarg
what is tramloc
This is one thing I love about dpy
ikr
The thing when u get when u didnt await
Any way to check if a discord invite link is valid?
IDK
!d
chromium or requests
?
are u the server owner?
Hmmmm
Yea
check the invite in ur server settings
scroll to the bottom
click on it ๐
true, easier
Click join and try it out
this is the disocrd-bots channel ๐ฟ
If you're homeless, just buy a house
I am sending it in #discord-bots for a reason, I wanna try if it's valid programmatically
i updated my dpy to 2.0, now it wont load cogs
idk, L
Repkit whyyyyyyyyy
U r trying to access a dict key which doesn't exist?
trying to acces a dick? ๐ญ
oh dict key
No, dict
i mean the error handling
Lmao
its not working
ayo what??
INVITE_RE = re.compile(
r"(discord([\.,]|dot)gg|" # Could be discord.gg/
r"discord([\.,]|dot)com(\/|slash)invite|" # or discord.com/invite/
r"discordapp([\.,]|dot)com(\/|slash)invite|" # or discordapp.com/invite/
r"discord([\.,]|dot)me|" # or discord.me
r"discord([\.,]|dot)li|" # or discord.li
r"discord([\.,]|dot)io|" # or discord.io.
r"((?<!\w)([\.,]|dot))gg" # or .gg/
r")([\/]|slash)" # / or 'slash'
r"(?P<invite>[a-zA-Z0-9\-]+)", # the invite code itself
flags=re.IGNORECASE
)
sick
Mans actually trying to get the mods on him...
apa ni
whats this lmao
This won't work, an invite link could still be expired
"Which doesnt exists"
Iโve been banned once, worse months of my life
I am just looking for if discord has an API or something for it
why did u write out dot 
๐ฅ
(not gonna self bot don't suggest chromium and stuff)
Didnt understand even 1 line
remember to set the invite link to this
It's regex
Then after validating that it's a valid discord url using aiohttp to check if invite is still up isn't too hard.
That's not what I am trying to do lmao
help ๐ญ
I'll try this
but its expired, so make a new one
ez
That's not what I want ffs bro
u cant make an expired link not expired ๐คฆโโ๏ธ
Alr cool
And I already told u I don't wanna do that
whatever
class ImageView(discord.ui.View):
def __init__(self, file):
super().__init__()
self.value = None
self.add_item(discord.ui.Button(discord.ButtonStyle.link, url=file))
``` ```Traceback (most recent call last):
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\Harckepy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given```
SO answer:
If you're wanting the user to input an invite via a command argument, it will throw an exception if the invite is invalid (a discord.NotFound error, to be exact):
@bot.command()
async def inv(ctx, invite: discord.Invite):
await ctx.send("That invite is valid!")
@inv.error
async def inv_error(ctx, error):
if isinstance(error, commands.BadArgument):
if isinstance(error.original, discord.NotFound):
await ctx.send("That invite is invalid or has expired.")
Or you can use
fetch_invite():
try:
invite = await bot.fetch_invite(URL_OR_ID_HERE)
await ctx.send("That's a valid invite!")
except:
await ctx.send("Sorry, that invite was invalid or has expired.")
There's no need for any other modules - just the discord library is capable of telling you information about the invite.
still awaiting on a valid reply tbh
How do you have the bot send a dm the member?
member.send()
why error handling not working
Show code
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
seccd = round(error.cooldown.get_retry_after())
mincd = 0
hrcd = 0
rseccd = 0
rmincd = 0
if seccd > 59:
rseccd = int(seccd % 60)
mincd = int((seccd - rseccd) / 60)
if mincd > 59:
rmincd = int(mincd % 60)
hrcd = int((mincd - rmincd) / 60)
else:
rseccd = seccd
await ctx.send(f'''
Dont spam :/
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
elif isinstance(error, commands.CommandNotFound):
await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
elif isinstance(error, KeyError):
await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
else:
raise error
59
World gonna end when he finds out about timedelta.
whats time delta
Im not asking 1.
why are you typing out few things like dot and slash and u dont need to escape . in []
๐ฟ
!d datetime.timedelta
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
Yo worked omg
:/
What does it mean by when my code error says member is a required argument that is missing.
one of ur argument(member) is missing
Define member.
Show ur code btw?
async def kick(user, ctx, member: discord.Member, *, reason=None):
await member.kick(reason=reason)
await member.send("You have been Kicked from the server")
```
what about me ;-;
โฌ๏ธ
user, ctx
Python docs description:
class
datetime.timedelta
A duration expressing the difference between two date, time, or datetime instances to microsecond resolution.
๐
Also u cant send after kick
Oops
thanks
If not in mutual servers
bot can i think
style=ButtonStyle....
I didn't make it since I've never needed it, if I would make it I would make it a oneline regex.
what ๐ฟ
It has kwargs where it feels like pos args don't make sense
