#discord-bots

1 messages · Page 768 of 1

quaint scaffold
#

You can send around 200 simultaneous API calls until your bot gets IP blocked, though this number is dynamic. I found that to be the limit

forest beacon
#

Wouldn’t instance passing voice channels be the same thing as just looking at text channels with guild.text_channels?

slate swan
forest beacon
#

Okay was just making sure there’s no preformance or api call count advantage lol.

quaint scaffold
#

*concurrently

round widget
#

well, Dan, Ashley, I'm still stuck with my emoticon. I've tried to send :white-check-mark:, \u2705, it still errors out with AttributeError: 'NoneType' object has no attribute 'add_reaction'

manic wing
quaint scaffold
#

Gifs are simply urls that expand into the video/photo.
As for emotes, you can declare them as a discord.PartialEmoji like this: emote = discord.PartialEmoji(name = 'foo', id = 123)

quaint scaffold
ebon island
#

I have a FastAPI app that's hosted in a docker-compose with my discord.py app - say I have a route

http://localhost:8000/test-route/

How do I make a post request properly to it? I got returned

ClientConnectorError: Cannot connect to host localhost:8000 ssl:default [Connect call failed ('127.0.0.1', 8000)]

with the following in aiohttp:

        async with aiohttp.ClientSession() as session:
            url = await session.post(f"http://localhost:8000/test-route/")

any ideas?

quaint scaffold
#

I'd recommend getting a help channel for that

#

That's more of a FastAPI issue

ebon island
#

Okay 🙂 Thanks!

round widget
quaint scaffold
#

Could you send your code please

round widget
#

yeah sure

quaint scaffold
#

huh your code should be fine, I don't use disnake but msg shouldn't be None

#

Perhaps you could ask in the disnake support server

round widget
#

honestly I've no idea what's going on, but I can't get it to work 😅

#

yeah that's a good idea, will check them out

desert ice
#

how do i define an emoji?

kindred drum
#

yo

#
 @commands.command(name="gamble")
    async def gamble(self, ctx):
        print("Gambling")
        channel = bot.get_channel(934495060987359272)
        message1 = await ctx.send("Test")
        message = await channel.fetch_message(message1)
        print(message)

returns this error In message_id: Value "<Message id=934496566448914462 channel=<TextChannel id=934495060987359272 name='gambling' position=41 nsfw=False news=False category_id=915357451484790917> type=<MessageType.default: 0> author=<Member id=915593618520158299 name='Cosmic Overground' discriminator='5232' bot=True nick=None guild=<Guild id=915357451484790916 name='Cosmic Overground (Private)' shard_id=None chunked=True member_count=10>> flags=<MessageFlags value=0>>" is not snowflake.

#

anyone got any idea

quaint scaffold
desert ice
#

nah

#

my english isnt good

#

not define

quaint scaffold
urban shell
#

hey y'all,
can someone help me regarding how to check if a member has left a particular vc, this is what I've tried so far -

@client.event
async def on_voice_state_update(member, before, after):
    if not after.channel and before.channel.id == vc_id:
        print('success!')
desert ice
#

<:emoji_name:emoji_id> i meant this @quaint scaffold

knotty badger
#

hey

#

im having trouble with slash commands

#
from pydoc import describe
from discord import Embed
import nextcord
from discord.ext.commands import Bot, Cog
from discord_slash import cog_ext, SlashContext
from nextcord.ext import commands
from nextcord import Embed

class slash(Cog):
    def __init__(self, bot: Bot):
        self.bot = bot
 
    guild_ids = [930186574078017597]

    @cog_ext.cog_slash(name="test", guild_ids=guild_ids)
    async def _test(self, ctx: SlashContext):
        embed = Embed(title="Embed Test")
        await ctx.send(embed=embed)


    @commands.Cog.listener()
    async def on_ready(self):
        print('Slash loaded!')
        
def setup(bot):
    bot.add_cog(slash(bot))
#

this is my code

urban shell
knotty badger
urban shell
knotty badger
#

it says that the cog is loaded

#

but it does not show up when i type /

urban shell
#

ic

knotty badger
#

soo any solution?

kindred drum
#

dw

#

yo how would I get a animated emoji link? like this one BlueAlert

urban shell
# knotty badger ```py from pydoc import describe from discord import Embed import nextcord from ...

I haven't worked a lot with discord_slash, but you can try this code mb -

import discord
from discord.ext import commands
from discord_slash import SlashCommand

intents = discord.Intents.all()
client = commands.Bot(command_prefix=".", intents=intents)
slash = SlashCommand(client, sync_commands=True)

guilds_ids = [930186574078017597]

@client.event
async def on_message(message):
    # Slash commands are an extra class but you can recognize them as commands as they got no message content using the on_message function


@slash.slash(name="test", guild_ids=guild_ids)
async def test(ctx):
    embed = Embed(title="Embed Test")
    await ctx.send(embed=embed)
urban shell
kindred drum
#

I got it

#

thanks tho

urban shell
#

aight

native wedge
#

