#discord-bots

1 messages · Page 32 of 1

austere vale
#

ooooooh. thanks lemon_sweat

gusty shard
#

can you send the past of command

mental hollow
#

past of command?

gusty shard
#

the codes above that line

#

sorry cursed

pale turtle
#

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

mental hollow
#
 @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>.")
pale turtle
#

For example, current time timestamp is 1660339732 @mental hollow

mental hollow
#

I’m confused, so how do I make my cool-down into a timestamp?

pale turtle
#

O think you can use datetime lib for that

gusty shard
#
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

sick birch
#

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

gusty shard
#

each cog make a help section or something

how can i make that

sick birch
mental hollow
sick birch
#

It's of type Mapping[Optional[commands.Cog], List[commands.Command]]

gusty shard
#

i think i will make a help command that has 50+ ifs

#

because that looks way more complicated

sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

21:34:20
sick birch
#

The timedelta is the important bit

pale turtle
#
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

mental hollow
gusty shard
#

sorry nir

pale turtle
#

All good

gusty shard
#

didnt mean to ping you

mental hollow
#

I’ll try it now

gusty shard
#

thank you

pale turtle
#

Np

gusty shard
#

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

pale turtle
#

You can't assign variable while giving it as an argument

#

Just use the timedelta

gusty shard
#

i got that code from another guy here

#

i dont know much about them

pale turtle
#

Just remove the e =

gusty shard
#

but its working perfectly for me

#

why isnt it working for him?

pale turtle
#

Are you sure there are no errors?

gusty shard
#

yep

gusty shard
sick birch
#

!e print(x := "hello, world")

unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

hello, world
slate swan
#

how can i get all members using a guild id?

sick birch
pale turtle
#

!e print(x = "hello, world")

unkempt canyonBOT
#

@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()
pale turtle
#

He did it like tho tho no?

#

Ohh he did it in the {}

#

Sorry

sick birch
slate swan
sick birch
#

For example, if I wanted to get all the members of this server, I'd do:

bot.get_guild(267624335836053506).members
slate swan
#

yea

#

wait oh my god, i'm so dumb my apologies

#

i forgot to int the guild id from my config file

#

sorryyy

limber bison
#

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 ?

sick birch
sick birch
pliant gulch
#

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

sick birch
#

Oh EC2? That's much easier to figure out, still a few variables but nowhere as much as some of their other services

pliant gulch
#

EC2 instance applications will usually have an irregular burst schedule as well

pliant gulch
#

I thought T2 was one of the options for EC2

limber bison
#

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 ?

sick birch
#

Not sure if they were talking about elastic beanstalk or lightsail or something or the other

pliant gulch
#

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

slate swan
sick birch
#

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)

pale turtle
#

Oh damn andy is here haven't seen him in a long timr

limber bison
#

clear no. sory for ping

pliant gulch
#

EC2 t3.small ram is 2 GiB

#

That's more than enough for memory

#

For most bots anyways

sick birch
#

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

limber bison
#

ohhh k k

#

going with t3 small then hahaha

#

thanks

mossy jacinth
#

Hello! Is it possible to add the time arg. to the current time using datetime? so it tells the user when it ends?

sick birch
#

Also I think you should extract your time parsing stuff into its own custom converter

limber bison
sick birch
limber bison
#

!e


time = timedelta(seconds=603)
print(time.minutes) 
unkempt canyonBOT
#

@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'
limber bison
#

@sick bircherror

#

!e
from datetime import timedelta

time = timedelta(seconds=603)
print(time.days)

unkempt canyonBOT
#

@limber bison :white_check_mark: Your 3.11 eval job has completed with return code 0.

0
limber bison
#

even days there lol

#

why not min

sick birch
#

Hmmm the docs say you can pass in minutes

limber bison
#

🥲

sick birch
#

The only properties timedelta has are these

limber bison
#

oh

#

btw one more question whats use of snapshots ? like if cpu > 100% right ?????/////

#

backup thing

mossy jacinth
#

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?

