#discord-bots

1 messages · Page 49 of 1

slate swan
#

^

#

@slate swan i'll have to use a setup hook right (for persistence)

#

how would that work when views are being created dynamically?

#

this might explain it better

slate swan
#

i want the second description to ping the reaction user, not author

slate swan
slate swan
slate swan
#

so thats not possible if buttons are being dynamically added/removed?

#

oh so is the persistence on views only for static ones?

slate swan
slate swan
slate swan
#

allg thanks ❤️

slate swan
# slate swan you're using a wait_for?
        return user == ctx.message.author and str(reaction.emoji) == '✅'
    await bot.wait_for('reaction_add', check=check)
    embed = Embed(color=discord.Color.dark_green(), title="?", description="<@{}> Has accepted".format(ctx.author.id))
    embed.set_footer(text="Game has been accepted")
    embed.set_thumbnail(url=ctx.author.avatar_url)
    embed.add_field(name="?", value="?", inline=True)
    embed.add_field(name="?", value="?", inline=True)
    confirmationMessage = await ctx.message.channel.send(embed=embed)
    await confirmationMessage.edit(embed=embed)
    await confirmationMessage.clear_reactions()```
vocal snow
slate swan
#

@slate swan my guy

#

^

#

we literally went through this 😭

#

OH

#

ignore my dumbness lmao

#

thanks!

#

❤️

bright wedge
#
[2022-08-21 16:07:05] [ERROR   ] discord.ui.view: Ignoring exception in view <ModalView timeout=180.0 children=1> for item <ModalButton style=<ButtonStyle.primary: 1> url=None disabled=False label='ΑΞΙΟΛΟΓΗΣΕ' emoji=None row=None>
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 412, in _scheduled_task
    await item.callback(interaction)
  File "ticket.py", line 70, in callback
    await interaction.response.send_modal(whitelist_collector)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\interactions.py", line 842, in send_modal
    await adapter.create_interaction_response(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\webhook\async_.py", line 221, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components.0.components.0: Value of field "type" must be one of (4,).
gusty shard
#

how can i check if the command used in dms?

silk fulcrum
vocal snow
#

or ctx.guild is None

silk fulcrum
#

yeah that also

gusty shard
#

if message.guild != None means the command used in a server, isnt it?

knotty agate
#

yes

silk fulcrum
#

if message.guild simplier

#

and yes

knotty agate
#

not sure what to do here

this line worked befor the discord.py update, but now it must be returning something different?

messages = await channel.history(limit=1000).flatten()

error:

File "main.py", line 1165, in on_message
    messages = await channel.history(limit=1000).flatten()
AttributeError: 'async_generator' object has no attribute 'flatten'
shrewd apex
#

lst = [i async for i in messages]

#

async iterator object now

knotty agate
#

okay thanks alot 🙂

cerulean shale
#

"titles":[{"type":"Default","title":"Horimiya"},{"type":"Synonym","title":"Hori-san and Miyamura-kun"},{"type":"Japanese","title":"\u30db\u30ea\u30df\u30e4"}

this is a part in the api and idk how to only get the title "titles":[{"type":"Default","title":"Horimiya"} pls tell me how to do it

vocal snow
#

value = dict[key]

whole sparrow
#

How do I make multiple on_message listener events?

primal token
whole sparrow
#

So I can keep code clean

cerulean shale
vocal snow
shrewd apex
primal token
vocal snow
#

he's never going to learn how to do it himself otherwise

shrewd apex
#

@commands.Cog.listener()

whole sparrow
cerulean shale
vocal snow
#

then why did you ask here? You could've easily figured it out on your own

shrewd apex
vocal snow
#

aha nice

#

inb4 syntaxerror !!!

primal token
#

parsing is hard😳

cerulean shale
vocal snow
#

what skip stuff

cerulean shale
#

i wanted to skip type and only get title

vocal snow
#

so you wanted to get the value at title key??

vocal snow
whole sparrow
#

Can you add on_message listener event in multiple cogs?

vocal snow
#

yes

whole sparrow
#

very cool kanye

primal token
#

!d nextcord.ui.button

unkempt canyonBOT
#

nextcord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`nextcord.ui.View`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.ui.View "nextcord.ui.View"), the [`nextcord.ui.Button`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.ui.Button "nextcord.ui.Button") being pressed and the [`nextcord.Interaction`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Interaction "nextcord.Interaction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.ui.Button "nextcord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
pastel finch
#

how to use discord emojis in python ? like when i copy them they come as :emoji_name: and not as an emoji. i wanna use them to make my bot add reaction but they dont work

cerulean shale
#
  @commands.command()
  async def anime(self, ctx, *, message):

    async with aiohttp.ClientSession() as cs:
      async with cs.get(f"https://api.jikan.moe/v4/anime?q={message}") as r:
        res = await r.json()

    em = discord.Embed(url = {res['url']},
                       color = h(),
                       timestamp = ctx.message.created_at,
                       title = f"{res['titles'][0]['title']}",
                       description = f"{res['synopsis']}\n\n\nSynonyms:{res['titles'][0][0][0]['title']}\n\nEpisodes: {res['episodes']}\n\nAired: {res['aired']['string']}\n\nDuration: {res['duration']}\n\nStatus: {res['status']}\n\nRating: {res['rating']}\n\nRating: {res['score']}\n\nSeason: {res['season']}\nTrialer: {res['embed_url']}")
    
    em.set_thumbnail(url = f"{res['images']['image_url']}")
    em.set_footer(text=f"Requested by {ctx.author.name}", icon_url=ctx.author.avatar.url)

    await ctx.send(embed=em)

I am trying to get info about anime and this is the address https://api.jikan.moe/v4/anime?q=horimiya, it is showing that keyerror and i dont know what to do, i think theres some mistake in taking the info from the api but idk so can anyone pls tell me what i can do to fix it?

gusty shard
#

can somebody help me please

cerulean shale
cerulean shale
#

hbdc is the folder its in?

gusty shard
#

yes

cerulean shale
meager chasm
#
{
"pagination": {}, // 4 items 
"data": []  // 1 item
}
``` is the response
meager chasm
cerulean shale
cerulean shale
meager chasm
#

dictionary key?

