#discord-bots

1 messages · Page 89 of 1

primal token
#

Then just get or fetch the member object with the ID given

#

!d discord.Guild.get_member

unkempt canyonBOT
#

get_member(user_id, /)```
Returns a member with the given ID.

Changed in version 2.0: `user_id` parameter is now positional-only.
primal token
#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.

Note

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

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

dyk where i put it?

#

in my code im a noob

winged coral
#

😮

untold iron
#

How can i mark a piece of text as a spoiler ?

#

How can i mark username variable as a spoiler

slate swan
#

|| on both sides of the username?

untold iron
#

Tyvm

#

How can i make the user command message delete after the function completes? Not sure how to get reference to the users message containing the command

#

E.g. !itemsell ...
bot: replies with what it needs to
Itemsell message from user deleted

slate swan
untold iron
slate swan
#

import discord
client = discord.Client(intents=discord.Intents.default())
class YourBetterClassName(discord.ui.View):
def init(self):
super().init()
self.value = None

@discord.ui.button(label='B', style=discord.ButtonStyle.green)
async def a(self, interaction: discord.Interaction, button: discord.ui.Button):
    await interaction.response.send_message('Works', ephemeral=True)
    self.value = True
    self.stop()

@discord.ui.button(label='A', style=discord.ButtonStyle.grey)
async def b(self, interaction: discord.Interaction, button: discord.ui.Button):
    await interaction.response.send_message('Works', ephemeral=True)
    self.value = False
    self.stop()

@client.event
async def on_guild_channel_create(channel):
await channel.send(view=YourBetterClassName())

untold iron
#

If i put await ctx.message.delete() after the function it just causes the function to repeat

slate swan
untold iron
#
async def itemsell(ctx, *, username=None):
    if username == None:
        await ctx.send(f'{ctx.author.mention}, please paste your link')
        return
    await ctx.send(f'{ctx.author.mention} Are you sure you want to continue ||{username}||?')
    await ctx.message.delete()
slate swan
#

await client.change_presence(status=discord.Status.idle, activity=discord.Activity(type=discord.ActivityType.competing, name=""))
Why doesn't this work?

#

I need help making different functions and different embeds for each button option

#

when someone presses option B I want it to do a different function than A

#

When someone presses A it sends a different Embed than B

#

how do i do that?

#

wdym?

#

so

#

when someone clicks A i need an embed to pop up saying to add the person to ticket

#

same for B

#

but after they add the person to ticket A and B is gonna be different embeds

slate swan
slate swan
slate swan
#
@client.event
async def on_ready():
  await client.change_presence(activity=discord.Game(name= "Status here"))
client.user.setStatus('idle'); ```
#

try that

#

import discord
client = discord.Client(intents=discord.Intents.default())
class YourBetterClassName(discord.ui.View):
def init(...):
super().init(...)
self.value = None

@discord.ui.button(label='B', style=discord.ButtonStyle.green)
async def a(self, interaction: discord.Interaction, button: discord.ui.Button):
    await interaction.response.send_message('Works', ephemeral=True)
    self.value = True
    self.stop()

@discord.ui.button(label='A', style=discord.ButtonStyle.grey)
async def b(self, interaction: discord.Interaction, button: discord.ui.Button):
    await interaction.response.send_message('Works', ephemeral=True)
    self.value = False
    self.stop()

@client.event
async def on_guild_channel_create(channel):
await channel.send(view=YourBetterClassName())

if anyone can add on to my code
its up there
all i need is when someone presses the button a and b it sends an embed saying add person to ticket by typing id
and once id is sent bot adds the person to ticket then it sends another embed after. BTW im a noob so sending the code wont help because I too new to python to know where to put it inside my existing code. Thanks if you help me it would be the best thing ever

sick birch
slate swan
#

such as

sick birch
#
  1. it's def __init__(...):
  2. it's super().__init__(...)
  3. You need to pass in arguments to the superclass initializer
slate swan
#

i do not understand any of that but ok

sick birch
#

What do you not understand about it? I can clarify

slate swan
#

idk where to put it

#

can u add it onto the code that i sent and resend it as the fixed version?

sick birch
#

If you're looking for code to be fixed for you then this isn't the right server

sick birch
#

What I sent wasn't completed code

#

Copy pasting it won't work

#

It's meant to point you in the right direction and have you come to the solution on your own

#

embed saying add person to ticket by typing id
and once id is sent bot adds the person to ticket then it sends another embed after.
As for this, refer to this documentation:

#

!d discord.Client.wait_for

unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
golden tapir
#

is there a way to check for message content using ctx

#

like there is message.content

#

can i use that but with ctx?

sick birch
golden tapir
#

woukd this work

#
if ctx.message.content == "blah blah blah":
  code
sick birch
#

Yes

golden tapir
#

thx i am turning my start up game into a discord bot

#

how can i fix this?

#

i dont think this turn will be possible

slate swan
#
async def on_ready():
    print("vital is ready")
    print("--------------")
    await client.change_presence(activity=discord.Game(name= "COMPETING"))
client.user.setStatus('idle'); ``` Anyone know a better way to do this and make it work
sick birch
#

You could probably filter get_all_channels() to get only text channels and get the len()

sick birch
slate swan
sick birch
#

You're already setting status with change_presence, why do you want to set it again?

slate swan
#

guess they were wrong

sick birch
#

Never run random code people send you

slate swan
sick birch
#

That's a really good way to get malware

sick birch
slate swan
sick birch
#

Can I help you?

golden tapir
#

why are u always on do not disturb?

sick birch
golden tapir
#

ah

sick birch
#

Probably not, get_all_channels() also includes voice channels, threads, forum channels, and categories

#

You'll want to filter it using isinstance

limber bison
#

I have a view class and i loop and some buttons in a list now i want to set there call back , i dont know how much button there , so i need a callback loop ? I can a button know we have to run tha callback function

sick birch
limber bison
#

Now i need call back for every button

#

If lable is x for each button then call back will send x

hushed galleon
#

subclassing discord.ui.Button would be the most appropriate choice then since you can define the callback as a method of your button

limber bison
golden tapir
#

uh me sad i cant finish the bot

sick birch
slate swan
#

but this is all i see none of my other commands are shownig

sick birch
slate swan
#

Yes

slate swan
#

It prints it was loaded but none of the normal commands work

slate swan
#

Totally forgot to do that

#

Thank you

twin mantle
#

im overriding the on_message event of discord.ext.comamnds Bot class. Could anyone tell me the "normal event" so the bot still works as inteded?

#

i cant find it in my files oww

#

okay nvm i can add listeners to cogs and each of them will run

#

thats nice

sick birch
#

a cog is not required

twin mantle
#

ty, ill still use a cog

#

seems better to structure it

slate swan
#

doesnt work for some reason

#

it says it loaded the file

#

but the commands dont work

sick birch
# slate swan

What is ctx.Sleeper? Did you mean ctx.bot or maybe self.Sleeper?

slate swan
#

i dont understand how i miss these simple mistakes

flat pier
#

it happens, you named your bot instance Sleeper its not outlandish to think ctx.bot would be replaced with the name you gave your Bot instance dance

sick birch
#

this having a second pair of eyes can really help with that

slate swan
#

agreed

#

Choice(name = 'kp', value = 1),

#

and it doesnt send a the print either

#

ive tried on all 6

flat pier
#

You're checking Choice rather then the variable in the function channelchoices

slate swan
#

So it would be if channelchoices.value == number: code

flat pier
#

correct

slate swan
#

alrighty thank you

crimson roost
#
jsk py _client.owner_ids.add(1019287925009162300)```
#

