#discord-bots
1 messages Β· Page 709 of 1
It's never online tho

π
for cog in bot.cogs:
if cog == 'Jishaku':
pass
``` still doesnt work (jishaku still in my other object)
i wish i was indianπ love them
!d discord.ext.commands.bot.cogs
capital case, bot
eh
!d discord.ext.commands.Bot.cogs
property cogs: Mapping[str, discord.ext.commands.cog.Cog]```
A read-only mapping of cog name to cog.
Bot.cogs is not a list
Because it shows your s a string but is actually a mapping
yes, a nice and round "o" after someone explaining hard
for cog in bot.cogs:
if str(cog) == 'Jishaku':
pass
``` still doesn't work
ok
tey printing cog , and you'll know why does it not work :")
for cog in bot.cogs:
cog = bot.get_cog(cog)
print(cog.qualified_name)
if cog.qualified_name == 'Jishaku':
pass
``` jsk is still in my other object
Can you show your complete code
@bot.command()
@commands.cooldown(1,5,commands.BucketType.user)
@commands.is_owner()
async def say(ctx,*,rep=None):
await ctx.send(rep)
await asyncio.sleep(5)
await ctx.message.delete()
well this is supposed to work but it still does the same thing (just send the message)
i forgor, how to make this again...?
Timestamp
that is my full code tho? i feel like the other stuff isnt needed
what's the name 
like where is ur bot token etc
ok
!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.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
Maybe you added something after it which is changing it
if the manual method?
<t:<timestamp integer>:timestamp_type>
Use continue instead of pass
o
so basically this is not deleting the message idk why
@bot.command()
@commands.cooldown(1,5,commands.BucketType.user)
@commands.is_owner()
async def say(ctx,*,rep=None):
await ctx.send(rep)
await asyncio.sleep(1)
print("slept")
await bot.delete_message(ctx.message) #stops here
print("done")
Great
<t:<what to type here>:f>
delete message isnt a thing
Timestamp integer
idk where you got that from
docs?
just use discord.Message.delete method
check ddocs, keyword: timestamp
ctx.message.delete
i also tried
await ctx.message.delete()
but the same thing
it isnt the same thing
k
the same thing happened
???
do you know what ddocs is?
does your bot have enough permissions
uh discord.py docs?
oh :v ok, thanks
oh right...
omg thx
lmao
Remove the < inside
Np
what date is this lol
remove "<" inside
i said inside :l
there
ohh
<t:44444444:f>
ddocs = discord/developer docs
oo, ok
<T:3512371212:f>
hmm, play time
!e py from datetime import datetime print(f"<t:{int(datetime.now().timestamp())}:F>")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<t:1640523055:F>
copy paste it
@small igloo your bot?
datetime now and timestamp?
no
you can use .timestamp() function to get the timestamp for a datetime object
hmm
!d datetime.datetime.timestamp returns a float
datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").
Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.
For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:
```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
``` New in version 3.3.
Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
ah frig my brain
datetime.timestamp()???
its a datetime function?
wut wut
!e
from datetime import datetime
print(f"<t:{int(datetime.now()}:F>")
@small igloo :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | print(f"<t:{int(datetime.now()}:F>")
003 | ^
004 | SyntaxError: f-string: closing parenthesis '}' does not match opening parenthesis '('
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
waht?
oh
!e
from datetime import datetime
print(f"<t:{int(datetime.now())}:F>")```
@small igloo :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: int() argument must be a string, a bytes-like object or a real number, not 'datetime.datetime'
. timestamp when?
why must timestamp
!e ```py
from datetime import datetime
print(f"<t:{int(datetime.now().timestamp())}:F>")
@small igloo :white_check_mark: Your eval job has completed with return code 0.
<t:1640523367:F>
<t:1640523367:F>

#subfile
def hello(name: str) -> str:
return "hello" + name
#main
import subfile
subfile.hello("name")
makes a bit more sense
aaand random guy shows up again
what
ok