i am trying to display the roles and channels of a server, i have 3 roles and 2 channels and it returns this:

#

i am using the len() function

#
@commands.command(name="serverinfo")
    @commands.cooldown(rate=1, per=30)
    async def serverinfo(self, ctx:commands.Context):
        embed=discord.Embed(title=f"{ctx.guild.name}", color=0x387ba2)
        embed.set_thumbnail(url=f"{ctx.guild.icon}")
        embed.add_field(name="Member Count", value=f"{ctx.guild.member_count}", inline=True)
        embed.add_field(name="Owner", value=f"{ctx.guild.owner}", inline=True)
        embed.add_field(name="Roles", value=len(f"{ctx.guild.roles}"), inline=True)
        embed.add_field(name="Channels", value=len(f"{ctx.guild.channels}"), inline=True)
        await ctx.send(embed=embed)
quaint scaffold
#

You are encapsulating the entire string in your len()

native wedge
#

oh

quaint scaffold
#

The .roles attribute will return a very long string of discord.Role objects. It'll be very long.

native wedge
#
embed.add_field(name="Roles", value=(len(f"{ctx.guild.roles}")), inline=True)```
#

?

quaint scaffold
#

Yes, but why are you encapsulating all of that in brackets?

#

You should learn Python, you are jumping from no fundamental knowledge to asynchronous bot programming

native wedge
#

where can i start python i have 0 programming knowledge

quaint scaffold
#

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

native wedge
#

ok

#

il come back when i have knowledge

slate swan
#

can someone help me

#
@bot.command()
async def nick(ctx, member : discord.Member = None, nick = None):
  if member == None:
    member = ctx.author
  await member.edit(nick=nick)
  await ctx.reply(f"Nickname was changed for {member.mention} ")
#

i want it so when u dont mention member

#

it changes ur nick

#

and when u mention a member it changes the members nick

quaint scaffold
#

Use Optional and an or

native wedge
# native wedge il come back when i have knowledge

i am now watching this 4 hour basics python course https://www.youtube.com/watch?v=rfscVS0vtbw

This course will give you a full introduction into all of the core concepts in python. Follow along with the videos and you'll be a python programmer in no time!
Want more from Mike? He's starting a coding RPG/Bootcamp - https://simulator.dev/

⭐️ Contents ⭐
⌨️ (0:00) Introduction
⌨️ (1:45) Installing Python & PyCharm
⌨️ (6:40) Setup & Hello Wor...

▶ Play video
quaint scaffold
#

!e py print(bool(None))

unkempt canyonBOT
#

@quaint scaffold :white_check_mark: Your eval job has completed with return code 0.

False
quaint scaffold
#

Here's a clue

slate swan
#

can u help me Dan

quaint scaffold
#

I just did

slate swan
#

where

native wedge
quaint scaffold
#

Ignore what I just said there, perhaps those videos are good for a start

#

But for more complex things, don't use videos

slate swan
quaint scaffold
#

!e py foo = None or 'hi' print(foo)

unkempt canyonBOT
#

@quaint scaffold :white_check_mark: Your eval job has completed with return code 0.

hi
quaint scaffold
#

And use Optional[discord.Member] for your typehint

slate swan
#

-_-

slate swan
#

pithink I'm so funny

#

please laugh

quaint scaffold
quaint scaffold
#

I'm trying to help you and you're just responding with -_-

slate swan
#

bro

#

i dont understand

#

thats supposed to work

quaint scaffold
#

Then tell me what you don't understand

slate swan
#

that optional thing

quaint scaffold
#

I'm not telepathic unfortunately

slate swan
slate swan
honest shoal
#

how can I have markdown support in my eval command

leaden hollow
#

anyway to limit button usage 1 per user in discord.py

quaint scaffold
leaden hollow
#

yeah would do so then

native wedge
#

what is considered basic knowledge for creating discord bots?

slate swan
manic wing
modern fiber
#

Guys how do I send emojis with bot?

#

is it like that?

manic wing
#

which it is

quaint scaffold
modern fiber
quaint scaffold
#

I hate to break the bad news to you, but RAM is volatile

spring flax
modern fiber
#

not an actual emoji red

#

it just appears as : red :

cold sonnet
#

whole path

manic wing
modern fiber
#

Help, it doesn't work uhh?

manic wing
#

depending on what Metal is doing

cold sonnet
#

!d discord.ext.commands.Bot.get_emoji

unkempt canyonBOT
quaint scaffold
#

I hate to break the bad good news to you, but persistent views exist

modern fiber
cold sonnet
#

perhaps try sending emojis with that method

manic wing
modern fiber
cold sonnet
#

he probably has that

cold sonnet
modern fiber
#

I do have those

#

@manic wing

manic wing
#

what have you passed into your bot=Bot(...)

#

what intents value

modern fiber
modern fiber
manic wing
#

what is intents

rustic onyx
#

does on_member_leave exist?

modern fiber
#

client = commands.Bot(command_prefix='.', intents=intents)

cold sonnet
#

the emoji intent is enabled by default

manic wing
unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
cold sonnet
manic wing
modern fiber
#

intents = disnake.Intents.default()
intents.members = True

rustic onyx
cold sonnet
cold sonnet
#

!d discord.Intents.emojis

unkempt canyonBOT
manic wing
cold sonnet
#

!d discord.Intents.emojis_and_stickers

unkempt canyonBOT
quaint scaffold
#

lolol

cold sonnet
#

why doesn't the tag say it

#

anyways

#

try the get_emoji method

manic wing
#

@quaint scaffold are you new to this channel? havent seen you around

quaint scaffold
#

I've started helping here a few days ago

cold sonnet
#

Caeden indeed good helpr :thumbsup_tone5:

quaint scaffold
cold sonnet
#

is this red emoji in your server?

#

lavox

manic wing
kindred drum
#
   for x in range(0,5):
            if number == 0:
                
                time.sleep(1)
                embed_dict = startMessage.to_dict()
                for field in embed_dict["fields"]:
                    if field["name"] == "STATUS":
                        field["value"] = "**ROLLING**"
                
                rolling = True
                if rolling == True:
                    e = 1
                    for x in range (0,100):
                        embed_dict = startMessage.to_dict()
                        for field in embed_dict["fields"]:
                            if field["name"] == "STAKE":
                                time.sleep(0.1)
                                field["value"] = str(e)
                                e = e + 1
                            ```