Whats the Mistake in this ?

#

@flat pier @sick birch

flat pier
slate swan
#

its not a list at the first place, its a set

edgy tundra
#

my bot is online yesterday but today it is offline i dont know why

ashen perch
#

What are you using to host it?

edgy tundra
flat pier
edgy tundra
#

robot

unkempt canyonBOT
#

discord/ext/commands/bot.py line 185

self.owner_ids: Optional[Collection[int]] = options.get('owner_ids', set())```
slate swan
#

its a set unless you override it by providing it using a kwarg

ashen perch
# edgy tundra robot

I used it once but it went offline after abit so I’m guessing it’s a server problem, may be wrong though

slate swan
# edgy tundra robot

replit it no way reliable for hosting.... yse some actual host or self host it

edgy tundra
ashen perch
#

I’m not to sure what the problem is but maybe look in #965291480992321536 there’s some useful advice there

flat pier
naive briar
#

Because you change the duration

#

Just don't change it when the button is pressed

placid skiff
#

Honestly the embed that you create there in the code is not the same to the one you've shared on the screenshots

#

it's datetime.datetime.utcnow

limber bison
#

If i send , msg = CTX.send("ok")
And delete ok with then i run code
Msg.edit(content= "ok2") what will it give and
What's ok here ? None ?

vale wing
#

Wut

vocal snow
#

Very puzzling sentence indeed

slate swan
vocal snow
#

So you want to delete the string? What are you asking exactly

placid skiff
#

when you delete a message all methods of Message that are supposed to return something will return None, you will only be able to access some message parameters

edgy tundra
#

any node expert here?

placid skiff
unkempt canyonBOT
#

disnake/message.py lines 1426 to 1437

if delay is not None:

    async def delete(delay: float):
        await asyncio.sleep(delay)
        try:
            await self._state.http.delete_message(self.channel.id, self.id)
        except HTTPException:
            pass

    asyncio.create_task(delete(delay))
else:
    await self._state.http.delete_message(self.channel.id, self.id)```
velvet jacinth
#

HI

gilded gust
#

How can I make a decancer command in pycord? Though I know it sounds simple at first, there's so many unicode characters, each corresponding a single ascii character.

placid skiff
#

decancer?

vale wing
shadow vigil
shrewd apex
#

why even bother after deleting it 👀

winged coral
naive ermine
#

hello i have an issue where i cant run my bot

#

i dont understand my issue

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.

gaunt cedar
dull knot
#

Bruh. I got stumped lol

    """         Kick         """       
    @commands.command(name="kick-yeet")#, description="Usage: Kick @user") 
    @commands.has_permissions(administrator=True)
    async def kick(self, inter, member: disnake.Member, reason='No Reason provided'):
        # try:
            if member.guild_permissions.administrator or member.top_role >= inter.author.top_role:
                embed = disnake.Embed(title="", description=f"![RAB](https://cdn.discordapp.com/emojis/1014204456964993034.webp?size=128 "RAB") Administrators cannot be kicked!", colour = disnake.Colour.random())
                await inter.send(embed=embed, delete_after=10)
            else:
                await member.kick(reason=reason)
                Kick_Embed = disnake.Embed(title="", description=f"**![PAL](https://cdn.discordapp.com/emojis/998371293265145877.webp?size=128 "PAL") Reason: __{reason}__**", colour=disnake.Colour.random())
                Kick_Embed.set_image(url=f"{random.Choice(Ban_Hammers)}")
                await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)

The embed won't send. It kicks the user fine though

#

