#discord-bots
1 messages · Page 32 of 1
can you send the past of command
past of command?
Unox timestamp doesn't work like that. 1 is 1st of january 1970, and every second it goes up by one. So if you do retry_after *1000, let's say it is 100, it'll be around 1970
sure one sec
@revive.error
async def revive_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f"Chat revive is on cool-down. You may use this command again <t:{round(error.retry_after*1000)}:R>.")
For example, current time timestamp is 1660339732 @mental hollow
I’m confused, so how do I make my cool-down into a timestamp?
O think you can use datetime lib for that
await ctx.send('Chat revive is on cool-down. You may use this command again in `{e:.1f}`'.format(e = error.retry_after))```
try adding that instead of that line
Use the timedelta
Add it to the current time
Voila
Or if you want, do it the manual way, get the current timestamp, add the number of seconds to it
each cog make a help section or something
how can i make that
Using get_bot_mapping
is there any examples, because I don’t work with timestamps much?
It's of type Mapping[Optional[commands.Cog], List[commands.Command]]
i think i will make a help command that has 50+ ifs
because that looks way more complicated
!e
from datetime import datetime, timedelta
now = datetime.now()
delta = timedelta(seconds=20)
time = now + delta
print(time.strftime("%X"))
@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.
21:34:20
The timedelta is the important bit
for cog_name, cog_object in self.bot.cogs.items():
cog_commands = [command for command in cog_object.walk_commands()]
And you have a list of the commands for each cog each loop @gusty shard
isn’t it supposed to return milliseconds, for the timestamp?
did you try that @mental hollow
sorry nir
All good
didnt mean to ping you
I’ll try it now
i will make some researchs
thank you
Np
says e is not defined
probably i wrote something wrong
@revive.error
async def revive_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.reply('Chat revive is on cool-down. You may use this command again in `{e:.1f}`.'.format(e = error.retry_after))```
i copyed it from my own bot
hope it works @mental hollow
Just remove the e =
Are you sure there are no errors?
could the not giving error correspond to a problem?
walrus operator
!e print(x := "hello, world")
@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.
hello, world
how can i get all members using a guild id?
bot.get_guild(...).members
!e print(x = "hello, world")
@pale turtle :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: 'x' is an invalid keyword argument for print()
I'm just saying it's possible to have an assignment as an expression
AttributeError: 'NoneType' object has no attribute 'members'
Is the guild ID valid and an integer?
For example, if I wanted to get all the members of this server, I'd do:
bot.get_guild(267624335836053506).members
yea
wait oh my god, i'm so dumb my apologies
i forgot to int the guild id from my config file
sorryyy
how aws t2/t3 work i mean price
if i use 90% cpu will it cost inc ?
hmmm pls help me to understand the price system , like it hv $0.0209 /hr if i use it at 90% will it cost me same ?
Not sure. AWS charges very dynamically, there's no static cost. You can try the AWS calculator to get a rough estimate of your charges
No worries
AWS ec2 does not charge based on computation usage
It charges based on when an instance starts, and when an instance stops
Then again I could be wrong cause it has been a while but that's exactly how I remember it
Oh EC2? That's much easier to figure out, still a few variables but nowhere as much as some of their other services
EC2 instance applications will usually have an irregular burst schedule as well
Are they separate?
I thought T2 was one of the options for EC2
t3.small 2
2.0 20% 24
5 Up to 2,085 $0.0209 $0.012 $0.008
whats 20% here ?
Baseline Performance/vCPU ????????????/
whats it ?
🤔 I think so, with their naming it's hard for me to figure out which one is which and what service they go to
Not sure if they were talking about elastic beanstalk or lightsail or something or the other
T2 & T3 are both EC2 instances
"T2 instances are a low-cost, general purpose instance type that provides a baseline level of CPU performance with the ability to burst above the baseline when needed. With On-Demand Instance prices starting at $0.0058 per hour, T2 instances are one of the lowest-cost Amazon EC2 instance options and are ideal for a variety of general-purpose applications like micro-services, low-latency interactive applications, small and medium databases, virtual desktops, development, build and stage environments, code repositories, and product prototypes." from AWS site
But then again AWS has alot, alot of services which makes it very convoluted
awww, ty <33
Alphabet soup, as it were
Anyway.. you mentioned you had many users?
i don't think a t3.small would cut it with the number that you mentioned (I don't recall of the top of my head)
Oh damn andy is here haven't seen him in a long timr
its 2L (total members) 4k online and aprox 500 intrect with my bot
clear no. sory for ping
EC2 t3.small is far far enough for 4k
EC2 t3.small ram is 2 GiB
That's more than enough for memory
For most bots anyways
Ah right. They mentioned the 200,000 before and I thought that's how many active users they had using the bot at any given time
If you've only got about 4k, yeah what andy said
Luckily the system scales really well so no big deal if you end up needing more
Hello! Is it possible to add the time arg. to the current time using datetime? so it tells the user when it ends?
if you can create a timedelta object, you can add it to your datetime object using just a + operator
Also I think you should extract your time parsing stuff into its own custom converter
how can i get timedelta in mins ?
Use the minutes= kwarg
!e
time = timedelta(seconds=603)
print(time.minutes)
@limber bison :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | AttributeError: 'datetime.timedelta' object has no attribute 'minutes'
@sick bircherror
!e
from datetime import timedelta
time = timedelta(seconds=603)
print(time.days)
@limber bison :white_check_mark: Your 3.11 eval job has completed with return code 0.
0
Hmmm the docs say you can pass in minutes
🥲
The only properties timedelta has are these
oh
btw one more question whats use of snapshots ? like if cpu > 100% right ?????/////
backup thing
I now have
today = datetime.date.today()
ends = today + datetime.timedelta(days=1)
print(ends)
but what if the user states a time like 5s for 5 seconds, how could i make it add only 5 seconds instead of 1 day?
You can convert any user arguments to seconds, and pass it into the timedelta. E.g if they user says 5m, convert it to 300s, etc
This is the perfect opportunity for ternary conditions, e.g ```py
import datetime
days: int = 0
seconds: int = 10
datetime.timedelta(
seconds=seconds if seconds else 0,
days=days if days else 0,
)
!e ```py
import datetime
days: int = 0
seconds: int = 10
delta = datetime.timedelta(
seconds=seconds if seconds else 0,
days=days if days else 0,
)
print(delta)
@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.
0:00:10
and how should i do it?
like this?
time_convert = {"s":1, "seconds":1, "m":60, "minutes":60, "h":3600, "hours":3600, "d":86400, "days":86400}
wait = int(time[:-1]) * time_convert[time[-1]]
today = datetime.date.today()
ends = today + datetime.timedelta(time_convert)
print(ends)
Pass in wait to your timedelta. Also get rid of the alternate keys, like seconds, minutes, and hours as they'll never be used
But again, definitely consider abstracting this into a custom converter
Where's the best place to learn discord.py?
You really do not want to use datetime.date.today here
Your looking for the EXACT time I'm assuming due to the time conversion map?
datetime.datetime.now or utcnow is optimal
thanks guys finally got it working but now there are dashes where spaces should be and theres also the milliseconds? how could i remove those things?
!d datetime.datetime.strftime
datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
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...
yes but idk how i should make those because how i see they use a 'code'
A UNIX timestamp, yes. You can get that using datetime.datetime.timestamp()
!e
from datetime import datetime
print(datetime.now().timestamp())
@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.
1660347679.246663
That's the current timestamp
To get relative time, like <t:1660347730:R> you'd use the R format tag
and then do it like this?;
code = datetime.datetime.timestamp()
print(f"<t:{code}:F>")
?
You need to call timestamp() on an actual datetime instance
Better yet, pass it into discord.utils.format_dt
dt = datetime.datetime.now()
discord.utils.format_dt(dt, "R")
hi, when i click on the button it said: This interaction failed, how to avoid This interaction failed if the bot is getting restarted by it self everyday?
you can't
if it's restarted, then the button callback is removed
you could just keep the bot running 100%
How do I connect a bot to vscode
I have created my application / bot but idk how to put it in vscode to start coding it
if i wanted to edit at the code and run the bot again (restart it) how its going to be worked? 😦
Use add_view
Ignoring exception in command clonechannels:
Traceback (most recent call last):
File "/home/runner/lyomlaclass3477d/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 35, in clonechannels
for channel in reversed(guild.channels):
AttributeError: 'NoneType' object has no attribute 'channels'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/lyomlaclass3477d/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/lyomlaclass3477d/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/runner/lyomlaclass3477d/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channels'
KeyboardInterrupt
```
@bot.command()
async def clonechannels(ctx,guild_id : int):
guild = bot.get_guild(guild_id)
for channel in reversed(guild.channels):
if isinstance(channel, discord.CategoryChannel):
global dareal
dareal = await ctx.guild.create_category(name = channel.name)
if isinstance(channel, discord.TextChannel):
try:
category = channel.category
await ctx.guild.create_text_channel(name = channel.name, category = dareal)
except:
await ctx.guild.create_text_channel(name = channel.name)
if isinstance(channel, discord.VoiceChannel):
try:
category = channel.category
await ctx.guild.create_voice_channel(name = channel.name, category = dareal)
except:
await ctx.guild.create_voice_channel(name = channel.name)
await ctx.send('Cloning channels done')```
i get this error
guild is None
sometimes looking at old code is perplexing
please explain what exactly i was thinking here
probably checking for cosmic rays 
guilt Id?
thx
try to do it like:
if len(str(guild_id)) != 18:
return await ctx.send('thats not a guild id') #cuz every guild id must equal to 18 numbers
guild = bot.get_guild(guild_id)
if guild is None:
return await ctx.send('The bot is not in that guild')
no lol ids can be 17-19 characters long, not just 18 (don't forget about really old and the newer guilds)
every id on discord*, not just guild ids
- Before even attempting to create a discord bot, please learn python (
?tag lp)
- To install discord.py, please run
python3 -m pip install discord.py(linux), orpy -3 - m pip install discord.py(windows)
... a. If you wish to use voice functionality, please usediscord.py[voice]instead ofdiscord.py - Take a look at https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py Mess around.
- When you start making your bot, use the commands ext: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html
- The library documentation is available at https://discordpy.readthedocs.org/en/latest/
The #381965515721146390 and #564950631455129636 channels in this server are related to using this library. If you want help with python questions, please ask in the discord.gg/python server or #738572311107469354.
If you are migrating from the old version of this library (0.16.XX; async) to version 1.XX.XX please follow the migrating guide http://discordpy.readthedocs.io/en/latest/migrating.html
Is it possible to have code that connects bot, sends message, and after that closes?
I mean technically yes, but why would you need a bot for that
because i want my bot being.... working from celery tasks
ideally i need to initialize it once somewhere, and from other program parts to send msgs into it
I was doing something with periodic tasks, It would be better to run them through your bot if they're purely discord related 
Otherwise use some kind of messaging service to communicate it to your bot app, don't run your bot from celery tasks
discord native periodic tasks are unreliable as hell
yeah it would be quite easy as its only using HTTP
i want to have more contorl over my code
They're just using call_later
or whatever the name that calls coroutine later
I was using celery, switching to bot tasks was easiest solution and it worked ok
thats simply just a while True loop running with your configurations, dont see how its unreliable.
discord/ext/tasks/__init__.py line 200
async def _loop(self, *args: Any, **kwargs: Any) -> None:```
you can check this function to figure out what the unreliable part is.
i think maybe a discord webhook might be better for you to use
mm regretfully i need post or edit or delete msg functionality. (all msgs are belonging to bot)
if your only goal is to send a message it seems pointless to log into discord with a bot
^ bots are more prone to getting ratelimited
that's why i will prefer to have my tasks, running in celery with @ retry every N minutes until it is success for few times
10x+ more reliable
if you are sending a message every few minutes you shouldn't have to worry about rate limits
ergh. the amount of users connecting my bot are more than 1
You could use redis pub/sub, rabbitmq, kafka, redis seems like the easiest one to use 
yeah, redis/celery i wish to use as i already used to it
And simply listen to messages on bot side
huh? 
Just listen to events that celery worker would send to your bot?
bot can listen to events from custom code parts?
keeping my connection to aiosqlite database global* won't cause any problems as long as im making local cursors right? 
I think you'd have to spawn an infinite loop somewhere, like:
async for event in redis.subscribe(...):
...
Not sure how exact interface looks like
Yeah
@client.group(invoke_without_command=True)
async def help(ctx):
embed=discord.Embed(title="Help Commands", color=Color.green)
embed.add_field(name="Mderation", value="!help Moderation", inline=True)
embed.add_field(name="Other", value="!help other", inline=True)
embed.add_field(name="Neutral", value="!help Neutral", inline=True)
embed.set_footer(text="For a more in-depth explination on each command, simply type `!help <command>` (replace <command> with the command you want help with)")
await ctx.send(embed=embed)```
nothing is being sent, why?
Idiotic idea
What if to raise discord bot that listens to JSON input from channel
And then sending via webhook requests to the channel
Thus, I will be able to send commands to my bot, like it is rest API
Can somebody take a quick peek at my discord bot code to see if I need to change anything for it to actually run? I'm having some issued defining my token
I cant get docker or heroku to run the bot
I DID IT!
__main__.py
from asyncio import gather, get_event_loop
from logging import basicConfig, INFO
from discord.ext.commands import Bot
from sys import argv
from aiohttp.web import AppRunner, Application, TCPSite
from viewer.core import settings
from viewer.api import routes
basicConfig(level=INFO)
async def run_bot():
app = Application()
app.add_routes(routes)
runner = AppRunner(app)
await runner.setup()
site = TCPSite(runner, "0.0.0.0", 8080)
await site.start()
bot = Bot(command_prefix="$")
app["bot"] = bot
try:
await bot.start(settings.DISCORD_TOKEN)
except:
bot.close(),
raise
finally:
await runner.cleanup()
if __name__ == "__main__":
loop = get_event_loop()
loop.run_until_complete(run_bot())
from aiohttp.web import RouteTableDef, json_response
from aiohttp import web
routes = RouteTableDef()
@routes.get("/guilds")
async def get_guilds(request):
client = request.app["bot"]
guilds = []
for guild in client.guilds:
guilds.append(guild.id)
return web.json_response(
{"guilds": guilds}, status=200, content_type="application/json"
)
This piece of... smth, is capable to turn discord bot into rest api 
no fastapi? 🤨
i just found this piece of example working. Now it is under question how to do it in fastapi
take a notice they have non blocking launching 
you can just create a task though
u know. I have absolutely no idea how to repeat it in fast api
it is also transmiting discord client through web server config
Hey man how did you set your token up?
bot.run(os.getenv("TOKEN"))?
await bot.close() should go in the finally
listener/core/settings.py line 7
DISCORD_TOKEN = config.get("discord.token")```
I cant get my bot to come online and there aren't any errors. It's so infuriating
But that seems pretty cool ngl
You could use pydantic
i already tried it a dozen of times
ok so replace ("discord.token") with the actual long token?
ergh, for my personal comfort, i made prefixes / my own config parser
from utils.config_parser import ConfigParser
config = ConfigParser(settings_prefix="listener")
DISCORD_TOKEN = config.get("discord.token")
code like this parses value from environment value
https://github.com/darklab8/darklab_darkbot/blob/34313388287d4e8962b6663c194ed98d25611e6d/docker-compose.listener.yml
LISTENER_DISCORD_TOKEN: "${LISTENER_DISCORD_TOKEN:-example}"
I originally had it set to "TOKEN = "my actual token"
why no list comps in the endpoint?
Fuck thats above my skill level
It's my first week and im trying to just deploy this damn bot and it wont deploy
this is copy pasted stuff from stackoverflow. i haven't touched it yet beyond being happy that it is working
is it possible to start FastAPI without uvicorn?
what is supposed to be inside asyncio.create_task for fastapi
I'm not sure, you could look into how uvicorn.run works
And if you can start it from async context
https://www.uvicorn.org/deployment/
if __name__ == "__main__":
uvicorn.run("example:app", host="127.0.0.1", port=5000, log_level="info")
it is not
The lightning-fast ASGI server.
alright and i would use fastapi for abstractions and whats the motive of making a REST API that retrives data from your bot? management for external use?
main motive to make endpoints for data input into this REST API, which would be able to send commands to Discord API
It allows me to use external my own code logic like... having my stuff in background celery tasks actually doing job
and only results sending for input into this exposed REST API
i reverse dependency 
instead of relying on Discord API code architecture forced upon my logic
i use freely anything outside, and sending to my predefined interface
Main motive = zero dependency on discord api implementations usage.
code should be living without it as much as possible
and being fault tollerant in celery tasks preferably (or gRPCs)
so to my understanding youre making a REST API that wraps an API/API wrapper that wraps a REST API and gateway/ws?
u had me lost on a second API word. I can draw a picture
ok ok, so basically youre using a REST API wrapper to already have objects and abstractions and then you create a custom REST API that returns objects of your bots data for better handling/management?
#help-burrito If anybody has ever made/hosted a discord bot before. Please see if you can fix my token issue, I'm new and I really want to learn
When we raise Discord Bot in a standard way, it suggests having it running in blocking way, and using its own implementation of periodic tasks / its own implementation of CLI interface builder. Discord.py I consider being awfully wrong, always falling in errors, and having this architecture design is just being awful to test
I reversed my dependencies, and instead of it having two Discord Bots listening to things
first Discord Bot listener intercepts all messages in channel, and sends to my CLI interface built in argparse, and returns whatever result from it
second Discord Bot discorder, opens me REST API to control Discord client, input and outputing data out of it. I will be able to communicate with it with external tools
Thhttps://github.com/darklab8/darklab_darkbot
and that point just make a CLI interactive wrapper
scrappy scraps third party REST APIs and web forum for data. Stores in database. Outputs at REST API or gRPC endpoints.
configurator is a REST API or gRPC application. That stores all possible user settings
listener is Discord API connected application, that accepts user commands from channel and sends to consoler, and gives from it answer
consoler is a CLI interface to accept input from listener and render it CLI answer back
viewer is main celery-beat application that in a loop gets user settings and connected channels, and rerenders to them view
REST API discorder around, allows me to send data from my viewer, which are fault tollerant celery tasks
https://github.com/darklab8/darklab_darkbot
User connects darkbot to some discord channel, and sets settings which space bases, player tags or space systems to track. Darkbot repeatedly updates information to discord channel
That's expected as final result
all the shenanigans are needed to increase horizontal scalability / fault tollerance of application, and its reliability through decreasing Discord client code usage to its bare minimum.
plus keeping stuff separated in different microservices = i have natural code layer isolation / minimum complexity in this case
yes, there are some drawbacks to having that many microservice parts... but whatever. That's the way. It is training execise anyway to create scalable infra
huh just remembered this and went back to it, made my own decorator. Thanks for the help 😁
https://raw.githubusercontent.com/darklab8/darklab_darkbot/master/architecture/architecture.drawio.svg updated how architecture is looking as picture
going to be fun
mhm nice project btw you made a typo in the middle cloud on top
I'd make architecture overview more high-level with no/less specific 
mmmm, dpy tutorials are so... good
It is not looking likely
:loooli: okay atleast they know its context not C-T-X
why ctx is bad
its not bad , but discord.py user's expectation with ctx is
okay, now I gotta watch yt tutorial
"how can i use ctx in an event"
it just started 😭
😔
lmao, good example of how to reveal your token
i made a handy event check decorator for my library
import asuka
bot = asuka.Bot("TowoKEN", intents=asuka.Intents.from_value(61965))
@asuka.listener_config(bots_only=True, guild_only=True, ignore_self=True)
@bot.listen(asuka.events.MessageCreate)
async def message_create(event: asuka.events.MessageCreate):
print(f"{event.user.username} sent a message in <#{event.channel_id}>")
bot.run()
saves from useless if/else s
better overkill than the opposite in case of documentation 🙂 and it is high level enough about my plans anyway
Nothing really forbids me to change it if it is not correct
probably
not really a fan of having an event argument im gonna be honest
hey i was trying to make a mod mailbot i did everything and it worked but it sends message only in 1 channel like i want it to make different ticket like channels for each user idk how to doit please help me
payload
i can share code if need
saves from the pain of constructing objects seperately + no missing arguments error
most of the times*
you can always pass an already constructed message object
its like the raw_x_event
@silk fulcrum do u know how to do that?
whypeopleareaskingme
because youre smart
sarth is smorter
ofcourse but for events with multiple args it would be hectic , 🗿 and no strict typecheck
no, you are a genius, sarth is very smart, compare
general payload obj👁️ 👁️
u r big brawn
now im big brown
lol
okmi
well instead of making that having a single class helps more
can u help me pleasseee
yes'
only acceptable case would be
event.message e.g if its a MESSAGE_CREATE event
doing event and having attributes of a payload obj makes me wanna eat cereal with a fork
dataclasses
Nv
i ate soup with a fork

cus of a challenge
why tf will i make people learn "what event take what args" discord.py cough cough
34 minutes...
in my lib i just had a payload obj which wouldve been a dict object with already parsed models lmao
dont give me ideas 😮
or having a generic class so users dont need to check docs for specific args to pass depending on the name space of the callback
why use typing.Dict?
to specify both key and value?
you can parameterize with the built in dict type lol
if you're about to ask why not use dict
i dm code
i knew that
yes
why should i not use the typing library if i already have that improrted
that point is like your grammar
poop
you;re aware that typing library is faster than builtins right?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
uhm
do u know how to add that?
So @west veldt , where (in what command, listener) do you want to create channel tickets?
how? and parametization were talking about and you cant instantiate with typing.Dict over the built in dict
wdym like when someone dm bot it makes a channel in server something like ticket-{username}-sr.no.
both should be almost same time right negligible diff
u get it?
i see
its a mutable mapping of dict...
mhm?
well then what's the problem with creating a channel called smth-user?
yeash
as I see you are getting it from your config
yea
just do channel = await your_guild.create_text_channel(f"smth-{user}-{user.id}") instead
and how do i make a command like ^close to close the ticket and delete channel
I would use a TypedDict
you can use it but its kinda useless and typing.Dict was deprecated as dict can already be parameterize
oh hm , didnt think of that
since the keys are fixed that would make more sense

nice pfp nova
I want to do it with her
make a command called close, for DM only, then check if there is a channel that endswith user.id and if this condition is met, delete that channel
i respect you being honest, but you should love a girl mate, either way she isnt real lol
alr tysm
I am alone and depressed
you have zeffo go talk to him
He is very mean to me
you have me added, im not mean
i love you more nova even if you cant spell my name correctly🫂
🫂
being nice to everyone doesnt cost you anything people so be nice to everyone even if they call you a ..... rider!
people call me a hog rider for some reason yes
😳
sex
sheeesh
wth is Stack 😳 first time I see it
3.11?
eww that's ..... so cringe
I have python installed form the website and vsc says to select a python interpreter
hog rider isnt cringe, hes the way of life
istg I ran the code 1 day ago and didn’t get this message 💀
probably something related to the call stack
i get that issue sometimes too, so just restart vsc
also
RULE 7
how much ram would be necessary to host a bot with music and some minigames on it?
depends
I plan on using youtube dl btw
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
pft
1gb is enough/overkill
alr ty
Start with 2gb/1gb. Then scale as your userbase increases
imagine on first launch, bot gets hit with 5 million users
either way user base isnt all that matters
!?!?
sus
i never saw anything lmao
.topic
Suggest more topics here!
filters are cool
buttons and slash commands
1wpm i see
are buttons and slash commands hard to code? I have never really used them
not really, depending on your library of choice
disnakes implementation of slash commands is quite easy, buttons are easy as well and mostly the same for all forks
most forks have examples on github btw
ill check it out since by the looks of it discord is encouraging bots to include them more
slash commands for discord.py arent hard either, just that the idea of a tree makes it look complicated even though it isnt
Slash commands are better imo due to handling ui wise and preventing horrible user experiences and buttons are also good ui wise and ratelimiting wise also
its still odd to me to have a tree structure
yeah it looks better
I dont see a difference but okay, use discord_slash
what?
cool pfp
wdym difference? ok?
yes, really lively
ty
🛸 🙏

meh let's abandon the topic, we don't do with bots anymore
Good point, got me speechless out here
more like I'm in no mood to argue so
maturing is realizing Discord bot development is boring
its 4am i shouldnt even be discussing topics with you lmao
discord bot development isn't boring, life is just too interesting
all i do is wake up code and sleep, yeah it is

I'll just go to sleep, im bored of staying up
im hungry so i cant go to sleep sadly
eat something
not in the mood to make myself something
either way i cant make waffles, not my first time making waffles at 4am lol
Don't sleep, take a shower, get dressed, go to a fancy restaurant and sleep
Guys is there way to add subcommands in dpy?
Forget to pay checkout also
mmmmm
Yes
CHamber is hot
Command group ig?
why not, protection
Omen hotter nom nom
Are you using cogs, and using app commands or prefix ones
viper hottest 😍
I have examples for slash subcommands with and without cogs in the gist, not for prefix cmds
.topic sorry Robin
hi zeffo :)
I know Robin is watching
um what this error for? raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 9 column 18 (char 261)
That JSON file is invalid
Can you make discord bots with languages other than js?
wha
Ofc
character is not supported by JSON
Show your code
alr ty
json file or main file?
Both, if possible
Cogs and prefix command
alr
No
don't do this to people who don't understand the concept of an API
!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/latest/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
This is similar to the [`command()`](https://discordpy.readthedocs.io/en/latest/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/latest/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.
lmao sorry
is ok 🥺
Ashley and okimii will explain the rest to you @robust fulcrum

https://hastebin.com/inaxibuguz.py
{
"token": "[token]",
"developers": [933207485148438528],
"replacements": {},
"prefix": "^",
"mod_role": 975660025416663072,
"blacklist": [],
"server": 975660025416663070,
"mail_channel": channel = await your_guild.create_text_channel(f"smth-{user}-{user.id}"),,
"from_field": 1
}
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hmmm?
"mail_channel": channel = await your_guild.create_text_channel(f"smth-{user}-{user.id}"),,
this is not valid JSON
that's JSON mixed with Python
what do you want that to do?
you cant store a GuildChannel obj like that
wait
creates dialect of JSON to prove you wrong
dafuq
i want it to make channel when someone dms the bot like ``ticket-username-userid
How to use it?
I will just go and sleep idk what im doing anymore
why would someone dm the bot a token? 😭
when did i 😳
ticket****
inb4 "no when did i ask"
?
💀
you know how to doit?
idk, i'm supposed to do my homework
Guys how to use command group in dpy?
use google
oof ok
It's not there on google
!docs
!docs discord
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
Any command suggestions?
!fish
returns a random ascii fish
mhm
utility command maybe?
what about !fish
I even found a website you can use https://www.asciiart.eu/animals/fish
!fish
Hello! I'm trying to add a time that shows the user when the giveaway is ending, everything works but i want to remove the milliseconds, but i dont know how i could make it to reality with my current code, I marked the code that generates the time...
adding a UNIX timestamp is too complicated for me, i tried it for 3 hours and failed...
a timestamp is supposed to be relatively easier than doing what you are currently doing so
!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...
I already saw this method but i dont know how to implement it into my code
Guys how we can make comamnd group in dpy pls tell anyone
@bot.group()
async def yes(ctx):
...
@yes.command()
async def no(ctx):
...
I saw on google it's given pass_context in the @bot.group
Whats use of that?
how can i get all the members with a specific role
@bot.command()
async def _(ctx):
time = datetime.datetime.now() + datetime.timedelta(minutes=34, seconds=35)
fdt = discord.utils.format_dt(time)
await ctx.send(fdt)

!d discord.Role.members
property members```
Returns all the members with this role.
thx so much
Thanks I will try my best to use it

Will it be
@self.bot.group() in cogs?
no?
@cogs.group?
!d discord.ext.commands.Group
class discord.ext.commands.Group(*args, **kwargs)```
A class that implements a grouping protocol for commands to be executed as subcommands.
This class is a subclass of [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and thus all options valid in [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") are valid in here as well.
the documentation help forshure
Oh @commands.group
can u plz tell me clearly how i can make a function that returns a list when i give it a param of roles object
- Get the Role object any way you want
- use the
membersattribute on it and it'll return a list ofMemberobject of all the members which have that role
what does message.content(int) mean for you?
um i want check the messga have int or not
like if it has int or is just an int
Python is intuitive, but that doesn't mean you can type whatever you want and expect it to do your bidding
@slate swan uhm... just to know..
;/
dude i want CHECK IF MESSAGE HAVE NUMBE OR NOT
SO I PUT INT DONE
jeez
No need to shout
I'm not even helping anymore, goodluck 
Well written, If only people would read and follow it 😄
ME DYING
yeah... well the list of knowledge (except reading the docs) is from Danny's FAQ
,
congrats
no one want help me :(
what this mean
you click the link and see what's in it
yes
and what's in it?
i click i undertsand 0%
You can use any function, with the str.isdigit function, like this
def has_numbers(inputString):
return any(char.isdigit() for char in inputString)
has_numbers("I own 1 dog")
# True
has_numbers("I own no dog")
# False
Alternatively you can use a Regular Expression, like this
import re
def has_numbers(inputString):
return bool(re.search(r'\d', inputString))
has_numbers("I own 1 dog")
# True
has_numbers("I own no dog")
# False
Share
Follow```
Not to discourage you from pursuing programming. But if you want to write good code and make cool projects, you will be required to learn basic python first. As well as have the ability to read documentation.
I DID
no you didnt
dude i did
you're message.content(int) says completely opposite
do you understand what that function does and how you can integrate it into your code?
yes
but this not
do you understand what def num_there(s): does?
nope
you know... if you knew at least the last paragprah of the list that I sent (reading docs), you would've seen: message.content returns me a string, i want to see if there is a number in it... hmmm... docs doesnt seem to provide such a method so i need to google it or ask in help channel, but NOT write message.content(int)
you guys are meanies 😠
That's called a function definition. Functions are blocks of code that can be reused. You can learn more about them here: https://automatetheboringstuff.com/2e/chapter3/
and you say you know basics of python
you cant even read something bigger than 300 symbols
Yes i can't read A B C D :)
That's not really a choice. We don't spoonfeed code here and you're going to need to read it if you want to fix your problem.
i read it but not all
No, you read it, all
regex 
;/
wtf
dude i near get 600 line in pyhton without read it all 
dude no one want help me ;/ 
And you don't understand what any of those 600 lines do.
i did DUDE
WTF??? SO HOW I CODE??
the main person who doesnt wanna help you is YOU
WTTF????
wtf
i can't help my self? how this possibile
Putting together code you find online is not difficult.
wtf
i know 95% of my code
😂
want check dm me 
i wanna see those 600 lines
i thought you dm\
no, feel free to use a pastebin and send it here
sure
no
feel free to dm me
no thanks 😄

um not all code working i sitll working in my code?
I wrote a math parser and yet I don't understand how the hell it works
im not gonna read that code, it's just... one look is enough
I have no clue what you're talking about, sorry
I'm just saying that nobody is going to help if you refuse to learn the required knowledge
the think is that the code is so bad
gimme a sec
ye ye bullying bullying me good you bad :)
this can blow up any time
alright glhf at being not helped gonna make some command
;/
:( what wrong i just want small help and people thinking i don't know python :(
and @meager chasm get rekt
i understand all 600 line :)
ok noow bye
rip
LOl
gg
lol
does this meme can get me ban from the server?
@silk fulcrum hi
hi
Am I stupid or how do I take files as an option with slash cmds?
message.content(int) to check if there is a number in message
I don't think you can code.
are you using discord.py 2,0?
!d discord.app_commands.Argument
class discord.app_commands.Argument```
Represents an application command argument.
New in version 2.0.
type argument
Can you just typehint discord.File?
i can i show him and he get rekt
i dont think so, but you can try
or discord.Attachment probably
No one got rekt bro
Do you know the basics of asynchronous programming, and do you know what the concept of a coroutine is?
only him :lmao:
Don't waste your time on that guy. He's just trolling
no his not trolling, that's just concept of 13 year old
I think he's under 13
i rekt master and endysis too
idk how I passed it at 10-11
I don't think he is. I used to be like that when I was like 9 or something
Well he's not supposed to be on discord then 😄
look at your self frist
I 13 
And me, I think I passed that phase when I was 11, I'm 13 now :p
Hmm... how do I know if I really passed that phase?
prove
I am not 10 my friend
passport
you 5
WTF??
Topic is flying right now
You don't say rekt anymore
A????
.topic
rekt
?cat
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
and in my country passport is at 14, i know that
@slate swan
Usa then?
you from usa then?
😁
nope
I don't think we're talking about Discord bots anymore guys 😔
um France?
who cares tbh
im too lazy to find that message
ez wtf
didnt even get the joke..
Now do it with list comprehensions, tuple unpacking, asyncio and ctypes :p
on join:
send "you do dumb" to player
Make it more esoteric
Hello how do I print hello world I tried this
any(print(print) for print in filter(lambda print: print is print, map(lambda print: print, ["h", "e", "l", "l", "0", " ", "w", "o", "r", "l", "d"])))```
But this no work why 😥
this is ome one blocked
😂
💀😂