sick birch
pliant gulch
#

!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)

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.

0:00:10
mossy jacinth
sick birch
#

But again, definitely consider abstracting this into a custom converter

scarlet widget
pliant gulch
#

Your looking for the EXACT time I'm assuming due to the time conversion map?

#

datetime.datetime.now or utcnow is optimal

mossy jacinth
#

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?

unkempt canyonBOT
#

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).
sick birch
#

Also you should consider using special discord timestamps

#

!d discord.utils.format_dt

unkempt canyonBOT
#

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...
mossy jacinth
sick birch
#

!e

from datetime import datetime
print(datetime.now().timestamp())
unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

1660347679.246663
sick birch
#

That's the current timestamp

#

To get relative time, like <t:1660347730:R> you'd use the R format tag

mossy jacinth
#

and then do it like this?;

code = datetime.datetime.timestamp()

print(f"<t:{code}:F>")

?

sick birch
#

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")
still swan
#

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?

quaint epoch
#

if it's restarted, then the button callback is removed

#

you could just keep the bot running 100%

scarlet widget
#

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

still swan
jovial sinew
#
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')```
heavy folio
#

guild is None

dull terrace
#

sometimes looking at old code is perplexing

#

please explain what exactly i was thinking here

#

probably checking for cosmic rays suspicious

jovial sinew
still swan
still swan
heavy folio
#

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

upbeat gust
# scarlet widget How do I connect a bot to vscode
  1. Before even attempting to create a discord bot, please learn python (?tag lp)
  1. To install discord.py, please run python3 -m pip install discord.py (linux), or py -3 - m pip install discord.py (windows)
    ... a. If you wish to use voice functionality, please use discord.py[voice] instead of discord.py
  2. Take a look at https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py Mess around.
  3. When you start making your bot, use the commands ext: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html
  4. 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

torn sail
#

Uh well this isn’t a good idea but maybe set it in on_ready

#

That’s like a last option

desert sparrow
#

Is it possible to have code that connects bot, sends message, and after that closes?

cursive barn
desert sparrow
#

ideally i need to initialize it once somewhere, and from other program parts to send msgs into it

honest laurel
#

Otherwise use some kind of messaging service to communicate it to your bot app, don't run your bot from celery tasks

desert sparrow
slate swan
desert sparrow
#

i want to have more contorl over my code

honest laurel
#

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

slate swan
unkempt canyonBOT
#

discord/ext/tasks/__init__.py line 200

async def _loop(self, *args: Any, **kwargs: Any) -> None:```
slate swan
#

you can check this function to figure out what the unreliable part is.

cursive barn
desert sparrow
cursive barn
#

if your only goal is to send a message it seems pointless to log into discord with a bot

slate swan
#

^ bots are more prone to getting ratelimited

desert sparrow
#

10x+ more reliable

cursive barn
desert sparrow
honest laurel
desert sparrow
honest laurel
#

And simply listen to messages on bot side

desert sparrow
honest laurel
#

Just listen to events that celery worker would send to your bot?

desert sparrow
#

bot can listen to events from custom code parts?

dull terrace
#

keeping my connection to aiosqlite database global* won't cause any problems as long as im making local cursors right? 7739monkathink

honest laurel
#

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

slate swan
#
@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?
desert sparrow
#

Thus, I will be able to send commands to my bot, like it is rest API

blazing stirrup
#

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

desert sparrow
# honest laurel I think you'd have to spawn an infinite loop somewhere, like: ```py async for ev...

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())

api.py

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 pithink

desert sparrow
#

take a notice they have non blocking launching pithink

honest laurel
desert sparrow
#

it is also transmiting discord client through web server config

blazing stirrup
#

bot.run(os.getenv("TOKEN"))?

torn sail
unkempt canyonBOT
#

listener/core/settings.py line 7