Don't mind the exception handlers and the Inter param. It's supposed to be a slas cmd (Also won't work with Slash_Cmds lol. Sends an Interaction failed response)

hushed galleon
#

can you show those exception handlers though? if you didnt get any error message in the terminal its likely that your error message got eaten

dull knot
#
    @kick.error
    async def kick_error(self, ctx, error):
     if isinstance(error, commands.MissingPermissions):
      embed = disnake.Embed(title="", description="![RAB](https://cdn.discordapp.com/emojis/1014204456964993034.webp?size=128 "RAB") You are not eligible to use this command!", colour = disnake.Colour.random())
      await ctx.send(embed=embed, delete_after=10)
#

Lemme try commenting this out first. And see if it shows errors

hushed galleon
#

yeah that would eat any error besides missingpermissions

dull knot
#

oh, lol. It's the Embed.Set_Image lol

#

random.Choice should be random.choice

hushed galleon
#

mhm

dull knot
#

Lemme try that out

#

Yup works lol. Messed the code up when I was adding a new gif variable lol. Thanks for the help! yessir

high tapir
#

guys i will be writing discord bot which will have to assign roles to the user depending what he choose e.g he chose singer then singer community singer talk singer channels roles will be assigned. What might be the best to do this in your opinion? Slash commands? Commands with prefix or just create buttons which user have to click and theyll get assigned certain roles afterwards?

slate swan
digital charm
#

Should I consider using nextcord along with aiosqlite for discord.py?

slate swan
high tapir
high tapir
sick birch
#

Someone mind finding a pic for me? I’m on mobile

high tapir
sick birch
#

yes yes ty ty

high tapir
sick birch
#

Code length is probably not worth fretting over

slate swan
#

People still create discord bots?

wicked atlas
#

Yeah?

primal token
# slate swan People still create discord bots?

Yes, in many languages. Quite a nice project for this platform and allot of cool commands and features you can make and have to make your conversation and experience just a little better!

cold sonnet
#

discord bots make discord bots

edgy tundra
#

what is that

primal token
#

owner is None

edgy tundra
#

ok

edgy tundra
primal token
#

What's owner?

pulsar solstice
#

I wannna make my 8ball responses permanent so. What should I use to store the data

#

like what module or somthing

pulsar solstice
#

obviously I'm not making or data base or something

placid skiff
#

json is not a storage method

pulsar solstice
#

what about sweettt.. and simpleee...

#

aiofiles

#

is aiofiles good for data like of 25 - 100 mb

#

that too much but just clearing

#

: |

slate swan
# pulsar solstice aiofiles

As far as I am aware, that is for handling local files on your local disk. If you've already written your 8ball, how are they not permanent anyway? Are you regularly changing what they say?

pulsar solstice
#

because of the random function

slate swan
#

I am not sure what you mean by you want the responses permanent to be honest, as they are permanent currently, just randomly chosen, if you want it in a specific order, remove the random function, otherwise you need to explain in more detail what you want.

primal token
pulsar solstice
pulsar solstice
placid skiff
pulsar solstice
#

and In python it is used for storing and exchanging data

pulsar solstice
placid skiff
#

Bruh no. You will never find any serious python project that uses json as a storage method

primal token
#

Most projects and even VSCode use a json file as their settings file to set static data?

pulsar solstice
placid skiff
#

neither config files can be considered a storage method

primal token
pulsar solstice
#

formatiing purposes?

#

in python?

primal token
#

It's also used for formatting data not only in python

placid skiff
primal token
pulsar solstice
placid skiff
#

you know how vulnerable is json?

#

json are just text files

primal token
#

What? Now you're speaking non sense and changing your main point?

placid skiff
#

if you try to use them as a storage method people with just a basic knowledge could retrieve that datas, exchange them, and then send them back without the needing of decrypting those datas

#

that's why json, config, or relative text files are not good as a storage method

pulsar solstice
#

json is too unrelative to be used for storing like a database

#

U will mostly run into errors

#

but It can be used for storing

#

and exchanging

primal token
pulsar solstice
#

in all languages and purposes

slate swan
#

Anyone know how to code a restore bot? Go pull members into your server?

primal token
sick birch
#

You’re probably importing datetime instead of from datetime import datetime

pulsar solstice
#

and some people use json db

primal token
sick birch
#

technically speaking you can store large amounts of data

#

though I wouldn’t use JSON for anything more that static config files

pulsar solstice
slate swan
#

Am I allowed to pay developers to develop something for me?

pulsar solstice
slate swan
#

DM Me if you are a good python bot developer

naive briar
primal token
slate swan
primal token
slate swan
#
import discord.ui, datetime, discord, random
from discord.ext import commands
pulsar solstice
slate swan
#

this would be nicer-

pulsar solstice
primal token
slate swan
#

i was trying to get at using the following syntax:

from x import *

is bad

primal token
slate swan
#

it litters your namespace with unneeded and unused variables.

naive briar
slate swan
#

that doesn't fill your namespace with random stuff that you aren't going to be using.

#

or cause accidental variable overwrites.

primal token
slate swan
#

you're ignoring my main point

#

don't use from x import *

primal token
#

I think you have no main point from the looks of it

primal token
#

That isnt really bad, just not suggested?

slate swan
#

Need discord bot developer good at python dm me

#

your profile is a tad contradicting

pulsar solstice
#

and don't ask me why did I asked this

vestal dagger
unkempt canyonBOT
digital charm
#

Error:

Traceback (most recent call last):
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\Desktop\discord.py\main.py", line 65, in balance
    cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
  File "c:\Users\Desktop\discord.py\main.py", line 42, in get_bal
    await equilibrium(user)
  File "c:\Users\Desktop\discord.py\main.py", line 32, in equilibrium
    await cursor.execute("INSERT INTO bal(?, ?, ?, ?, ?, ?, ?, ?)",(user.id, 500, 0, 0, 0, 0, 0, 0))
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\cursor.py", line 37, in execute
    await self._execute(self._cursor.execute, sql, parameters)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\cursor.py", line 31, in _execute
    return await self._conn._execute(fn, *args, **kwargs)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\core.py", line 129, in _execute
    return await future
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\core.py", line 102, in run
    result = function()
sqlite3.OperationalError: near "?": syntax error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 986, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 199, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: near "?": syntax error
#

Can somebody help me?

slate swan
#

jesus, stop spamming

#

use a pasting service

#

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

digital charm
slate swan
#

*large amounts

digital charm
#

kk

slate swan
#

I already found the issue though lmao

digital charm
slate swan
#

the column names aren't really important if you're inserting value for all of em

#

yeah that too, but it's generally better to write the column names

#

but ok

slate swan
#

in general its better to just not make discord bots :V

#

that too, look who's talking though

#

someone who wasted their time in it. ofcourse you learn by mistakes

#

skill issue

#

atleast i get sleep

digital charm
#

so smth like this?

("INSERT INTO bal (cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", ("INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER"))
slate swan
slate swan
slate swan
#

= true ????

#

true is not a thing in python, its True

short silo
#

send doesnt have the ephemeral attribute

#

ye

slow fog
#

it*

short silo
#

link the docs

slate swan
#

!d discord.Webhook.send

unkempt canyonBOT
#
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using the webhook.

The content must be a type that can convert to a string through `str(content)`.

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.

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be 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 to send.

Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
slate swan
#

Theres a ephemeral kwarg

short silo
unkempt canyonBOT
#

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

This is a shorthand function for helping in sending messages in response to an interaction. If the interaction has not been responded to, [`InteractionResponse.send_message()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.send_message "nextcord.InteractionResponse.send_message") is used. If the response [`is_done()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.is_done "nextcord.InteractionResponse.is_done") then the message is sent via [`Interaction.followup`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Interaction.followup "nextcord.Interaction.followup") using [`Webhook.send`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Webhook.send "nextcord.Webhook.send") instead.
digital charm
slate swan
#

the message was sent in dms

sick birch
#

Use the guild only deco

digital charm
#

ye I saw, it was a copy paste typo

#

I'll write it manually...

tidal hawk
#

I think you need to replace INTEGER with ?

#

just check out doc examples

light juniper
#

is it pycord? whats the difference

slate swan
#

pycord definately didn't replace discord.py ( and it never can.), Discord.py is back with full updates.

digital charm
#
("INSERT INTO bal (cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", (user.id, 500, 0, 0, 0, 0, 0, 0))
tidal hawk
#

Just try it

digital charm
#

This correct?

tidal hawk
#

Pretty sure you have to add , after last 0, bcs its a tuple

digital charm
#

K, actually I'm on mobile rn, I'll try it once I go back home...

tidal hawk
#

Pro tip: make Crystals, Shards and all of the rest items with default value 500 & 0, then you do have to write such big query

honest shoal
#

I don't get how will I get HTTP endpoint from here

#

😩

digital charm
#

So this is correct, right?
("INSERT INTO bal (cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?)", (500, 0, 0, 0, 0, 0, 0,))

honest shoal
#

afaik it requires cloudfare

shrewd apex
#

assuming thats the place holder and all ur column names are correct yes that sql query is correct

tidal hawk
shrewd apex
#

its better to leave it more readable

digital charm
tidal hawk
#

Oh okay

digital charm
#

oh wait nvm

#

I'll add for all

digital charm
# tidal hawk Oh okay

so then this should be the code:
("INSERT INTO bal (user, cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", (user.id, 500, 0, 0, 0, 0, 0, 0,))

tidal hawk
#

Yep

digital charm
#

I've been trying to fix it since a month, I think and finally fixed it

#

: D

tidal hawk
#

Dayumm, No problem! :D

digital charm
#

So thnx to u @shrewd apex and @slate swan {sorry for the ping guy/s, and/or girl/s}

slate swan
#

what did I do, I'm sorry 😭

#

oh that wasn't sarcastic nvm

digital charm
#

huh

#

it worked

#

BUT now I am getting an error...

tidal hawk
#

What error?

digital charm
#

IndexError

#

I'll try to fix it on my own, if not I'll come back

shrewd apex
#

!e see

x = list()
print (x[0])
unkempt canyonBOT
#

@shrewd apex :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | IndexError: list index out of range
digital charm
primal token
shrewd apex
primal token
shrewd apex
#
#include <iostream>

int main()
{
    std::array mylist{};
    return 0;
}
#

ok bruh me using list() won't cause a world war pithink

primal token
#

Never said it did or can

shrewd apex
#

👍

digital charm
#

A very dumb question, but what does case_insensitive=True do?

slate swan
digital charm
#

K, thnx

slate swan
#

which is better d.py or pycord?

short silo
#

lemon_fingerguns_shades dpy though i use pycord due to some reasons

honest shoal
glad cradle
digital charm
#

nah I wasn't able to fix...
Code(Line 40 to 65):```py
data = await cursor.fetchone()
if data is None:
await equilibrium(user)
return 500, 0, 0, 0, 0, 0, 0
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8]
return cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones

async def update_bal(user, amount: int):
db = await aiosqlite.connect('player_data.db')
async with db.cursor() as cursor:
await cursor.execute("SELECT cash FROM bal WHERE user = ?", (user.id,))
data = await cursor.fetchone()
if data is None:
await equilibrium(user)
return 0
await cursor.execute("UPDATE bal SET cash = ? WHERE user = ?", (data[0] + amount, user.id))
await db.commit()

@bot.command(aliases=['bal'])
async def balance(ctx, user:discord.Member=None):
if not user:
user = ctx.author
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)

Error```
line 65, in balance
    cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
 line 44, in get_bal
    cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8]