why does this not initiate the cool down periodically? right now it just waits 10 seconds then sends the message "100" instead of counting its way up
quaint scaffold
#

I do, when you use disnake and call someone inferior when you are wrong about a concept :)

latent anvil
cold sonnet
#

discord bots channel

quaint scaffold
cold sonnet
#

complete python code

slate swan
latent anvil
#

what is the newest ?

native wedge
#

You can use forks of it

cold sonnet
#

disnake prolly

slate swan
cold sonnet
#

disagree

slate swan
spring flax
manic wing
#

using a database is not necessarily the right answer

#

one can cache or log

quaint scaffold
#

Caches are volatile

manic wing
#

who said a) the bot was turning off b) it was a button that was going to be resilient

#

we lack context, therefore you are not correct

final iron
slate swan
manic wing
#
  • i am always superior
final iron
cold sonnet
#

nextcord has its issues

native wedge
cold sonnet
#

typehints

#

decorators

kindred drum
cold sonnet
#

SCOPING is important

slate swan
slate swan
#

time is sync and will stop your whole code

#

use

await asyncio.sleep(1.0)
#

which sleeps on the coro only

cold sonnet
#

yeah this

potent spear
kindred drum
kindred drum
potent spear
#

counting in general is a bad idea

slate swan
#

and you shouldnt compare something with bool

#

use is