gusty shard
#
``` like that?
cerulean shale
cerulean shale
meager chasm
#

those paths don't use dot notation like that

knotty agate
#

ever since the new discord.py update i havent been able to use tasks.loop 😦

anyone know how i can get them to work again

example

@tasks.loop(seconds=60)
async def reminder():
  id = #number
  await client.fetch_channel(id)
  await channel.send("it has been 60 seconds!")

error i keep getting when i try to start it

File "main.py", line 1227, in <module>
    reminder.start()
  line 398, in start
    self._task = asyncio.create_task(self._loop(*args, **kwargs))
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/tasks.py", line 381, in create_task
    loop = events.get_running_loop()
RuntimeError: no running event loop
slate swan
knotty agate
#

just befor i start the client

cerulean shale
#

getting this error now

primal token
#

i think zeffo had a pointducky_beer

knotty agate
slate swan
#

yes cool

knotty agate
#

yh ik lol

slate swan
#

hm, try usinhg start instead of run

knotty agate
#

okay

meager chasm
#

that list contains multiple dicts which have a url key

knotty agate
slate swan
#

that's weird

knotty agate
#

this only happend after the new update

#

so idk if it has something to do with the new intentions thing

cerulean shale
primal token
#

or make task

knotty agate
primal token
knotty agate
#

could i get docs or an example of how to use this?

primal token
unkempt canyonBOT
#

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

A coroutine to be called to setup the bot, by default this is blank.

To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.

This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") event.

Warning

Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_for "discord.ext.commands.Bot.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_until_ready "discord.ext.commands.Bot.wait_until_ready")...
knotty agate
#

thx

meager chasm
#

!d nextcord.Interaction.edit

unkempt canyonBOT
#

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

This is a shorthand function for helping in editing messages in response to a component or modal submit interaction. If the interaction has not been responded to, [`InteractionResponse.edit_message()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.edit_message "nextcord.InteractionResponse.edit_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 edited via the [`Interaction.message`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Interaction.message "nextcord.Interaction.message") using [`Message.edit()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Message.edit "nextcord.Message.edit") instead.
knotty agate
primal token
#

cheersducky_beer

steep torrent
#

Hi guys, I have read that discord.py was non-existent for a while due to the restructuring of discord and slash commands. My plan is to start with python and I would like to start with a bot as a first project. Which python wrapper is currently the best and most up to date? I am migrating my discord.js bot, which python wrapper is on the same current state?

meager chasm
#

it was down for a while but it's on track again

primal token
#

for 6 months until it goes brrr

vale wing
#

Unless you know programming like very well

slate swan
#

Had an argument with some guy I was working on a bit with, he asked to switch to discord.js because it’s more up to date but I screamed at him

primal token
#

kek

slate swan
vale wing
#

Write a discord bot in JDA I dare you

steep torrent
slate swan
vale wing
#

Java discord API wrapper

#

Your brain is gonna explode real quick

slate swan
#

EW

pastel finch
#

how do i copy discord emojis which are not on google to copy like 🇩 ,🇮 ,🇱 and all ? when i copy them they come like :emoji_name: and i cant use them in my command here in python

steep torrent
vale wing
#

Ok

steep torrent
#

So discord.py or nextcord what would you recommend?

steep torrent
meager chasm
#

I'd say go with discord.py since more people know about it in general but it's ultimately up to you

vale wing
#

Because java networking is true hell

meager chasm
#

try networking in cpp 😄

vale wing
#

Oh mo

shrewd apex
slate swan
#

!charinfo 🇦

unkempt canyonBOT
slate swan
steep torrent
#

Yes larger community means I find more on stackoverflow and co. so discord.py. Thank you for the thought

pastel finch
shrewd apex
#

regional_indicator_a

#

🇦

still ridge
#

Anyone knows how slash commands work ?

shrewd apex
slate swan
still ridge
#

Traceback (most recent call last):
File "smth\slash-commands.py", line 2, in <module>
from discord import app_commands
ImportError: cannot import name 'app_commands' from 'discord' (smth\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord_init_.py)
I get this error @slate swan

slate swan
still ridge
#

it worked

#

thanks guys

slate swan
#

Ok

sacred plume
#

How can I make it so if the ```py
data = requests.get(f"https://eu.mc-api.net/v3/server/ping/{serverdata}").json()

ping takes too much (more than 3 secs, meaning server not is down) I would get a print of `server offline` or something ?

*if the server is offline my bot is remains stuck on that line and does not update the embed with `Server is offline` as it should
still ridge
#

finally some real help (discord.py server is a scam)

sacred plume
still ridge
#

indeed

still ridge
primal token
#

ive never entered the server and i got banned :kek:

still ridge
#

lel

quaint epoch
#

use aiohttp

#

lemme write an example

sacred plume
sacred plume
slate swan
quaint epoch
slate swan
#

Because it’s asynchronous or smth

quaint epoch
#

when something takes long to eval, you need async

sacred plume
primal token
quaint epoch
primal token
#

nor was your point directed at making a requests

sacred plume
quaint epoch
#

you can't depend on the request taking a very short amount of time

hushed galleon
#

the issue with blocking code in asyncio is that your bot cant multitask during that process

quaint epoch
#

the best practice for dpy, is async

#

your code should be non-blocking as much as possible

hushed galleon
#

imagine just 10 users trying to use commands, and one of those commands holds up the bot for a second or two

primal token
#

the whole point is to use asynchronous libraries to reach concurrency lmao

hushed galleon
#

mhm

pastel finch
pastel finch
# unkempt canyon

i want these codes, how can i get them ? should i invite this bot in my server then get those codes there or is there a channel in this server where i can get these codes ?

pastel finch
#

meaning ?

slate swan
#

What is the question your asking 😭

primal token
#

you cant invite @unkempt canyon as hes an exclusive bot for this server, you can use the command in #bot-commands for personal use

unkempt canyonBOT
quaint epoch
#

all the bots here are open source (except black knight, but that didn't stop me) so you can fork the repos, adjust it and deploy

primal token
quaint epoch
#

yes

#

but they wanted @unkempt canyon

primal token
#

yup

slate swan
vale wing
quaint epoch
#

@inland quail why are you not open sourced?

vale wing
#

"nature of functions" tf this means

quaint epoch
#

oh yeah, i got a few leaks fmor staff

#

im very convincing

#

staff said that black knight was used for raid mitigation and handling

primal token
#

Its not open sourced because it would be more vulnerable to exploits, TL;DR security

quaint epoch
#

might be scanning on all users on join

vale wing
#

Raid prevention? It shouldn't be too hard to implement

quaint epoch
#

by leaking this information, i've put myself at risk of being silenced by the orange role

#

i must leave

primal token
#

maybe it uses machine learning

sick birch
primal token
#

Watch robin get banned

whole sparrow
#

how to get bot id?

#

in cogs

#

nvm ioll figure

vale wing
#

!d discord.Client.application_id or smth

unkempt canyonBOT
#

property application_id```
The client’s application ID.