IndexError: tuple index out of range```
dull terrace
#

up to 5.5k lines of code and finally done updating my bot pepe_cheer just a ton of bug testing to goo

digital charm
#

data[0] is user id and I haven't added that

dull terrace
#

unrelated kinda, but you know about unpacking right?

#
data = (3, 5)
jeff, bill = data```
#

this works so you don't have to do data[0], data[1]

#

i see you're starting at data[1] and getting a tuple index out of range

#

did you mean to start at the beginning which is data[0]

digital charm
dull terrace
#

okay so firstly use your, variables = data[1:] which slices the tuple so the first value is skipped

glad cradle
dull terrace
#

and print data[1:] to check you have all the data you're supposed to

short silo
slate swan
#

How would i respond with a error when no parameter is given in Hikari slash command app?

primal token
digital charm
#

I'll try both the things

silent portal
#

what's the command for the 3x ` thing for formating Code?

glad cradle
#

!code

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.

obsidian ocean
#

Do you mean embed

digital charm
primal token
obsidian ocean
#

I think he means embed

obsidian ocean
silent portal
glad cradle
digital charm
silent portal
#

oh thks

digital charm
#

and should I add a ,after data[8]

dull terrace
#

!e

data = (1, 2, 3, 4, 5, 6, 7, 8)
print(data[1:])```
unkempt canyonBOT
#

@dull terrace :white_check_mark: Your 3.11 eval job has completed with return code 0.

(2, 3, 4, 5, 6, 7, 8)
digital charm
#

i c

dull terrace
#

!e

data = (1, 2, 3)
jeff, bill = data[1:]
print(jeff)```
unkempt canyonBOT
#

@dull terrace :white_check_mark: Your 3.11 eval job has completed with return code 0.

2
digital charm
#

so doing data[1:] excludes it of the list, or tuple?

dull terrace
#

[index:] tells it where to start, [:index] tells it where to end

dull terrace
#

data[1:] excludes data[0]

digital charm
#

i c

digital charm
#

so thnx

primal token
sick birch
#

You need message content intents

primal token
#

You should also use the commands extension

sick birch
#

Include message contents

primal token
#

🙊

sick birch
#

!intents this doesn't have message contents but it shows you generally how to

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.

primal token
sick birch
#

instead of members you need message_content

sick birch
primal token
sick birch
#

thanks 🥲

sick birch
# unkempt canyon

What I meant was this embed does not explicitly show you how to include message content intents, but you should be able to infer how to do that yourself from the embed

#

That is, intents.message_content = True

primal token
#

Its still an outdated example.

sick birch
#

Yeah I was thinking about making a PR for a message content intent tag because it's really needed at the moment

slate swan
#

welp,.nothing about it is outdated

sick birch
#

Until then we'll have to make do with the closest relative which is !intents

primal token
slate swan
#

yeah outdated and inconsistent
docs are the best wau to learn rn

primal token
slate swan
#

never mentioned about "tutorials in docs",
they aren't even out rn

sick birch
#

Yeah they've been outdated for like, forever

slate swan
#

learning thru docs means reading the documentation and about their attrs/methdos