DISCORD_TOKEN = config.get("discord.token")```
blazing stirrup
#

I cant get my bot to come online and there aren't any errors. It's so infuriating

torn sail
#

But that seems pretty cool ngl

desert sparrow
blazing stirrup
desert sparrow
# blazing stirrup 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}"
blazing stirrup
#

I originally had it set to "TOKEN = "my actual token"

slate swan
blazing stirrup
#

Fuck thats above my skill level

#

It's my first week and im trying to just deploy this damn bot and it wont deploy

desert sparrow
desert sparrow
honest laurel
#

And if you can start it from async context

desert sparrow
slate swan
desert sparrow
#

i reverse dependency pithink

#

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)

slate swan
#

so to my understanding youre making a REST API that wraps an API/API wrapper that wraps a REST API and gateway/ws?

desert sparrow
slate swan
#

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?

blazing stirrup
#

#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

desert sparrow
#

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

slate swan
#

and that point just make a CLI interactive wrapper

desert sparrow
#
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

desert sparrow
#

That's expected as final result

desert sparrow
#

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

zealous jay
#

huh just remembered this and went back to it, made my own decorator. Thanks for the help 😁

slate swan
honest laurel
silk fulcrum
#

mmmm, dpy tutorials are so... good

honest laurel
#

I hate it, thanks

silk fulcrum
slate swan
silk fulcrum
slate swan
#

its not bad , but discord.py user's expectation with ctx is

silk fulcrum
#

okay, now I gotta watch yt tutorial

slate swan
#

"how can i use ctx in an event"

silk fulcrum
#

it just started 😭

silk fulcrum
#

lmao, good example of how to reveal your token

slate swan
#

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

desert sparrow
silk fulcrum
slate swan
west veldt
#

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

west veldt
#

i can share code if need

slate swan
#

most of the times*

slate swan
#

its like the raw_x_event

west veldt
silk fulcrum
#

whypeopleareaskingme

slate swan
#

because youre smart

silk fulcrum
#

okimii is way more smart

#

lol

slate swan
#

sarth is smorter

slate swan
silk fulcrum
#

no, you are a genius, sarth is very smart, compare

slate swan
west veldt
silk fulcrum
#

now im big brown

west veldt
#

lol

grim oar
#

okmi

slate swan
west veldt
#

can u help me pleasseee

silk fulcrum
slate swan
#

doing event and having attributes of a payload obj makes me wanna eat cereal with a fork

#

dataclasses

slate swan
slate swan
silk fulcrum
#

cus of a challenge

slate swan
#

why tf will i make people learn "what event take what args" discord.py cough cough

silk fulcrum
#

34 minutes...

slate swan
#

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?

silk fulcrum
#

to specify both key and value?

slate swan
#

you can parameterize with the built in dict type lol

#

if you're about to ask why not use dict

west veldt
slate swan
#

i knew that

slate swan
#

why should i not use the typing library if i already have that improrted

slate swan
#

poop

#

you;re aware that typing library is faster than builtins right?

west veldt
#

uhm

#

do u know how to add that?

silk fulcrum
#

So @west veldt , where (in what command, listener) do you want to create channel tickets?

slate swan
west veldt
shrewd apex
slate swan
#

mhm?

silk fulcrum
silk fulcrum
#

as I see you are getting it from your config

west veldt
#

yea

silk fulcrum
#

just do channel = await your_guild.create_text_channel(f"smth-{user}-{user.id}") instead

west veldt
grim oar
slate swan
# slate swan mhm?

you can use it but its kinda useless and typing.Dict was deprecated as dict can already be parameterize

slate swan
grim oar
slate swan
#

nice pfp novapithink

grim oar
#

I want to do it with her

silk fulcrum
slate swan
grim oar
#

I am alone and depressed

slate swan
#

you have zeffo go talk to him

grim oar
#

He is very mean to me

slate swan
#

you have me added, im not meanyert

grim oar
#

yes

#

luv you okmi

slate swan
#

i love you more nova even if you cant spell my name correctly🫂

grim oar
#

🫂

slate swan
#

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

slate swan
#

😳

rugged shadow
#

you have to tell me

rain olive
#

sex

slate swan
#

sheeesh

rugged shadow
#

Nova

#

Outside?

silk fulcrum
#

wth is Stack 😳 first time I see it

vale wing
#

3.11?

slate swan
#

I have python installed form the website and vsc says to select a python interpreter

slate swan
#

istg I ran the code 1 day ago and didn’t get this message 💀

rugged shadow
slate swan
edgy maple
#

how much ram would be necessary to host a bot with music and some minigames on it?

slate swan
#

depends

edgy maple
#

I plan on using youtube dl btw

rugged shadow
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

rugged shadow
#

pft

slate swan
edgy maple
#

alr ty

rugged shadow
slate swan
#

even 500-600mb is a lot for that

#

faxs

#

but okimii is never enough for us

rugged shadow
#

imagine on first launch, bot gets hit with 5 million users

slate swan
#

either way user base isnt all that matters

slate swan
edgy maple
#

sus

slate swan
#

i never saw anything lmao

rugged shadow
#

.topic

lament depotBOT
#
**What's one feature you wish more developers had in their bots?**

Suggest more topics here!

edgy maple
#

filters are cool

slate swan
#

auto mod is better

#

nice

rugged shadow
#

ash keeps on typing

#

"nice"

slate swan
rugged shadow
#

1wpm i see

edgy maple
#

are buttons and slash commands hard to code? I have never really used them

slate swan
#

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

edgy maple
#

ill check it out since by the looks of it discord is encouraging bots to include them more

slate swan
#

slash commands for discord.py arent hard either, just that the idea of a tree makes it look complicated even though it isnt

slate swan
slate swan
edgy maple
#

yeah it looks better

slate swan
swift pumice
slate swan
slate swan
edgy maple
rugged shadow
swift pumice
slate swan
#

Good point, got me speechless out here

#

more like I'm in no mood to argue so

rugged shadow
#

maturing is realizing Discord bot development is boring

slate swan
#

its 4am i shouldnt even be discussing topics with you lmao

slate swan
#

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

rugged shadow
#

Don't sleep, take a shower, get dressed, go to a fancy restaurant and sleep

slate swan
#

^^

#

im in debt

robust fulcrum
#

Guys is there way to add subcommands in dpy?

vale wing
#

Forget to pay checkout also

rugged shadow
#

mmmmm

rugged shadow
#

get dressed fancy like Chamber

#

look like this guy

slate swan
#

CHamber is hot

rugged shadow
#

Remove the gun remove the gun

#

Don't bring a gun

robust fulcrum
slate swan
slate swan
vocal snow
rugged shadow
#

viper hottest 😍

slate swan
#

I have examples for slash subcommands with and without cogs in the gist, not for prefix cmds

rugged shadow
#

.topic sorry Robin

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

swift pumice
#

hi zeffo :)

rugged shadow
#

I know Robin is watching

west veldt
#

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)

next prairie
#

Can you make discord bots with languages other than js?

west veldt
slate swan
#

character is not supported by JSON

rugged shadow
next prairie
#

alr ty

west veldt
rugged shadow
robust fulcrum
west veldt
rugged shadow
slate swan
#

yes no

#

idk why but no

rugged shadow
#

don't do this to people who don't understand the concept of an API

vocal snow
unkempt canyonBOT
#

@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.
slate swan
#

lmao sorry

rugged shadow
#

is ok 🥺

vocal snow
#

Ashley and okimii will explain the rest to you @robust fulcrum

slate swan
west veldt
# rugged shadow Both, if possible

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
}

rugged shadow
#

"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?

west veldt
#

um

#

this is a modmail bot

#

oh wait

slate swan
#

you cant store a GuildChannel obj like that

west veldt
#

wait

slate swan
#

use an ORM instead

rugged shadow
rugged shadow
west veldt
robust fulcrum
slate swan
#

I will just go and sleep idk what im doing anymore

slate swan
west veldt
west veldt
rugged shadow
west veldt
west veldt
rugged shadow
#

idk, i'm supposed to do my homework

robust fulcrum
#

Guys how to use command group in dpy?

slate swan
west veldt
robust fulcrum
slate swan
unkempt canyonBOT
slate swan
#

!docs discord

unkempt canyonBOT
#

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.

slate swan
#

Any command suggestions?

slate swan
#

returns a random ascii fish

#

mhm

#

utility command maybe?

#

what about !fish

swift pumice
#

!fish

mossy jacinth
#

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...

slate swan
#

a timestamp is supposed to be relatively easier than doing what you are currently doing so

#

!d discord.utils.format_dt

unkempt canyonBOT
#

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...
mossy jacinth
robust fulcrum
#

Guys how we can make comamnd group in dpy pls tell anyone

slate swan
robust fulcrum
paper vector
#

how can i get all the members with a specific role

slate swan
slate swan
unkempt canyonBOT
paper vector
#

thx so much

mossy jacinth
slate swan
robust fulcrum
slate swan
robust fulcrum
#

@cogs.group?

slate swan
#

!d discord.ext.commands.Group

unkempt canyonBOT
#

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.
slate swan
#

the documentation help forshure

robust fulcrum
paper vector
slate swan
paper vector
#

oh

#

thx so much

slate swan
#

heelp

silk fulcrum
slate swan
#

um i want check the messga have int or not

slate swan
meager chasm
#

Python is intuitive, but that doesn't mean you can type whatever you want and expect it to do your bidding

silk fulcrum
#

@slate swan uhm... just to know..

slate swan
#

;/

slate swan
#

SO I PUT INT DONE

#

jeez

silk fulcrum
#

No need to shout

slate swan
#

I'm not even helping anymore, goodluck UniSips

meager chasm
#

Well written, If only people would read and follow it 😄

slate swan
silk fulcrum
slate swan
#

,

silk fulcrum
slate swan
#

no one want help me :(

slate swan
#

wtf]

silk fulcrum
#

you click the link and see what's in it

slate swan
#

yes

silk fulcrum
#

and what's in it?

slate swan
#

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```
meager chasm
# slate swan no one want help me :(

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.