cold sonnet
#
rolling = True
if rolling == True:```?
slate swan
kindred drum
pliant gulch
slate swan
#
if a is True:

and not

if a == True:
kindred drum
potent spear
potent spear
kindred drum
#

I wouldn't need to

cold sonnet
#

okay but that's just a community made habit

#

okimi

slate swan
#

not really

potent spear
#

editing messages every x seconds is a bad idea, there's a reason you haven't seen it in other bots

pliant gulch
#

They lock the bucket once it gets depleted

pliant gulch
#

Locking it won't let any other threads enter

potent spear
slate swan
#

you should always compare something with bool with is

native wedge
slate swan
pliant gulch
#

The handler only handles the ratelimits

native wedge
potent spear
slate swan
native wedge
potent spear
#

I won't ever change my examples

slate swan
potent spear
#

better than foo or bar or whatever they use in normal docs

slate swan
#

fax

potent spear
slate swan
#
@command(
    aliases=[
        "kickhammer",
        "userkick",
        "memberkick",
        "banmember",
        "banuser"
        ]
        )
async def kick(
    self,
    ctx: Context,
    member: Member,
    *,
    reason: str = "No Reason Provided"
    ) -> Optional[Message]:
    if ctx.author.id == member.id:
        return await ctx.send(
            f"{ctx.author.mention} you cannot ban yourself"
            )
    await ctx.send(
        f"Would you like to kick {member.mention}",
        view=KickConfirmation(
            ctx.author,
            member,
            reason
            )
            )

my commands look like this to follow pep8😭

cold sonnet
#

command = bot.command?

slate swan
cold sonnet
#

commands.command

#

makes sense

#

just saw the self

slate swan
#
from disnake.ui import (
    View,
    button,
    Button,
)
from disnake.ext.commands import(
    Cog,
    Bot,
    command,
    Context
)
from disnake import (
    MessageInteraction,
    Member,
    ButtonStyle,
    Message
)

from typing import Optional
slim ibex
#

🧐

potent spear
#

import with () ?

slate swan
cold sonnet
slate swan
potent spear
#

never seen that

slate swan
slate swan
slim ibex
#

just for a lot of imports

slate swan
#

very nice

slim ibex
#

Can’t say I use that feature though

potent spear
#

it's optional
like if (shit):
ig

cold sonnet
#

and why are you typehinting ctx

slim ibex
#

^

potent spear
#

ig for the autocomplete / intellisense

slate swan
#

cause i did

ctx: Context
#

i went all out

cold sonnet
#

if member == ctx.author is also enough blobthinkmad

pliant gulch
pliant gulch
potent spear
cold sonnet
#

and you missed a ? in the last send() 😠

livid cosmos
#

how can i add slash commands to my bot?

pliant gulch
#

And it also handles 429s (ratelimit) responses to stop you further afterwards

slim ibex
slate swan
#

im not missing anything lol

cold sonnet
#

what

#

Would you like to kick this member

potent spear
pliant gulch
slate swan
pliant gulch
#

It HANDLES the ratelimits

slate swan
#

like confirm and cancel

slate swan
cold sonnet
#

hm

slate swan
# cold sonnet hm

and i pass the author and the member and the reason to the view class and i do it within the View subclass

keen talon
slate swan
cold sonnet
#

I would like to learn using buttons so much

cold sonnet
#

I'll start doing that

manic wing
slate swan
#

i know about buttonspithink

cold sonnet
cold sonnet
keen talon
cold sonnet
#

definitely

slate swan
# cold sonnet I don't
class KickConfirmation(View):
    def __init__(
        self,
        author: Member,
        member: Member,
        reason: str
        ) -> None:
        self.member = member
        self.author = author
        self.reason = reason
        super().__init__(timeout=60.0)
    
    async def on_timeout(self) -> None:
        self.stop()
    
    async def interaction_check(
        self,
        interaction: MessageInteraction
        ) -> bool:
        if interaction.author != self.author:
            return False
        return True
    
    @button(
        label="Confirm",
        style=ButtonStyle,
        emoji="✅"
        )
    async def confirmcallback(
        self,
        interaction: MessageInteraction,
        button: Button
        ) -> None:
        await interaction.send(
            f"You have Confirmed to kick {self.member.name}",
            ephemeral=True
            )
        await self.member.kick(
            reason=self.reason
            )
        self.stop()

seepithink

#

basic buttonpithink

manic wing
#

okimii

cold sonnet
#

copied the whole thing

slate swan
#

no

cold sonnet
#

now I have your code

quaint scaffold
#

dude wtf is that

cold sonnet
#

beware

slate swan
#

🏃

manic wing
#
async def on_timeout(self) -> None:
        for child in self.children:
            child.disabled = True
``` this wont actually make the buttons disabled - you need to edit the message
slim ibex
#

thanks for the code g

cold sonnet
#

I'm a professional stackoverflow copy paster

slim ibex
#

allow me to redistribute

cold sonnet
slim ibex
slate swan
#

🧠

quaint scaffold
#

Is your code written like that as a joke?

quaint scaffold
#

Or do you genuinely try to make it as long as possible

keen talon
cold sonnet
#

yeah, better devs only know better what to copy paste

slate swan
#

i have to follow pep8s max line

quaint scaffold
#

You don't have to follow shit

slate swan
#

yes

#

i do or else🧑‍🦯

quaint scaffold
#

Devise your own style of programming, take what you find useful from PEP8

cold sonnet
slim ibex
#

seems like we have an anti-statictyper

keen talon
slate swan
slate swan
slim ibex
#

static typing is so satisfying doh

#

seeing all the type hints 😩

keen talon
slate swan
#

i did it at 4am last night so i was high

keen talon
cold sonnet
boreal ravine
slate swan
#

@manic wing i used jarvide for the imports so dont sue me

cold sonnet
#

what

#

all I'm saying is that it has its issues

keen talon
slate swan
#

caeden is the type of guy who would

keen talon
#

Take care of your health 🙂

slate swan
#

programming > sleep

keen talon
boreal ravine
#

!ot

unkempt canyonBOT
slate swan
cold sonnet
#

thats not nice

keen talon
slate swan
cold sonnet
#

sorry

slate swan
#

just subclass the bot class in your about me🧠

boreal ravine
keen talon
slim ibex
#

_BotBase

boreal ravine
#

the amount of times this chat has gone off-topic is wild

cold sonnet
#

nobody's asking for help

slate swan
#

were all humans give us a break

cold sonnet
#

are you?

#

we will help you

slim ibex
slate swan
#

were all friendly unlike the dpy server🏃

slate swan
cold sonnet
#

true

slim ibex
#

what if we are cyborgs but look like humans

slate swan
cold sonnet
#

well made and well reasoned

keen talon
#

🙂 🙂

slate swan
slim ibex
#

And we eliminated humans a while ago

cold sonnet
slate swan
keen talon
slim ibex
#

But the government wants to hide that

#

because the government

slate swan
#

and pigeons are russian spies with cameras and batteries

keen talon
slim ibex
keen talon
#

One of my fav gif nowadays

cold sonnet
#

y'all have to stop watching c# stackoverflow codes

slate swan
slate swan
keen talon
slate swan
#

:hmmcat:

slim ibex
#

runs in Python, c# and rust

slate swan
keen talon
slate swan
#

runs in shoes

slim ibex
#

Runs on basketball court