If this is not passed via `__init__` then this is retrieved through the gateway when an event contains the data or after a call to [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login "discord.Client.login"). Usually after [`on_connect()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_connect "discord.on_connect") is called.

New in version 2.0.
vale wing
#

For bots it is the same with bot's ID so you can just use this

dry kelp
#

How can i set those to default?

sick birch
vale wing
#

Or bot.user.id

dry kelp
whole sparrow
vale wing
dry kelp
vale wing
#

I mean don't provide them at all

dry kelp
#

Looks like its required to provide them once the guild feature community is being enabled

quaint epoch
# sick birch Open source for me 😉

boutta remotely connect to your computer to gain access to the repos. purely to review it's contents so i can perform further, general leaks on the nature and use of @inland quail as to gain popularity

dry kelp
#

yes i did not provide any of them lol

#

but i have to

vale wing
unkempt canyonBOT
#

Hey @cerulean shale!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

dry kelp
#

but i have to set the community to True lol

quaint epoch
#

for all i know bots in the server are selling my data to zuck

primal token
vale wing
#

await after.edit(community=True) and that's it

dry kelp
#

Bro that's how i got that error

#

i have to provide them

vale wing
#

Ah hold up

#

You are understanding it wrong

dry kelp
#

if this makes more sense tho. My bad for sending just the last line of the error

vale wing
#

To enable community you have to define the rules channel and public updates channel too

#

If community is not enabled there's no default value at all

dry kelp
#

Exactly. How can i define it to create default channels for it?

vale wing
#

One sec

dry kelp
#

oh

vale wing
#

!d discord.Guild.edit

unkempt canyonBOT
#
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., afk_channel=..., owner=..., afk_timeout=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.

Changed in version 1.4: The `rules_channel` and `public_updates_channel` keyword parameters were added.

Changed in version 2.0: The `discovery_splash` and community keyword parameters were added.

Changed in version 2.0: The newly updated guild is returned...
dry kelp
#

            if "COMMUNITY" in set(before.features).symmetric_difference(after.features):
                if "COMMUNITY" in before.features:
                    #await after.ban(i.user, reason="Anti-Nuke: Managed guild community")
                    await after.edit(community=True, rules_channel=)
#

here is more of the code. Im checking if there is being a change made using `symmetric_difference``

vale wing
#

@dry kelp try setting them to None and see if it works

dry kelp
#

👍

#

But that won't work

vale wing
#

Otherwise I think you might have to create the channels by yourself first

dry kelp
#

pretty sure. because you cannot set a none value when turning on community manually

vale wing
#

There's no mention about that thing in docs

cerulean shale
#

i want to get image_url from images dict which is in data dict, how can i do it? i tried f"{res['data'][0]['images'][0]['image_url']}" i copied the data and formatted it a bit as it was clumsy, any ideas?

https://paste.pythondiscord.com/ikahuyepiy

dry kelp
#

let me try using it none...

whole sparrow
#

How do I make it so multiple roles can be assigned to use a specific command in cogs?

vale wing
#

Use @commands.has_any_role deco ig

#

!d discord.ext.commands.has_any_role

whole sparrow
#

It doesnt accept lists though D:

unkempt canyonBOT
#

@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.

Similar to [`has_role()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.

This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
vale wing
#

You can provide a common list by putting an asterisk before it

your_roles = [1, 2, 3]

@commands.has_any_role(*your_roles)
...```
dry kelp
#

I will try after the rain stops x)

whole sparrow
#

You're an absolute gem, tysm

dry kelp
#

@vale wing Currently at my gradma. Internet is really bad, will be a pain to test lol

vale wing
#

Same for every seq

austere vale
#
    author=message.author
    guild=message.guild
    async with self.bot.db.cursor() as cursor:
      await cursor.execute('SELECT xp FROM levels WHERE user = ? AND guild = ?',(author.id,guild.id))
      xp=await cursor.fetchone()
      await cursor.execute('SELECT level FROM levels WHERE user = ? AND guild = ?',(author.id,guild.id))
      level=await cursor.fetchone()
      await cursor.execute('SELECT ssc FROM levels WHERE user = ? AND guild = ?',(author.id,guild.id))
      ssc=await cursor.fetchone()
      if not xp or not level or not ssc:
        await cursor.execute('INSERT INTO levels (level, xp, ssc, user, guild VALUES (?,?,?,?,?)',(0,0,0, author.id, guild.id))

can someone help me with my leveling code please?

shrewd apex
vale wing
cerulean shale
shrewd apex
#

who inserts default stuff 😔

shrewd apex
#

then VALUES

cerulean shale
#

can i add video to embed?

#

random video from api not predetermined

shrewd apex
#

yes

#

set_image(url=url)

slate swan
#

How to add a reaction
I’m currently using

my_msg = await interaction.response.send_message(embed=embed1)

await my_msg.add_reaction(“. . .”)

Error:
Command ‘gcreate’ raised an exception: AttributeError: ‘NoneType’ object has no attribute ‘add_reaction’

cerulean shale
#

the video is from youtube tho

#

https://www.youtube.com/embed/42LiC4xY8YE?enablejsapi=1&wmode=opaque&autoplay=1

austere vale
primal token
slate swan
#

So what should I do?

primal token
#

!d discord.Interaction.original_response

unkempt canyonBOT
#

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

Fetches the original interaction response message associated with the interaction.

If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).

Repeated calls to this will return a cached value.
primal token
#

found it lol

cerulean shale
shrewd apex
#

also is the url valid

cerulean shale
#

em.set_image(url = f"{res['data'][0]['trailer']['url']}")

cerulean shale
cerulean shale
slate swan
shrewd apex
#

hmm remove those queries after ? mark maybe

cerulean shale
shrewd apex
#

remove the ? mark also

primal token
#

The error is quite explanatory?

shrewd apex
#

no column reason in the table

primal token
#

check your spelling lol

#

python never liesducky_beer

#

if it doesnt exist, check your table

shrewd apex
#

drop it and make the table again

primal token
#

kek

shrewd apex
#

i think u made the table first and then edited the code later and the table was never updated

#

drop the table 🗿

primal token
#

is connection corruption posible in aiomysql?

shrewd apex
primal token
#

in sqlite it always happens if you never close a connection, which makes troubleshooting hard sometimes

glad cradle
#

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

shrewd apex
#

i don't use aiomysql or aiosqlite just use pgsql never happened there

slate swan
#

How to like show role list when user select an option in slash command?

cerulean shale
shrewd apex
primal token
shrewd apex
slate swan
primal token
silk fulcrum
shrewd apex
shrewd apex
primal token
#

yes, but i mean can you use something like docker compose to have everything localized

shrewd apex
#

rpi so i don't wanna keep the db local in case i somehow corrupt the sd card

#

yeah u can

primal token
#

lol

shrewd apex
#

i mean the sd has a lock mode where it locks itself to prevent writes in case it reaches beyond its limits but don't wanna take the risk

slate swan
#

how can I remove a reaction from a specific user?

silk fulcrum
unkempt canyonBOT
#

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

