#discord-bots

1 messages Β· Page 1146 of 1

slate swan
#

the rest of the functions is working

sick birch
#

What do you mean by "wrong moments"?

dull tide
#

I have json file:

{"996181533356462200":{"t":15},"996178824540737598":{"t":13}}

I want to change the values of each message to 1, so that I can delete messages later when the value is 0, but I don't know how to change the values by picking up the ID of messages. (python)

slate swan
#

at the same time

sick birch
#

So "this user doesn't have ban" and "user is now whitelisted" at the same time?

slate swan
#

yes

sick birch
#

Hmmm

#

That's odd because the else block is supposed to run if there is no error in the try block

slate swan
#

there is no error

remote hatch
#

can somebody help me to fix?

slate swan
#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

dull tide
# dull tide I have json file: ```json {"996181533356462200":{"t":15},"996178824540737598":{"...

I tried this but gave an error

allow_channels = [47283746372828,294746292934]
with open("json.json","r") as f:
    j = json.load(f)
for idq in j:
        if j[str(idq)]["t"] > 0:
            j[str(idq)]["t"] -= 1
        if j[str(idq)]["t"] == 0:
            for cid in allow_channels:
                channel = client.get_channel(cid)
                message = await channel.fetch_message(idq)
                print(f"{cid}")
                await message.delete()
            del j[str(idq)]
    with open("json.json","w") as f:
        json.dump(j, f)
OUTPUT:
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message
sick birch
#

You're deleting the message inside the for loop

#

So it successfully deletes the first time, but the 2nd time it'll throw an error because you're trying to delete a message that's already been deleted

flat solstice
#

So I have this func which I'm calling from both a slash command and a context menu but when I call it the interaction fails bc role is apparently None which I find weird bc I have the exact same code elsewhere applying the role and it's working finepy async def end_further_support(interaction: Interaction, user: Union[User, Member] = None): log.critical(f"Role ID: {client.config.FURTHER_SUPPORT_ROLE}") role = interaction.guild.get_role(client.config.FURTHER_SUPPORT_ROLE) log.critical(f"Role Object: {role}") if role is None: log.error(f"Could not find a role with ID '{client.config.FURTHER_SUPPORT_ROLE}', it's returning 'None'") try: await interaction.user.remove_roles(*[role], reason="User no longer needs further support",) except Forbidden as e: log.error(f"Could not remove '{role.name}' from '{user.name}', bot has insufficient permissions\n{e}") except HTTPException: log.error(f"Could not remove '{role.name}' from '{user.name}', adding the roles failed\n{e}") await interaction.response.send_message(f"Successfully removed {user.mention} from {role.mention}.", ephemeral=True,) but as you can see in the logs it can see the role ID.
Logs: https://paste.pythondiscord.com/mocahasewe
I'm running this on Ubuntu but when I run the code locally on Windows it works fine. This is how I'm applying the role if your curious https://github.com/SnowyJaguar1034/ModMail-FAQ/blob/371d790108d3a8310e4049bf2893360231388b79/classes/fsupport_button.py#L42-L65

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
flat solstice
faint sapphire
#

im using replit free version, and wanna keep the bot alive
i was using this method, but then would get errors i should use a wsgi server

so ive got this script now, but idk how to use uptimerobot to keep pinging the bot

remote hatch
#

what should i put to the bot send the embed when i make the "/roll"?

sick birch
faint sapphire
sick birch
#

Well I'll add that to my list of channels to not recommend for discord bots then. That's kind of unfortunate really

flat solstice
# slate swan so ubuntu read it as a string?

yep, which it really is as it's a variable in a environment file but Windows was doing some black magic to convert the string to int without being asked as it knew what type get_role wanted.

slate swan
#

i use int over os.getenv(key)/os.environ[key] in these cases just to double check.

slate swan
#

where can I find the docs for d.py 1.7.0?

slate swan
dusky pine
#

why are you still using 1.7.0

#

move over to 2.0 or some fork lol

slate swan
#

How do you get the icon url in 1.7.0? Is it just ctx.guild.icon_url ?

hidden snow
#

hey im trying to make something that will print something to the console every time a member joins, from what i understand this is how ur supposed to do it, it doesnt seem to be working for me

client = discord.Client()

@client.event
async def on_member_join():
    
    print('A member joined the server')
unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

why are you in 1.7.0????????

slate swan
#

and yes you're correct

#

can you set guild's icons using that though?

#

Like icon=ctx.guild.icon_url

#

theres probably a method for it just check 1.7.0s docs

#

πŸ₯Ί

#

docs on mobile is a pain 🀞

#

Seems like I need the byteslike object to set the icon

shrewd apex
gentle sphinx
#

Hello

#

I'm having difficulties with my Discord Bot...

#

I'm trying to make a ping command but for some reason it isn't showing up.

slate swan
# shrewd apex u can

no that wouldn't work, It has to be a bytes-like object. so I just made a request to the guild icon url and set the data content as the icon

slate swan
gentle sphinx
#

My Main.py file:

import disnake
from disnake.ext import commands

client = disnake.Client()


@client.event
async def on_ready():
    print(f'We have logged in as {client.user}')


@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('Hello'):
        await message.channel.send('Hello!')

bot = commands.Bot(
    command_prefix='!',
    test_guilds=[996245432931995720],  # Optional
    sync_commands_debug=True
)

bot.load_extension("commands.ping")

client.run('**********')

My ping.py file located in a commands folder:

import disnake
from disnake.ext import commands


class PingCommand(commands.Cog):
    """This will be for a ping command."""

    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.slash_command()
    async def ping(self, inter: disnake.ApplicationCommandInteraction):
        """Get the bot's current websocket latency."""
        await inter.response.send_message(f"Pong! {round(self.bot.latency * 1000)}ms")


def setup(bot: commands.Bot):
    bot.add_cog(PingCommand(bot))
shrewd apex
slate swan
visual island
#

@gentle sphinx did you enable application.commands scope when inviting the bot?

slate swan
shrewd apex
#

requests is blocking

#

use aiohttp then

gentle sphinx
slate swan
#

How would you do it with bytesio? @shrewd apex

shrewd apex
#

bytesio is not necessary actually i used it coz i needed to use it with pillow

#

u can just use aiohttp

shrewd apex
#
set_footer(*, text=None, icon_url=None)
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Parameters
text (str) – The footer text. Can only be up to 2048 characters.

icon_url (str) – The URL of the footer icon. Only HTTP(S) is supported.
gentle sphinx
slate swan
#

your issue is youre not even running your bot

#

youre running your client instance

shrewd apex
#

slash commands dont have cogs do they?

gentle sphinx
#

What? I'm confused πŸ˜…

shrewd apex
#

just ignore me i am not sure i havent used slash before

slate swan
#

you made a discord.Client instance which youre running

#

delete the client variable and replace client.run with bot.run and others

