#discord-bots
1 messages · Page 976 of 1
Neural networks are my bane
@sick birch Do we have to install discord Ui in terminal
and import it
for select menu
No, installing 2.0 will do
The timestamps?
Yea
Yes
<t:1649907236:F> like so?
Yep
Joined,value= user.joined_at
Registered,value= user.created_at
@sick birch I did this and it gives the time format in a messy way
Yes i also have did this
Right, that gives you the datetime.datetime object
You can get the UNIX timestamp by using datetime.datetime.timestamp() object
Or, in your case, user.joined_at.timestamp()
!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...
Ok let me try
Make sure to surround it properly with <t::F>
Ohk
Or you can use the util methods I linked earlier, it can help
but like if u ping a user it should show there thing too
Not a specific one
weird error in my terminal that won't allow my bot to boot, any ideas why this is happening and how to fix it? (included are the most important parts of the error message)
discord.utils.format(user.created_at, style='f')
``` for example
Are you on replit?
It got it like this
yeah
Right, like I mentioned you have to surround it with the proper tag: <t:TIMESTAMP_HERE:F>
Makes sense. replit tends to do that, one of the reasons replit sucks and you should consider not using it
the owner of the website banned u temporarily from accessing that website
That is to say, Discord
But that would send a specific timestamp right
It shd be like if you ping any member in the server the bot shd send their created and joined
and not a specific time we put in the code
Right, but we're getting the timestamp from a user object
So we're not hard-coding anything in
It'll get the timestamp of the user you mention
true, but at the same time it's the only way I know how to get cloud hosting for free, if there's any other way even if it's not free but still cheap please tell me, i wanna get off that dogshit platform tbh
bryan 😮
AWS has a free tier. t2.micro instances, 700 hours/month for a year iirc
?
And most reputable providers (google cloud, azure, etc) will all have some level of free-tier hosting
Ok so I shd just leave it as <t:TIMESTAMP_HERE:F>
Cuz if I put in a timestamp it would send that specific date
and not the user who i mention right?
Nono, you have to get the user's created at timestamp in there
Use the format_dt util I mentioned earlier
But there are so many users
I have to put it for each one of them?!
no idea how to use those, would it be similar to replit? the way i keep my bot running right now is by using uptimerobot to ping it every 5 minutes to stay awake
No, your command handler will give you the user object that was pinged
AWS EC2 instances are like seperate computers in the cloud. You can do anything on them. Anything you can do on your local computer, you can do on it
Ohhhh Ok I got what u are saying
So inside i shd just put a timestamp right?
Its Of Discord.py version 2.0 ?
ohhh got it, so like a cloud based virtual machine?
@bot.command()
async def my_command(ctx, member: discord.Member):
# member is the user that that someone mentioned
discord.utils.format_dt(member.created_at, style='F')
Right
You'd SSH into it
no idea what that means but ill go with it
SSH stands for secure shell. It lets you log in to a remote computer somewhere else in the world, and control it as if you were sitting in front of it with a keyboard and mouse plugged into that remote computer
yeah im definitely moving to that
Cool
Great. They also have other services if you decide you want to expand your bot. Personally, I have a web dashboard for my bot so I need a domain and multiple EC2 instances
is the free tier any good?
@sick birch 'discord.utils' has no attribute 'format_dt'
Ah. Make sure you're on 2.0
yeah alll id need to run is like VSCode
oh ok
Nah. You'd run vscode on your local computer
Only thing that'd be running on the VPS is Linux and your code
oh so i need an understanding of linux for this?
return f'<t:{int(dt.timestamp())}:{style}>'
Don't need but it'd be helpful to know your way around
Not much
Yeah that works too but I find it kind of messy
nah thats the src of utils.format_dt
Well, most of the times, it will be as easy as:
-> Installing Python
-> Installing deps
-> Running python main.py
That's the point, to hide the messiness behind a nice function
(The first step cz iirc Linux still uses 3.7 or smth)
So why not use the nice function right?
I'm always bleeding edge. I'm on arch with rolling release so maybe that
hmm, makes sense
Wait, so why does Linux not update its Python to 3.9 or smth?
:D
i'll just end up watching a YouTube tutorial probably
It has more to do with how the distributions handle their package managers and versioning
i have 3.10.2 installed on my distro by default
ubuntu uses 2.7 & 3.8 , kali is on 3.9
Oh hm
can't u upgrade from 3.10.0 to 3.10.4 without having to install the whole thing again, is there like a command for that?
Eh, I am not using Linux anyways
Seems complicated to me
Sure. Many package managers let you do that
😔 there's nothing complicated with linux
atleast its not that hard how people represent it in memes
In my case I'd just run $ sudo pacman -Syu to do a full system upgrade including python
what about the default?
I know (I have used it some times), but I am not just used to using the command line that much
The default python is different for each distro
0.o
oh hm makes sense
I live off the command line haha
Eh, also my laptop doesn't support Dual Booting soooo
That's unfortunate
Yea, smth like Secure Boot is getting in the way haha
Tho I might install Linux on my old potato since the specs are, uhhhh, no comments
you can turn it off~
Nah, don't wanna mess around with this laptop
would i be able to import my code from replit to it or would i have to rewrite the entire thing
I had to go out and get myself more storage for dualbooting. Now I'm at 4.5TB but it still doesn't feel like enough
Just copy paste everything
meanwhile windows asking to turn off secure boot just to run valorant on win11
oh sick i didn't think i would be able to do that
Me at 500 GB SSD in my new laptop and 300 GB HDD in my older one: 😐
No? I was able to play Valo without turning it off
you can't even disable secure boot because of TMP lmfao
not everyone has to do it
Well, the world of coding is an awesome one and you can do that!
but thats a known issue
Ah yea I heard bout it
Has anyone here created a discord sales bot?
Hm?
aight sick, definitely gonna do that tomorrow cus it's late af for me
Using, actual money?
Wym sales bot lol
What do u wanna sell
sales bot
Yup. Same here. Good night
He do be converting discord to an eCommerce website/app
what even is happening on discord anymore
you can actually downlaod all your replit code
instead of copy pasting it
If you want to use actual transactions, best way would be to have users pay money on your web dashboard frontend using something like Stripe API, and add some amount of "Credits" in the backend database. From discord, they can buy/sell things using those "Credits"
Since money transactions are not a thing on discord yet unfortunately
In theory it shouldn't be all that difficult
Might as well code him the Dashboard since I suck at web deving :D
I like web dev
Ik (:
Anyway. I'm off to bed. Good night to you all!
https://deadrare.io/collection/EAPES-8f3c1f?tab=activity
Check out this website of 'recent activity'. I am trying to build some type of python program to document the amount of sales per day to help out someone who has been doing it manually, I am really just unsure of how to scrape that data, maybe sales bot was a bad use of words, lol
gn
Ah, so u wanna build a website scraper?
Yes
Well, is this your website? Since I know an easy way to get the data
It is not. It is a buy/sell website for NFTs, that link is just the recent activity of a specific collection
Oh
Hm, I don't think the website would like u scraping it but
!pypi beautifulsoup4
You should use this
Also, be vary that there is a possibility u r breaking the ToS and your IP can get blocked by the website
Also, run that in an executor since the process is blocking
!d asyncio.loop.run_in_executor
awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.
The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor") instance. The default executor is used if *executor* is `None`.
Example:
It does not like me scraping it, lol. I get weird errors, but when i use repl i am able to print all html data but not specific information like the value of sales
If the errors are related to scraping, then please open a help channel. Refer to #❓|how-to-get-help
thank you friend
python main.py
Oo
can someone pls help me with why my discord bot isnt working
How
can you?
what,
not at the top top, the embed.Title
it's the description of the embed if you mean the timestamp
I wanna do like if the guilds id is in a variable (in the same file) so the bot should leave the guild automatically
make the variable as a list and check py if guild_id in variable: #leave
@buoyant zodiac <t:UNIX_TIMESTAMP>
example please
<t:999999> <t:999999>
the timestamp has a white background
soo is ctx.guild.created_at , would that work?
no
you'd wanna do guild.created_at.timestamp() to get the timestamp of when the guild was created
okay thank you
@buoyant zodiac don't u think u should change yr nick? 😐
Tell me how to fix it
I make a pokemon bot
@lyric needle
Please sir help me
You are a helper
don't ping random users to help :/
dont get mad over little things :/
hmm?
Huh
he pinged a "helper"
if you have a certain problem,
and it quite literally says "ask (person) for help"
who do you ask?
I don't have a "problem" I just mentioned that I don't think they should be pinging random users for help.
embed.add_field(name="__Generals:__" , value=f"**Role Name**: {role.name}\n**Role ID**: {role.id}\n**Hex value**: {role.color}\n**Hoisted**: {role.hoist}\n**Managed**: {role.managed}\n**Integration**: {role.is_integration()}\n**Mentionable**: {role.mentionable}\n**Created**: <t:{role.created_at.timestamp()}>", inline=True)```
the time stamp isnt working
The timestamp formatting requires an integer, cast it to int.
how do i do it
Do not ask to ask.
Might as well say to a doctor "Why is my arm hurting?".
..
Is there any way that my bot can read the message and get a response from the user? Example
Bot: Say something
Me: Hello123
Bot: You said "Hello123"```
yes
I know, there is a way, but I just don't know how.
No, that's not what I want.
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**...
yes that
Say I do this.
Me: .hello
Bot: Hello, say something.
Me: Sdksds
Bot You said "Sdksds"```
it's simple, ```py
message = await bot.wait_for('message', timeout=15)
await channel.send(f'You said {message.content}')
Like
await ctx.send(f"y or n")
# This will make sure that the response will only be registered if the following
# conditions are met:
def check(msg):
return msg.author == ctx.author and msg.channel == ctx.channel and \
msg.content.lower() in ["y", "n"]
msg = await client.wait_for("message", check=check)
if msg.content.lower() == "y":
await ctx.send("You said yes!")
else:
await ctx.send("You said no!")```
Found this on SOF
that would work yes
allows for multi-line shit iirc
nvm i got it
@slate swan
indeed it is
how do I get colored text?

Read pins, theres a message on how to
uhhhh
am I the only who uses less lines as much as possible .-.
How can I send a message when it times out?
Try to write italian sentence in strings 
You're just efficient, nothing wrong with that.
well
try:
msg = await bot.wait_for(...)
except Exception as err: # timeout/a bug occured
await channel.send(err)
else: # worked
...
I only know french, spanish and english 😔
Better use error events 
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Plus it is better to use discord.py exception for... discord exception lol
you need to copy paste those unicodes from the website
Ahhh, how can I send a message to the channel with "on_raw_reaction_add"?
What character goes where
Oh nvm.
Lambda check looks better imo
\u001b[0;40m\u001b[1;32mThat's some cool formatted text right?
\u001b[1;40;32mThat's some cool formatted text right?
copy paste the unicodes from their website
Is it that
cant see but replace that unicode with the \u001b, i mean the vice versa
what do you mean
[0;40m[1;32mThat's some cool formatted text right?
[1;40;32mThat's some cool formatted text right?
[1;32mhello world
[38;2;17;170;35mLMFAO[0m[48;2;120;35;156m[0m, [38;5;167;48;5;232mThis Is kinda[0m[31m cool[0m
howd u do that
just copy paste this instead of \u001b
so I replace the \u001b for that character?
[1;30mHello
wrong
you have to be on pc if you wanna use that
[1;41mHi!
error?
hmm, yea
how do i save my bot from being rate limited?
like how many requests can i send to discord api in a minute?
to not get rate limited

Discord’s API has a global rate limit which by default is 50 requests/second (This number can be raised if your bot is big enough). It also has a dynamic endpoint-specific ratelimit which mostly isn't documented.
hm so i wanna animte my server name with my bot changing the name like idk 1 time in a second will there be some problem?
yes, I doubt that you can change a guild's name 1 time per second.
but i know a server its already doing that
come to dm ill show
if u want
You can share it here
even if you could, its such a bad bad idea
the server link?
no
ik a server its already doing it
well
can i show in dms?
no thanks, you could run a task loop and change the server's icon every 1 second
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
oh will there be any problem?
cant i use a normal loop?
Ratelimits
Nope
Yes
^^
i guess, never tried though
no never ever
i can use wait function yk
dude
?
sure
does someone have the color codes of discord.py?
Every color code works
where can I get them 😭
that is the issue
nvm got em
Lol
default = 0
teal = 0x1abc9c
dark_teal = 0x11806a
green = 0x2ecc71
dark_green = 0x1f8b4c
blue = 0x3498db
dark_blue = 0x206694
purple = 0x9b59b6
dark_purple = 0x71368a
magenta = 0xe91e63
dark_magenta = 0xad1457
gold = 0xf1c40f
dark_gold = 0xc27c0e
orange = 0xe67e22
dark_orange = 0xa84300
red = 0xe74c3c
dark_red = 0x992d22
lighter_grey = 0x95a5a6
dark_grey = 0x607d8b
light_grey = 0x979c9f
darker_grey = 0x546e7a
blurple = 0x7289da
greyple = 0x99aab5```
Just search up HTML Color Code selector
i have them no worries
Cool
Green prolly
Yea
alright
um
Divide the bytes by 1 million?
Function?
def converter(amount):
return amount / 2 ^^ 20
Basic math?
yeah lol
uh don't do this, you'll get banned for api abuse eventually
pls clean your desktop
agreed
epic youth hahahah
What does this mean
channel is an integer
you do
await channel_id.send(something)
instead of
channel = bot.get_channel(channel_id)
await channel.send(something)
!d discord.Guild.get_channel to get the channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
Changed in version 2.0: `channel_id` parameter is now positional-only.
lmfao
color picker
why type too much when you can have less
use the len function and decrease 1 from it since there is an everyone role too
roles = [role for role in guild.roles if role != ctx.guild.default_role]
this i used for everyone
yeah use the len func
i maked another command for it and mentioned it there
btw ty
how do i make my bot find the ID of the last message it sent in any channel?
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
thanks
!d discord.TextChannel.last_message_id
The last message ID of the message sent to this channel. It may not point to an existing or valid message.
are there API's twitter,, Instagram, YouTube , Twitch and Trovo?
!pypi twitchAPI
Hey there, I had a issue regarding discord.py. How can I receive a discord.exe command (@client.commands) from a webhook? For example, i make a web hook send a message to a channel, which contains a command, how do i make my discord.py bot read that command and execute it. Alternatively, is there a better way to send messages to a discord.py bot, through a web javascript application.
Thanks
Command?
Like a webhook triggering a command?
yes
Or like the webhook contains the code
No, say the webhook says !help
I want my bot to read that command
like it would read from a normal user
Can a webhook even trigger a command?
not by default, so i asked here
Isn't there a much easier way to have your two services connect?
i am not sure, do you know of any?
What are these two services? An API backend and your Discord bot?
its legit just this
where that url is the web hook url
so this is the simple bit
Where is this running? In the browser?
yes its a website
and when i run the function, i get a message on the webhook channel
That's an extreme security vulnerability ⚠️
so al that works just as it should, just my discord.py bot doesnt read it
yes im aware this is just a test space, im gonna secure it later
rn this is not even connected to a proper thing, when i do that, im going to store sensitive info as env
You can't secure it "later" because fundementally sending a webhook like this is insecure
anyone?
ye ik, but this website is for personal use
You're giving anyone on the internet, access to this webhook which they can do anything with
its not getting published anywhere public
so no one except me and people i add can use it
How? Are you just not gonna give anyone the address?
Nope, its a long story 🥲
for now any help on the discord.py bit?
Twitter, Twitch and YouTube all have APIs. I don't know whether Instagram fors and I have no idea what Trovo is.
I think you'll need to change this:
https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/bot.py#L1336-L1370
temp = x
x = y
y = temp
x, y = y, x
uh true ye
!e
a = 1
b = 2
a, b = b, a
print(a, b)
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
2 1
See
Ty
U didn't print
ye mb
async def send_bot_help(self, mapping):
filtered = await self.filter_commands(bot.commands, sort=True)
e = disnake.Embed(description=filtered)
await self.context.send(embed=e)
!e
x = 1
y = 2
temp = x
x = y
y = temp
print(x)
print(y)
@junior verge :white_check_mark: Your eval job has completed with return code 0.
001 | 2
002 | 1
works too
self.context.bot?
Yea
gives
same output
I have this now but same thingfiltered = await self.filter_commands(self.context.bot.commands, sort=True)
iterate through filtered ig
oh wait
commands.HelpCommand
!d discord.ext.commands.HelpCommand.filter_commands
await filter_commands(commands, /, *, sort=False, key=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns a filtered list of commands and optionally sorts them.
This takes into account the [`verify_checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HelpCommand.verify_checks "discord.ext.commands.HelpCommand.verify_checks") and [`show_hidden`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HelpCommand.show_hidden "discord.ext.commands.HelpCommand.show_hidden") attributes.
Changed in version 2.0: `commands` parameter is now positional-only.
i'm confused how does it sort commands
How i can fix this error? I am making a pokemon bot on replit```
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Show full error
kotlin huh?
Kotlin?
@slate swan
replit 
Why
And why do you keep pinging people
to make pokemon bots
Sry
poketwo broke ig
:/
I am using 3.8
What discord.py version are you using, not your python version
how to get a message link?
no a particular message
the link should be of the message the user sent to use the command
Hey there, I was wondering how I could have embed displays the different information in rows instead of having a weird layout. I'm using embed.add_field to add a new field to an embed but it doesn't add a new row for some reason
here is an example
it uses columns and when I have more field it makes something really bad looking
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
yeah
I just found that I thought the default value was set to False
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining. Can only be up to 25 fields.
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing `None` removes the thumbnail.
Replit
I am using replit
To make bots
@surreal ruin can you do pip show discord.py in the shell?
Not your weird ide choice
Its coming like this
pip install discord.py
Ok
Or since you are using repl.it just add in code import discord.py and it should install it automatically
Version 1.7.3
install d.py master to use poketwo
@surreal ruin does it work now?
How to get it?
Enter pip install -U git+https://github.com/Rapptz/discord.py in the shell
Ok
make sure u have git installed
wow!
oo
nice, now try running your repl again and see if it works
download the zip file, unzip it and move the discord.py source code to your project directory, rename the discord.py folder to dpy and use that folder's source code by importing stuff into your project files
🗿
why even bother with zip files, just copy paste each file
lol
just type it out 🤷♂️
I have a question about help commands. I'm trying to change the default command but I getting an error saying that Help doesn't inherit commands.HelpCommand, even though it does.
# Help class (in cog)
class Help(commands.HelpCommand):
#...
async def send_bot_help(self, ctx):
#...
# Bot init
bot: commands.Bot = discord.ext.commands.Bot(
#...
help_command = cogs.Help.Help,
)
``` Anyone know why this doesn't work? Thanks
show the error
maybe your using the commands extension of another library
show the cog's imports
Also says that commands is for the wrapper
from client_container import * is the only import
and in client container is just this
you didn't call the class
What should i do now
show full error?
They're all used in other files, so in other files I can just use from client_container import *
Nothing actually happens there
maybe, dont do that...
Oh. Thank you! lol
Why not?
Its full above is before that
it just puts so many unnecessary objects in the namespace
and it makes it hard to understand
Is ur file named maim.py
Wait
"call the class", nice
yeah that's true :) classes have a __call__ method
yes?
Actually that's meant for class instances
So that there's functionality for smth like MyTotallyNotCoolClass()()
@winged bone :white_check_mark: Your eval job has completed with return code 0.
001 | <method-wrapper '__call__' of type object at 0x55d4a48082a0>
002 | <__main__.MyClass object at 0x7f96cffc14e0>
Wtf

Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
^
```py
```kotlin
how
```py
cope
```
cope
\
^
hm??
Oh I was doing
\`\`\`py
\`\`\`
..
show ss
```kotlin ```
Nice.
finally
Finaaly
aa
What are you doing?
Wtf is even kotlin
Looks sussy
Is it javascript only?
idk
@pliant gulch ```py
for module in pkgutil.walk_packages(ext.path, f"{ext.name}.", onerror=on_error):
if unqualify(module.name).startswith("_"):
# Ignore module/package names starting with an underscore.
continue
if module.ispkg:
imported = importlib.import_module(module.name)
for name, obj in inspect.getmembers(imported):
if inspect.isclass(obj) and issubclass(obj, Group):
yield obj
Why'd you censor the google account avatar
a programming language
Why
why what
kotlin > java
`oo``
kotlin >= java
:0
this channel is everything but discord-bots related
I made a exts loader for Client :3
it happens sometimes
hi this not working :<
kotlin >= java
import bot
from bot import magic
bot.run(magic)
@boreal ravine this error is coming
funny................?
..
yes
Magic is the token? lol
no clue
?
ye xD
Can you join my repl to fix it if you want
no thanks
ill help u
Please don't raid on it
ok
Come in dm
Hey im new to this and im getting an error to which idk the fix
Its a very long error lol
which error
Hi there, I made a bot to create information cards. So I have a command that asks the user for several information, the thing is that I'd like to display of the user took too much time. I found a method using try and except asyncio.TimeoutError, that works well on one input but I feel like repeating the same thing for 6 inputs might be really bad, so would there be any better way?
give the last 10 lines
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 563, in connect
self.ws = await asyncio.wait_for(coro, timeout=60.0)
File "/usr/lib/python3.8/asyncio/tasks.py", line 494, in wait_for
return fut.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/gateway.py", line 305, in from_client
gateway = gateway or await client.http.get_gateway()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 969, in get_gateway
raise GatewayNotFound() from exc
discord.errors.GatewayNotFound: The gateway to connect to discord was not found.
the bot works for sometime and then goes off showing this error and works again
..
I think he's blocking the connection with Discord, maybe an antivirus.
its hosted by replit
..
Ah that makes more sense.
show code btw
anyone?
what do you recommend to use ?
vsc
bot code or flask ?
i meant to host
there are only paid one
can you recommend a good one ?
don't expect to find a reliable free hosting services
sry idk
Hmm pretty difficult since you can't save them mid way.
oh
see this
netcup is like 5.55 bucks a month and offer pretty good services.
can you recommend any paid ones ?
is there any with lifetime membership ?
not really, i'm still developping my bot and for now I only run it on my pc
No those don't really exists with a VPS.
oh ok
yeah that's why
rip .
well thanks guys for the info
try heroku
Since I wrote this chunck whenever I have a cooldown going on I was wondering If i could do the same with that
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
retry = error.retry_after
remaining_time = str(datetime.timedelta(seconds=int(retry)))
embed = discord.Embed(title=":clock1: Slow Down!!", description=f'{ctx.author.mention}, you can use this command again in ' + str(remaining_time), color=0xE74C3C)
await ctx.send(embed=embed)```
"try"
don't try it
wdym
lol
is the general advice
there are no free hosts then 🤷♂️
Same error
try smthing like aws
ur shell is just loading
well, aws exists, you could have 12 months of service
aws, gcp or azure
Updating dependencies
Resolving dependencies..
each 12 months
pings
what
srsly?
Well free until they change it
yeah
ill try it now
wut abt it?
u just hv to setup a vm and run ur program
Only certain instances. Check what qualified for free tier. Also only 1GB egress traffic
it has 800mbps speeds
@slate swan it coming ^C
^C
for free tier
uh i was trying to copy
Oracle is good also. U get free 4 core arm vps with 24gb ram
:/
oh
SolverProblemError
Because discord.py (rev master) depends on discord.py (rev master) which doesn't match any versions, discord.py is forbidden.
So, because poketwo depends on discord.py (branch master), version solving failed.
at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
exit status 1
Replit: Updating package configuration
--> python3 -m poetry lock
Updating dependencies
Resolving dependencies...
SolverProblemError
Because discord.py (rev master) depends on discord.py (rev master) which doesn't match any versions, discord.py is forbidden.
So, because poketwo depends on discord.py (branch master), version solving failed.
at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
exit status 1
``` anyone?
But they sometimes have technical problems and take ur vps down until u login and out it back up. They also give 2 free amd cpu vps but those are shit
try uninstalling packages directory and reinstalling all packages
Well, whenever a user has to input something with bot.wait_for there is a timeout. I'd like to show the user that the timeout is, well, out. And maybe I could make a global function just like that cog listener for that
*directory
you could do
if isinstance(error, asyncio.TimeoutError): ...```
achso!
line 51, in on_user_update color=self.log_channel.guild.get_member(after.id).colour, AttributeError: 'NoneType' object has no attribute 'colour'
Why i keep getting this error=
I could even put it in the same listener
It's none
Your member object is none
Do you have intents turned on?
@Cog.listener()
async def on_user_update(self, before, after):
if before.name != after.name:
embed = Embed(title="Navne Skifte",
colour=after.colour,
timestamp=datetime.utcnow())
fields = [("Før:", before.name, False),
("Efter:", after.name, False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
await self.log_channel.send(embed=embed)
if before.discriminator != after.discriminator:
embed = Embed(title="Discriminator Skifte",
colour=after.colour,
timestamp=datetime.utcnow())
fields = [("Før:", before.discriminator, False),
("Efter:", after.discriminator, False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
await self.log_channel.send(embed=embed)
if before.avatar_url != after.avatar_url:
embed = Embed(title="Profilbillede Skifte",
description="Nyt billede er nedenunder, og gamle er til højre.",
color=self.log_channel.guild.get_member(after.id).colour,
timestamp=datetime.utcnow())
embed.set_thumbnail(url=before.avatar_url)
embed.set_image(url=after.avatar_url)
await self.log_channel.send(embed=embed)```
yup
but should i have the intents in cogs also=
No
or only in the main file?
If you have intents already enabled in your bot constructor it should be fine
GOOGLE CLOUD NEED CREDIT CARD!!
Yeah?
bro
What
@supple thorn
should i have more?
No

but its still sending error
what error?
color=self.log_channel.guild.get_member(after.id).colour,
AttributeError: 'NoneType' object has no attribute 'colour'
can u print self.log_chanel.guild
why
i wanna what that is
It's a guild

You do have member intents enabled in the developer portal right
yes, i just tried to turn off and on
welp it doesn't do anything, I just added a ctx.send but nothing happens
Wdym?
Can you send the code you tried
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
retry = error.retry_after
remaining_time = str(datetime.timedelta(seconds=int(retry)))
embed = discord.Embed(title=":clock1: Slow Down!!", description=f'{ctx.author.mention}, you can use this command again in ' + str(remaining_time), color=0xE74C3C)
await ctx.send(embed=embed)
elif isinstance(error, asyncio.TimeoutError):
await ctx.send('You took too long, process canceled.')
Uh
I needed the doc lol
the first one is for cooldown and works perfectly, the second one tho doesn't do anything
!d rich
So you tried out the error handler by waiting out the timeout?
yes
When you trigger the timeout error
Does it throw the error in the console?
nope
I gotta sleep but can you try and use a elif
Yo, so i managed to find the free subscriptions page but which one should i get? id assume a Lambda server because it's for compute but i just wanna be sure
maybe it's not an error
not a on_command_error
but something else ?
anyone fresh here, that's my issue
that's my code
You could make a dict in format of {question: value} and iter through it with waiting for message inside the loop
hbday
mmh
Thx
Lol
ho ! and then use a try and except asyncio.TimeoutError ?
because this is what I do rn:
await ctx.send('Enter the name of the character: ')
name = await self.bot.wait_for('message', check=check, timeout=30)
await ctx.send('Enter the age of the character: ')
age = await self.bot.wait_for('message', check=check, timeout=30)
await ctx.send('Enter the gender of the character: ')
gender = await self.bot.wait_for('message', check=check, timeout=30)
await ctx.send('Enter the picture url of the character: ')
picture = await self.bot.wait_for('message', check=check, timeout=60)
await ctx.send("Enter the hex code of the character (without the `#`): ")
Hex = await self.bot.wait_for('message', check=check, timeout=60)
await ctx.send('Enter the description of the character: ')
desc = await self.bot.wait_for('message', check=check, timeout=60)
await ctx.send('Enter the universe the character belongs to: ')
universe = await self.bot.wait_for('message', check=check, timeout=30)
f[f'{name.content}'] ={'age': age.content,
'gender': gender.content,
'picture': picture.content,
'hex': f'0x{Hex.content}',
'description': desc.content,
'universe': universe.content```
and f = fetch(f'database\{id}\{id_user}') already
so I would first define the final dictionnary and then json.dump into the file I want?
@lofty pecan what I mean is something like this
questions = {"What is your name?": None, "What is your age?": None}
for q in questions:
await ctx.send(q)
m = await bot.wait_for(...)
questions[q] = m.content```
You could surround the for loop with try-except
Such kind of database will lead to you getting extremely confused when you want to modify data model
does the ctx.send send the key or the value?
When you iterate through dict you get its keys
for now it's useful lol
I'd recommend to learn some sqlite
How many files do you have in your "database" so far?
sqlite bothers me a lot, I already didn't like it at university
5 files, that's 5 users
its the way they teach, not sqlite itself
What the hell
Sqlite can't be that complicated
no?
Unless they teach you something like more than select/insert/update
they did
lol
Indexes and rules for example
Postgres functions are kinda fun tho
I tried to use sqlite at first but I got annoyed so I use json and dictionnaries instead
can relate
Trust me, you will get annoyed with updating data structure when you update your data model
Hehe
funny number
yeah idk
for the moment it does all I need lol
and if I change everything to sqlite I have to completely rewrite my bot
and learn sqlite
which is demoralizing
ok
You would only have to learn like 5 statements
Agreed about rewriting but it's better to do this before your project becomes bigger
ye
Because I have been in the same situation
40 fps
thats why you use helper functions 🏃♂️
It's also weird how people explain how to use sqlite with discord py

you can just change those functions whenever you need to, and it wont affect your commands
I did some of that
With the power of OOP I created a bunch of datamodels and stored all the objects with the pickle files 💀
not for everything tho because my bot doesn't have 100 commands and is focused on one thing only
It turned into pure hell when the bot hit 100 servers
you could use postgreSQL
Next I rewrote it to sqlite without async wrapper
And then to asyncpg and now I am fine with that way
one command is the fetch one, just to load a json, I use it everywhere so I simply made it a global function
60 fps nvmd ot

i started with pickle, moved to json because .bin files not readable, and finally shifted to sqlite3
ik mysql and pgsql but dont want to create a db server for a dumb bot project
very demoralizing lmao
I am currently working on antispam bot based on AI and am using postgres it's fast af
oh and, happy birthday Exenifix 🥳
now you know how to use it yeah
Ty
The AI model I created works on any text
It's non verbal tho but I am gonna try verbal method as well later
I got like ~2k training samples so it's decently accurate now
10k would be perfect
It's a personnal project that sounds very useful to a lot of people I asked about, I learnt how to code a discord bot, how to use json, dictionnary, embed, etc; but SQL ? my nightmare lol
Create an API with django and use django's orm db
Plus we used to have SQL class, but just SQL not related to python
And yeah that bot's gonna be open source so yall can contribute
SQL isnt related to python anyways so uhhhhh
why not?
cool
@slate swan
@paper sluice

🎉

wait that counts deleted msgs too?
i think it does
oh wait
#bot-commands
async def Embed(message):
if message.content.startswith('c.commandlist'):
embedVar = discord.Embed(title='Help', description = 'commands', color=1)
embedVar.add_field(name='c.intro', value='introduces you to the settler', inline=False)
embedVar.add_field(name='c.start', value='Builds your first settlement', inline=False)
embedVar.add_field(name='c.gather', value='gathers resources', inline=False)
await message.channel.send(embed=embedVar)
@settler.event
async def on_message(message):
if message.content.startswith('c.start'):
embedhelp = discord.Embed(title='Settlement created!', description = 'You can now do c.gather to gather resources ', color=1)
embedhelp.add_field(name='c.intro', value='introduces you to the settler', inline=False)
await message.channel.send(embed=embedhelp)
this is for 2 commands
but they dont work no matter what i type
What's the issue/error?
hi
It also does not show any error message
so the code doesnt work but no error message
anyone know what going on?
Nah, lambda isn't the best. Get the EC2, those have a free tier and they're general purpose
Lambda is for serveless functions
what
oh sick
I just re-read what I said. that was stupid. Let me clarify, lambda isn't the best for discord bots
Other than that, it's excellent
EC2 doesn't have a free tier
So my bots been in a large server for years handing out a role. And it suddenly stopped giving the role yesterday. Anyone have an idea?
t2.micro do
Any errors?
oh got it thx
anyone can help me, the commands just wont work but no error message is showing up
so this
That's the database
Why not just get a VPS and setup the database there
You could
That's what I'm doing but AWS RDBMS is more scalable and has more features
trying to move my code from one cloud host to another for more reliability
I wouldn't call replit a cloud host
Most do, which is terrible
i still can't find the correct t2.micro server, does it have a specific name or type?
EC2 -> launch instance -> select AMI -> ubuntu -> t2.micro
im on the AWS website lmfao
It shows up when you click on "Launch instance" orange button on the top right
i don't even have the plan set up yet, im just trying to find the correct one
Could you screenshot where you are at right now
why i cant use User Profile Picture urls with <img> tag on html?
I havent got around to checking yet. I just have an exception that sends "couldnt add role". Its odd it just stopped out of nowhere
i wonder if its possible that my bots integrated role is borked up in that server cuz my delete reactions stopped working awhile ago
I think it means 'fucked up'
correct
why are you using event for commands
could be
thats obvious
it's prolly because some js people who recently switched to py are uploading "tutorials" using events, cuz i've seen some
xD
YT tutorials about fast-changing libs are just a bad idea in general
I mean yes, but its in development again
and? it never broke
👋
yes, while js was getting updates every week or so, python dev slept
is that a slap?
I know
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Hello
..
Well it should havepermission to delete reactions but that stopped working too awhile ago
Only in that server
Is there a way to print what permissions my bot has in that guild
!e
print('''
_____ _____ _____ _ ____ __
/ || __ \ /\ | __ \ | |/ /\ \ / /
| ( | |) |/ \ | |) || ' / \ _/ /
__ \ | // /\ \ | _ / | < \ /
____) || | / ____ \ | | \ \ | . \ | |
|__/ || // _|| _||_\ |_|
''')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | _____ _____ _____ _ ____ __
003 | / ____|| __ \ /\ | __ \ | |/ /\ \ / /
004 | | (___ | |__) |/ \ | |__) || ' / \ \_/ /
005 | \___ \ | ___// /\ \ | _ / | < \ /
006 | ____) || | / ____ \ | | \ \ | . \ | |
007 | |_____/ |_| /_/ \_\|_| \_\|_|\_\ |_|
?
Oh oops looks like my message came in late
..
Ah, is that a big issue or?
well it doesn't tell me what the cost is afternoon so kinda yeah
The cost after depends heavily on what instance you're and what you're doing on it
It's not a flat fee like for other hosts
They charge you per second and computing resources used iirc
Oracle VM exists 👀
Yeah I've heard that's another good one. They have a free tier as well
I'm pretty sure so does google cloud hosting
In exchange for yr cc info
that's much better than the ones AWS gives lmao
IKR
they need cc?
iirc AWS gives like 1 or 2 GB RAM
i really doubt a free tier would give 24 gigs of RAM
Yea, else I would have got it
yeah but they also have ones like 400gigs of ram with 60 something cores
:<
cc with money or without??
They charge 1 USD for verifying if the CC is original
Tho they refund it
oh
jesus christ.
Hahaha
that's more than my pc has >(
free forever?
same haha
Same, that is 3x my laptop's RAM
thats 12x then my pc
Yea
hello Im testing cogs but it doesnt work
wow
code?
im gonna register for that the value is nuts
Haha ofc it is
What's the "2 AMD based compute VMS with 1 gb memory each"?
Do you get to pick what type of CPU you want?
No