silk fulcrum
#

no you didnt

slate swan
#

oop- caps

#

just saying you cant suceed by cutting corners

slate swan
silk fulcrum
slate swan
#

um

#

this what i get lol

#

this? def num_there(s): return any(i.isdigit() for i in s)

meager chasm
#

do you understand what that function does and how you can integrate it into your code?

slate swan
#

yes

meager chasm
slate swan
#

nope

silk fulcrum
# slate swan this what i get lol

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)

slate swan
#

i will not read all this

#

i busy ;/ rn

#

lol

rugged shadow
#

you guys are meanies 😠

slate swan
meager chasm
slate swan
#

this boring stuff

#

i don't want read it all

silk fulcrum
#

and you say you know basics of python

#

you cant even read something bigger than 300 symbols

slate swan
meager chasm
meager chasm
#

No, you read it, all

slate swan
slate swan
slate swan
#

dude i near get 600 line in pyhton without read it all Joy3D

#

dude no one want help me ;/ Joy3D

meager chasm
#

And you don't understand what any of those 600 lines do.

slate swan
#

WTF??? SO HOW I CODE??

silk fulcrum
slate swan
#

WTTF????

slate swan
meager chasm
slate swan
#

i know 95% of my code

#

😂

#

want check dm me Joy3D

silk fulcrum
#