keen talon
#

Lol

slate swan
#

**levitates ** 🕴️
___________________________________________

cold sonnet
#

who wants to teach me buttons

slate swan
#

basic subclassing

keen talon
slate swan
keen talon
#

Battery on 20%

cold sonnet
keen talon
cold sonnet
#

meet you in 3 hours

slate swan
#

🧠

cold sonnet
#

infront of the school

slate swan
pliant gulch
#

Be smart and read the source code to see how to use them

#

😳

slate swan
slim ibex
#

class Buttons(lib.ui.View):
def init(self):
super().init()

@ui.button()
#

Shit I tagged someone

pliant gulch
#

no it's just easy to read the source code

slate swan
pliant gulch
#

I find them better than examples

slim ibex
#

mhmm ik

slate swan
slim ibex
#

I’m on phone so I’m not gonna bother to add

slate swan
#

i should do thatpithink

hoary cargo
#

_ _

slate swan
boreal ravine
slate swan
boreal ravine
#

what

#

what children??

slate swan
#

a list of components?

#

!d disnake.ui.View.children

unkempt canyonBOT
pliant gulch
#

Without the constructing the super classes constructor, you won't have the children attributes

#

Unless otherwise giving it to your subclass

slate swan
#

yeah

pliant gulch
#

And internally your wrapper of choice will iterate through the children of your view to add them

#

Thus either way, constructing the super class or adding the attribute manually is needed

slate swan
#

🚶

pliant gulch
#

and my old wrapper does that as well

slate swan
#

nice

cold sonnet
#

understanding what you just said would be sexy

slate swan
#

boi wut

#

🚪⬅️

cold sonnet
#

sure

cold sonnet
#

those indents

boreal ravine
#

only call super when using methods/attrs from the subclassed class

pliant gulch
slate swan
boreal ravine
slate swan
#

^

pliant gulch
#

Yes disnake seems to have fixed this

boreal ravine
pliant gulch
#

If you take a look at discord.pys examples you see them call the super classes constructor

cold sonnet
#

if you wouldn't use them, they wouldn't be written

#

🧠

boreal ravine
#

that is what I just said

cold sonnet
#

so you basically said to use super

boreal ravine
#

no?

#

only call super when using methods/attrs from the subclassed class

cold sonnet
#

yes

boreal ravine
#

yes

pliant gulch
unkempt canyonBOT
#

disnake/ui/view.py lines 154 to 159