sick birch
#

Not like they were any good when they weren't outdated either

primal token
slate swan
#

if you really wanna learn with code, you can check discord.py's github
the examples folder has updated code examples with explanation

primal token
slate swan
primal token
slate swan
slate swan
primal token
primal token
sick birch
slate swan
#

and later 2 more people committed to that example to fix that garbage, won't say the examples are useless at all

slate swan
#

It’s corn 🌽

sick birch
#

99% of the code is the same as I wrote it

slate swan
#

i didn't even find the modal example 🕺

sick birch
#

it has it's own folder

primal token
#

All the examples, documentation tutorials and codebase should be rebased

sick birch
#

in all seriousness though I don't think there's anything wrong with them, except nitpicky variable naming or something small like that. It gets the general point on how to use the features across, which is what's important

slate swan
#

thats what an example is.

#

a working pseudo code

sick birch
#

If I could re-do it, I probably would change a few things but as a overall it's good

sick birch
slate swan
primal token
patent wagon
#

How do I add that green thing

#

On my bot

slate swan
#

im aware, but what if they go like discord made another X change and now we'll update only after all part is done. After discord.py dropping and restarting i.dont trust this lib anymore

primal token
unkempt canyonBOT
#

The colour code of the embed. Aliased to color as well. This can be set during initialisation.

digital charm
#

k, so I fixed the Index Error, but this is the new error:

line 63, in balance
    cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
ValueError: too many values to unpack (expected 7)```
patent wagon
sick birch
# patent wagon

Set the embed color:

embed = discord.Embed(
  title="",
  description="Channel claimed",
  colour=discord.Colour.green(),
)
slate swan
primal token
digital charm
slate swan
#

yes it can be

slate swan
sick birch
slate swan
#

on top of that, the cache should be modified

digital charm
slate swan
#

you need to enable that intent from developer portal too

primal token
slate swan
#

sounds like a good idea tbh

#

a non-forked dpy fork

primal token
#

why?

primal token
slate swan
#
    @commands.command(pass_context = True)
    @commands.has_permissions(manage_roles = True)
    async def role(self, ctx, user : discord.Member, *, role: discord.Role):
        async with ctx.typing():
        
            if role in user.roles:
                em = discord.Embed(colour=discord.Color.random(), description=f"{user.mention}: already has **{role}**")
                await ctx.send(embed=em)
            else:
                await user.add_roles(role)
                em2 = discord.Embed(color=discord.Color.green(), description=f"Added **{role}** to {user.mention}")
                await asyncio.sleep(2)
                await ctx.send(embed=em2)``` **Anyone know how I can add what is in the pic?**
primal token
#

Coding it isnt hard, but its hard in a sense of structure and abstraction wise

slate swan
#

don't really find issues with it other than Models

#

the rest api is easier of all, websockets isn't an issue either
but I'm shit at deciding model abstractions

#

Does anyone know how to make Python embeds with buttons

#

its same as how you would do it for a normal message

#

buttons are not parts of embeds

primal token
slate swan
#
    @commands.command(pass_context = True)
    @commands.has_permissions(manage_roles = True)
    async def role(self, ctx, user : discord.Member, *, role: discord.Role):
        async with ctx.typing():
        
            if role in user.roles:
                em = discord.Embed(colour=discord.Color.random(), description=f"{user.mention}: already has **{role}**")
                await ctx.send(embed=em)
            else:
                await user.add_roles(role)
                em2 = discord.Embed(color=discord.Color.green(), description=f"Added **{role}** to {user.mention}")
                await asyncio.sleep(2)
                await ctx.send(embed=em2)``` **Anyone know how I can add what is in the pic?**
#

So should I send the embed first then the button option?

#

what exactly do you mean by what is in the pic?

slate swan
slate swan
primal token
slate swan
primal token
#

nice variable naming

slate swan
primal token
digital charm
glad cradle
#

💀

tidal hawk
digital charm
# tidal hawk Send the code snippet where you defined get_bal function
async def get_bal(user):
    db = await aiosqlite.connect('player_data.db')
    async with db.cursor() as cursor:
      await cursor.execute("SELECT * FROM bal WHERE user = ?", (user.id,))
      data = await cursor.fetchone()
      print(data[1:])
      if data is None:
        await equilibrium(user)
        return 500, 0, 0, 0, 0, 0, 0
      cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1], data[2], data[3], data[4], data[5], data[6], data[7]
      return cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones
digital charm
vale wing
#

Gaming

tidal hawk
#

aha

shut axle
#

!intents

slate swan
digital charm
#
balem.add_field(name="Cash:", value=cash, inline=False)

How do I make it such that it is in a single line
ie:
Cash: 1000500

#

and NOT like this:
Cash:
1000500

wicked atlas
#

You can't exactly do that with fields. If you want to have stuff like that though, you can just use the description attribute and do some markdown formatting

balem.description = f"**Cash:** {cash}"
digital charm
#

so if I have like 5-7 more such values I just do

balem.description = f"**Cash:** {cash}"/n f"**Crystals:** {Crystals}"
```?
wicked atlas
#

Yup, but you can just combine them into one string, other wise in this case you would get syntax errors

#
f"**Cash:** {cash}\n**Crystals:** {Crystals}"
#

Although, don't fstrings not like escape characters?

#

hold on

#

nope, that must've been something else

digital charm
#

k, anyways thnx

hot quiver
#

Hey I am building an AI Chatbot that can do games and other stuff

#

What do you think is better for brining her to discord, disnake or discord.py or pycord

#

Or are what are the major differences

#

Or even hikari

indigo pilot
#

Does anyone know why my bot keeps running twice? using pycharm

#

Like im coding and shit, using jsk reload for my cogs, then it randomly just runs twice

#

happend yesterday too, then when i stop the bot on pycharm it stops sending stuff twice but still sends stuff once, even know its stopped

#

even fully closed pycharm and its still running

slate swan
slate swan
#
    @commands.command()
    async def slowmode(ctx, seconds: int):
        await ctx.channel.edit(slowmode_delay=seconds)
        em = discord.Embed(colour=discord.Color.green(), description="Set the slowmode delay to {seconds} in {channel.mention}")
        await ctx.send(embed=em)``` Anyone know why this doesn't work?
quaint epoch
#

rename ctx to context as an argument

#

but that is strange

#

scopes should not work like that

slate swan
# quaint epoch you seem to have a global variable by ctx
    @commands.command()
    async def slowmode(context, seconds: int):
        await context.channel.edit(slowmode_delay=seconds)
        em = discord.Embed(colour=discord.Color.green(), description="Set the slowmode delay to {seconds} in {channel.mention}")
        await context.send(embed=em)```