i wanna see those 600 lines

slate swan
#

no one dms you all scared Joy3D

silk fulcrum
#

i thought you dm\

meager chasm
silk fulcrum
#

sure

slate swan
slate swan
meager chasm
#

no thanks 😄

slate swan
silk fulcrum
#

face reveal @meager chasm

#

that's his message

slate swan
#

um not all code working i sitll working in my code?

vale wing
#

I wrote a math parser and yet I don't understand how the hell it works

silk fulcrum
#

im not gonna read that code, it's just... one look is enough

slate swan
#

;/

#

really

#

ok then ask me

#

@meager chasm will get rekt

meager chasm
#

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

slate swan
#

@meager chasm get rekt

#

i know frist qustion

#

He so scared

#

scared cat

silk fulcrum
#

the think is that the code is so bad

slate swan
#

yes but it work

#

no lag and it work

silk fulcrum
#

gimme a sec

slate swan
#

good good

#

and test !fight???

slate swan
#

ye ye bullying bullying me good you bad :)

silk fulcrum
#

alright glhf at being not helped gonna make some command

slate swan
#

;/

#

:( 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

silk fulcrum
#

hi

slate swan
#

e

#

lol people start ignore me for no reason now

#

What happened?

slate swan
#

and i rekt him

slate swan
silk fulcrum
slate swan
silk fulcrum
unkempt canyonBOT
silk fulcrum
#

type argument

slate swan
#

Can you just typehint discord.File?

slate swan
silk fulcrum
meager chasm
slate swan
rugged shadow
silk fulcrum
slate swan
#

want see??

meager chasm
silk fulcrum
#

no his not trolling, that's just concept of 13 year old

slate swan
#

i rekt master and endysis too

silk fulcrum
#

idk how I passed it at 10-11

rugged shadow
slate swan
#

Cache is right

meager chasm
#

Well he's not supposed to be on discord then 😄

slate swan
slate swan
#

you 10

#

Lol

rugged shadow
#

And me, I think I passed that phase when I was 11, I'm 13 now :p

rugged shadow
#

Hmm... how do I know if I really passed that phase?

silk fulcrum
slate swan
#

I am not 10 my friend

slate swan
#

i mean to show you me 13

silk fulcrum
#

passport

slate swan
slate swan
rugged shadow
#

Topic is flying right now

slate swan
#

A????

rugged shadow
#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

slate swan
slate swan
#

PASSPORT AT 14?

silk fulcrum
slate swan
#

DOES YOU GUYS FROM USA?

#

bc usa is werido

silk fulcrum
#

depends on a country ig

slate swan
#

I'm in usa

#

dude you 13

slate swan
#

Not 14

#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

silk fulcrum
slate swan
slate swan
#

you from usa then?

silk fulcrum
slate swan
#

😁

silk fulcrum
rugged shadow
#

I don't think we're talking about Discord bots anymore guys 😔

slate swan
slate swan
#

no one

#

@silk fulcrum how print hello world

#

print('Hello world')

silk fulcrum
slate swan
#

ez wtf

silk fulcrum
#

didnt even get the joke..

rugged shadow
slate swan
#

on join:
send "you do dumb" to player

slate swan
vale wing
slate swan
#

you sitll block @slate swan

meager chasm
#

😂

rugged shadow
#

💀😂

slate swan
slate swan
rugged shadow
#

Also, grammar please

slate swan
#

:)