def __init_subclass__(cls) -> None:
    children: List[ItemCallbackType] = []
    for base in reversed(cls.__mro__):
        for member in base.__dict__.values():
            if hasattr(member, "__discord_ui_model_type__"):
                children.append(member)```
pliant gulch
#

They iterate through the methods of your subclass

#

and the decorator marks the callbacks you make as components

cold sonnet
#

so what do you actually need

pliant gulch
#

Differs from wrappers, if you are using discord.py you do indeed need to call the super classes constructor, if your using disnake you don't need to

cold sonnet
slate swan
#

huh

boreal ravine
cold sonnet
#

in cogs, defining the bot as self.bot is needed

slate swan
cold sonnet
#
  • your own stuff are optional
slate swan
#

thats a subclass of View which doesnt need bot lol

cold sonnet
#

here, in views, everything's optional

cold sonnet
slate swan
#

then why say about self.bot lol

cold sonnet
#

cuz I wanna know if anything's necessary

slate swan
#

ah

cold sonnet
#

so I used an example to define what I meant

slate swan
#

well no bot isnt needed

gentle badger
#

Where to put it?

cold sonnet
#

member=discord.Member=None

#

:thumbsup_tone5:

gentle badger
#

Where to put it

slate swan
gentle badger
#

I new

cold sonnet
#

I don't want to see that

slate swan
#

!pep 484

unkempt canyonBOT
#
**PEP 484 - Type Hints**
Status

Provisional

Python-Version

3.5

Created

29-Sep-2014

Type

Standards Track

cold sonnet
#

never again

slate swan
pliant gulch
#

member= 👁️👁️

slate swan
cold sonnet
#

and you didn't put an n to make it incorrect

slate swan
#

wut

cold sonnet
#

I basically took it from you

#

I took your n

slate swan
#

where

cold sonnet
#

never(ever) again

#

me either(neither)

slate swan
#

oh

#

ngl the example that was given is horrible

cold sonnet
#

can you even make an embed without a description

gentle badger
#

How I mention in embed message the user using the command

slate swan
#

and with f string in the description

gentle badger
#

Yes I think

cold sonnet
#

you can't do that in the title!!4!!!4!

slate swan
#
f"{ctx.author.mention} hello"
slate swan
cold sonnet
#

I pointed it out

slate swan
#

yeah ik

cold sonnet
#

teamworks makes perfect

slate swan
#

yes

slate swan
cold sonnet
#

no homo

slate swan
#

only for the homies

#

😳

cold sonnet
#

right

slate swan
cold sonnet
#

wait what

#

bro no

slate swan
#

😔

#

but bro

cold sonnet
#

no

slate swan
#

yes bro😔

cold sonnet
#

🤫

slate swan
#

😉

quick gust
#

!ot

unkempt canyonBOT
native wedge
#

i found the solution

cold sonnet
#

we're done

slate swan
#

😠

quick gust
slate swan
cold sonnet
#

and for what problem

quick gust
#

jk

slate swan
#

you are superior sorry master

native wedge
# cold sonnet what is it

i tried to use len() to find the number of roles in a server, i realized i had to make a new variable to use () correctly and just make a new field displaying the variable i made

quick gust
devout iris
#

How can i use config.json data??

slate swan
cold sonnet
#

not here

#

@devout iris

devout iris
#

i want to use config.json for take prefix or smthng

slate swan
#

use a db

#

json is for formatting data not storing

devout iris
#

i know

slate swan
#

then why use it

devout iris
#

Cus my datas are fixed

#

Not changable prefix ....

slate swan
#

just use mongo its close to json

#

if you want a json alike

cold sonnet
devout iris
slate swan
devout iris
devout iris
cold sonnet
#

bot = commands.Bot(command_prefix="!")

slate swan
devout iris
slate swan
#

json is not for storing data.

cold sonnet
#

okay but if you can't change the prefix then why store it in a json

#

why not just put it in the kwarg

devout iris
slate swan
#

then why not use a db.

devout iris
cold sonnet
devout iris
slim ibex
#

databases are easy no kappa

cold sonnet
#

once starting a career as a programmer, no one will allow you to use a json

slate swan
cold sonnet
#

for a db

gentle badger
slate swan
slim ibex
#

SQl is not hard and is very useful

slate swan
slim ibex
#

well it gets harder when you have to long queries with joins and shit lmao

devout iris
slim ibex
#

uhh

slate swan
slim ibex
#

nobody uses json for storing data

gentle badger
slate swan
slim ibex
#

^

cold sonnet
slate swan
slim ibex
#

use sqlite

slim ibex
devout iris
#

K i'm gonna try then thx :))

gentle badger
cold sonnet
slate swan
cold sonnet
#

not ctx.author

slate swan
#

basic oop

slate swan
slim ibex
#

postgres > all

devout iris
gentle badger
#

mention the user using the command

slim ibex
#

mongo is a document db

slate swan
slim ibex
#

it’s similar to json

slate swan
#

really doesnt matter lol but sql is like more standard tbh

slim ibex
#

but rdbms’s are more generally used

keen talon
potent spear
#

use an object oriented/rdbms db, since that's parallel with dpy

cold sonnet
slate swan
slim ibex
#

Choose from:

  • MySQL
  • sql server
  • MSSQL
  • oracle
  • SQLite
  • postgresql
#

SQLite is prolly best for beginner

potent spear
#
  • async wrapper
slate swan
#

but if you are use their async bridges ofc

slim ibex
#

^

#

aiosqlite and asyncpg

slate swan
#

yes

slim ibex
#

A guy in #databases said you don’t need async bridge

#

I was like bro

slate swan
#

bruh

devout iris
slim ibex
#

He said “blocking is not necessarily bad”

devout iris
#

Also mySQL and SQL are different??

slim ibex
#

SQL is the language used to make wqueries

slate swan
slim ibex
#

MySQL is a database

slate swan
#

^

slim ibex
#

my backend skills coming out 😮

devout iris
#

Ahh 🤦🏻

#

Thx

potent spear
#

just check out sql, start from there

slim ibex
#

^

devout iris
#

What about noSQL?

devout iris
slim ibex
#

NoSQL are Dbs like mongo

potent spear
slim ibex
#

Document databases

#

but yeah don’t worry about that lmao

slate swan
devout iris
#

K then

potent spear
#

if you know how to set up tables(decent db structures) and do CRUD operations, you're golden as a beginner

slate swan
#

if you know how to update, add, take, delete data youre good

slim ibex
#

Triggers

gentle badger
#

How fix that

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

cold sonnet
slate swan
#

🧍‍♂️

potent spear
slate swan
#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

slim ibex
#

Don’t worry about joins and shit

slate swan
#

a pain

slim ibex
#

you’ll not use that a lot in a simple bot

slate swan
#

yeah

cold sonnet
#

use the sfuff you actually have

slim ibex
#

Speaking of async bridges

#

I need to change my bot SQLite to aiosqlite

slate swan
#

its easy

#

just a bunch of awaits

#

^ easy to learn

slim ibex
#

ik

#

Why does “async with” sound so badass

slate swan
#

nah youre crazy

gentle badger
cold sonnet
#

did you put the f there

slim ibex
#

🙃

slate swan
#

read my about me

slate swan
gentle badger
cold sonnet
#

great

slate swan
#

i told it many times stop ignoring me😠

cold sonnet
#

hah

#

ignored

slate swan
#

read my about me smh😠

gentle badger
slate swan
#

or this

#

not sure whats it called

cold sonnet
#

why is it in a code block

slate swan
#

Inline code blocks

slate swan
#

thank you

#

and the top msg isnt how you mention a user

#

@pastel pike is how you do it

#

Considering you have ID, I guess you can simply use .mention

#

^

gentle badger
#

Thanks

#

But I need more help

#

With this

cold sonnet
#

you have 2782 pings

slate swan
#

LMAO

gentle badger
#

?

#

What?

slate swan
cold sonnet
#

well what's the code for the reason field

#

didn't you mean

#

value=reason

slate swan
#

dont ask to ask

#

just say

gentle badger
cold sonnet
gentle badger
#

DRG מאתה עושה פה?

slate swan
#

Please English only.

gentle badger
cold sonnet
#

assuming your variable is named reason

cold sonnet
slate swan
#

omggggggggg

slate swan
cold sonnet
#

use db

slate swan
#

that wouldve been funny

#

why tomorrow

#

What do you get as output.

#

What is saved in the variable words

cold sonnet
#

repl and json

slate swan
#

How does your JSON file look like.

#

What is the content of the gradepoints.json

#

Completely empty?

keen magnet
#

hello im new to python and im looking for help for my boot

#
@bot.command()
async def unban(ctx, member:discord.Member = None):
    if (member == None):
        await ctx.send("Vous devez entrer un @ d'utilisateur valide.")
    else:
        await member.unban()
        await ctx.send("Vous avez débanni {member} !")```