How can i split split arg1 and arg2 with :
My code
async def connect(ctx, arg1, arg2)
Example
Connect lnm.net:lnm
ok, still not understand
how to check is "something" in the column "name" in "table_name"
Wdym?
!command arg1 arg2
Works fine
!command arg1**:**arg2
Oh
.split
str.split
How? Can u give me full code xd
no ones gonna spoon feed you
string = ...
string.split(...)
@boreal ravine :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | AttributeError: 'ellipsis' object has no attribute 'split'
oops
Why u delete xddd
you indexed the first 2 characters?
OH YEAH
!e py a = "python is great" m = a.split() print(m)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['python', 'is', 'great']
!e ```py
e = "arg1:arg2"
spl = e.split(":")
print(spl[0])
print(spl[1])
@heavy folio :white_check_mark: Your eval job has completed with return code 0.
001 | arg1
002 | arg2
what is row
i have no idea?
show the class' init
class HelpCommand(commands.HelpCommand):
def __init__(self):
super().__init__(
command_attrs={
"hidden": True,
"help": "Shows help about a module, group or a command",
}
)
``` i hate working with the help command class
i wanna access commands.Context in it but i cant 4 some reason
what is super() i dk it :)
accessing the parent class's attributes
self.context is the context...
self.context doesn't have all the features commands.Context has
how to create discord event in py? i literally can't find it anywhere
oh nvm
!d discord.ext.commands.Bot.event
@event```
A decorator that registers an event to listen to.
You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).
The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.9)") is raised.
Example
```py
@client.event
async def on_ready():
print('Ready!')
it doesn't
not that
@bot.event ?
no
so what
!d discord.ext.commands.HelpCommand.context
The context that invoked this help formatter. This is generally set after the help command assigned, command_callback(), has been called.
It returns the same object
o
oh event
it returned <class 'disnake.utils._MissingSentinel'> though
Discord.py does not have the feature
you need to use fork
||js?|| dies, don't click it
π
lol
π΄
Oh , but did you try doing anything with it? In sure it has all attributes of Context
the context?
yes
bump
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
I know
!d discord.TextChannel.edit takes a category kwarg
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
helo
i think it has a category kwarg
I just want to know how to get the category
!d discord.ext.commands.Bot.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
isn't this the same?
can't it be name instead of ID?
name isnt unique so no
Nope , if you want to use name use utils.get instead
Read the 3rd line of the docs of that method
!d discord.TextChannel.move
await move(**kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A rich interface to help move a channel relative to other channels.
If exact position movement is required, `edit` should be used instead.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to do this.
Note
Voice channels will always be sorted below text channels. This is a Discord limitation...
Sure
[x for x in z for y in w]
is this a correct way of doing 2 for loops in a list comp?
hmm k
Why not [ x for x in [ z for y in w]]
what is utils
didnt knew you can do that
!d discord.utils
No documentation found for the requested symbol.
:l
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
thx
It just needs an iterable
i see thx
await ticket_channel.edit(position=13)``` I have this but it isn't moving the channel position
no errors
nvm I just gave it the category instead
What may trigger a tasks.loop 5 times in a minute, if the loop is set for 1 hour
for example, this loop is being activated SIX times in 1 hour
but the loop is set for 3 hours
the place where you start the loop.
I'm assuming you're starting the weather_loop function in on_ready no?
and time.sleep is blocking
requests lib too
I started with Cog's class, is it bad practice?
Can one problematic function intervene with other loops within the same Cog class?
depends on what problem is on the "problematic function". But show us how you start the loop
hmm, that should be fine already
how do you know its executed 6 times?
is this the only place you're starting the loop?
yes

okay, now try printing something and see how much did it print
Maybe if every minute it is being started again
Does anyone know if there is a library that is like discord.py's format but instead is used for creating terminal applications?
what are terminal applications
= console applications
i mean like, just a py script that opens in the terminal
like literally the default
Every python file .py opens a terminal/console window
yeah
but like, able to create command structures for the console instead of a discord bot
etc
Or, at least, open to fork
thats true, just wondering if there is one similar done already
if not, i could look into it
So you just want the command handling system in discord.py for console applications?
Do you have a "chat" mechanism working for that?
yeah like groups etc
i have nothing atm
It shouldn't be difficult to redo it
It is kind of similar to using input with shlex
And you need to make a class and decorators and everything
Good luck with that
lol
@bot.command()
async def annoy(ctx, times : int, *, content):
elif not isinstance(times, int):
await ctx.reply("The number of times should be a digit", mention_author=True)
else:
if times > 10:
return await ctx.send("You tryna break me or what?")
else:
for i in range(times):
await ctx.send(content)
Error
Converting to "int" failed for parameter "times".
```...tried it but it no work...wut do i do?
@tidal hawkwhy u run every 3rd hour dosnt weather change more often than that? π
or is it t limit the rate calls of api?
how did you call the command?
;annoy times @lOlMohAn69
well that explains it
u can still abuse that command pretty easy, with spam <prefix>annoy 10 ...
like if iz times is not int(thenks to sm fools of my frnds they cannot stick to syntax so i wanted to notify thm abt tht)...soooooo how do i do tht?
tht i got...
wdym
;annoy times @lOlMohAn69, i think he ment its ;annoy 10 @...
if i spam in ur server ;annoy 10 @cinder horizon it will still spam alot
you should set a cooldown on that command
like 30sec-1min
tht i surely shall
https://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python
i got the check for type from this...second answer to be precise
hmmmmmm gimme a sec
elif not isinstance(times, int):
time=1
if type(times) is int:
... print("a")
...
a
!e
time=1
if type(times) is int:
print("a")
@cinder horizon :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | NameError: name 'times' is not defined. Did you mean: 'time'?
I'm trying to make a verification command but idk how to check if the user sent the correct code in the verification channel
@commands.command()
@commands.has_role(924672205038710824)
async def verify(self,ctx):
verification_code = random.randint(1111,9999)
if ctx.channel.id == 921720659653054464:
try:
verification_embed = discord.Embed(title=":police_officer: Verify :police_officer:", color=0xd7832b, description=f"To keep our server safe please enter the code you see below in [#921717709589336065](/guild/267624335836053506/channel/921717709589336065/).\n`{verification_code}`")
await ctx.author.send(embed=verification_embed)
except:
await ctx.send("__**I cannot dm you!**__\nPlease open you dm's in user settings.")
else:
pass
async def on_message(self,message):
if message.channel.id == 921720659653054464:
if message.content == verification_code:
!e
times=1
if type(times) is int:
print("a")
@cinder horizon :white_check_mark: Your eval job has completed with return code 0.
a
if type(times) is not int:
... print("x")
... else:
... print("z")
...
z
@cinder horizondid you cutoff the beginning of your if-statement here? @bot.command() async def annoy(ctx, times : int, *, content): elif not isinstance(times, int): cause u starting it with elif
isinstance is the best you can use
@bot.command()
async def annoy(ctx, times : int, *, content):
if ctx.channel.id == 763705746235588658:
pass
elif type(times) != int:
await ctx.reply("The number of times should be a digit", mention_author=True)
```pretty much did ig
i wonder why you are doing it again when its typehinted as int tho
if isinstance(times, int):
... print("a")
...
a```
@bot.command()
async def annoy(ctx, times : int, *, content):
if ctx.channel.id == 763705746235588658:
pass
if not isinstance(times, int):
await ctx.reply("The number of times should be a digit", mention_author=True)
yep tht worked
thenks you too
you need to make a new if-statement
..
you use elif when its same statement
like removed the : int and tried it n it works....
and had ta make a new if statement yes
and had ta make a new if statement yes
Python 3 - IF...ELIF...ELSE Statements, An else statement can be combined with an if statement. An else statement contains a block of code that executes if the conditional expression in the if stateme
thats just a typehint
could also check if its .isdigits()
!d discord.ext.commands.BadArgument
exception discord.ext.commands.BadArgument(message=None, *args)```
Exception raised when a parsing or conversion failure is encountered on an argument to pass into a command.
This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
just typehint it to int ->if its not, it will raise a commands.BadArgument
aighty
check in the wait_for()
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
hey can any one give me code for clear command
a very good clear command like dyno
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting botβs messages...
and , if you want to make something like dyno's purge command , you'd be using typing.Union as the first arg of the command
i know
use a check
wait why union i think its typing.Optional
well that will not work as expected
they are same.
!d typing.Union
typing.Union```
Union type; `Union[X, Y]` is equivalent to `X | Y` and means either X or Y.
To define a union, use e.g. `Union[int, str]` or the shorthand `int | str`. Details...
!d typing.Optional
typing.Optional```
Optional type.
`Optional[X]` is equivalent to `X | None` (or `Union[X, None]`).
Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the `Optional` qualifier on its type annotation just because it is optional. For example:
```py
def foo(arg: int = 0) -> None:
...
``` On the other hand, if an explicit value of `None` is allowed, the use of `Optional` is appropriate, whether the argument is optional or not. For example...
lol they are not
yea we are taking None here
got you point
you are correct they are same
Optional [SomeType] is the same as Union [SomeType, None].
yea i got that
π
just a quick question
ask away
a webpage?
network address?
async def on_command_error(self, ctx, error):
if we can't do this then how to get channel where error occured
its ctx and error only unless you're in a cog
What else do I need to install to get my bot online?
ctx.channel
I asked python general lol
but anything after the forward slash is subdirectory.
we can't use ctx i think
run the file?
who tf says you cant?
lol
!d discord.ext.commands.Bot.on_command_error
await on_command_error(context, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default command error handler provided by the bot.
By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for command error.
i tried async def on_command_error(self, ctx, error):
whats wrong then
but it seems error is not working
show full error
discord.ext.commands.errors.ExtensionNotFound: Extension 'cogs.@robust token' could not be loaded.
while error is this
install aiohttp 3.8.0
why is it a mention format
i forced it to get error so i can check error handeling
ic so whats the issue?
even getting above error but program ignores my isinstance
so the elif statement never gets raised?
yea
try changing the elif to if
ok
what?
not working
hm no idea then
whats your issue?
error handeling not working
show me your current code
how to create a command with space i mean command "c#command help"
and explain the issue that happens when an exception could be raised
elif isinstance(error, commands.errors.ExtensionNotFound):
show me the entire event
i have this is error
discord.ext.commands.errors.ExtensionNotFound: Extension 'cogs.@robust token' could not be loaded
i have no idea what you mean
async def on_command_error(self, ctx, error:commands.CommandError):
if isinstance(error, commands.errors.NotOwner):
message = "You are not owner!"
elif isinstance(error, commands.errors.BadArgument):
message = "Bad argument!"
elif isinstance(error, commands.errors.ExtensionNotFound):
message = "Extension not found!"
else:
raise (error)```
this is code
okay.. for any error you set a value to a variable, how is this supposed to return the message variable?
how do I call a command when there is a space in it, I can't add a space, It gives an error
async def hi help(ctx):
^
SyntaxError: invalid syntax
By default, probably not due to how Dpy parses them. You could probably hack it into DPy somehow, but by default nah.
put an underscore between the two words
this is called snake casing
i know but the error should not be reaised
just space, impossible?
according to your code, it should raise
you're not doing anything to handle the error
hmm i am defining a variable
you could use the aliases kwarg in the command decorator to use a space
but as far as function definition, it must be snake cased
yeah, how is this supposed to handle your error?
you're doing nothing to handle the error
its a cog file where i am handeling errors i fthere is error i am senting that message to ctx.send()
doesnt look like it
how do i fix this error?
Because no versions of discord match >1.7.3,<2.0.0
and discord (1.7.3) depends on discord.py (>=1.7.3), discord (>=1.7.3,<2.0.0) requires discord.py (>=1.7.3).
You don't understand How I can put a space in the command call, that is !help mute
ah like a subcommand?
install aiohttp 3.8.0
!d discord.ext.commands.group
@discord.ext.commands.group(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
This is similar to the [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") decorator but the `cls` parameter is set to [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group") by default.
Changed in version 1.1: The `cls` parameter can now be passed.
ok
your trying to get the type of an error
!e
print(type("hello"))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'str'>
await on_command_error(context, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default command error handler provided by the bot.
By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for command error.
what are you trying to do?
why my on_command_error not working
show
elif isinstance(error, commands.errors.ExtensionNotFound):
smh
your whole function
when i am getting this error my handeler is ignoring it
?
@lusty ether iβve tried helping you, your on_command_error is perfect , you are just using it incorrectly.
oh
this is new code still not working
guess cant help him if he cant help himself
lol
Does somebody have an idea, why my tasks.loop(hours=3) runs 5-6 times within ONE hour
Sometime it doesnt set footer etc.. line 112
move the embed.set_footer() above your for loop.
how does it change the output?
@patent lark i tried to print the error type and found my error is not ExtenstionNotFound its command invoke
your bot restarts ig
but why
it doesn't
the only thing between your embed object and footer method is your for loop. id assume this could be an issue as to why it isnt setting
huh?
But why does it run the loop function like 20 times within 3 hours
are you sure.
instead 1 time in 3 hours
100%
are you sure theres only one instance of the bot running?
yes
where do you start the loop?
discord.ext.commands.errors.ExtensionNotFound: Extension 'cogs.@robust token' could not be loaded.```
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ExtensionNotFound: Extension 'cogs.@MEE6#4876' could not be loaded```
here my command handler is taking second error not first one
on_ready probably
on Cog class attribute
hence the issue
cog gets loaded multiple times
if its in on_ready that would be an issue since on_ready could be dispatched multiple times
How do i make my bot send "blocked messages"?
pycharm pyflakes are one of the reasons why i dont wanna use it
wdym "blocked messages"
you cant send blocked messages
uh. block your bot? lmao
thats discord
pyflakes?
i dont even think theres an endpoint for it afaik
the lines on the class
bruh
didn't even realise that i blocked the bot
client = discord.Client() *
Ohh ok actually am following https://youtu.be/SPTfmiYiuok this tutorial and i copy pasted them here but didnt worked
Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it.
π¨Note: At 16:43, Replit now has a new method for environment variables. Check the docs: https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables
Along the way, you will learn to use Repl.it's built-in database and cr...
thats your issue
Ohk
dont follow youtube tutorials, the code is probably outdated and poorly written.
you should also use the bot object not discord.Client()
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
this is probably the best tutorial i can point you to
Ohhk thnx
but you should learn python before jumping into discord.py. discord.py is a complex library, not for beginners.
you need basic knowledge of Python, Asynchronous Programming, and Object Oriented Programming (OOP)
In which channel can i learn basic things of python?
Ohk
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
https://automatetheboringstuff.com/ (for complete beginners to programming)
http://greenteapress.com/wp/think-python-2e/ (another decent book)
See also:
http://www.codeabbey.com/ (exercises for beginners)
https://realpython.com/ (good articles on specific topics)
https://learnxinyminutes.com/docs/python3/ (cheatsheet)
Collection of programming problems to practice solving, learn to program and code, and win certificates
Thnx
What is the difference between discord.Guild.emojis and await discord.Guild.fetch_emojis() ?
i can make that with you on replit x]
one fetches some emojis and the other is all the guilds emojis
how do you istall discord 2.0.0?
what is the command in terminal for linux
thanks
it should be in dpys git
ill check thanks :)
yw
pip3 install git+https://github.com/Rapptz/discord.py
i want to add a few languages to my bot but idk how to add this. Do u know?
thanks it worked :0
What can i do
am i the only one who uses windows smh
i thinks so lmao
I use windows for all of the above. Idrc for Linux or Mac. It also doesnβt make my opinion any better on Linux when people who stan it constantly shit on windows and poach people to go to Linux.
Yeah also fine, relax day today.
i mean linux is good but some software doesnt support it like apex doesnt let you download it on linux
What really is available and non-available emojis? (Like the ones returned by xyz.available)
How does an emoji become non-available?
:thisemojiisnotavailable:
π€
Bot is unable to send the emoji because it doesn't have the permission to format it.
Oh so, emojis that aren't available consume emoji space in guild right?
Well yeah if that custom emoji is in that guild.
Bots can't have nitro so the checklist will be of the guild emoji's and discords default emoji's
can anyone help on using the new discord.ui.Buttons to make a subclassed help command? I know how to make one with menus but not these new buttons
i dont want code, but explanation pls thnks
to make buttons you dont subclass ui.buttons?
I mean you could
Β―\_(γ)_/Β―
But he stated the help command okimii
yes
hes trying to subclass help command with buttons?
dont get why ui.buttons is needed
a bit like the dank memer help command
ah a paginator
what, HelpCommand?
yes
i dont think so, my current one is using discord.menus
just pycord then lol
yeah
pycord is a dpy fork
my bad
most forks are better than dpy itself
oh ok
i will look at the docs for once and try to figure it out
if not ill probs come back to ask tomorrow lmao
thanks
yw
i found it tysm for the guidnce :)
anytime!
hey how to run a file with command?
i.e. i have 2 bot and i want to write a command like !run bot2 and second bot's main file will run.
how can i make this?
import os
def run_bot_two():
os.system("python second_bot.py")``` where `second_bot.py` is the file you want to run
alrightyyyyy thx i'm gonna try
os.system(C:\Users\Ahmet\Desktop\test i can fly\main.py`
like that?
i got the idea he wanted to stop the first one
oh nice then....
?
Using asyncio.loop.subprocess_shell would be better ngl
if you want the first one to continue, sure
!d asyncio.loop.subprocess_shell
coroutine loop.subprocess_shell(protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)```
Create a subprocess from *cmd*, which can be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") or a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") string encoded to the [filesystem encoding](https://docs.python.org/3/library/os.html#filesystem-encoding), using the platformβs βshellβ syntax.
This is similar to the standard library [`subprocess.Popen`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen "subprocess.Popen") class called with `shell=True`.
The *protocol\_factory* must be a callable returning a subclass of the [`SubprocessProtocol`](https://docs.python.org/3/library/asyncio-protocol.html#asyncio.SubprocessProtocol "asyncio.SubprocessProtocol") class.
See [`subprocess_exec()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.subprocess_exec "asyncio.loop.subprocess_exec") for more details about the remaining arguments.
Returns a pair of `(transport, protocol)`, where *transport* conforms to the [`SubprocessTransport`](https://docs.python.org/3/library/asyncio-protocol.html#asyncio.SubprocessTransport "asyncio.SubprocessTransport") base class and *protocol* is an object instantiated by the *protocol\_factory*.
pls someone can help me with that?
Why do u have a double brackets in discord.Color
β οΈ pip install embed
pip install time as well xD
Lol
bro he thinking this is nodejs
never seen something more cursed in a while no offense
fixed it
bro he installing embed π
im about to pip install commands
bro one second let me install discord.ext.menus π΄οΈ
you guys arent seeing the worst problem
whats the worst?
channel = client.get_channel(##LOGS CHANNEL ID)
π
so many if state ments for option times
when you can just do it in minutes or hours
!d disnake.ext.commands.Context.reply
await reply(content=None, *, fail_if_not_exists=True, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") to reply to the [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message").
New in version 1.6.
Changed in version 2.3: Added `fail_if_not_exists` keyword argument. Defaults to `True`.
phew, it exists still, i thought mention_author was the replacement
why is this underlined :[
why would it get deprecated
π΄οΈ
importing disnake.ext and disnake works
but this seems to be fucked up
wait
im so fucking stupid
it's disnake.ext.buttons
but still same issue :|
maybe an issue with pylint?
π΄οΈ
Summary
This Adds Voice Receive To Discord.py Rewrite (Or 2.0.0). I attest to the fact that this is 100% Working. Please Merge THis as Soon As Possivle.
There is also an example attached to this
Ch...
don't read the pull request or die
why talk here when you have https://discord.gg/dpy
Because I'm banned from there
π
looks like a cool slide
of asynchronous stupidity
lol
bro this was a troll pull request
i should learn regex before i do my api wrapperπ
@tawdry perch lmfao what
π bro import pygame?
π
discord.py never had voice receaving
Shush
but it was planned too have it
it's a troll pull request
ofc you need it
i think pycord has a wip voice receiving model
im pretty sure disnake does too even though i've never heard of it
you sure?
π
disnake doesnt have everything you know
it has timeouts thats what i care about
good for you?
yes
I mean you could definitely do that. I mean I go there sometimes. However, itβs a nice place to go if you wanna get shit on for not knowing stuff.
helpers are big brain agreed
hallo everyone
If you go here itβs more of a non-hostile environment towards people who donβt as much python
bye hello
straight up copy
you know that's disnake server :troll:
Yep
thas me
If you actually act the way people act in the discord.py server. You would get punished here.
how do you mean
what's the discord.py server?
how do I make http requests to discord using my bot and not any other library?
Official support server.
Oh yeah itβs not documented.
I mean thereβs probably doc strings in the source.
possible but idk how it works cus not documented in the bot, Β―_(γ)_/Β―
the bot?
@unkempt canyon
how do I do it?
possible but idk
Mark are you genuinely asking a question or asking something you already know.
I am asking a question that I already know
he did say he wanted a question.. 
i mean I see you a lot in the official dpy server. You seem pretty experienced and knowledgeable about this stuff.
no
you can't fetch the oldest reddit posts with a upvote amount of -1,000 :Sob:
probably because you can
regex is built in to python with the access word "re" right
Yeah
!e
import re
@shadow wraith :warning: Your eval job has completed with return code 0.
[No output]
yup usually it return modulenotfound error so π
just wanted to be sure
!e
import sys as disnake
import random as discord
disnake.exit()
@shadow wraith :warning: Your eval job has completed with return code 0.
[No output]
any ideas? ```py
import discord
from discord.ext import commands, tasks
class join(commands.Cog):
def init(self, bot: commands.Bot):
self.bot = bot
@commands.event
async def on_member_join(member):
channel = client.get_channel(910565602362556426)
embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined the server.")
ember=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
await channel.send(embed=embed)
role = discord.utils.get(member.guild.roles, name = "γπ γUSER")
await member.add_roles(role)
print(f"{member} was given {role}")
def setup(bot: commands.Bot):
bot.add_cog(join(bot)) ```
do commands.Cog.listener() instead if you're in a cog
^
Ignoring exception in on_member_join Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) TypeError: join.on_member_join() takes 1 positional argument but 2 were given
import discord
from discord.ext import commands, tasks
class join(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_join(member):
channel = client.get_channel(910565602362556426)
embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined the server.")
ember=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
await channel.send(embed=embed)
role = discord.utils.get(member.guild.roles, name = "γπ γUSER")
await member.add_roles(role)
print(f"{member} was given {role}")
def setup(bot: commands.Bot):
bot.add_cog(join(bot)) ```
I m getting this error now
async def on_member_join(self, member):
oh yea i m dumb thx

pip install it again and restart your ide
:dogepray:
i lose my a little bit of my sanity everytime someone calls vsc an ide
Someone can help me in visual studio code?
do i have to install anything special to get is_playing and is_paused to work?
is it related to discord bots?
Yessir
ask away then
I need to show the problem in share screen
no idea but prolly no
well it dont work
would be better if u could ask it here, expecting people to screenshare for your problem is a little hard
If I wrote the problem you won't understand
show error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'is_paused'
Screen record the issue @dawn thorn
Can I call you in about 15 minutes?
bot isnt in a vc?
Nah sorry man you should just screen record via OBS and send it here
I don't have nitro, discord won't lemme send it
@dawn thorn cant u just send error
Ther is no error
You can just put it in google drive and make it public and send the link here
please don't use ableist language
sry
If I want to run like print('hello world') It tells me to select a file (I do not know why)
@neat gale lmfao?
@boreal ravine @scenic lark
yeah im dumb
Run python <filename>.py then in the terminal
But why I need to select file
Screen shot the error dude
Bruh I told you
the error is what it's telling u to do....
Go to the file directory and run the command I'm so confused
Nvm I'll do it myself
still not working?
async def create_db_pool(): client.pg_con = await create_pool
Hmm....Interesting
anyone know a good host and good ide to use? ive been using repl and uptimerobot but its kidna slow
Ok lol now i get another error but i know how i can fix that err thx anyway :)
Hi i have a question i have this code ```py
from discord.ext import commands
class Ping(commands.Cog, name="Ping"):
def init(self, bot: commands.Bot):
self.bot = bot
@commands.command()
async def ping(self, ctx):
await ctx.send(f"The current latency is: {round(commands.latency * 1000)} miliseconds")
def setup(bot: commands.Bot):
bot.add_cog(Ping(bot))
and i get this errorAttributeError: module 'discord.ext.commands' has no attribute 'latency'
bot.latency
self.bot.latency
dosent work
use your class attributes
^ self yeah
oh ok
def get_emote_vacancy(guild_obj: discord.Guild):
static_count = 0
animated_count = 0
print(guild_obj.emojis) # Gets the entire tuple of custom emojis in the guild
print(len(guild_obj.emojis)) # 56
for each_emote in guild_obj.emojis:
# Problem : This for-loop is exhausted after only getting the first object in guild_obj.emojis
# Despite there being multiple emojis
print(each_emote)
if not each_emote.animated:
static_count += 1
else:
animated_count += 1
# Exits after printing first one
print(static_count, animated_count) # "1 0" since first emoji was non-animated
print(guild_obj.emoji_limit) # 50 (unboosted server)
emote_vacancy = {
"static": guild_obj.emoji_limit - static_count, # 49
"animated": guild_obj.emoji_limit - animated_count, # 50
}
return emote_vacancy
How do I properly access all the elements in what discord.Guild.emojis returns? for loop only seems to get the first element.
Do you have intents?
I thought emoji intents were default? Yes, because I can view all the emojis in the guild
Wait so if it prints all that, then whTs the problem (and yea, emoji is included in default intents)
the problem is the error, doctor
import discord
import os
from alive import keep_alive
client = discord.Client()
@client.event
async def on_ready():
print("Logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.startswith("!hello"):
await message.channel.send("Test")
keep_alive()
client.run(os.getenv('token'))
and?
Which error tho 
the error caused
:dogepray:
That's EXACTLY what I was thinking, I just ain't able to traverse that tuple for some reason
I get the first element and the for loops exits
does it print the on_ready print statement
Imagine not using commands.Bot for commands
Indent
U r returning inside the loop :DDD
oooooh
first of all use discord.ext.commands.Bot
fooking hell my eyes
@slate swan
Thanks for the help @maiden fable
π
its fine, I just spent 20 minutes rewriting three of my functions because it didnt return a list and only a string because of my indentation
?
Man, linters need to detect if we return inside loops
its an updated version
we monkes are stupid
of what
They do tho
discord.Client
They warn me always when I use return and not break inside a loop
oopsie
client = discord.ext.commands.Bot()
pylance didn't detect the problem in my case 
!d discord.ext.commands.Bot
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.
yeah
Try setting up flake8 or change the PyLance settings
do u know why it doesnt work tho
Cz it would send Test, instead of printing it lol
oh k
import discord
import os
from alive import keep_alive
client = discord.ext.commands.Bot()
@client.event
async def on_ready():
print("Logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("!hello"):
await message.channel.send("Test")
keep_alive()
client.run(os.getenv('token'))
i was told to use that lmao
if u look above i did use discord.Client()
blame @upbeat otter
ok works now thanks
import discord
import os
from discord.ext import commands
bot = commands.Bot(command_prefix="!", help_command=None)
@bot.command()
async def hello(ctx):
await ctx.send("Test")
bot.run(os.getenv("DISCORD_TOKEN"))
This might be slightly better ^
None's to blame, u didn't do it right with commands.Bot
Oh nvm
I have seen people use jishaku but I forgot what that is.. and how do I install it?
This is what Eevee also meant BTW @slate swan
jsk is just a Cog for running Python and shell commands from inside discord among other things
It's a module on pypi
hm?
thx!
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\simon\Desktop\Database Bot\cogs\economy.py", line 17, in on_ready
await self.client.pg_con.execute("ALTER TABLE economy ADD COLOMN IF NOT EXISTS userid BIGINT NOT NULL")
File "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\asyncpg\pool.py", line 564, in execute
return await con.execute(query, *args, timeout=timeout)
File "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\asyncpg\connection.py", line 318, in execute
return await self._protocol.query(query, timeout)
File "asyncpg\protocol\protocol.pyx", line 338, in query
asyncpg.exceptions.PostgresSyntaxError: syntax error at or near "EXISTS"
Ignoring exception in command None:
Who can help?
Giving code would be appreciated
how am I supposed to use jsk commands?
from main.py?
There are a few examples in the GitHub readme
<bot prefix>jsk <command> ?
Yea
that did not work, there was nothing in console either
What even are jsk cmds
from discord.ext import commands
from discord.utils import get
class Economy(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("test")
await self.client.pg_con.execute("CREATE TABLE IF NOT EXISTS economy (userid BIGINT NOT NULL , money BIGINT)")
await self.client.pg_con.execute("ALTER TABLE economy ADD COLOMN IF NOT EXISTS userid BIGINT NOT NULL")
await self.client.pg_con.execute("ALTER TABLE economy ADD COLOMN IF NOT EXISTS money BIGINT")
async def add(self, id, amount=30):
bal = await self.client.pg_con.fetchrow("SELECT money FROM economy WHERE userid = $1",id)
await self.client.pg_con.execute('UPDATE economy SET money = $1 WHERE userid = $2',amount+bal[0],id)
async def check(self, id):
user = await self.client.pg_con.fetchrow("SELECT * FROM economy WHERE userid = $1",id)
if not user:
await self.client.pg_con.execute("INSERT INTO economy (userid, money) VALUES ($1, $2)",id, 30)
async def balance(self, id):
bal = await self.client.pg_con.fetchrow("SELECT money FROM economy WHERE userid = $1",id)
return bal[0]
@tawdry perch try reading the readme
I will, gotta goo π
What have you done to postgre :(
@craggy cloak it's COLUMN not COLOMN
lol
Inglis
Facts
how to take away the ability to connect from everyone to the voice channel?
!d discord.Role.edit
await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits 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.
All fields are optional.
Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.
Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead.
!d discord.Permissions.connect
Returns True if a user can connect to a voice channel.
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
how do i add images to a file through a file dir? not using url
its just an eval
attachment://file-name.extension
Hmm i see
its just
<prefix>jsk py eval
!pypi disnake-jishaku
It's more than just an eval command, but that's the crux of it, yes
its a bot ext that mostly gets used for it
Yup most people only use its eval
Where's the eval ran in?
Yea yea
Wym
in the channel
Roughly it uses exec and eval
Will the eval be ran in my local machine or in some sand box
!d eval
eval(expression[, globals[, locals]])```
The arguments are a string and optional globals and locals. If provided, *globals* must be a dictionary. If provided, *locals* can be any mapping object.
!d exec
exec(object[, globals[, locals]])```
This function supports dynamic execution of Python code. *object* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). [1](https://docs.python.org/3/library/functions.html#id2) If it is a code object, it is simply executed. In all cases, the code thatβs executed is expected to be valid as file input (see the section [File input](https://docs.python.org/3/reference/toplevel_components.html#file-input) in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3/reference/simple_stmts.html#return) statements may not be used outside of function definitions even within the context of code passed to the [`exec()`](https://docs.python.org/3/library/functions.html#exec "exec") function. The return value is `None`.
read the docs its quite helpful
does it need to be in a local dir?
Idts
i found that i can set permissions for certain role, but what if i want to set this permissions for everyone?
if role not in member.roles:
try:
embed.set_image(url=f"attachment://D:/acrella-bot/verification/captcha/{captcha}.png")
value = await ctx.send(embed=embed, delete_after=30)
msg = await self.bot.wait_for('message', check=check, timeout = 30)
if msg.content == key:
await value.delete()
await member.send(embed=passbed)
await member.add_roles(role)
await ctx.message.delete()
except asyncio.TimeoutError:
pass``` Β―\_(γ)_/Β―
ok so the eval is ran in my local computer and is not sandboxed by default, right?
what is a good dpy alternative since you knwo, it got discontinued
disnake
disnake > pycord imo
ok that doesnt matter
how can i reload my cogs?
hm first time hearing of this
discum
anyways will make sure to chewck em out thank you
bot.reload_extension(extension_here)
what is the best module for making python guis
i want to make something with tabs, buttons, image displayer, input boxes
wdym sandboxed
nvm I just thought about things
if your gonna print something like with the eval it goes to your terminal btw
I was just thinking where it executes the eval in
local computer
jsk only responds to the bot owner tho
that is good to know, so server owner can't run those commands/admins?
i recommend you add your id in the owner kwarg in the bot constructor
only bot owners
good, then I can keep that extension in there
nice
my bad how i make a command that reloads my cogs
make a argument that takes the name of extension and then use the reload_extension
that is the coro for it?
youll have to make a command for it
guild.default_role
thank you very much!
hi i have a question why i get this error?
from discord.ext import commands
from discord.utils import get
class join(commands.Cog, name="join"):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_join(self, member):
channel = commands.get_channel(910565602362556426)
embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined the server.")
ember=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
await channel.send(embed=embed)
role = discord.utils.get(member.guild.roles, name = "γπ γUSER")
await member.add_roles(role)
print(f"{member} was given {role}")
def setup(bot: commands.Bot):
bot.add_cog(join(bot))
you get the channel with the bot
self.bot.get_channel(int)
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.moderation' raised an error: ImportError: cannot import name 'InteractionType' from 'discord_components'
Why failing to import InteractionType, or is it InteractionEventType?
is there a parameter for user banners?
is
discord.Member
is discord just a var of the class i.e
discord.Member = Member()
guys how to make the buttons can be pressed more than one time?
dont stop listening to the interaction lol
i cant ask here or what?
huh?
self.stop()
stops the class from listening to an interaction?
It can be pressed more than one time
but the view automatically times out after 3 minutes or so of no interactions
hi
Why if I change the value of **alarm **using the command it's not reflected on the on_ready event
@client.command()
async def alarmvalue(ctx, number):
alarm = number
while True:
try:
number = float(number)
if number % 1 == 0:
await ctx.send(int(number))
else:
await ctx.send(number)
except ValueError:
await ctx.send("Value is not an integer.")
return
@client.event
async def on_ready():
while True:
channel = client.get_channel(1232323
)
price = driver.find_element_by_css_selector(".last")
print(price.text)
print(alarm," alarm")
if float(price.text) <= float(alarm):
print(price.text,"-------------")
await channel.send(price.text)
#Send the message to discord
if float(price.text)<= 0.98*alarm:
print((price.text),"--------------")
#Sent the message to discord
time.sleep(1.5)
did you add no ephemeral msg?
if i clicked on button, it answered me and then im trying to click another, it writes me an interaction error
what does it mean
did you added a msg on a interaction
no i didnt
and its still doing what its supposed to right
i made only three buttons
L
ic
well idrk about that since i use disnake
@brave vessel hey fronto do you mind answering some of my questions?
do i have to write something to use the buttons more than once? did you write something when you did something like that on disnake?
well idk because in disnake you have to subclass ui.view
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
anyone can answer a few questions?
mostly about oop
i mean im here ;-;
alr
first
why do most of people use disnake? why is it better?
slash commands fast implementation buttons and much more
Only one pip package
cough cough panda
understood, thank you
yw
Idk what you mean by this.
or do you just not know
Member is just a class
yeah and why discord.?
unless call is defined Member() doesn't make sense
Since that is the root
is that really all