slate swan
vale wing
slate swan
slate swan
vale wing
#

😥

silk fulcrum
rugged shadow
slate swan
rugged shadow
#

And what does that have to do with anything

slate swan
#

i think me will ban

slate swan
slate swan
silk fulcrum
#

aight im blocking him. too bad play... there were two ways: much more toxicness or stop being dumb

slate swan
rugged shadow
slate swan
#

Do it then you won't

rugged shadow
#

watching for green buttons rn

silk fulcrum
#

not you

rugged shadow
#

😹

silk fulcrum
#

you are gud

slate swan
#

Not real!!

rugged shadow
#

only a few minutes until a mod arrives

slate swan
#

No, I do nothing

#

um

#

want any other proof?

slate swan
#

and you guys bullying for no reason

silk fulcrum
#

We did npthing, just trying to get blue sky to understand that he doesnt know enough python

slate swan
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

<@&831776746206265384>

slate swan
rugged shadow
#

Yea

slate swan
slate swan
#

Calm down buddy

#

Don't raise your tone at me

silk fulcrum
slate swan
#

this command

slate swan
rugged shadow
#

You have to understand the basics of asynchronous programming and Python itself to make bots

slate swan
slate swan
silk fulcrum
slate swan
rugged shadow
slate swan
#

PLZ STOP BULLY