slate swan
#

You need to have at least {} in that file.

with open("gradepoints.json", 'w') as f:
  user[str(grade.id)]['points'] = user[str(grade.id)]['points'] + 1
with open('gradepoints.json', 'w') as f:
  json.dump(user, f)

Why opening twice the file when you can directly overwrite (.dump()) it after increasing the amount by 1?

keen magnet
#

i don't understand why it is not working if anyone can explain me thanks

#

my error is: discord.ext.commands.errors.MemberNotFound: Member "@tall sandal" not found.

slate swan
slate swan
#

do you have members intents?

#

it doesn't matter.

#

You open the same file twice.

#

Open it only once and do your manipulation.

keen magnet
slate swan
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

wut

#

Well, there's one small issue.

#

theres a cooldown

#

You never read the file content :p

gentle badger
#

How do I do the reason?

slate swan
#

Add your variable after =

cold sonnet
gentle badger
#

No, the reason they called the staff I'm doing a command to call the staff

slate swan
cold sonnet
#

he don have it

slate swan
#

and thats a coro lol

slate swan
cold sonnet
#

me ignored

slate swan
#

+=

#

first

gentle badger
slate swan
#

As I said.

gentle badger
#

how i fix the ''REASON ''

slate swan
cold sonnet
#

you can set a bracket

slate swan
#

means

a += 1

a = a + 1
potent spear
#

it's just + 1, not +=1 probably
you're doing
shit = shit += 1
just do
shit += 1

slate swan
cold sonnet
#

remove the last equal to sign

devout iris
#

How can i add reaction if message == "....":

slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

aaaaaa
slate swan
#

However, consider using commands.

slate swan
potent spear
devout iris
slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | 3
002 | 3
gentle badger
#

If someone
can help me fix the reason send me in DM how

devout iris
cold sonnet
#

he's the ignorant one

slate swan
slate swan
potent spear
slate swan
#

!e

my_str = "!help aaaaaa bbbb"

print(" ".join(my_str.split(" ")[1:]))
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

aaaaaa bbbb
slate swan
#

However, consider using commands.

#

we cant spoonfeed you smh

devout iris
slate swan
gentle badger
slate swan
devout iris
#

Smh, ty

gentle badger
slate swan
#

What I printed would be your reason argument.

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

cold sonnet
potent spear
slate swan
#

Replace my_str with message.content

cold sonnet
#

read traceback

gentle badger
devout iris
potent spear
devout iris
#

Hmmm

potent spear
#

2 things you can learn from it

  1. which line
  2. why
slate swan
#

Much more actually

potent spear
#

I just summarized the main ones

cold sonnet
gentle badger
potent spear
gentle badger
#

NOT WORK

cold sonnet
#

and the line, in which the error appeared, is also there

gentle badger
slate swan
devout iris
#

👍

potent spear
slate swan
#

Do you see this anywhere in your code?

#

With my_str replace to message.content

#

I don't think so..

devout iris
#

Also can i use lower() func with aliases?

potent spear
slate swan
#

It's not what they want.

slate swan
potent spear
slate swan
gentle badger
cold sonnet
#

tho he's here without that knowledge

slate swan
#

Was it so hard to replace one thing?

cold sonnet
#

so that's not easy either

slate swan
#

Not put value= and that thing.

potent spear
gentle badger
#

@slate swan אתה יכול לעזור לי עם משהו עם אמר?

#

לא הבנתי בשיט.

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

cold sonnet
#

ENGLISH

rustic onyx
#

what does message return in a message listener?
Like I know content is one, which are the others?

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

x != y Checks if two messages are not equal.

hash(x) Returns the message’s hash.
cold sonnet
#

take a look yourself

rustic onyx
#

ty sir

cold sonnet
#

yw