Remove a reaction by the member from the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").

If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.

The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

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

member arg

shrewd apex
#

u ain't alone its on my arsenal too

primal token
silk fulcrum
#

i wanna use this

slate swan
#

Just how 💀

silk fulcrum
#

💀

worn onyx
slate swan
worn onyx
#

@glad cradle

slate swan
primal token
#

using the str class to convert an int into a string in an f string, kek

sick birch
silk fulcrum
#

lmao

#

imagine installing an orange and eating it

slate swan
quaint epoch
# sick birch me after breaking arch

as a seasoned windows user, when your installation crashes for the 8th time in 30 seconds, you don't need to panic. but when your default browser changes? now thats~ r e a l f e a r

sick birch
#

average windows experience

silk fulcrum
#

there is no more orange in ubuntu 20.04((((

#

sadge:( i cannot eat orange anymore

#

what do i do(((

shrewd apex
#

i managed to corrupt the theme files once no gui for 6 hrs after till i fixed it somehow

primal token
#

ive managed to corrupt a game 3 times already lol

pulsar solstice
#
2022-08-21 08:50:13 ERROR    discord.ext.commands.bot Ignoring exception in command steal
Traceback (most recent call last):
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 195, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\8ster\OneDrive\Desktop\projects\Discord Bots\Novicookies\main.py", line 48, in steal
    random_steal = random.randrange(0, member_cookies_amt, -1)
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\random.py", line 363, in randrange
    raise ValueError("empty range for randrange()")
ValueError: empty range for randrange()

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

Traceback (most recent call last):
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 991, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: empty range for randrange()```
#

lemme send the code

primal token
#

kek

silk fulcrum
#

kwek

#

wrong place

shrewd apex
#

no need ur randrange is empty

#

add some stuff in there

pulsar solstice
#
import discord
from discord.ext import commands
import json
import random

bot = commands.Bot(command_prefix='>', intents=discord.Intents.all())

@bot.event
async def on_ready():
    print("Bot is Now Online")


@bot.event
async def on_message(message):
    user_id = str(message.author.id)

    with open("jar.json", "r+") as file:
        jar = json.load(file)
        
    if not user_id in jar:
        jar[user_id] = {}
        jar[user_id]["cookies"] = 5
    
    jar[user_id]["cookies"] += 5

    with open("jar.json", "w") as file:
        json.dump(jar, file)
    await bot.process_commands(message)


@bot.command()
async def jar(ctx):
    user_id = ctx.author.id
    user=ctx.author
    with open("jar.json") as f:
        data = json.load(f)
    cookies_amt=data[str(user_id)]["cookies"]
    await user.send(f"You currently have **{cookies_amt}** cookies in you jar.")


@bot.command()
async def steal(ctx, member : discord.Member):
    with open("jar.json", "r+") as file:
        jar = json.load(file)
    member_id = member.id
    member_cookies_amt=int(jar[str(member_id)]["cookies"])
    random_steal = random.randrange(0, member_cookies_amt, -1)
    user_id = str(ctx.author.id)
        
    if not user_id in jar:
        jar[user_id] = {}
        jar[user_id]["cookies"] = 5
    
    if not member_id in jar:
        jar[member_id] = {}
        jar[member_id]["cookies"] = 5
        member_cookies_amt=jar[str(member_id)]["cookies"]
        random_steal = random.randrange(0, member_cookies_amt, -1)
        jar[user_id]["cookies"] += random_steal
        jar[member_id]["cookies"] -= random_steal
    
    member_cookies_amt=jar[str(member_id)]["cookies"]
    random_steal = random.randrange(0, member_cookies_amt, -1)
    jar[user_id]["cookies"] += random_steal
    jar[member_id]["cookies"] -= random_steal



    with open("jar.json", "w") as file:
        json.dump(jar, file)


    
        

bot.run(<token!!!!!!!!!!>)
primal token
#

blockingio kek

silk fulcrum
#

again the whole code

pulsar solstice
#
@bot.command()
async def steal(ctx, member : discord.Member):
    with open("jar.json", "r+") as file:
        jar = json.load(file)
    member_id = member.id
    member_cookies_amt=int(jar[str(member_id)]["cookies"])
    random_steal = random.randrange(0, member_cookies_amt, -1)
    user_id = str(ctx.author.id)
silk fulcrum
#

do print(member_cookies_amt) to make sure who are they, and are they supposed to be negative?

pulsar solstice
#

this is where the error occurs

worn onyx
#

@silk fulcrum

silk fulcrum
#

me

silk fulcrum
pulsar solstice
#

should I start over the steal command?

worn onyx
#

@silk fulcrum

silk fulcrum
pulsar solstice
pulsar solstice
silk fulcrum
pulsar solstice
silk fulcrum
pulsar solstice
silk fulcrum
pulsar solstice
primal token
#

concurrency

silk fulcrum
silk fulcrum
#

wtf did i say exhaustive about it

primal token
#

i see your literature is quite unique🙂

silk fulcrum
#

yeah

primal token
#

i think you ment extensive?

silk fulcrum
#

maybe I should learn more engilsh

primal token
#

kek

silk fulcrum
#

but exhaustive is literally not what describes those words

pulsar solstice
primal token
# primal token concurrency

with open is synchronize and runs on bare python, while aiofiles uses the abstraction of an event loop and schedules the task to the event loop to manage it, to reach concurrency over running it in order of calls/bare python

pulsar solstice
#

hehe

silk fulcrum
#

but I don't care, I just use with open because I use it very rare :fricc:

primal token
silk fulcrum
primal token
silk fulcrum
#

meticulous :lmao:

slate swan
tulip ice
#

is there anyway to have tickets/buttons to stay open even after restarting the bot?
i have made this ticketing system but when restarting bot, the interaction command becomes inactive

unkempt canyonBOT
#

add_view(view, *, message_id=None)```
Registers a [`View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View") for persistent listening.

This method should be used for when a view is comprised of components that last longer than the lifecycle of the program.

New in version 2.0.
tulip ice
slate swan
#
if req not in interaction.user.roles:
            msg = await interaction.original_response()
            await msg.remove_reaction(":giveaways:", interaction.user)

Reaction is not removed
Role is this
role: discord.Role

silk fulcrum
#

and what is req?

#

because most likely req is in interaction.user's roles

slate swan
primal token
silk fulcrum
#

oh bruh

primal token
silk fulcrum
#

my eyes are dying

#

bruh....

#

dying

#

33's week in this year is almost gone

#

for someone already gone

slate swan
#

It’s not there I’ve checked

silk fulcrum
#

and that's the problem

#

my brain bruhed outsideness, so...

#

your check is if req NOT in ...roles: @slate swan

#

and my brain bruhed again

#

kill me pls

#

no idea what is the problem

slate swan
silk fulcrum
#

and better not ask me ig, my brain is dead, it's not enough power to understand basic if conditions

#

@primal token go help, your brain and blockingio are not dead

primal token
#

kek

slate swan
silk fulcrum
#

kek

slow fog
#

mr master32

silk fulcrum
#

but find only trash

slow fog
polar granite
silk fulcrum
#

and one app that looked good, but no idea how to make a repeating task in it (every day)

primal token
silk fulcrum
slate swan
polar granite
silk fulcrum
#

check the link I sent

primal token
# polar granite All intents are on

In your application, you never passed the intent abstraction of dpy, to connect to the gateway and identify which gateway events you shall receive

pulsar solstice
#

@silk fulcrum

silk fulcrum
#

what:(

pulsar solstice
#

where and how can I learn aiofiles

#

:\

silk fulcrum
#

do watch hikaru's bongcloud speedrun

pulsar solstice
#

not simple at all

vale wing
#

It's same with common open isn't it? Just async

#

!pypi aiofiles

unkempt canyonBOT
zealous haven
#

how do i make my discord bot automatically send a message as soon as a ticket is made by ticket tool?

primal token
#

docs kek

silk fulcrum
slate swift
#

can someone help me make this command?

primal token
zealous haven
silk fulcrum
vale wing
#

TicketTool is a bot

zealous haven
#

yes

pulsar solstice
zealous haven
#

i want my bot that im making to send a message as soon as ticket tool makes a ticket

silk fulcrum
#

what is not understandable here?

pulsar solstice
slate swift
pulsar solstice
#

soo...

primal token
#

its literally the same syntax but with async and await syntax lol

silk fulcrum
vale wing
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

vale wing
#

!d discord.on_guild_channel_create

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
primal token
silk fulcrum
#

you want to use db instead of json? @pulsar solstice

vale wing
#

No idea why I wrote on_guild_message_create wtf

pulsar solstice
primal token
#

kek

pulsar solstice
#

json is also a db right?

silk fulcrum
vale wing
#

No

primal token
#

KEK

pulsar solstice
#

and aiofiles is also a db?

silk fulcrum
#

BRUH

primal token
#

💀

silk fulcrum
#

it's a library

#

to open files

vale wing
pulsar solstice
#

cause I use them as a db it not my fault

primal token
#

aiofiles is a library to do file operations asynchronouslyducky_beer

vale wing
#

I remember reading somewhere that it's pointless

primal token
#

because something can hold data doesnt make it automatically a database

vale wing
#

Not sure why but they said like "I/O operations are CPU blocking anyway"

pulsar solstice
vale wing
#

I don't understand asyncio principles that well so not gonna argue or smth

silk fulcrum
primal token
unkempt canyonBOT
slate swift
#

can someone help me make this

tidal hawk
#

Created an embed with 3 fields

vale wing
primal token
pulsar solstice
slate swift
silk fulcrum
#

okkay

primal token
pulsar solstice
primal token
#

it is, SQL is quite good and simple and is used for many dbs that are based uppon the language, e.g postgresql is used in production level

silk fulcrum
unkempt canyonBOT
silk fulcrum
#

iterate through members and check if they're bots or not -- Humans + Bots

#

!d discord.Guild.icon.url -- server icon url

unkempt canyonBOT
silk fulcrum
#

@slate swift

slate swift
primal token
#

kek

silk fulcrum
#

kwek

primal token
slate swift
primal token
#

kekducky_beer

silk fulcrum
primal token
#

master can help you with that hes smart

silk fulcrum
#

no

#

my brain doesnt work propeperly today

#

bruh, propeperly, see?

slate swift
#
async def whois(ctx,user:discord.Member=None):

    if user==None:
        user=ctx.author

    rlist = []
    for role in user.roles:
        if role.name !="@everyone":
            rlist.append(role.mention)
    
    b = ','.join(rlist)

    embed = discord.Embed(color=user.color,timestamp=ctx.message.created_at)

    embed.set_author(name=f"User Info - {user}")
    embed.set_thumbnail(url=user.avatar_url),
    embed.set_footer(text=f'Requested by - {ctx.author}',
  icon_url=ctx.author.avatar_url)

    embed.add_field(name='ID',value=user.id,inline=False)
    embed.add_field(name='Name:',value=user.display_name,inline=False)

    embed.add_field(name='**Dates**',value=user.created_at,inline=False)
    embed.add_field(name='**Created**:',value=user.created_at,inline=False)
    embed.add_field(name='**Joined**:',value=user.joined_at,inline=False)

    embed.add_field(name='Bot?',value=user.bot,inline=False)

    embed.add_field(name=f'Roles:({len(rlist)})',value=''.join([b]),inline=False)
    embed.add_field(name=f'Top Role:',value=user.top_role.mention,inline=False)

    await ctx.send(embed=embed)   ``` can someone tell me why this command doesnt work
silk fulcrum
#

an error?

#

bruh @sick birch is there a doesn't work paragraph somewhere on the website? it's so required

sick birch
silk fulcrum
#

PR? waht does that mean?

sick birch
#

pull request on GitHub

silk fulcrum
#

ohkay

pliant gulch
#

Who and why are they asking this question lol

glad cradle
sick birch
glad cradle
slate swan
#

ps: not a windows user

glad cradle
#

rm bin

silk fulcrum
#

just throw the PC out the window

primal token
silk fulcrum
#

why all that

slate swan
#

nvm

pliant gulch
silk fulcrum
slate swan
silk fulcrum
#

lmao

slate swan
#

or just add an __int__ method to that class

dull terrace
#

im guessing i have to but hoping i dont - if i pass a class instance to another module do i have to pass it back if i make changes to an attribute

slate swan
leaden cosmos
#

i have problem with pil
Bot = running
Ignoring exception in on_member_join
Traceback (most recent call last):
File "/home/runner/swpmdcdc12345/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 53, in on_member_join
draw.text(text, (257, 169, 245), font=font, align="center")
File "/home/runner/swpmdcdc12345/venv/lib/python3.8/site-packages/PIL/ImageDraw.py", line 463, in text
draw_text(ink)
File "/home/runner/swpmdcdc12345/venv/lib/python3.8/site-packages/PIL/ImageDraw.py", line 408, indraw_text
mask, offset = font.getmask2(
File "/home/runner/swpmdcdc12345/venv/lib/python3.8/site-packages/PIL/ImageFont.py", line 669, in getmask2
size, offset = self.font.getsize(
TypeError: expected string

slate swan
#

if thats the case, you don't need to

pliant gulch
#

Although that design choice is questionable at best

dull terrace
dull terrace
#

okay thanks

maiden fable
slate swan
#

😂 get ?tag lped

#

cannot import name 'RequestWebhookAdapter' from 'discord'

#

why am i getting this error in my script

maiden fable
cold sonnet
#

tias

#

is usually just what you get

leaden cosmos
#

hey anyone help me pls

cold sonnet
#

you asked a question that's not related to this channel
you sent the error, that's good
but the lines of code you sent are random

leaden cosmos
#

and add role

cold sonnet
#

not the code where you got the error

#

please send the code where you got the error

leaden cosmos
#

ok wait me check again

leaden cosmos
cold sonnet
#

mhm, what's text?

#

text = ?

leaden cosmos
#

nothing wrong
i want to draw the text welcome in my image
so i use that
anything wrong?

#

if anyone join my server bot say that in log console

cold sonnet
#

not an expert of this lib

wicked atlas
cold sonnet
#

as far as I know font is also supposed to be just the filename

#

is font also a string?

leaden cosmos
leaden cosmos
#

uhh anything wrong?
i check and nothing bad happened

zealous haven
#

im using replit to host my discord bot but it keeps saying errors that im not getting when i run my bot script on python

cold sonnet
#

replit sucks

wicked atlas
leaden cosmos
wicked atlas
#

provide that xy argument

zealous haven
#

im using replit to host my discord bot but it keeps saying errors that im not getting when i run my bot script on python
can anyone help

wicked atlas
sick birch
#

Ratelimits, maybe?

leaden cosmos
zealous haven
wicked atlas
#

if you're only getting errors on replit, the IP your bot is running on probably got ratelimited or blocked

zealous haven
leaden cosmos
#

bot run good but when change token bot = offline

sick birch
wicked atlas
#

Ah yes, 2.0

sick birch
#

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

leaden cosmos
zealous haven
leaden cosmos
zealous haven
#

it was working like 7 days ago fine on replit

wicked atlas
leaden cosmos
wicked atlas
#

It probably only works on your computer and not replit because you still have 1.7.3 installed on your computer, and replit installed 2.0

zealous haven
#

oh thats why my codes had a stroke

leaden cosmos
#

add intents=discord.Intents.all() in commands.Bot

zealous haven
leaden cosmos
wicked atlas
#

Usually you should only enable the intents that you want or need to use

#

less your script has to process

cold sonnet
#

Robin flexing reaction perms

#

😭

wicked atlas
#

fr

leaden cosmos
leaden cosmos
#

if you want to use
intents = Intents.default()
intents.members = True
so still nothing wrong just it's longer only

sick birch
cold sonnet
#

counter ratio

wicked atlas
#

I can't event thumbs up or thumbs down to either of those messages

leaden cosmos
#

ok sure

cold sonnet
#

you'll have to start thinking about that when you have more limitations

leaden cosmos
cold sonnet
#

what

#

it's measured in bytes...

leaden cosmos
cold sonnet
#

oh hours of learning

leaden cosmos
cold sonnet
#

you'll get to it 👍

leaden cosmos
#

and also if i get it but i still want fast way
if i really need so i'll change
but not at all so still no need

golden tapir
#

izs there any documentation on bump for disboard

wicked atlas
leaden cosmos
wicked atlas
#

👍

leaden cosmos
#

💯

#

now i'm fixing xy to let it be in center

golden tapir
#

izs there any documentation on bump for disboard

leaden cosmos
golden tapir
#

like how to do it

leaden cosmos
#

like logs?

golden tapir
#

i want a auto bump command

#

for my bot

#

like every 120 mins it bumps the server disboard

leaden cosmos
golden tapir
#

no

leaden cosmos
#

i can use /bump
but bot can't use them

golden tapir
#

wdym

leaden cosmos
#

just user can bump only (real person)
bot = can't

golden tapir
#

then why can carl bot do it

leaden cosmos
golden tapir
#

i heard carl bot could do it

leaden cosmos
#

i don't trust you
just give me proof

#

if you have proof so i lost
if you don't have so i win and also bot can't bump

leaden cosmos
golden tapir
#

ok

#

tell me

leaden cosmos
golden tapir
#

wdym by that

leaden cosmos
#

i only tell you how

golden tapir
#

ok?

leaden cosmos
#

first you need to learn c++
then use discord rich rpc and then make you as a user bot
then c++ will auto send bump when 120 minutes

leaden cosmos
golden tapir
#

yeah i am not doing that

leaden cosmos
golden tapir
#

but then how does disboard bot do it

leaden cosmos
swift pumice
golden tapir
#

what

#

how

leaden cosmos
swift pumice
#

self botting is against the discord tos

leaden cosmos
#

auto 24/24

golden tapir
#

what is self botting

leaden cosmos
swift pumice
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

devout cave
#

hello everyone

swift pumice
leaden cosmos
silk fulcrum
#

hi

devout cave
#

i am trying to make a bot using pyton

leaden cosmos
#

if discord ban you so good luck

devout cave
#

not so good at it

leaden cosmos
golden tapir
devout cave
#

i am not getting what i did wrong

silk fulcrum
golden tapir
#

try remove the pratenthis

silk fulcrum
devout cave
#

ye

leaden cosmos
# devout cave

client = commands.Bot(command_prefix = "prefix", intents=discord.Intents.all())

silk fulcrum
golden tapir
shrewd apex
silk fulcrum
golden tapir
#

()

leaden cosmos
golden tapir
#

i dont know how to spell

silk fulcrum
leaden cosmos
#

i never use os before so idk

leaden cosmos
golden tapir
#

ok

silk fulcrum
leaden cosmos
shrewd apex
#

i was looking to form a team👀

silk fulcrum
#

hmmm interesting

leaden cosmos
silk fulcrum
#

well ofc I know python at all too but not as much as discord.py

shrewd apex
leaden cosmos
shrewd apex
#

people

silk fulcrum
leaden cosmos
#

imagine no one care about robot

leaden cosmos
silk fulcrum
shrewd apex
#

🗿

silk fulcrum
#

well anyways I won't tell her about pyweek and you... she won't even understand

#

@shrewd apex Well, I don't mind at all, but I don't know almost anything about game dev in python pithink

#

so do you accept me to be your teammate? 👉 👈 @shrewd apex

silk fulcrum
leaden cosmos
#

hmm so fun
imagine robot sad

silk fulcrum
#

wow that's first time I participate in online event, english online event, in team and in english team

#

all that for first time

leaden cosmos
#

uhh
imagine robot sad more

silk fulcrum
leaden cosmos
silk fulcrum
#

why am I not crying???!?!?!

vocal snow
#

me too !!

silk fulcrum
#

you cannot defer my crying

leaden cosmos
#

because no one want me and also i did my best in 4 days joined this server

leaden cosmos
vocal snow
#

im rewriting site !!

silk fulcrum
#

i also know web btw

#

i forgot

#

but on PHP

leaden cosmos
vocal snow
#

picture of what !

silk fulcrum
#

@shrewd apex you were typing something I saw

vocal snow
#

i will add picture of papaya

silk fulcrum
vocal snow
leaden cosmos
silk fulcrum
#

I'm just very excited

#

of what happened right now

shrewd apex
#

oh i was just randomly thinking of a team name url and stuff

#

just made an entry

silk fulcrum
#

ohkay

#

im not good at making names

shrewd apex
silk fulcrum
#

you can see that from my file names:(

shrewd apex
leaden cosmos
shrewd apex
#

dw i made one already

leaden cosmos
silk fulcrum
#

@shrewd apex do i register on that site and join the team?

glass sapphire
#
class ticket_launcher(discord.ui.View):
    def __init__(sellf) ->None:
        super().__init__(timeout = None)
    @discord.ui.button(label = "Sipariş oluştur", style = discord.ButtonStyle.blurple, custom_id = "ticket_button")
    async def ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
        ticket = utils.get(interaction.guild.text_channels, name = f"{interaction.user.name}-{interaction.user.discriminator} için bir sipariş")
        if ticket is not None: await interaction.response.send_message(f"Zaten bir siparişin var! {ticket.mention}", ephemeral = True)
        else:
            overwrites = {
                interaction.guild.default_role: discord.PermissionOverwrite(view_channel = False),
                interaction.user: discord.PermissionOverwrite(view_channel = True, send_messages = True, attach_files = True, embed_links = True),
                interaction.guild.me: discord.PermissionOverwrite(view_channel = True, send_messages = True, read_message_history = True)
            }
            channel = await interaction.guild.create_text_channel(name = f"{interaction.user.name}-{interaction.user.discriminator}nin-siparişi", overwrites = overwrites, reason =
                                                                  f"{interaction.user} sipariş açtı")
            await channel.send(f"{interaction.user.mention} Bir sipariş Oluşturdu!")
            await interaction.response.send_message(f"Senin için bir sipariş odası oluşturdum. Gitmek istersen {channel.mention}", ephermal = True)
tree = app_commands.CommandTree(bot)
@tree.command(guild = discord.Object(id=1010669233954365461))
async def ticketing(interaction: discord.Interaction):
    embed = discord.Embed(title = "Eğer sipariş vermek istiyorsan Aşağıdaki buton tıkla yakın zamanda yardım edilecektir!", color = discord.Colour.blue())
    await interaction.channel.send(embed = embed, view = (ticket_launcher))
#

this is my code

#
Traceback (most recent call last):
  File "main.py", line 222, in <module>
    tree = app_commands.CommandTree(bot)
  File "C:\Users\tekno\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\app_commands\tree.py", line 134, in __init__
    raise ClientException('This client already has an associated command tree.')
discord.errors.ClientException: This client already has an associated command tree.```
#

this is my error

#

how can i fix

silk fulcrum
#

sent a request @shrewd apex

vocal snow
sick birch
#

Hate eating them

vocal snow
#

Why does everyone hate them 😔

#

@slim ibex said the yellow ones are good

silk fulcrum
#

you just do @bot.tree.command() instead of all that

slim ibex
#

oh yeah

#

yellow dragon fruit is fire

glass sapphire
#

and how can i open the / commands

vocal snow
#

just type / and it'll bring up a menu

glass sapphire
#

nope

#

on the code

#

im trying to ask

shrewd apex
vocal snow
glass sapphire
#

i made a / command but dont work without any error

vocal snow
#

oh you want to sync them

slate swan
#

whats problem (disnake)

vocal snow
#

Missing Permissions

silk fulcrum
vocal snow
#

i knoow the bot has admin perms so how can there be missing permissions !!

marsh violet
#

move up the bot role in role hierarchy

silk fulcrum
#

trouble maker has come 😳

slate swan
silk fulcrum
#

we also cannot get more info

sick birch
#

Missing permissions

#

Joe can ban me no problem

silk fulcrum
sick birch
#

I’m telling

slate swan
primal token
silk fulcrum
#

imagine allowing everyone to ban joe and kick lemon 💀

vocal snow
leaden cosmos
#

or another software

leaden cosmos
rapid knoll
#

how do I fix this

@bot.command()
async def test2(ctx, emojis):
    message = await ctx.reply("--- - --- - ---")
    for emoji in emojis:
        await message.add_reaction(emoji)

the emojis

limber bison
#

how can i reset cooldown

glad cradle
unkempt canyonBOT
glad cradle
#

finally

silk fulcrum
#

just why.... commands.Command.cooldown = app_commands.Cooldown

#

wth

glass sapphire
#

i made a / command but dont work without error

#

how can i fix

glad cradle
glass sapphire
#
class ticket_launcher(discord.ui.View):
    def __init__(sellf) ->None:
        super().__init__(timeout = None)
    @discord.ui.button(label = "Sipariş oluştur", style = discord.ButtonStyle.blurple, custom_id = "ticket_button")
    async def ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
        ticket = utils.get(interaction.guild.text_channels, name = f"{interaction.user.name}-{interaction.user.discriminator} için bir sipariş")
        if ticket is not None: await interaction.response.send_message(f"Zaten bir siparişin var! {ticket.mention}", ephemeral = True)
        else:
            overwrites = {
                interaction.guild.default_role: discord.PermissionOverwrite(view_channel = False),
                interaction.user: discord.PermissionOverwrite(view_channel = True, send_messages = True, attach_files = True, embed_links = True),
                interaction.guild.me: discord.PermissionOverwrite(view_channel = True, send_messages = True, read_message_history = True)
            }
            channel = await interaction.guild.create_text_channel(name = f"{interaction.user.name}-{interaction.user.discriminator}nin-siparişi", overwrites = overwrites, reason =
                                                                  f"{interaction.user} sipariş açtı")
            await channel.send(f"{interaction.user.mention} Bir sipariş Oluşturdu!")
            await interaction.response.send_message(f"Senin için bir sipariş odası oluşturdum. Gitmek istersen {channel.mention}", ephermal = True)
@bot.tree.command(guild = discord.Object(id=1010669233954365461))
async def ticketing(interaction: discord.Interaction):
    embed = discord.Embed(title = "Eğer sipariş vermek istiyorsan Aşağıdaki buton tıkla yakın zamanda yardım edilecektir!", color = discord.Colour.blue())
    await interaction.channel.send(embed = embed, view = (ticket_launcher))```
#
    await interaction.response.send_message("Sipariş sistemi çalıştı", ephermal = True)```
glad cradle
glass sapphire
#

still dont work

dull terrace
#

got my blackjack minigame on my bot down to 117 lines of code including all the image drawing and buttons ablobsweats

cold sonnet
#

how do you avoid ratelimits on replit again

#

kill 0

silk fulcrum
cold sonnet
#

idek how you open it

glass sapphire
silk fulcrum
#

@slate swan where are you

cold sonnet
#

Imma search

glass sapphire
silk fulcrum
cold sonnet
#

not okimii lmao

silk fulcrum
#

oh :((

vocal snow
#

...

cold sonnet
#

wtf is happening

limber bison
#

why unexpected indent ?

silk fulcrum
#

more code?

#

@limber bison

limber bison
#

sure

silk fulcrum
#

lol diff days

#

for me

limber bison
dull terrace
limber bison
dry kelp
#

How can i check if 'COMMUNITY' is in before guild features but not in after guild features

dull terrace
#

where is it saying the unexpected indent is

silk fulcrum
#

you can add a check at the start of group command. like this:

@bot.group(name="antinuke", description="A beautiful group.", invoke_without_command=True)
async def antinuke(ctx):
    # Checking if subcommand is not None and is not in our subcommands list
    if ctx.invoked_subcommand and ctx.invoked_subcommand not in ["whitelist", "blacklist"]:
        return
    
    # Send an antinuke embed
    await ctx.send("Never gonna give you up")

@antinuke.command()
async def whitelist(ctx, something):
    ...

@antinuke.command()
async def blacklist(ctx, something):
    ...```
#

bruh no need to repeat

odd mango
#

can i change a subclassed view's interaction check to only server mods if i do this? or do i have to check for it inside button callback?

        async def interaction_check(self, interaction):
            return interaction.user if "manage_guild" in [key for key, value in (dict(interaction.user.guild_permissions)).items() if value == True]```
silk fulcrum
# dry kelp ^

check if 'COMMUNITY' in before_guild_features and 'COMMUNITY' not in after_guild_features

dry kelp
#

ah

silk fulcrum
#

oh wait nvm im just stupid

#

if ctx.invoked_subcommand is None then it's either no subcommand executed or wrong name

#

but how do you check if a user provided something as a subcommand..

#

actually I have no idea how to properly do it

#

I just know that ctx.invoked_subcommand will return None if the subcommand is not given or given wrong

odd mango
#

cannot, it's like 3rd nested interaction

silk fulcrum
#

what

cold sonnet
#

try-except discord.errors.Forbidden doesn't handle it

#

why

silk fulcrum
cold sonnet
#

tried that too

silk fulcrum
#

and what?

cold sonnet
#

console also shows discord.errors.Forbidden

cold sonnet
silk fulcrum
#

show error and code?

#

sounds weird

#

well discord.py also raises commands.errors.CommandInvokeError

#

but you use isinstance(error, commands.CommandInvokeError)

#

if you make error handler ofc

cold sonnet
#
try:
      await bot.get_channel(714960348435709988).send(f"{message.author.mention} en figyelmeztettelek")
      await asyncio.sleep(300)
      await message.author.remove_roles(message.guild.get_role(1011009261352013845))
    except discord.errors.Forbidden:
      await bot.get_channel(714960348435709988).send(f"nincs jogom lenemitani teged de csibesz vagy {message.author.mention}")
silk fulcrum
#

looks like you should you handle commands.MissingPermissions instead

cold sonnet
silk fulcrum
#

or not

cold sonnet
#

looking at the error again nah

#

the error below is also bullshit

#

that has a try except too

silk fulcrum
#

except discord.Forbidden doesnt work 100%?

#

btw wth is that error below

#

what is wrong?

#

and?

silk fulcrum
#

see link I sent

#

and !intents in #bot-commands to get more help on how to enable intents

lone lichen
#

Send ur question

slate swan
#

is there a command in terminal i can do to check my discord.py version

raven bolt
#

pip show <package>

slate swan
#

ah ok

#

why am i getting this error File "c:\Users\user\Desktop\Tools\Luna Tools\DisBot\main.py", line 61, in <module> Luna = discord.Client() TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'

raven bolt
#

why does literally everybody redefine their bot variable???

raven bolt
slate swan
winged coral
unkempt canyonBOT
vocal snow
slate swan
#

Could a really tech savvy guy dm me so I can quote a code to you. There’s 2 problems I don’t know how to change (still learning discord bots) 😆

slate swan
vast egret
#

what is an easy way i could get a users cooldown for a certain command when mentioning them? because i have a command involving 2 users and if one of the users is on cooldown i want my bot to send an error msg

vocal plover
#

You need to have 2FA enabled, as the message says

#

whatever action is trying to be performed

#

on servers that require 2FA for moderation actions (deleting a message is that) you must have 2FA enabled for your bots to perform those actions

sick birch
hazy oxide
slate swan
#

lmao it wasn’t that

#

just because discord.py 2.0 doesn’t have all that stuff

#

the thing i made was with discord 1.7.3

#

had to downgrade to get it working

quick brook
#

im so used to working with pycord and other forks of discord.py at this point....

sick birch
quick brook
#

i've used discord.py when i was first learning how to program discord bots like 1 year ago, and when discord.py stopped being maintained for like 6 months, i ended up learning pycord

sick birch
quick brook
#

it's fine for me tbh. haven't rlly learned any of the other forks yet

meager chasm
#

I went through the pychord source and it's... something

winged coral
#

^ UX might not differ for many but they’re certainly different

#

Afaik they gave up on typehinting at all at some point

loud junco
#

#bot-commands tp

hushed galleon
# vast egret what is an easy way i could get a users cooldown for a certain command when ment...

afaik its not that convenient to get cooldowns for other users due to their implementation, but for prefix/hybrid commands you can use the Command.is_on_cooldown(ctx) with a mocked context to check
if you're wondering what attributes you need to include, see the get_key() method defined in cooldowns.py, near the top of the file
https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/cooldowns.py

primal token
pale turtle
#

Oh I remember my first time

pulsar bridge
#

Basic question
Could someone refer me to where I could read up on adding tags or whatever the term is to users?
Tags, or values
Like if I wanted to assign a.. 'is_muted' tag to a user so a section of code would only trigger on it
E.g.
If user.get_value 'is_muted'
Do stuff

loud junco
#

the bot doesnt want to reload farm 💀
no error in console

potent spear
pulsar bridge
#

How would that help adding a tag?
Quite new to python so you may have to dumb it down

potent spear
loud junco
#
@commands.command()
  async def reload(self, ctx, arg):
    try:
      if ctx.author.id == 757508305256972338:
        await self.bot.reload_extension(f'commando.{arg}')
        await ctx.send(f'**{arg}** is reloaded')

    except commands.ExtensionNotLoaded:
      await ctx.send(f'**{arg}** is not loaded')
    except commands.ExtensionNotFound:
      await ctx.send(f'**{arg}** is not found')