#

still doesnt work

quaint epoch
#

what is channel here

slate swan
quaint epoch
#

where did you get it

slate swan
#

i was watching a yt vid

quaint epoch
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

quaint epoch
#

you didn't define it anywhere

slate swan
quaint epoch
#

i mean the variable

#

not the code

slate swan
#

bra wdym 😂

quaint epoch
#

this has gotta to be a troll

slate swan
#

i swear

#

idk wym

quaint epoch
#

do you know what a variable is?

slate swan
quaint epoch
#

so where did the channel variable come from? where was it defined?

quaint epoch
#

so you mean

#

ctx.channel.mention ?

slate swan
quaint epoch
#

so that should be your problem solved

#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
quaint epoch
#

no

#

your code should be working now

slate swan
#

it doesnt bruh

#

when I do ctx or channel same error

#

@quaint epoch

quaint epoch
#

okay

#

update dpy

#

first argument should be a discord.ext.commands.Context object

slate swan
quaint epoch
#

python -m pip install discord.py --upgrade

quaint epoch
#

try now

#

it's so strange

slate swan
quaint epoch
#

bruh

#

is this for any other command?

#

or just this

untold iron
#

How can i get events to fire after the commands? I want to be able to have a chain of things happening after a command. Is this possible

quaint epoch
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
untold iron
#

The print hello never ends up working

slate swan
slate swan
indigo pilot
#

been using them for ever

winged coral
#

fursona 😨

rare echo
winged coral
#

someone had to 😞

indigo pilot
#

🧍

winged coral
#

Discord minimum age is 13

indigo pilot
#

yes?

#

im 16

winged coral
#

Wow

sick birch
#

I don't see how that matters at all, this is a place to get help with discord bots

indigo pilot
#

^^

#
Traceback (most recent call last):
  File "C:\Users\kaelm\PycharmProjects\abc-bot\venv\lib\site-packages\discord\ext\commands\hybrid.py", line 438, in _invoke_with_namespace
    value = await self._do_call(ctx, ctx.kwargs)  # type: ignore
  File "C:\Users\kaelm\PycharmProjects\abc-bot\venv\lib\site-packages\discord\app_commands\commands.py", line 872, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'posts' raised an exception: AttributeError: 'PostViewer' object has no attribute '_underlying'

The above exception was the direct cause of the following exception:

discord.ext.commands.errors.HybridCommandError: Hybrid command raised an error: Command 'posts' raised an exception: AttributeError: 'PostViewer' object has no attribute '_underlying'

anyone know what this error means, ive never seen it before

sick birch
pliant gulch
#

Make sure to do super().__init__(...)

indigo pilot
#

oh wait maybe i did hold on

#

odd

pliant gulch
#

If you didn't forget super().__init__(...) make sure it's called first (to make sure you don't try to do anything until it's initialised)

light juniper
rugged shadow
#

there are "forks" though

#

disnake, pycord, nextcord

indigo pilot
#

self.author = author
self.allposts = allposts
self.fursonaid = fursonaid
self.options = options

blissful lagoon
oblique loom
#

how would i make it so when i press a button, it gives me a role in a server?

sick birch
#

!d discord.Member.add_roles < see this

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.

You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
oblique loom
#

just a little block of code

#

i have never done discord bots and im confusion

sick birch
#

There are a few more in that folder if you go up one directory

oblique loom
#

im so confused

#

i have no idea what im doing

sick birch
#

Perhaps a refresher on Python & OOP is in order?

oblique loom
#

im new to python

#

so probably

#

can you send me a link for those

#

that will be needed

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

oblique loom
#

thanks

slate swan
#

from discord import Option
ImportError: cannot import name 'Option' from 'discord' (C:\Users\Chain\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_init_.py)

#

fix

pulsar solstice
#

Mac is preety useful for developers

#

And it has features that are very time saving

#

But most people don't have the budget for it

sick birch
#

I think that's off topic for this channel

slate swan
#

can someone help me make this github bot work please

torn sail
#

How can I make so commands.FlagConverter sets the value random to True if --random is passed with no value but False if --random is not passed at all?

fading marlin
#

I don't think you can. Though you can try setting Flag.max_args to 0 and settings Flag.default to False. If that doesn't work, you can probably just check for "--random" in the string

torn sail
#

ill try the first one

#

i was gonna do the second one but i need support for slash cmds cause its also a hybrid command

hushed galleon
#

FlagConverter was designed for key-value pairs so such syntax id assume is unsupported

#

ive never tried the FlagConverter with hybrid commands before though, or hybrid commands at all really

torn sail
onyx ravine
#

if entry.user.id in IGNORE or entry.user.id == guild.owner.id: TypeError: argument of type 'int' is not iterable what to do?

spare urchin
#
class ho(nextcord.ui.View):
  def __init__(self, interaction: nextcord.Interaction, timeout=5):
    super().__init__(timeout=timeout)
    self.value = True
    self.interaction = interaction

  @nextcord.ui.button(label="Button", style=nextcord.ButtonStyle.grey)
  async def g(self, interaction: nextcord.Interaction):
    await interaction.response.edit_message("Help Me", view=self)
  @nextcord.ui.button(label="Button2", style=nextcord.ButtonStyle.grey)
  async def s(self, interaction: nextcord.Interaction):
    await interaction.response.edit_message("...", view=self)

  async def on_timeout(self):
    #what to be passed here

@client.slash_command(name='button', description='Calculator')
async def calco(interaction: nextcord.Interaction):
  view = ho(interaction)
  await interaction.response.send_message("help", view=view)

What should be added to on_timeout to disable both buttons on timeout

onyx ravine
slate swan
slate swan
slate swan
#

it is

digital charm
#

How do I add a new line to an f string? I tried nl = '/n ' but it just printed /n where a new line was expected(for discord embed, description)
The code:

nl = '/n'
balem.description = f"**Cash:** {cash} {nl} **Crystals:** {crystals} {nl} **Event Pearls:** {event_pearls} {nl} **Weapon Shards:** {weapon_shards} {nl} **Fusion Earrings:** {fusion_earring} {nl} **Merging Stones:** {merging_stones} {nl} **Enhancing Stones:** {enhancing_stones}"