slate swan
potent spear
cold sonnet
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

slate swan
#

We don't do this type of help. As per rule 9.

potent spear
#

just ask ig

spring flax
#

Of course that's what this server is for

slate swan
#

It will be much easier for you.

rustic onyx
#

How can I avoid the bot from adding {} and "" ? I'm using {message.author.mention} and {message.content}

potent spear
#

you have to think about it again
your thought process should be like this

  1. open json and read the data
  2. edit the data
  3. dump the edited data back to the json
cold sonnet
#

never seen again

teal marten
#

Can someone recommend a database that's the closest to just using JSON?

I don't need it to be heavy duty, it's for a trading bot and I just want to memorize positions if the bot is reset or shutoff briefly.

The key is just ease of use and simplicity

slim ibex
#

use sqlite

#

not close to json but its prolly best for beginners

potent spear
#

async wrapper tho

slim ibex
#

^

#

you will need to learn basic SQL

slate swan
slim ibex
#

that would be the closest

#

or some nosql db

cold sonnet
#

but sql is superior

slim ibex
#

yer

rustic onyx
slate swan
#

It will work. Want me to prove it by making a command?

#

If you do value=message.author.mention, which is what I've said, it will work. If you put value="message.author.bot" of course it won't work.

potent spear
#

a variable vs a string brainmon

#

they're both strings actually, but yeah

slate swan
#

Well if you don't use it correctly of course it won't work.

potent spear
#

logic involved 😉

devout iris
#

is embed.edit() will work?

#

embed.edit(embed = embed)

slate swan
#

It's message.edit()

devout iris
slate swan
#

Yes

cold sonnet
#

yes

slate swan
#

.edit(embed=embed)

cold sonnet
#

edit completely removes everything

slate swan
#

But it only works on a Message object

cold sonnet
#

and then sends in what's passed in

devout iris
#

Need add message param?

cold sonnet
#

no

slate swan
#

Not a parameter.

#

You use the method on a message object.

devout iris
slate swan
#

Well you need a message variable..

devout iris
#

Message = embed?

slate swan
#

No.

devout iris
#

How then

slate swan
#

What are you trying to do exactly?

devout iris
#

i want to make a time counter, if i use reboot command, bot will count from 5 to 0 and when it's 0, it will reboot

slate swan
#

How does the command look like, like the code.

#

You can maybe get the message object you need based on what you did above.

devout iris
#

i'm really confused about that lol

slate swan
#

Okay so, you will need to send the first embed.

#

When you send it, it returns a message object that you can later edit.

devout iris
#

Hmmm

slate swan
#
msg = await ctx.send(..)
#

Then you can use .edit() on msg.

devout iris
#

Sent 2 message and stayed at 1

dry kelp
#
class InteractiveView(discord.ui.View):

    def __init__(self, ctx):
        super().__init__(timeout=10)
        self.expr = ""
        self.calc = simpcalc.Calculate()
        self.ctx = ctx

    async def interaction_check(self, interaction: discord.Interaction):
        if interaction.user != self.ctx.author:
            await interaction.response.send_message("Um, Looks like you are not the calculator author...", ephemeral=True)
            return False
        else:
            return True

    async def on_timeout(self):

        for button in self.children:
            button.disabled = True

        await interaction.response.edit_message(view=self)

        await self.ctx.send("Um, Looks like the calculator has expired!")
slate swan
#

You only send it once, then you edit it.

dry kelp
#

buttons wont get disabled

#

i am trying to work on this

#

but idk how to do it in another way

devout iris
slate swan
#

And yes it stayed at 1, since you made your loop do it.

slate swan
#

!e
for x in range(0, 5):
print(x)

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
slate swan
#

interaction has the send attr

#

See how it doesn't stop at 5 but 4?

slate swan
devout iris
#

Ah yes 🤦🏻🤦🏻🤦🏻🤦🏻

native wedge
#

how do i make it so the timestamp on an embed is when the server was created? i only know about

embed=discord.Embed(color=0x387ba2, timestamp=ctx.message.created_at)```
#

i cant seem to find it on the disnake docs

slate swan
#

It's exactly the same.

#

!d disnake.Guild.created_at

unkempt canyonBOT
slate swan
#

And you have a Guild object in ctx.guild.

devout iris
native wedge
slate swan
slate swan
native wedge
devout iris
#

!e
for i in range(4,0,-1)
print(i)

unkempt canyonBOT
#

@devout iris :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     for i in range(4,0,-1)
003 |                           ^
004 | SyntaxError: expected ':'
devout iris
#

!e
for i in range(4,0,-1):
print(i)

unkempt canyonBOT
#

@devout iris :white_check_mark: Your eval job has completed with return code 0.

001 | 4
002 | 3
003 | 2
004 | 1
devout iris
#

Nice

slate swan
#

Now you know the small edit to do ^^

leaden jasper
#

When will discord change intents?

slate swan
#

Change intents?

devout iris
#

how can i fix these errors?

potent spear
devout iris
#

decode errors

leaden jasper
#

well yea in 2022

#

but which month