slate swan
rugged shadow
slate swan
#

get rekt

rugged shadow
vale wing
#

Do we call mods

slate swan
silk fulcrum
slate swan
silk fulcrum
#

by blue sky

slate swan
rugged shadow
slate swan
vale wing
eternal fox
#

Wat is happening

slate swan
silk fulcrum
slate swan
#

????

slate swan
rugged shadow
#

gets proven wrong
"block message here"

slate swan
rugged shadow
slate swan
#

now shut up

slate swan
rugged shadow
silk fulcrum
#

!shhh :lemao:

slate swan
#

What is skript

vocal snow
tawdry karma
#

Who whay

silk fulcrum
#

aysnc skript def

slate swan
rugged shadow
slate swan
#

😭

slate swan
rugged shadow
#

inb4 someone forks CPython and adds skript kw

tawdry karma
#

TheBlueSky they are telling the truth

slate swan
#

WTF

low latch
#

what is happening here

slate swan
#

i see all blocked messages

rugged shadow
slate swan
rugged shadow
rugged shadow
#

^ my understanding of what's happening

slate swan
#

read statues

tawdry karma
slate swan
#

aadd to block list

tawdry karma
#

LOL

slate swan
#

who want join :)

#

all messages are block now but not francis

slate swan
slate swan
#

You have to be trolling

slate swan
#

no one truuuuuuust meeeeeeeee

tawdry karma
#

TheBlueSky block me forever?

slate swan
#

😭

#

so hooooooooow i writeeeeeeee 600 lines without know pyhton

silk fulcrum
rugged shadow
#

It's as if I'm looking at myself from 3 light years away

slate swan
tawdry karma
tawdry karma
#

Well then

slate swan
#

e

meager chasm
#

how hasn't this guy gotten banned yet 😂

slate swan
tawdry karma
rugged shadow
#

Don't know if that light year thing is true

#

Lemme check

slate swan
low latch
#

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

slate swan
#

lol

tawdry karma
#

He didn't know how to do
try: and except:

slate swan
slate swan
slate swan
rugged shadow
slate swan
visual island
#

just stop please

slate swan
rugged shadow
slate swan
visual island
#

all of you

low latch
#

can you take the pissing contest to one of the off topic channels please

slate swan
#

I'm going to sleep

low latch
#

!ot

unkempt canyonBOT
slate swan
rugged shadow
#

pissing contest 💀

slate swan
#

Okay

#

a

#

but i here for help

#

and no one want help me :(

#

Say your question

rugged shadow
#

And this time don't get mad

slate swan
#

Yes

slate swan
tawdry karma
#

LOL

supple thorn
slate swan
#

it should check if message have int or not right?

visual island
#

no

slate swan
#

lol

tawdry karma
#

no

supple thorn
#

No

slate swan
#

this what i was asking

#

...

#

And people start bullying

tawdry karma
#

Google it

rugged shadow
#

If content was a function then ig

tawdry karma
#

JUST GOOGLE IT

slate swan
rugged shadow
#

but it isnt'

slate swan
low latch
#

"google it" is not an accepted response here

visual island
slate swan
slate swan
slate swan
rugged shadow
#

!d str.isdigit

unkempt canyonBOT
#

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.
slate swan
#

^^^

rugged shadow
#

iterate over all characters in message.content, check if it's a number

tawdry karma
slate swan
#

let me reeadd

rugged shadow
#

though idk if that's efficient

low latch
#

@slate swan provide an example input/output

visual island
# unkempt canyon

that will check if the string is a digit, not if a digit is in the string

slate swan
#

Francis a goat

low latch
#

no, i'm a starfish

slate swan
#

o

silk fulcrum
#

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

slate swan
#

i think so :D

#

star fish = nice star LOl

#

me dumb

slate swan
silk fulcrum
slate swan
#

very nice to see alot of blocked messages

#

Yeah

silk fulcrum
#

it doesn't metter, it gave me same error when there was and when there wasn't

slate swan
#

e? will work