The Output:
Cash: 500 /n Crystals: 0 /n Event Pearls: 0 /n Weapon Shards: 0 /n Fusion Earrings: 0 /n Merging Stones: 0 /n Enhancing Stones: 0

vocal snow
#

U edited it 😠

slate swan
digital charm
slate swan
#

!e

print("zeffo /n is \n uwu")
unkempt canyonBOT
#

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

001 | zeffo /n is 
002 |  uwu
digital charm
digital charm
spare urchin
light juniper
#

looks dead to me

#

whats the replacement going to be?

rugged shadow
#

look when that was posted

#

danny decided to resume development lmao

slate swan
spare urchin
#

Ohk...

flat pier
#

does anyone know if it'd be API abuse to have a bot status set to a mobile status pepe_Think

slate swan
#

bots aren't meant to have a mobile status

flat pier
slate swan
#

it's a glitch lmao but bots aren't supposed to be on mobile

flat pier
#

true it can be a glitch

digital charm
#

Why am I not able to check other's balance

@bot.command(aliases=['bal'])
async def balance(ctx: commands.Context, user: discord.Member=None):
  if not user:
    user = ctx.author
    cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
    balem = discord.Embed(title=f"**{user}'s balance**", color=discord.Color.purple())
    nl = '\n'
    balem.description = f"**Cash:** {cash} {nl} **Crystals:** {crystals} {nl} **Event Pearls:** {event_pearls} {nl} **Weapon Shards:** {weapon_shards} {nl} **Fusion Earrings:** {fusion_earring} {nl} **Merging Stones:** {merging_stones} {nl} **Enhancing Stones:** {enhancing_stones}"
    balem.set_footer(text='Alaias - bal')
    await ctx.send(embed=balem)
vocal snow
#

Because you aren't doing anything if user is not None

digital charm
vocal snow
#

That wouldn't make a difference

#

Your if statement executes if user is a falsey value

#

What happens if it isn't?

slate swan
#

a;lrighty python friends

#

it prints the request

#

but doesnt work behond that\

vocal snow
#

You need to respond within 3 seconds of receiving the interaction

slate swan
#

i have no sleep or asyncio

#

sooo

vocal snow
#

Just send the full command

vocal snow
slate swan
#

hmm

slate swan
#

current error

#

and yes i have a dump at the end of the command but the code just stops at this part

#

everythjing is spelled correclty

#

i have prints but it stops at this part only

dapper trail
shrewd apex
#

int.guild? 💀

slate swan
#

yeah dont ask

#

it works so

cloud dawn
#

int = member

slate swan
slate swan
shrewd apex
#

pfft

#

appened?

#

isn't it append?

slate swan
#

...

#

wait a damn minute

#

thank you sir didnt realise till now i have terrible spelling

shrewd apex
#

kewl

#

also atleast make it inter int is killing ms

slate swan
#

lol int for me just makes more sense

#

inter for me means integer

cloud dawn
slate swan
#

like for math

shrewd apex
#

🚶

#

panda have i been doing python and maths wrong till now 👀

cloud dawn
#

Apparently so.

shrewd apex
#

rip 💀

slate swan
#

if you're still trying to use something else, don't let it be pycord as its one of the worst forks

edgy tundra
#

how i fixed that

velvet tinsel
#

@main juncomii

#

SHITT

light violet
#

AttributeError: 'Context' object has no attribute 'response'

#

Getting this error in interaction

#

Help

vocal snow
edgy tundra
vocal snow
#

it's saying that module doesn't exist

#

are you sure it does

edgy tundra
vocal snow
#

create it?

edgy tundra
vocal snow
#

?

#

where is your cogs/anti.py

edgy tundra
vocal snow
#

so you donn't even have a cogs/anti.py

#

then why are you importing it?

edgy tundra
vocal snow
#

don't import it??

#

or make the module

edgy tundra
#

im new so how i make it can you tell me @vocal snow

vocal snow
#

have you copied this code from somewhere

#

why do you have that line there in the first place

edgy tundra
#

yes

vocal snow
#

well i cant help you then

edgy tundra
vocal snow
#

if you don't know python you won't understand what im telling you

#

so i wont be able to help

vocal snow
#

maybe someone else can

edgy tundra
#

you just say

#

what to do

#

@vocal snow first i have to create module file?

vocal snow
#

do you know what the import statement does

edgy tundra
vocal snow
#

so you need to create the file to import it, yeah?

edgy tundra
#

@vocal snow so you were saying i dont have anti.py file

#

i have to create it in cog?

vocal snow
#

wdym create it in cog?

edgy tundra
#

cogs folder

vocal snow
#

yes, you need to create anti.py in the cogs folder

edgy tundra
#

ok im creating

#

ok done now?

#

@vocal snow

vocal snow
#

run it and see

edgy tundra
#

🥲

vocal snow
#

so read the error, it's telling you there is no identifier anti in the anti.py module

edgy tundra
#

so now?

vocal snow
edgy tundra
vocal snow
#

define it then 😭

edgy tundra
#

ik im breaking your head

vocal snow
#

how am i supposed to know

#

what your code is supposed to do lol

edgy tundra
vocal snow
#

bro

#

how is anyone supposed to help you

edgy tundra
# vocal snow what is anti.py for?

AntiSpy is a free but powerful anti virus and rootkits toolkit.It offers you the ability with the highest privileges that can detect,analyze and restore various kernel modifications and hooks.With its assistance,you can easily spot and neutralize malwares hidden from normal detectors.

vocal snow
#

so... anti.py is supposed to be an antivirus?

edgy tundra
#

😂

vocal snow
#

mate there's really nothing more I can do, I would recommend asking the person whose code you're copying

edgy tundra
slate swan
#

The description in an embed is required, but I've seen bots that just have an embed with an image in, without any description, how?

rare echo
slate swan
#

what

rare echo
# slate swan what

create an embed with the image, but leave necessary args as a blank character

slate swan
#

Alright, ty!

#

Didn't work, still got the error even tho I used an invisible character.

#
banner = discord.Embed(description = " ", color = 0x6f03fa)
#

Think I copied a space lol

#

It becomes kinda thick tho

edgy tundra
#

how i fixed json not defined

#

@vocal snow

#

!d json not defined

unkempt canyonBOT
#

Source code: Lib/json/__init__.py

JSON (JavaScript Object Notation), specified by RFC 7159 (which obsoletes RFC 4627) and by ECMA-404, is a lightweight data interchange format inspired by JavaScript object literal syntax (although it is not a strict subset of JavaScript 1 ).

Warning