gentle sphinx
#

Right...

#

Hey that's awesome it works now! Tysm

slate swan
#

youre welcome

#
\u001b[30;1m A
#

hmm dont know what im doing wrong

gentle sphinx
#

I have a question, I'm using Disnake but I'm not sure if there's a better API I should be using or if Disnake is bad. Is there a better API I should be using instead?

slate swan
#
\u001b[0;40m\u001b[1;32mThat's some cool formatted text right?
\u001b[1;40;32mThat's some cool formatted text right?
#

hmm nope

slate swan
gentle sphinx
#

Well what do you recommend using? πŸ™‚

slate swan
#

i used disnake myself

#

i like their impl tbh

gentle sphinx
#

Well you say 'used' which one do you use now?

shrewd apex
slate swan
gentle sphinx
#

Ah

slate swan
#

so the last lib i used is disnake

gentle sphinx
#

I'll give hikari a try and see if I like it better.

slate swan
#

its structure is quite good and unique but can be complex if you dont have experience

gentle sphinx
slate swan
gentle sphinx
shrewd apex
#

i once asked which is better discord.py or hikari in dpy server they kept talking in circles 🀣

gentle sphinx
slate swan
slate swan
shrewd apex
slate swan
slate swan
rain olive
slate swan
#

he hates forks because of their impl which is something you would expect with a public lib

slate swan
#

noone will ever know \πŸ—Ώ

#

but clearly he has commited to some so idk

hidden snow
#

hey i sent this before but didnt get a response hence the repost but im trying to make something that will print something to the console every time a member joins, from what i understand this is how ur supposed to do it, it doesnt seem to be working for me
client = discord.Client()

@client.event
async def on_member_join():

print('A member joined the server')
slate swan
#

!intents

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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

paper sluice
hidden snow
#

so using this i could do @ bot.event ?

#

ill try that

#

didnt change anything

slate swan
#

youre missing intents

hidden snow
#

ill try that now

#

from discord import Intents

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

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

client = discord.Client()

@client.event
async def on_member_join(member):

print('A member joined the server')
#

still doesnt work

slate swan
#

remove the bot variable and pass the intents instance to your client

hidden snow
#

huh?

#

remove the client replace it with bot?

slate swan
#

you can yeah

#

but youre not using commands so no need

#

just remove bot and do intents=intents inside of the parenthesis() in discord.Client

#

and ofc enable the intenr in dev portal if you havent

hidden snow
#

ah i think that may be my problem

#

ive tried this before but i havent tried that

#

still didnt work

slate swan
#

remove the bot var and are you running the client?

hidden snow
#

bot car?

#

and wdym running the clien?

slate swan
#

variable

slate swan
hidden snow
#

yes

#

should this work?

slate swan
#

have you enabled the intent? and are you running the up to date code?

hidden snow
#

yes

slate swan
#

and are people actually joining so the event gets fired?

hidden snow
#

ye i keep leaving and rejoining

#

waitdo i need presence and server members intent

#

or just message content intent

slate swan
#

the server member intent

hidden snow
#

still doesnt work D:

slate swan
#

show your code

hidden snow
#

ive tried both variations

slate swan
#

are you actually running the client instance? because your code seems fine

hidden snow
#

this is all the way at the bottem idk if thats a difference

slate swan
#

and your token is in an env file i suppose?

hidden snow
#

naw its in a variable called token

#

TOKEN i mean,

slate swan
#

ah okie

hidden snow
#

kinda a weird way to do it but it worked at the end of the day

slate swan
#

have an on ready event to see if your bot runs

hidden snow
#

oh

#

yeah i have that and it stopped working

slate swan
#

wdym

hidden snow
#

i have on ready

#

now its not sending it

slate swan
#

show your terminal and your code

hidden snow
#

waiut

#

i got it to work

#

the on ready

slate swan
#

does it print anything?

hidden snow
#

prints my on ready stuff

#

let me truble shoot further

slate swan
#

well then youll have to wait for the bot to recieve an event

hidden snow
#

ok im back and this thing is busted

#

i have this

#

and when i join it just puts in the console
SnowZillin said

slate swan
#

you dont need your bot instance and did you enabled the intent and did you made the event fire?

hidden snow
#

yes

slate swan
#

idk it seems to me like you arent triggering the event

hidden snow
#

hm

#

could it be that if i have already joined my server before it doesnt care about on_mem join

slate swan
#

do you have the intents enabled?

hidden snow
#

well i figured it out

#

its because i lied to you thats why, i had this too

#

if i get rid of the second client it fixes it

slate swan
#

yes remove it

hidden snow
#

well my bad

#

why does that cause problems btw?

slate swan
#

and check the developer portal

hidden snow
#

i got the message

#

so everything is good

slate swan
#

to the Bot class so it wont recieve any events

hidden snow
#

man :(

#

ig i learn for now on share all of ur code

slate swan
#

pardon?

hidden snow
#

ty for the help

slate swan
#

youre welcome

hidden snow
slate swan
#

ah

#

thats fine, you learn from your errors!

hidden snow
#

yes sir

#

failing forward

slate swan
#

yup

hidden snow
#

anyways ty for the help

#

ima go experiement

slate swan
#

anytime

ivory owl
#

I am trying to make some changes to my bot. I have it hosted in heroku. but turning on maintenance mode does not get my bot offline. how do I make it offline?

slate swan
#

hello

#

how can i get started making a bot in python?

#

you can also check pins which has some more handy stuff

#

thanks

#

you're welcome

fluid fog
#

is this service safe?

shadow vigil
#

i say you can't trust them

vocal snow
#

There are better alternatives available

shadow vigil
fluid fog
#

Thanks for the suggestion!

left idol
#
@bot.slash_command(description = "Your inventory")
@commands.cooldown(1, 10, commands.BucketType.user)
async def inventory(ctx):
    if ctx.channel.id != 994308916743782550:
        await ctx.respond("You can't use this command here", ephemeral = True)
    else:
        await ctx.defer(invisible = True)
        inventory = await inventory(ctx.author.id, ctx.author.name)
        embed = discord.Embed(title = 'Player Inventory', description = f'<@{ctx.author.id}> \n {inventory}')
        await ctx.followup.send(embed = embed)
@inventory.error
async def inventory_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        msg = f'Try again in {round(error.retry_after)}s'
        await ctx.respond(msg, ephemeral = True)

is there any reason why this command wouldn't return any error but just says 'didn't respond'? i tested the inventory function itself and have it after the command

vocal snow
placid skiff
#

bruh raise is so rude

ivory owl
#

I am trying to implement slash commands for my bot. but how do I add the library of version 2.0 to my requirements.txt? should I just do discord.py==2.0?

#

I am gettin the doubt because when I did pip install --upgrade discord.py, it upgraded only to 1.7.3

placid skiff
#

you will have something like:

discord==2.0
git+https://github.com/Rapptz/discord.py
#

should work

left idol
#

if i have a list, can i make it vertical in an embed?

#

can i do something like join \n in my list?

placid skiff
#

wdym by vertical? something like:

Embed title

My_List:
element_1
element_2
element_3
etc..
left idol
#

uhh just vertically stack

#

instead of like this

placid skiff
ivory owl
#

but in this case, should I also specify git in my requirements.txt?

placid skiff
#

yeah literally tou will have the package name with version and below it the git link

#

you will need git installed on your pc

ivory owl
#

no

#

I have installed it on my pc. I am asking about hosting it

placid skiff
#

hosting? wtf?

ivory owl
#

hosting the bot

#

I have hosted my bot on heroku before

placid skiff
#

it will be installed if heroku has installed git on his machine, otherwise it will not work

ivory owl
#

let's see

buoyant quail
#

is there a way to do something like that (to don't make extra function)

from discord.ext import commands

async def some_command(self, ctx):
    await ctx.send("it works")


class Cog(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.command()
    some_command

or only way is

    @commands.command()
    async def command(self, ctx):
        some_command(self, ctx)

?

forest oyster
#

how i can install dotenv libraries?

paper sluice
slate swan
unkempt canyonBOT
#

add_command(command, /)```
Adds a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") into the internal list of commands.

This is usually not called, instead the [`command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin.command "discord.ext.commands.GroupMixin.command") or [`group()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin.group "discord.ext.commands.GroupMixin.group") shortcut decorators are used instead.

Changed in version 1.4: Raise [`CommandRegistrationError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandRegistrationError "discord.ext.commands.CommandRegistrationError") instead of generic [`ClientException`](https://discordpy.readthedocs.io/en/latest/api.html#discord.ClientException "discord.ClientException")

Changed in version 2.0: `command` parameter is now positional-only.
slate swan
#

and use command.cog = YourCogObject

#
@commands.command()
async def foo(ctx):
    ...

bot.add_commmand(foo)
foo.cog = YourCog()
buoyant quail
#

thx

brave moth
#

i need some help. ive decided to se unix time to show cooldown times instead of using strftime but when i tested it out, it works but the timestamp shows an hour early than the lastest time

robust fulcrum
#

What would be check for it ?

slate swan
robust fulcrum
#

K

#

What I ahve to type at message object?

#

like object = await ctx.send("fool")?

slate swan
#

yes

robust fulcrum
paper sluice
#

just do discord.ButtonStyle.blurple

#

#5865F2

tepid sundial
#

Hello
What should I do to make a command that the bot plays a sound?

#

pls help me

slate swan
tepid sundial
#

help me

#

pls

#

!d discord.player.FFmpegAudio

unkempt canyonBOT
#

class discord.FFmpegAudio(source, *, executable='ffmpeg', args, **subprocess_kwargs)```
Represents an FFmpeg (or AVConv) based AudioSource.

User created AudioSources using FFmpeg differently from how [`FFmpegPCMAudio`](https://discordpy.readthedocs.io/en/latest/api.html#discord.FFmpegPCMAudio "discord.FFmpegPCMAudio") and [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/latest/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio") work should subclass this.

New in version 1.3.
tepid sundial
#

@bot.command()
async def play(context):
channel = context.author.voice.channel
vc = await channel.connect()
vc.play(discord.player.FFmpegAudio(source="vc.mp3"))

discord.player.FFmpegAudio(source="vc.mp3")

await context.send("playing a audio")
#

is True?

tepid sundial
vale wing
tepid sundial
#

but i have error

vale wing
#

And yeah you need to play audio differently iirc

tepid sundial
#

how about?

vale wing
#

!d discord.FFmpegPCMAudio

unkempt canyonBOT
#

class discord.FFmpegPCMAudio(source, *, executable='ffmpeg', pipe=False, stderr=None, before_options=None, options=None)```
An audio source from FFmpeg (or AVConv).

This launches a sub-process to a specific input file given.

Warning

You must have the ffmpeg or avconv executable in your path environment variable in order for this to work.
brave moth
# vocal snow Can you show your code?
 @free.error
    async def free_error(self, ctx: Interaction, error):
        await ctx.response.defer()
        if isinstance(error, CallableOnCooldown):
            reset_hour = round(error.resets_at.timestamp())
            cooldown = Embed(
                description=f"You have already used your free chance\nTry again after <t:{reset_hour}:t>", color=0xff0000)
            await ctx.followup.send(embed=cooldown)```
brave moth
haughty echo
#

Hey everyone

#

Anyone know how to transfer bot ownership to other person?

carmine crater
#

How do you make a discord bot send a tts message? (discord.py)

vocal snow
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
vocal snow
#

tts kwarg

slate swan
carmine crater
slate swan
#

Might be able to do it through the teams function, not tried it.

haughty echo
#

Means can you explain?

vocal snow
#

why do you want to transfer ownership πŸ€”

haughty echo
slate swan
# haughty echo Means can you explain?
  1. Set up a new app in the discord developers portal.
  2. Give it any permissions/intents required
  3. Generate a token and apply it to your code.
  4. remove old bot from server, invite new one.
#

You really need to speak to your friend first and find out all the details, whats needed, is it even python etc....Then once you have then can then plan out how you will take ownership, manage it, etc.

haughty echo
#

Hmm

robust fulcrum
#

I did that how can I check that reaction is πŸ“Œ

slate swan
robust fulcrum
slate swan
#

Working dude, I can't write your code for you unless somsone else can offer. Google is your bf here.

slate swan
#
    @discord.ui.button(style=discord.ButtonStyle.gray, emoji=":PepeHeist:") # or .primary
    async def blurple_button(self,interaction: Interaction, button: Button):
        button.disabled=False
        guilds = await get_role()

        id = guilds[str(interaction.user.guild.id)]["role"]
        mute = interaction.user.guild.get_role(id)
        if mute not in interaction.user.roles:
          await interaction.user.add_roles(mute)
          await interaction.response.send_message(f"I've added <@&{client.role}> role to you!", ephemeral=True)

error:

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1329, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'role'
robust fulcrum
vocal snow
#

you'll probably have to cast payload.emoji to str, but otherwise should be fine

#

didn't you want it in your check though?

robust fulcrum
#

No

#

Cuz i ahve to send message if reaction == " πŸ“Œ "

vocal snow
#

yeah, so you could just make sure reaction is that in the check and send a message after receiving the event

pure lintel
#

I was wondering if it possible to access guild count without being there+

swift pumice
placid skiff
#

Via discord developer is not possible

#

You can only set or change owner ids in your bot instance so they will have access to commands available only for owners

vocal snow
robust fulcrum
#
@bot.command()
async def bm(ctx):
    reply = ctx.message.reference
    conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)).content
    contents = (reply.cached_message or await ctx.fetch_message(reply.message_id))
    url = contents.jump_url
    auth = contents.author
    embf = discord.Embed(title=f"{auth}\nbookmark",color=discord.Color.green())
    embf.add_field(name="bookmark message",value=conten,inline=False)
    embf.add_field(name="bookmark link",value=f"[link to message]({url})", inline=False)
    embf.set_thumbnail(url='https://media.discordapp.net/attachments/993363454519955466/996046786928070696/unknown.png')
    embff = discord.Embed(title="bookmark", description="react to πŸ“Œ to bookmark the message",color=discord.Color.red())
    message = await ctx.send(embed=embff)
    await message.add_reaction('πŸ“Œ')
    try:
        payload = await bot.wait_for("raw_reaction_add", check=lambda p: p.message_id == message.id, timeout =20)
        if payload.emoji == 'πŸ“Œ':
            await ctx.send("testing")
    except:
        await ctx.send("nah")

Guys this command is not sending message on reaction hiw to fix?

slate swan
#

Your embed variables are wrong. You set 2 for the same thing, which isn't going to work.

#

Hello, I make a system of ticket in private message for my bot but I have problems I block to close the ticket in mp directly thanks to a command and how to answer with a command reply directly in mp with the bot but to the person having opened the ticket concerned

placid skiff
#

i didn't understand nothing D_D

slate swan
#

I'm looking to make a private message ticket system

#

How to answer the person who opened the ticket with a command knowing that the person does not have access to the ticket

paper sluice
#

you want to dm the person who ran the ticket command?

pure lintel
#

can someone please try getting information into a certain guild without your bot being there

#

if you could try using the api thanks!

placid skiff
#

you can't

slate swan
#

Yes to answer his ticket

pure lintel
slate swan
#

I have already searched the api

placid skiff
#

neither D_D, the bot can0t access to all the information

slate swan
#

I use discord.py==1.7.3

paper sluice
placid skiff
#

Those are the data that you will not be able to get

slate swan
#
@slash.slash(name="ticket", description="Open a ticket to contact the staff")
async def ticket(ctx):
    member = ctx.author
    guild = bot.get_guild(932745412140482690)
    overwrites = {
    guild.default_role: discord.PermissionOverwrite(read_messages=False),
    guild.get_role(933104717377179680): discord.PermissionOverwrite(read_messages=True),
    guild.get_role(933104276320956527): discord.PermissionOverwrite(read_messages=True),
    guild.me: discord.PermissionOverwrite(read_messages=True)
}

    channel = await guild.create_text_channel(f'Ticket de {member}', category = bot.get_channel(934518633370099783), overwrites=overwrites)
    await ctx.send("Ticket crΓ©e")


@slash.slash(name="Reply", description="Reply to the ticket")
async def reply(ctx, message):
    if ctx.author 
    


@slash.slash(name="close", description="Close a ticket")
async def close(ctx, channel : discord.TextChannel):
    guild = bot.get_guild(932745412140482690)
    await channel.delete()```
pure lintel
#

pain desu ne

slate swan
#

This is my code

pure lintel
#

but can you access people in without being in the same guild?

placid skiff
slate swan
#

it's people on my server

pure lintel
#

I mean directly access people without being in the same guild?

placid skiff
#

if you have their id

pure lintel
#

yes that

placid skiff
#

!d discord.Client.fetch_user

unkempt canyonBOT
#

await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_user "discord.Client.get_user") instead.

Changed in version 2.0: `user_id` parameter is now positional-only.
pure lintel
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a β€œserver” in the official Discord UI.

x == y Checks if two guilds are equal.

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

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
slate swan
slate swan
pure lintel
#

!d discord.Guild.approximate_member_count

unkempt canyonBOT
slate swan
#

Ok first of all, to answer the person what do you want to do, DM them or reply in the channel?

#

I want to reply in private message through the bot

slate swan
#

So step 1 ) It creates this channel?
Step 2) await ctx.send("Ticket crΓ©e") is this part suppose to amil the author? if yes, does it do what its suppose to? See earlier what Ryuga said, use ctx.author.

pure lintel
#

can someone quickly post my id here thanks! I can't use my mouse nor my touchpad rn

robust fulcrum
#

991178068343390223

pure lintel
#

thaks

robust fulcrum
#

Welcome

placid skiff
slate swan
carmine crater
#

Does anyone know how I could make my discord bot send a random image from a predetermined set of images?

slate swan
#

See what Blvck just posted.

placid skiff
slate swan
#

I want to answer in the ticket room and the bot sends in dm to the person who opened the ticket

placid skiff
#

it's not like you create a DMChannel in an instance and then the bot knows that you want to respond to that channel in another instance D_D

robust fulcrum
slate swan
#

What code do I need for the database, I have trouble with databases

#

I don't know how to retrieve information from a database

robust fulcrum
#

Learn SQL

placid skiff
#

it is useless if we just sent to you a random code, you will not even be able to adapt that code to yours, you'll need to learn SQL

slate swan
#

I use Sqlite3

robust fulcrum
#

So learn

placid skiff
#

sqlite 3 is SQL D_D

slate swan
velvet compass
#

Python comes with sqlite3 already, so its pretty handy to use

placid skiff
#

hello brad, chillin' around?

velvet compass
#

Yeah just channel jumping

placid skiff
#

fair enough

robust fulcrum
slate swan
#

A site for a sql doc?

placid skiff
#

reply me your code

slate swan
#
    embf.add_field(name="bookmark message",value=conten,inline=False)
    embf.add_field(name="bookmark link",value=f"[link to message]({url})", inline=False)
    embf.set_thumbnail(url='https://media.discordapp.net/attachments/993363454519955466/996046786928070696/unknown.png')
    embff = discord.Embed(title="bookmark", description="react to :pushpin: to bookmark the message",color=discord.Color.red())
    message = await ctx.send(embed=embff)```
placid skiff
slate swan
#

Seriously read it lol. Look at the variables you are using. especially the last 2.

robust fulcrum
placid skiff
#

i see that but why lmao?

slate swan
#

But they are in the same code block.

robust fulcrum
#

πŸ˜’

robust fulcrum
placid skiff
#

btw add this to your code cuz if there is an error the try except block is eating it

robust fulcrum
#

and print e?

placid skiff
#
import sys, traceback

try:
  [...]
except Exception as e:
  print(f"ignoring exception in {ctx.command.name}\nUnknown error", file=sys.stderr)
  traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr)
quartz reef
#

Hello. does anyone know how groovy bot managed command permissions with slash commands? I would like to have a set of permissions like this bot, e.g. manage player - only users that have this permission can use commands like player, seek... (I'm using discord.py)

placid skiff
quartz reef
placid skiff
quartz reef
#

so I can perform all checking operations

placid skiff
placid skiff
robust fulcrum
#

@placid skiff i removed the if emoji == pin
And it sent the message but without the emoji check

#

Ig there is problem with payload.emoji

placid skiff
#

How it sent the message bruh the check requires a payload which is given from the raw_reaction_add event

robust fulcrum
quartz reef
placid skiff
#

The pin is unicode right?

robust fulcrum
#

Whats unicode?

#

Hmm

placid skiff
placid skiff
robust fulcrum
#

No

pure lintel
#

Why use dpy when hata exists

placid skiff
#

sorry pins

#

Oh yeah is that, i'm freakin blind lmao

#
if payload.emoji.name == 'πŸ“Œ':
```try with this
vale wing
#

Unicode emoji is a str isn't it

fading knot
#

is there any cross server chat script

pure lintel
#

No

#

Make your own

paper sluice
#

I don't think you can access the text in a users status

unkempt canyonBOT
paper sluice
#

oh that comes under acitivty

#

cool, you can using that @slate swan ^

slate swan
#

I made a code for the database for the ticket system, I can show it to you to confirm me that there is no error ?

placid skiff
#

Lol we could check it but the best way is to test it D_D

slate swan
#

why it say's "set_dono_ac" is not defined

#

Are you in a class

#

yes

#

self.set_dono_ac

#

rather than async def?

#

No, while calling it

#

k

paper sluice
#

they should take self ( convention) as first arg

slate swan
#

And either make it a static method or add self as the first arg

#

I don't make it

slate swan
paper sluice
#

have a task which loops every x mins and looks for the link in their activity

slate swan
#

I can't get the user id of the database to send my message to the user

placid skiff
#

code?

paper sluice
slate swan
#
import os
import sqlite3

class DatabaseTicket():
    def __init__(self, database_name : str):
        self.con = sqlite3.connect(f"{os.path.dirname(os.path.abspath(__file__))}/{database_name}")
        self.con.row_factory = sqlite3.Row


    def create_ticket(self, user_id : int, guild_id : int):
        cursor = self.con.cursor()
        query = "INSERT INTO ticket (user_id, guild_id) VALUES (?, ?, ?);"
        cursor.execute(query, (user_id, guild_id))
        cursor.close()
        self.con.commit()

    
    def reply_ticket(self, user_id : int):
        cursor = self.con.cursor()
        query = f"SELECT * FROM ticket WHERE user_id = ? AND active = 1;"
        cursor.execute(query, (user_id))
        result = list(map(dict, cursor.fetchall()))
        cursor.close()
        self.con.commit()
        return result


    def close_ticket(self, user_id : int):
        cursor = self.con.cursor()
        query = f"UPDATE ticket SET active = 0 WHERE id = ?;"
        cursor.execute(query(user_id,))
        cursor.close()
        self.con.commit()```
placid skiff
#

lol i needed only the part where you retrieve the id but ok

vale wing
#

Names are kinda breaking logic

#

You create, reply and close tickets with a ticket

placid skiff
#

and btw you have more instance of cursor in the same code, you will need to use aiosqlite

slate swan
#

!e paginator logic

def foo(list):
    pgno = 5
    itemper  = 3
    a = {}
    items = []
    for x in list:
        if len(items) == itemper:
            a[pgno] = items
            items = []
            pgno-=1
        items.append(x)
    return a
print(foo([1,2,3,4,5,6,7,8,9,123,12,4634,23526,578574,252346456]))
unkempt canyonBOT
#

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

{5: [1, 2, 3], 4: [4, 5, 6], 3: [7, 8, 9], 2: [123, 12, 4634], 1: [23526, 578574, 252346456]}
paper sluice
#

!e

a = [1,2,3,4,5,6,7,8,9,123,12,4634,23526,578574,252346456]
print([*zip(*[iter(a)]*3)])
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

[(1, 2, 3), (4, 5, 6), (7, 8, 9), (123, 12, 4634), (23526, 578574, 252346456)]
slate swan
#

what the

#

hell

paper sluice
slate swan
#

🀯

shrewd apex
#

oops

vale wing
slate swan
#

πŸ™

shrewd apex
#

!e

a = [1,2,3,4,5,6,7,8,9,123,12,4634,23526,578574,252346456]
print({int((i/3)+1):tuple(a[i:i+3]) for i in range(0, len(a), 3)})
unkempt canyonBOT
#

@shrewd apex :white_check_mark: Your eval job has completed with return code 0.

{1: (1, 2, 3), 2: (4, 5, 6), 3: (7, 8, 9), 4: (123, 12, 4634), 5: (23526, 578574, 252346456)}
slate swan
#

now fine

shrewd apex
#

mhm

slate swan
#

HOW

#

WHY

slate swan
shrewd apex
#

coz one liners has its own swag

slate swan
#

πŸ’€

#

tvsier just made that meme

#

right?

placid skiff
#

Hahahaha i could not hold me back

slate swan
#

lol cool

shrewd apex
#

lmfao

slate swan
#

hehe

#

Yes

slate swan
paper sluice
slate swan
slate swan
placid skiff
#

23 hrs? why wasting that 1 hour? that is so much time

slate swan
slate swan
paper sluice
placid skiff
cloud dawn
paper sluice
#

ya, plus minus 6hrs every now and then

slate swan
#

So long as your getting paid for that time, its fine lol!

#

its not fine if that's affecting you mentally ( totally not coming from someone who sleeps just for 2-3 hr a day)

placid skiff
#

well my mentality is already broken so why sleep D_D

slate swan
#

Lol, I am made of tough skin, a few hours kip a day does me fine.

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Donation.get_dono_ac() takes 2 positional arguments but 3 were give
``` error ^
code: 
```py
@dono.command()
    @commands.has_permissions(administrator=True)
    async def add(self,ctx,member: discord.Member,*,amount: int):
        if amount > 10000000000000:
            await ctx.send("Bro, you can't add that much into my db.")
        else:
            await self.get_dono_ac(self,ctx.author)

            users = await self.set_dono_ac()

            users[str(ctx.author.id)]["user_id"] = member.id
            users[str(ctx.author.id)]["donated_amount"] += amount

            total = users[str(ctx.author.id)]["donated_amount"]

            e = discord.Embed(title=f"Donation Added",color=discord.Colour.dark_theme())
            e.add_field(name="Amount Added:", value=f"{amount}", inline=False)
            e.add_field(name="Total Donations:", value=total)

            e.set_footer(text=ctx.guild.name,icon_url=ctx.guild.icon.url)

            await ctx.send(embed=e)

            with open("donations.json", 'w') as f:
                json.dump(users,f)
cloud dawn
slate swan
placid skiff
#

Lol you did your best ash, don't worry

slate swan
cloud dawn
#

If you would have slept you wouldnt be making those mistakes

slate swan
#

go sleep everyone

#

its time

#

to sleep

slate swan
slate swan
placid skiff
slate swan
#
await self.get_dono_ac(ctx.author,user)
#

and what's the get_dono_ac function again?

slate swan
#

if ur doing work

#

avg dc addict

#
async def get_dono_ac(self,ctx):
        user = await self.set_dono_ac()

        if str(ctx.author.id) in user:
            return False
        else:
            user[str(ctx.author.id)]["user_id"]
            user[str(ctx.author.id)]["donated_amount"]

        with open("donations.json" 'r')as f:
            json.dump(user,f)

        return True
``` this ^
#

what happened?

slate swan
placid skiff
slate swan
placid skiff
#

the fun fuct is that i'm paid for my availability LMAO

slate swan
#

you're living my dreams

slate swan
#

gimme name ideas for a command handler

cloud dawn
#

lmao

placid skiff
#

Bruh no

slate swan
slate swan
cloud dawn
cloud dawn
slate swan
#

meh

slate swan
slate swan
#

i'll name it sparky if i dont get a proper idea troll

slate swan
paper sluice
slate swan
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

discord-bot    
slate swan
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Donation.set_dono_ac() missing 1 required positional argument: 'user'
#

did what ashley said

slate swan
# slate swan wdym 😑
import sparky
spam = sparky.send_emoji()
await sparky.wait_for("someone else's message")
await spam.delete()
``` you life in a nutshell, isnt it
#

ofc needs to be a coro

#

but im too lazy to write it

#

πŸ˜‘

slate swan
# slate swan <:cathmm:892764091020636180> show code
@dono.command()
    @commands.has_permissions(administrator=True)
    async def add(self,ctx,member: discord.Member,*,amount: int):
        if amount > 10000000000000:
            await ctx.send("Bro, you can't add that much into my db.")
        else:
            await self.get_dono_ac(ctx)

            users = await self.set_dono_ac()

            users[str(ctx.author.id)]["user_id"] = member.id
            users[str(ctx.author.id)]["donated_amount"] += amount

            total = users[str(ctx.author.id)]["donated_amount"]

            e = discord.Embed(title=f"Donation Added",color=discord.Colour.dark_theme())
            e.add_field(name="Amount Added:", value=f"{amount}", inline=False)
            e.add_field(name="Total Donations:", value=total)

            e.set_footer(text=ctx.guild.name,icon_url=ctx.guild.icon.url)

            await ctx.send(embed=e)

            with open("donations.json", 'w') as f:
                json.dump(users,f)
paper sluice
carmine crater
#

When I run my bot I get an error on the "client.run" line

slate swan
slate swan
slate swan
carmine crater
slate swan
#

set not get

maiden fable
slate swan
cloud dawn
slate swan
#

πŸ˜‘

#

🀣

slate swan
maiden fable
slate swan
#

πŸ˜”

cloud dawn
#

I wish I could unsee this.

carmine crater
#

Here is the error message @slate swan

slate swan
#

light moe

slate swan
cloud dawn
slate swan
#

change @bot.event to bot.listen()

slate swan
#

read the message panda linked for "why"

#

everyone hates my [msg,pfp,joke,name]

slate swan
#

ok

cloud dawn
maiden fable
cloud dawn
carmine crater
#

import discord
import random
import list

client = discord.Client()

@client.event
async def on_ready():
print('Bot is online')

@client.event
async def on_message(message):
if message.author == client.user:
return

await message.channel.send(random.choice())

client.run('')

slate swan
cloud dawn
carmine crater
slate swan
#

you did it worng.

cloud dawn
#

What did you try?

slate swan
#

dont insert the event names inside it, you dont need to do that

#

just replace the .event to listen()

slate swan
maiden fable
#

And yea, u pinged the wrong person

carmine crater
slate swan
cloud dawn
#

Admire the cleanness tough.

carmine crater
#

@slate swan I sent the wrong code sorry

cloud dawn
#

You still need the . tough

slate swan
cloud dawn
#

☹️

carmine crater
slate swan
#

i dont hate anyone like sarth

carmine crater
#

@cloud dawn ARGH I didn't paste all of the code

#

I'm messing up everytime

slate swan
#

L

cloud dawn
#

πŸ˜‚

#

n1

paper sluice
#

Panda-beer 😳

cloud dawn
#

It wasn't

#

🍻

slate swan
paper sluice
#

ur underage

carmine crater
#

yes I am

paper sluice
#

no?

#

how do you know everyone's age? pithink

cloud dawn
#

I'm on 0.0 rn tough.

#

Speak for yourself, child.

#

🀏

#

πŸ’

#

😘 @slate swan

slate swan
slate swan
slate swan
# carmine crater yes I am

Ok, I am not 100% sure how to use/work replit. Think you need to look at running a kill command against the container in the shell, not sure if it can or how it would be done from the discord code.

carmine crater
#

hmm

#

thank you so much

cloud dawn
#

kill 0 suffices

slate swan
#

anyways back to topic

#

i dont want mute

cloud dawn
#

So bots huh

slate swan
#

yeah so why discord

carmine crater
#

Good news Jammy

slate swan
#

delete discord.py 1.7.3 version and download 2.0 or disnake

carmine crater
slate swan
#

Did you run what Panda said?

cloud dawn
#

You need 60 seconds?

#

That's quite short.

slate swan
#

asycio.sleep(60)

cloud dawn
#

Yeah what spark said you are blocking the whole bot with the sleep

#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

slate swan
#

i didnt said anything

cloud dawn
slate swan
#

ye but

slate swan
#

it was the reply to this

#

not saying that time.sleep blocks ur code

cloud dawn
#

!d asyncio.sleep

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
cloud dawn
#

You are sleeping the bot with time.sleep, that is a blocking call.

slate swan
#

ye

paper sluice
#

basically that time.sleep(60) stops your bot for 60 seconds, so it will not respond to any commands or events for that duration

cloud dawn
#

Either remove time.sleep(60) to make it instant or use asyncio.sleep(60)

slate swan
#

yes

cloud dawn
#

!d asyncio

unkempt canyonBOT
#

Hello World!

import asyncio

async def main():
    print('Hello ...')
    await asyncio.sleep(1)
    print('... World!')

asyncio.run(main())
```...
paper sluice
#

ya you need to import asyncio

cloud dawn
slate swan
#

my asyncio.sleep doesnt work

#

i did 4 seconds

cloud dawn
paper sluice
#

did u await?

slate swan
#

but it sends in like 1 sec

#

with no errors

paper sluice
#

did you await it?

slate swan
#

um let me check

paper sluice
#

asyncio.sleep is a coro

slate swan
#

uh

#

i didnt awaited lol

cloud dawn
#

!async-await

unkempt canyonBOT
#

Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

slate swan
#

enough

cloud dawn
#

It's info πŸ’

slate swan
#

i just forgot 1 await

#

dont you ever did that mistakeπŸ˜”

cloud dawn
#

I did do some other things.

slate swan
#

I've had this error for 10 minutes

paper sluice
cloud dawn
paper sluice
paper sluice
#

it requires an iterable, so (object, ) makes a tuple
(object) doesn't

paper sluice
slate swan
paper sluice
#

execute

slate swan
#

ok thanks I go test

slate swan
paper sluice
#

you mean an error for not awaiting?

#

im confused

slate swan
#

leave it

cloud dawn
#

More like "await" it

#

βœ‹

slate swan
#

leave it

#

new error

slate swan
cloud dawn
# slate swan

What data type is user_id and what did you define the column as?

#

I recommend using type()

#

To be certain.

slate swan
cloud dawn
#

What db is this?

slate swan
#

sqlite

#

SQlite studio

cloud dawn
#

Okay so ID's are in the right range.

placid skiff
#

Uh hunter

cloud dawn
#

I suspect that the id is a string or something.

placid skiff
#

you're alive lmaopuffy

maiden fable
#

Indeed

slate swan
#
@slash.slash(name="Reply", description="Reply to the ticket")
async def reply(ctx, message):
    user_id = discord.Member
    database_ticket.reply_ticket(user_id)
    embed=discord.Embed(title = "Ticket", inline = False)
    embed.add_field(name = "Message", value = message)
    embed.set_footer(text=f"By {ctx.author}")
    await ctx.send(embed=embed)```
placid skiff
#

bruh you can't save Member object to a database lmao

slate swan
#
def reply_ticket(self, user_id : int):
        cursor = self.con.cursor()
        query = f"SELECT * FROM ticket WHERE user_id = ? AND active = 1;"
        cursor.execute(query, (user_id, ))
        result = list(map(dict, cursor.fetchall()))
        cursor.close()
        self.con.commit()
        return result```
placid skiff
#

You need an object relational mapping database to save objects, and they're harder than sqlite D_D

cloud dawn
#

Just use the id.

placid skiff
#

I'm not doing it in fact

#

For a discord bot it is useless tho

slate swan
#

Bruhhh

placid skiff
#

since you can retrieve objects from their ID

cloud dawn
#

Just store the info you need.

placid skiff
#

user_id = ctx.author.id this is how you should do

slate swan
#

how is that related

#

?

#

he's talking about the data type which is getting saved, not an ORM

#

object relational mapping database

#

same thing uhhh my bad

#

but how is that any different

#

more like I just read half the convo tbh

#

Now how can I get the bot to send the message privately to the member who opened the ticket?

slate swan
#

like a discord.Member

#

.

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
placid skiff
slate swan
#

timezones

slate swan
placid skiff
#

you're right:
We've answered to that like 7 hours ago

slate swan
#

Excused

placid skiff
#

apologies accepted lemon_fingerguns

slate swan
#

I am lost after almost 8 hours of programming

slate swan
placid skiff
#

i'm lost after 2 hours lmao

slate swan
#

xD

#

who even programs for 2 hours continuously wtf

#

im in future

placid skiff
dull terrace
placid skiff
#

And most of the time was:
me: coding for 2 hours*
me: reading what i wrote*
also me: "What the fuck did i just write?"

slate swan
#

damn 150 reactions in 5 seconds

paper sluice
remote hatch
#

why the bot doesnt send the embed on the chat when i use the command?

ionic turtle
slate swan
#

pandabear is pandabweer or what

slate swan
ionic turtle
paper sluice
placid skiff
dull terrace
slate swan
slate swan
paper sluice
ionic turtle
#

bro what

slate swan
#

Meh, going to take a while getting use to that.

ionic turtle
#

discord.idents πŸ’€

paper sluice
placid skiff
ionic turtle
paper sluice
remote hatch
slate swan
slate swan
#

🐢 🐻

slate swan
remote hatch
#

now its like this

slate swan
#

indents

#

1 line

#

ew

#

smexy indents moment

dull terrace
paper sluice
#

bro πŸ’€ my terminal does better indentation work than replit

slate swan
#

embed = discord.Embed(
await interaction.response.send_message()
)

#

and color = discord.Color.blue()

slate swan
#

poor spinal cords PepeHandSad

paper sluice
dull terrace
#

5 hours can pass before i even realise

#

i wish i could get into that frame of mind more often

slate swan
#

i cant even think when i wake up

slate swan
slate swan
slate swan
dull terrace
#

what should i put on the website im making for my bots

vocal snow
#

cats

paper sluice
slate swan
#

your bot stats, uptime chart and most importantly cats like zeffo said

dull terrace
slate swan
#

def not

slate swan
#

Use mira jane as the logo for the site...

#

πŸ₯±

dull terrace
#

coding it from scratch with bootstrap and flask ablobsweats first time doing everything like this

dull terrace
#

im gonna do optional ad videos eventually for one of my bots, got the discord login system done for it so far

slate swan
#

I have been looking into django personally for a backend to connect my bot to one day....

#

django is certainly uwu

#

uwu? Lol sorry no good with slang!

dull terrace
#

what's wrong with flask

placid skiff
#

django has an async interface so it's absolutely better

dull terrace
#

ooo

slate swan
#

like a hundred times

vocal snow
#

django is way too overkill for this

placid skiff
#

We don't talk about java||shit|| here D_D

dull terrace
#

i swear, every time i start something new i somehow choose the wrong options for everything

slate swan
slate swan
#

Yeh seen a lot of recommendations on django to use with discord bots thats why I added to my own project list. First stage get a standard bot working and upskill in my python, then move into SQL then connect it to web app.

dull terrace
#

i've done css before, still hate everything about front end

vocal snow
#

use fastapi πŸ™

dull terrace
#

i wish i could write everything in python, hate html too

quaint epoch
unkempt canyonBOT
slate swan
quaint epoch
quaint epoch
slate swan
#

I HATE css

dull terrace
#

yeah it doesn't seem that hard but really finicky

slate swan
#

for no reason

quaint epoch
#

css and html aren't bad, they're just hard and frustrating a lot of the time

#

another reason to stick to backend

slate swan
#

kek me

quaint epoch
#

anyway imma play some fn πŸ™ peace

slate swan
#

ew imagine playing fortnite

quaint epoch
#

smh

dull terrace
slate swan
#

text-align/margin exists

paper sluice
#

google exists

slate swan
#

stackoverflow logo_stack_overflow

dull terrace
#

what bots have websites that i can get inspiration from 7739monkathink

slate swan
#

just keep adding whitespaces ;-; and align it manually

slate swan
#

carl

#

js fLOOsh

#

php is love, php is life ❀️ fk js

dull terrace
#

im gonna try and do the whole website without writing a single line of js doge_kek

slate swan
#

not too hard cuz they allow that

#

try doing the same in python

#

rust is something other languages can never be, change my mind lol

#

just like you fLOOsh

slow fog
dull terrace
#

hmm, when should you shard a bot

slow fog
#

i have seen you before somewhere

#

im sureemojisky

#

idk but i didemojisky

warm tulip
#

Idk why

#

But

#

Can someone say how I can get my c// disk free

#

It's only 1gb free rn emoji_29 emoji_29 emoji_29

vocal snow
#

upgrade it/get another drive

warm tulip
#

I have 3drives

#

D// f// e//

#

But c// is only 1/54 free

#

And no games is in that

slate swan
#

Use the tree size app, find where the larger directories/files are, remove them if possible.

warm tulip
#

Um

#

Can you pls say with new words I don't understand

#

What u mean

vale wing
unkempt canyonBOT
dull terrace
vale wing
#

Then it's ok to go without shards until it faces performance issues

sick birch
#

Wasn't it 2000 or 2500 for sharding?

vale wing
#

I don't remember where I read that

#

!d discord.AutoShardedClient

unkempt canyonBOT
#

class discord.AutoShardedClient(*args, intents, **kwargs)```
A client similar to [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") except it handles the complications of sharding for the user into a more manageable and transparent single process bot.

When using this client, you will be able to use it as-if it was a regular [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") with a single shard when implementation wise internally it is split up into multiple shards. This allows you to not have to deal with IPC or other complicated infrastructure.

It is recommended to use this client only if you have surpassed at least 1000 guilds.

If no [`shard_count`](https://discordpy.readthedocs.io/en/latest/api.html#discord.ShardInfo.shard_count "discord.ShardInfo.shard_count") is provided, then the library will use the Bot Gateway endpoint call to figure out how many shards to use.
sick birch
#

Ah okay

slate swan
#

!e

"""Scene \{
    // normalized rgb triplet
    background_color: (1, 0, 0)
    // 3d vector representing camera's position
    camera_position: ({0}, {1}, {2})
    // field of view in degrees
    field_of_view: 70
\}""".format(1, 1, 1)
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 8, in <module>
003 | KeyError: '\n    // normalized rgb triplet\n    background_color'
slate swan
dull terrace
slate swan
#

hi what it isn't work?

#
@client.command()
async def clear(ctx, amount = None):
  if amount == None:
    await ctx.reply('``πŸ”§`` correct use: `+clear {ammount}`')
  else:
    await ctx.channel.purge(limit = amount)```
#

@sick birch

carmine crater
#

Does anyone know how I can deal with this problem?

#

In other words

#

How do I stop my discord bot from exceeding rate limits?

hushed galleon
carmine crater
#

yes

hushed galleon
#

thats a common issue for bots running on replit since there's plenty of them running on the same datacenter

slate swan
hushed galleon
#

u know

hushed galleon
slate swan
#

+clear working but +clear 10 no work

faint sapphire
#

im using heroku and github to host my bot
is there a way to use a database with that?

slate swan
bitter depot
hushed galleon
# slate swan

that would be because you tried passing a string to the limit= parameter; command arguments are read as strings by default, but to have dpy convert your "10" into an actual python integer, 10, you need to typehint your amount parameter with int

bitter depot
#

There's also a typo in your f-string @slate swan

#

amount has one m, not two

hushed galleon
#

coincidentally the f' is missing as well

slate swan
#
@client.command()
async def clear(ctx, amount = None):
  if amount == None:
    await ctx.reply('``πŸ”§`` correct use: `+clear (ammount)`')
  else:
    await ctx.channel.purge(limit = amount)```
paper sluice
#

and type hint amount with int as mentioned

slate swan
#

can u edit this because i'm not understend u

#

i'm starting with python

sick birch
paper sluice
#
@client.command()
async def clear(ctx, amount: int = None):
  if amount == None:
    await ctx.reply(f'``πŸ”§`` correct use: `+clear {ammount}`')
  else:
    await ctx.channel.purge(limit=amount)

its advised to learn python before making discord bots because they are fairly advanced, so take sometime and get the basics down

sick birch
#

By default without any typehints, discord.py won't parse any user arguments and will return them to you as a regular string. That's why it won't be an int

sick birch
paper sluice
#

sorry

sick birch
#

np

cold oyster
#

Hello. So I am making some CAD system RP bot (Roblox stuff)

But the point is that it says command not found

import nextcord as discord
from nextcord.ext import commands

intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='.', intents=intents)

client.command()
async def backup(ctx, *, unit = None, location = None, reason = None):
  embed = discord.Embed(title="Backup Needed!", description=f"Attention all units, {unit} needs backup. ||<@&996463467471065159>")
  embed.add_field(name="10-20", value=location)
  embed.add_field(name="10-31", value=reason)
  ctx.send(embed=embed)```
quick gust
#

@client.command

#

it's a decorator

cold oyster
#

-sighs-

#

I am so dead, Just a @ made this

cold oyster
#

Thanks...

quick gust
#

no worries, happens

cold oyster
# quick gust no worries, happens

Isnt it supposed to say the unit name, Then under 10-20 should be location and 10-31 should be Reason

@client.command()
async def backup(ctx, *, unit = None, location = None, reason = None):
  embed = discord.Embed(title="Backup Needed!", description=f"Attention all units, {unit} needs backup. ||<@&996463467471065159>")
  embed.add_field(name="10-20", value=location)
  embed.add_field(name="10-31", value=reason)
  ctx.send(embed=embed)```
quick gust
#

well you are defaulting location to None

cold oyster
#

Idrk how that thing works

quick gust
#

since u also have the * operator, I am pretty sure it's eating up all the values for unit and location is None

#

try printing unit

cold oyster
#

Oh

#

It works

#

Unit works

quick gust
#

print unit and tell me what it says

cold oyster
#

Wait

#

(I put test in every field)

#

Or I tried to

quick gust
cold oyster
#

Yes

quick gust
#

what u need to do is remove the *, and when u use the command, u dont supply it commas,

cold oyster
#

Ok

quick gust
#

also since the reason can contain spaces, u can do *, reason=None

cold oyster
#

Let me check

#

Location and reason, Both can

quick gust
#

something like

async def backup(ctx, unit = None, location = None, *, reason = None):```
quick gust
cold oyster
#

Well anyways thanks, Im happy with this for now

quick gust
#

okay

quick gust
cold oyster
#

Lol

slate swan
#

trying to make an embeded message but it doesnt seem to be working? @client.command() async def embed(ctx): embed = discord.Embed(title = 'EndoBot Commands', description = 'This is a list of commands to use with EndoBot! ', color = discord.color.blue()) embed.add_field(name = 'General Commands', value = 'do Hello (Say Hello to the bot), do Bot (Says Bot Description), do Help (Says how to use the Bot and its features)', inline = true) embed.set_thumbnail(url = 'https://cdn.discordapp.com/attachments/996104926264565862/996456504033017896/BOT_NAME_1.png') await ctx.send(embed=embed)