Why so many lambdas I can't comprehend
Also, grammar please
You get rekt my dude :) now stop lol Me who lol :)
I no know i copy and paste from stack superflow or something
Really me no know that
you don't even have nitro 
😥
You don't even clearly understand that word rekt meaning my dude)
Chill out mom's credit card
Rekt mean you get in your mom again :)
And what does that have to do with anything
Please bless him he doesn't understand 🙏 😢
i can sent rn nitro dummy
aight im blocking him. too bad play... there were two ways: much more toxicness or stop being dumb
But you won't
"mom can I borrow your credit card please one last time"
i aready did
watching for green buttons rn
not you
😹
you are gud
only a few minutes until a mod arrives
dude stop bullying and me will eb good
and you guys bullying for no reason
We did npthing, just trying to get blue sky to understand that he doesnt know enough python
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
<@&831776746206265384>
@slate swan read this
Yea
DUDE I SWERAR TO GOD I KNOW PYTHON FUCK
I DID DUMB
Calm down buddy
Don't raise your tone at me
then try reading this #discord-bots message
I'm not a girl.
You have to understand the basics of asynchronous programming and Python itself to make bots
yes you girl
I FRICKING DID
How? I just said I'm a male
what does async mean?
you act like girl
Show me a basic program using asynchronous programming then :p
PLZ STOP BULLY
it for command dumb
😂
nah we're laughing at you honestly
Do we call mods
what
alrady
<@&831776746206265384>
by blue sky
He pinged mods on himself
The async keyword is not exclusive to discord.py
they will do nothing
Genius
Wat is happening
block message here
something really weird
????
dumb people bullying me for no reason
gets proven wrong
"block message here"
Don't call people who know more than you dumb and maybe they'll stop?
We're trying to explain to Mr. @slate swan that you need to understand the basics of Python to make a [Python] bot
dude i know skript and pythin and very small at java dude
now shut up
How do you print hello world in Java?
Oh damn
Explain what if message.content(int) is then 😂
!shhh :lemao:
What is skript
In this server expecting people to know python before doing an advanced python project is gatekeeping
Who whay
a key word that goes after key word aysnc
aysnc skript def
e
Lmao
😭
me don't want swear = me ban
inb4 someone forks CPython and adds skript kw
TheBlueSky they are telling the truth
WTF
what is happening here
i see all blocked messages
Swearing is allowed, but not directed to other people :p
bullying and rude
Just trying to explain to him that he needs to learn the basics of Python to make a bot, and now for some reason he's being rude
I KNOW PYTHON
^ my understanding of what's happening
👍
I don't mind
aadd to block list
LOL
The Blue Sky is being a smart ass saying he knows python, when he asks for help on many simple issues
dude wtf i knowwwww pythooooooon
You have to be trolling
TheBlueSky block me forever?
just do print(message.content(int)) , you'll se how smart he is
It's as if I'm looking at myself from 3 light years away
i think so
Ok
go at night
Well then
e
how hasn't this guy gotten banned yet 😂
i will not
Agreed
it true
i dont have the energy to take sides; i finished back reading and my verdict is both of you took it wayyy too far
drop the topic or else mutes will be handed out
lol
He didn't know how to do
try: and except:
What about
a = 0
b = "1"
print(a + b)
this like java
Alright.
Except it's not lol
01
dude ;/ you don't even java
just stop please
addd block list
I've had some experience modding Minecraft ig
who
all of you
can you take the pissing contest to one of the off topic channels please
wdym
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
good night
pissing contest 💀
And this time don't get mad
Yes
um if message.content(int): what this should do?
LOL
What do you think does it do
it should check if message have int or not right?
no
lol
no
No
Google it
If content was a function then ig
JUST GOOGLE IT
google = bad
but it isnt'
a
"google it" is not an accepted response here
stop it, that's not helpful
What do you think int is?
angad get rekt
is number
!d str.isdigit
str.isdigit()```
Return `True` if all characters in the string are digits and there is at least one character, `False` otherwise. Digits include decimal characters and digits that need special handling, such as the compatibility superscript digits. This covers digits which cannot be used to form numbers in base 10, like the Kharosthi numbers. Formally, a digit is a character that has the property value Numeric\_Type=Digit or Numeric\_Type=Decimal.
iterate over all characters in message.content, check if it's a number
you didn't try the code I gave you :/
let me reeadd
though idk if that's efficient
@slate swan provide an example input/output
that will check if the string is a digit, not if a digit is in the string
Francis a goat
no, i'm a starfish
o
Does anyone know why this give's me an error when I'm deleting more than like... 10 messages? I have an error handler and I tried my best to get the full exception, like traceback.format_exc(), e.t.c but all I get is: NoneType: None. I'm using a hybrid_command, and usual message command works properly, but slash command gives me this error
you are
i think so :D
star fish = nice star LOl
me dumb
Are there more than 10 msgs ?
where
in channel you mean?
it doesn't metter, it gave me same error when there was and when there wasn't
That's weird idk