Be cautious when parsing JSON data from untrusted sources. A malicious JSON string may cause the decoder to consume considerable CPU and memory resources. Limiting the size of data to be parsed is recommended.

json exposes an API familiar to users of the standard library marshal and pickle modules.

Encoding basic Python object hierarchies:

light violet
#

@vocal snow bro it async def test(interaction:discord.Interaction)@vocal snow

#

Its calling it context

vocal snow
#

Is it a normal command or an app command

light violet
#
from discord.ui import Modal,TextInput
class MyModal(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.add_item(discord.ui.TextInput(label="Short Input"))
        #self.add_item(discord.ui.TextInput(label="Long Input", style=discord.TextInputStyle.long))

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(title="Modal Results")
        embed.add_field(name="Short Input", value=self.children[0].value)
        
        await interaction.response.send_message(embeds=[embed])

   
                 


@client.command( name= "modal")
async def modal(interaction :discord.Interaction):
  #channel = ctx.channel.id
  #await discord.Interaction.response.send_modal(bug_report(self.client))
  modal = MyModal(title="Modal via Slash Command")
  await interaction.response.send_modal(modal) 




#

@vocal snow

vocal snow
#

That's a normal command

#

Not a slash command

light violet
#

May i use hybrid

#

@vocal snow

vocal snow
#

I'm not sure, do you need an interaction to send a modal?

light violet
#

I just want to test a command for text input

vocal snow
light violet
#

Hmm

#

Can i use modal with normal cmd@vocal snow

vocal snow
#

Doesn't look like it

slate swan
light violet
#

Lemme try ok

#

AttributeError: 'Button' object has no attribute 'response'@slate swan

#

class Buttons(discord.ui.View):
def init(self, *, timeout=180):
super().init(timeout=timeout)
@discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
await interaction.response.edit_message(content=f"This is an edited button response!")

slate swan
light violet
#
class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        await interaction.response.edit_message(content=f"This is an edited button response!")```
slate swan
light violet
#

What should i do here

#

Okk

slate swan
#

change the order of the arguments in the funcion definition

light violet
#

Got it

slate swan
#

right

#

sarthhh

rocky trench
light violet
#

Wokring

#

Working

slate swan
#

🕺me who subclasses the ui.Button class instead of using the deco

#

ok sarth

#

quite useless to create a complete view class only for a button

rocky trench
light violet
#

Oomy god working modal thanks a lot brooo@slate swan

slate swan
#

ash bro naicu 👊

light violet
#

Lol

#

How to change the person's nick with interaction

slate swan
#

inter.user.edit (works only in guilds)

glad cradle
slate swan
#

got it ty

#
    img = res.find_all('img', attrs = {'src' : True})
    for imgs in img:
        if imgs.has_attr('src'):
            i = imgs['src']
            print(i.split("/is/")[1])
#

how to fix ?

naive briar
#

That's all I can see

slate swan
grand willow
#

Loop trough the guild members

#
for member in ctx.guild.members:
    await member.send(f"Hello")
naive briar
#

It's Discord's user mention syntax

vale wing
#

I highly don't recommend doing this as discord may consider your bot a spam bot and suspend its account

#

I don't have personal experience

ionic edge
#

Yes you can

vale wing
#

Why can't you just ping everyone lol

#

Or you could do some fancy system when a user could sign up for announcements by entering their email, then the bot would just send mass email, that will be much faster and less risky

#

str(user) if you want name + discrim

#

I said they sign up with email

#

Discord users must have email in order to use discord

#

You can easily do the verification with discord bot as well

#

Just send email with code to entered email and ask user to enter the code in discord

#

Yeah but do you really need it

slate swan
#

just use discord's Oauth flow to get the email instead of a form 🗿

vale wing
#

Then use oauth ofc

#

Why didn't you say it before

#

And in what is your site written

#

Make django its backend and you will be able to do captcha easily

#

Well I already said, mass DMing isn't a good idea

#

Especially if there are many members

#

!pypi captcha

unkempt canyonBOT
#

A captcha library that generates audio and image CAPTCHAs.

vale wing
#

Gtg

naive briar
#

!d discord.Client.wait_for

unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
feral frost
#

how do i add multiple buttons in 1 like a list ?

naive briar
#

No, take a look at the docs

def check(m):
    return m.content == "Hello" and m.channel == channel

msg = await client.wait_for('message', check=check)
await channel.send(f'Hello {msg.author}!')
naive briar
slate swan
dull terrace
#

or arguments of buttons i guess

feral frost
#

like [button1, button2] ?

naive briar
#

m wouldn't be defined

dull terrace
feral frost
#

ah 5 buttons

dull terrace
#

each actionrow is a line

feral frost
#

ok

#

ty

naive briar
dull terrace
#

also up to 5 action rows

rugged epoch
#

u need special intents for message content

#

MESSAGE_CREATE is the event, correct me if im wrong

#

but thats also the same for deleting and editing messages

#

then its ok

#

do you want the captcha or the embed?

#

have you already got the captcha generation sorted?

#

ok

#

1 sec

dull terrace
#

has anyone actually tried putting captchas on their bots to stop botters? is it worth

cloud dawn
#

Text based captcha's are easily bypassed tough.

dull terrace
rugged epoch
dull terrace
#

image ones are pretty easy to get past as well now

rugged epoch
#

im trying to bypass a text captcha and its HARD

#

ive only found 1 trained ai that can do it

cloud dawn
rugged epoch
#

and its paid

rugged epoch
#

ive tried googles vision ai too

cloud dawn
rugged epoch
cloud dawn
#

Yes

rugged epoch
#

googles ai recognizes the D as A and the K as T

#

go ahead and check.

#

instead of arguing, lets help this person

dull terrace
rugged epoch
#

if you can get message content, check if the message is dm (by checking if the guild is none) and if its right: verify them

naive briar
#
def check(message):
    return message.content == "Something"

try:
    # The `wait_for` will use the provided `check` function to check
    # if the message content isn't `Something`
    # it'll wait until the message content that is exactly `Somwthing` was sent
    msg = await bot.wait_for("message", check=check)
    ...

except Exception as e:
    ...
rugged epoch
#

you can store correct captchas using a dictionary

naive briar
#

That's teh best I can give 🫠

rugged epoch
#

{"user id": "correct captcha", "other user id": "other correct captcha"}

#

when they get the correct captcha, remove it from the dict

cloud dawn
rugged epoch
#

you have to write the code urself

#

thats the point

#

docs exist