#discord-bots

1 messages · Page 83 of 1

slate swan
#

my macbook cant even lemme install anything from the internet after the new mac update....

cloud dawn
#

nice_cube

vale wing
#

And you won't be getting conflicts in the future

slate swan
#

so i literally cant uninstall and reinstall it

faint sapphire
#

have you tried disabling SIP

cloud dawn
#

Okay let's just jailbreak it then. ||joke||

faint sapphire
#

go into recovery mode and type crustil disable in terminal
it turns off protection

vale wing
#

Install linux 👍

#

This connection is so nice I ate phone antenna

slate swan
#

/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
Using cached pip-22.2.2-py3-none-any.whl (2.0 MB)
Installing collected packages: pip
WARNING: The scripts pip, pip3 and pip3.8 are installed in '/Users/bai/Library/Python/3.8/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
NOTE: The current PATH contains path(s) starting with ~, which may not be expanded by all applications.
Successfully installed pip-22.2.2

ive just updated pip and i run the command again, no work

vale wing
#

Do what @faint sapphire said and uninstall the pythons, then install the latest with path checkmark

faint sapphire
#

i didnt say anything ;-;

faint sapphire
#

ok try this

#

/usr/sbin/spctl kext-consent add TEAMID

#

if python.og has a team ID

vale wing
slate swan
vale wing
#

Thx god

#

Uninstall python 2.7 btw who tf still uses it

faint sapphire
wicked atlas
vale wing
#

😳

#

Apple doesn't update their applications or smth

wicked atlas
#

¯_(ツ)_/¯

slate swan
faint sapphire
#

i know the command to put in shell

thorn seal
#

How do i make an embed in whilst using slash commands?

wicked atlas
vale wing
#

Well seems like some applications rely on it for no reason so leave it there and just use pip3 or even better venvs

wicked atlas
faint sapphire
#

ah ok

slate swan
#

Traceback (most recent call last):
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/aww pika beta discord bot.py", line 14, in <module>
@bot.tree.command(name="test", description="test slash command")
AttributeError: 'MyBot' object has no attribute 'tree'

vale wing
#

Very nice

#

What code editor do you use

slate swan
#
from discord.ext import commands

class MyBot(commands.Bot):
    def __init__(self) -> None:
        super().__init__(command_prefix=">", intents=discord.Intents.default())
        
    async def setup_hook(self) -> None:
        await self.tree.sync()

bot = MyBot()


@bot.tree.command(name="test", description="test slash command")
async def test(interaction: discord.Interaction) -> None:
    await interaction.response.send_message("true")

bot.run('my token here')```

still having this error
slate swan
vale wing
#

Super nice

slate swan
#

uhm.. so how to fix?

vale wing
#

Nevertheless python builtin editor is good for beginners I would recommend using something like visual studio code or pycharm for convenience

vale wing
slate swan
#

it doesnt work on mac

vale wing
#

What the hell is wrong with it

#

This is why I am not using apple products

slate swan
#

u sure there isnt anything wrong with my script?

vale wing
#

The issue is with python versions

#

Are you serious? Macs don't have command line?

wicked atlas
#

I don’t think this has anything to do with your editor. Like the error says, MyBot does not have the attribute ‘tree’

wicked atlas
#

Exactly what it says

vale wing
#

You have discord.py installed for different interpreter

#

You need to run it with the same

wicked atlas
#

You probably forgot the create the ‘tree’ attribute

wicked atlas
#

I think app command trees require you create that attribute yourself

vale wing
wicked atlas
#

Gimme a second

vale wing
#

!d discord.ext.commands.Bot.tree

unkempt canyonBOT
#

property tree```
The command tree responsible for handling the application commands in this bot.

New in version 2.0.
wicked atlas
#

This example shows defining the tree attribute

vale wing
#

They are subclassing Client

wicked atlas
#

They have a terminal, zsh I think

vale wing
#

Yes in Bot it's already defined

slate swan
wicked atlas
#

Are you sure you’re using the latest version of d.py?

wicked atlas
vale wing
#

@wicked atlas he just runs the script with the python version the wrong dpy is installed in

slate swan
#

im on macos montery...

vale wing
#

@slate swan you might want to install at least visual studio code so we can avoid some hell and comfortably use venv, can you install it now

vale wing
#

Open your project there then

slate swan
#

ok

vale wing
#

When you do that, open a terminal inside vsc and use python3 -m venv venv

slate swan
#

ok

vale wing
#

Tell me when you're done

slate swan
vale wing
#

Just do what I tell you

#

Don't try running anything yet

slate swan
#

ok

vale wing
#

Wait until it executes

#

Might take a couple of minutes

slate swan
#

no work

vale wing
#

You mean it doesn't finish executing?

#

Or you got some error

slate swan
#

it doesnt show anything

vale wing
#

Ok wait a bit more

slate swan
#

do i have to change MyBot to SlashBot?

#

or does the name doesnt matter

vale wing
digital charm
#

I'm not sure how to create a for loop, I just know the absolute basic:

nums = [1, 2, 3, 4, 5]
for n in nums:
print (n)
slate swan
vale wing
#

Wtf

slate swan
#

now i did, it shows this

digital charm
#

wait what

vale wing
#

Isn't the terminal supposed to be a bit of colored

#

@slate swan anyway was the folder named venv created in your project

digital charm
vale wing
vale wing
#

Where are you executing this thing

slate swan
#

in visual studio code terminal

spring needle
#

Why my invoke command raised an error NoneType is not callable

wicked atlas
#

Looks like its open in their user folder

vale wing
#

@slate swan and you opened the folder in vsc not the file right?..

digital charm
slate swan
#

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/bai/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 39, in <module>
cli.main()
File "/Users/bai/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/Users/bai/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "/Users/bai/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "/Users/bai/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/bai/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/aww pika beta discord bot.py", line 14, in <module>

#

@bot.tree.command(name="test", description="test slash command")
AttributeError: 'MyBot' object has no attribute 'tree'
@ian-wu Aww Pika Discord Bot % python3 -m venv venv
@ian-wu Aww Pika Discord Bot %
@ian-wu Aww Pika Discord Bot % cd /Users/bai/Documents/Personal\ Things/Do\ not\ delete/Only\ viewable\ by\ me/Aww\ Pika\ Discord\ Bot ; /
usr/bin/env /usr/local/bin/python3 /Users/bai/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/adapter/../../de
bugpy/launcher 52857 -- /Users/bai/Documents/Personal\ Things/Do\ not\ delete/Only\ viewable\ by\ me/Aww\ Pika\ Discord\ Bot/aww\ pika\ bet
a\ discord\ bot.py

#

this error

vale wing
#

The living hell

wicked atlas
#

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

vale wing
#

You have at least 3 versions of python installed

vale wing
#

I noticed 2.7, 3.7 and 3.9

slate swan
#

what-

digital charm
#

@slate swan just write py in the terminal

vale wing
#

Your PATH is now messed up in terms of python

digital charm
#

for the version and when u get '>>>' type exit()

thorn seal
#

from ..enums import AppCommandOptionType, AppCommandType, ChannelType, Locale
ModuleNotFoundError: No module named 'discord.enums'

cold sonnet
#

your folder name is discord?

thorn seal
cold sonnet
#

now wait a minute

#

did you import all those

thorn seal
#

no

cold sonnet
#

or does the lib do it

#

ok then the lib does it

thorn seal
#

the lib

cold sonnet
#

that's weird

#

you could try reinstalling discord

thorn seal
#

sure

#

pip install discord-py

#

that?

cold sonnet
#

with a dot

#

maybe uninstall it first

thorn seal
#

requirements already satisfied

#

oh ok

#

ahh ty

#

what does the M mean?

cold sonnet
#

that has to do with github I suppose

#

I can research it

thorn seal
#

alright

#

ohh its because of procfile

#

and heroku

cold sonnet
#

it means modified

thorn seal
#

it says master for me haha

cold sonnet
#

holy my internet sucks

#

this is great explanation

cold sonnet
thorn seal
#

this slash command shit is so weird

cold sonnet
#

I'd say

thorn seal
#

how do you do an embed in slash 😭

cold sonnet
#

making an embed is the same

thorn seal
#

oh

cold sonnet
#

you just don't have ctx anymore

thorn seal
#

ah alright i got it

mossy jacinth
#

How can i send something like "Test" if the user picks the #1 and "Test2" If he picks #2 and so on?

dire grove
#

hey there

#

im writing a bot for stable diffusion

#

using that template on git

#

anyways i got a cog called sd

#

the module i use is called txt2img from the modules folder but when i try to import/call it from my cog

#

discord.app_commands.errors.CommandInvokeError: Command 'ddim' raised an exception: TypeError: 'module' object is not callable

#

well that flopped

unkempt canyonBOT
dire grove
#

anyone got any idea ?

feral frost
#

how do i make a loop task in a slash bot ?

#

i found smth but it isnt working

quaint epoch
unkempt canyonBOT
#

@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
dire grove
#

awesome i got it working nice

#

nm thanks

feral frost
#

ok ty

feral frost
quaint epoch
#

Import issue

feral frost
#

now i get this

#

RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'Loop._loop' was never awaited

quaint epoch
#

Bruh

#

Code

fallen marsh
#

i'm trying to use discum for member scraping but it says module not found even tho i installed it from the discum repo

#

i also tried installing it with pip but same result

cold oyster
#

Shouldn't it just send the message instead of printing the error?

#

dead

#

chat

#

xd

quaint epoch
#

Why not just iter over discord.Guild.members

quaint epoch
cold oyster
quaint epoch
#

I swear everyone in this channel are half trained gpt models

paper sluice
#

xD

cold oyster
quaint epoch
cold oyster
#

.?

quaint epoch
#

Br

#

Apply some critical thinking and it'll solve itself

cold oyster
quaint epoch
#

print prints to console

#

Ctx.send sends to channel

cold oyster
#

ik?

#

My god

quaint epoch
#

So why the heck are you printing it?

cold oyster
#

So that if there is another error, It will raise it in the terminal

cunning trellis
#

How do I force send_group_help on a command group's main command?

quaint epoch
#

Bruh

#

I gotta go to period 5

#

Someone else help

cold oyster
#

thats how it was when there were no slash cmds 💀

#

its the same fking code

tidal hawk
#

What are you trying to do?

cold oyster
#

if missing a role send error msg, else print error

tidal hawk
#

And that doesn't work?

cold oyster
#

no

#

it prints error

tidal hawk
cold oyster
#

its supposed to print when there is another error

plucky shoal
#

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

tidal hawk
#

Aha okay

cold oyster
# tidal hawk ?

Ex. If there is another error which aint specified, it'll print it

plucky shoal
#

Try to send code in these code blocks this

cold oyster
plucky shoal
plucky shoal
cold oyster
#

👍

#

h e l p

#

my god

tidal hawk
#

Not sure, but did you create that error message yourself?

cold oyster
#

erm wdym?

paper sluice
cold oyster
#

im deing

#

im coding after a while so

paper sluice
#

its from a slash command, why would the error be from discord.ext.commands

cold oyster
#

🗿

paper sluice
#

!d discord.app_commands.MissingAnyRole

unkempt canyonBOT
#

exception discord.app_commands.MissingAnyRole(missing_roles)```
An exception raised when the command invoker lacks any of the roles specified to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure").

New in version 2.0.
paper sluice
#

find the disnake equivalent of that and use

cold oyster
#

ok..

#

its the smae just saying

paper sluice
#

no

cold oyster
#

i've used both, i see no difference inn disnake

paper sluice
slate swan
primal token
balmy bobcat
#

hi, exceptions don't show up anymore in my terminal

primal token
tidal hawk
#

lol

paper sluice
#
void
noid()
{
}
primal token
paper sluice
#

llvm 😳

#

idk if llvm suggests that

#

no, it doesn't

ionic edge
#

how to use this time thingy

paper sluice
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
mossy jacinth
#

The command works but discord shows me this? Theres no error in the console

tidal hawk
#

From my experience, Discord does this when the bot doesn't send a Interaction Response back

primal token
#

An interaction is marked as "Failed", if not responded to.

slate swan
#

i need help, i tried to run my bot after a long time, but the commands are no working

#

i get no errors

paper sluice
#

enable message_content intent in the dev portal and in your code

feral frost
lone lichen
unkempt canyonBOT
#

await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.

This is only supported with the following interaction types...
unkempt sinew
#

are there any bot growth servers or any servers i can add my bot to for member count? i have 45k rn

acoustic parcel
#

does anyone know why this keeps happening? my bot doesnt do anything like raid, it just does commands stuff

hushed galleon
#

thats common for replit hosting

acoustic parcel
hushed galleon
#

some people say you can type kill 1 in the shell as a temporary fix

visual sundial
#

can someone help me with this?

hushed galleon
#

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

hushed galleon
#

note that message_content is one of those privileged intents so you want to enable that if you want your bot to properly read messages

fallen marsh
#

thanks for telling me lol

tidal hawk
#

Np xD

acoustic parcel
#

anotehr question, how do I put the message authors avatar in the set_author thing?

primal token
#

!d discord.Asset.url

unkempt canyonBOT
acoustic parcel
primal token
acoustic parcel
primal token
acoustic parcel
#

embed.set_author(name=str(message.author), icon_url=message.author.avatar_url) thats the code thats not working

#

it says discord members dont have the attribute avatar_url

primal token
#

Its just message.author.avatar.url? reading given info is quite helpful for yourself you know

acoustic parcel
primal token
acoustic parcel
#

is there a way to put the avatar even if its a default

primal token
#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
acoustic parcel
#

oh tyty

primal token
#

I would recommend you dont use replit aswell, if you're trying to dodge future problems

acoustic parcel
#

idk anything else to use thats free

primal token
#

Localhost?

crimson plover
#

im not sure why this is not working unless there is another way to send the message that I am not seeing, it sends messages to the game with this message scheduler bot im using but not my custom discord bot even though it sees the message....

Here is my code:

    if message.author.id == 1005924637147922546:
        if message.content.startswith('Xerp:'):
            if ComPrefix + 'test' in GameCommand:
                await message.channel.send('Test Passed all Checks, Hello Admin')
                return
        if ComPrefix + 'test' in GameCommand:
            await message.channel.send('Test Passed all Checks, Hello User')
            return
dull terrace
#
hc = await cursor.execute(f"SELECT HCID FROM hc WHERE ID = ?", (interaction.guild.id,))

#use placeholders

hcid = (await cursor.fetchone())[0]

#im assuming you're using the async version of sqlite in which case you need to await and for both versions, the result would be a tuple so you'd need to choose the first value in the tuple
cursive pelican
#

RuntimeError: Timeout context manager should be used inside a tas
Why do I get this error when trying to run both flask and discordpy, trying to run a discordpy func with bot.loop.create_task

plush rock
#

I'm working with embeds and I'm trying to get something like this on discord.py, but I can't figure out how to make it so "tight". The example wasn't made on discord.py so I'm not too sure it's even possible

sick birch
slate swan
#

Can someone help me with this? Basically I am making a snake game on discord, and I plan to edit the message every 1.5 seconds, (the delay is changable)

#

My only problem is if I do:

while self.lost is False:
  time.sleep(self.delay)
  await self.move()
#

the problem is it halts the buttons

#

I tried threading but honestly it wont work for an async function

#

I tried using asyncio.run but it didn't work

#

so now I'm stuck.

slate swan
#
    # Protocol
    async def protocol(self) -> None:
        pass
    
    # Update direction
    async def update_direction(self, direction: str) -> None:
            
        # Guardian statements
        if self.check_direction(direction) is False:
            return None
        
        self.direction = direction
        
        if self.started is False:
            self.started = True

    # Move
       
#

Those are the ones we have to worry about

#

I'm not sure what to do for protocol(the function that makes it move every 1.5 seconds)

primal token
#

!d asyncio.sleep

slate swan
#

and update_direction is the one that should trigger protocol, again the error is that it will halt the buttons if I don't thread it.

unkempt canyonBOT
#

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

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

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

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

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

Example of coroutine displaying the current date every second for 5 seconds:
slate swan
#

hm

pliant gulch
slate swan
slate swan
#
    @discord.ui.button(label = 'Left', style = discord.ButtonStyle.blurple, custom_id = 'Left')
    async def Left(self, interaction: discord.Interaction, button: discord.ui.Button):
        game = OCCUPIED['OWNERS'].get(interaction.user.id, None)
        if game is None:
            return None
        else:
            if OCCUPIED['OWNERS'][interaction.user.id].instance.id == interaction.message.id:
                await OCCUPIED['OWNERS'][interaction.user.id].update_direction('left')
                await interaction.response.defer()
                
#

thats one function

primal token
primal token
slate swan
#

am i missing anything?

primal token
slate swan
#

Okay but this is my NEW problem, IT WORKS ALMOST PERFECTLY

primal token
slate swan
#

Okay!

#

When I click a button for the first time, what happens is that all the buttons are disabled for a few seconds, is there any reason why?

primal token
#

Like they dont respond or they actually get disabled?

slate swan
#

Here I'll send a screenshot.

#

@primal token

#

you see that?

primal token
# slate swan

I'm pretty sure that only happens when you defer the interaction 😅

slate swan
#

oh

#

I add that because @primal token it says that it doesn't respond, but let me see if that is still the cas.e

#

still happens:

#

Ignoring exception in view <Button timeout=None children=4> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Right' emoji=None row=None>

naive briar
slate swan
#

I will in 5 minutes, sorry I am eating

primal token
slate swan
# naive briar Can you send the entire traceback?

[2022-09-13 16:47:35] [ERROR ] discord.ui.view: Ignoring exception in view <Button timeout=None children=4> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Right' emoji=None row=None> Traceback (most recent call last): File "C:\Users\toplo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\view.py", line 425, in _scheduled_task await item.callback(interaction) File "c:\Users\toplo\OneDrive\Documents\GitHub\Arcade-5.0\main.py", line 90, in Right await OCCUPIED['OWNERS'][interaction.user.id].update_direction('right') File "c:\Users\toplo\OneDrive\Documents\GitHub\Arcade-5.0\main.py", line 222, in update_direction await self.protocol() File "c:\Users\toplo\OneDrive\Documents\GitHub\Arcade-5.0\main.py", line 208, in protocol await self.move() File "c:\Users\toplo\OneDrive\Documents\GitHub\Arcade-5.0\main.py", line 235, in move self.update_board() File "c:\Users\toplo\OneDrive\Documents\GitHub\Arcade-5.0\main.py", line 163, in update_board self.board[self.head[0]][self.head[1]] = '😳' IndexError: list assignment index out of range

#

the out of range is okay, i didnt add loss detection yet.

unkempt canyonBOT
#

@primal token :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | IndexError: list index out of range
slate swan
#

I know but I still think that this error doesnt cause the buttons to disable, unless it does?

primal token
#

If the button doesnt respond the buttons cant be clicked so its probably the buttons getting deffered or the error which makes your bot go offline

crimson plover
slate swan
#

I know it's out of range...

#

let me add loss detection.

#
async def move(self) -> None:
        y, x = self.DIRECTIONS.get(self.direction, (0, 0))
        self.head = (self.head[0] + y, self.head[1] + x)
        if self.head == self.apple:
            self.body.insert(len(self.body) - 1, self.previous_head)
            self.generate_apple()
        self.body.insert(0, self.previous_head)
        previous_body = self.body.pop()
        self.board[previous_body[0]][previous_body[1]] = ':black_medium_square:'
        self.previous_head = self.head
        self.update_board()
        await self.post(edit = True)
#

this is my move function.

#

I'ma take a break.

slate swan
#

yoo guys whats up im getting a KeyError for my guild id, basically saying it’s invalid or something but its not?

naive briar
#

Errors don't lie

slate swan
#

i right clicked and copied id though

primal token
#

Revise your code, Python's interpreter doesn't lie! ~~IndexError: You're a loser 😔 ~~

slate swan
#

wtv

upbeat gust
#

you really need to give more info than just that

slate swan
# upbeat gust you really need to give more info than just that

i really have no idea what any of that means, i just bought the bot and neither me or the seller know how to fix.

Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\client.py", line 352, in _run_event
    await coro(*args, **kwargs)
  File "C:\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect
    await self.register_commands()
  File "C:\Python310\lib\site-packages\discord\bot.py", line 338, in register_commands
    to_update = update_guild_commands[guild_id]
KeyError: '1019415471696654436'```

thats what it says though
slate swan
#

server id

upbeat gust
#

why are you using on_connect anyway

slate swan
#

huh

#

what should i be using?

upbeat gust
#

can you send your whole code

slate swan
#

yea in dms

upbeat gust
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

is that ok?

upbeat gust
#

why not here

slate swan
#

cuz i bought it i dont want everyone to

upbeat gust
#

ok sure ig

slate swan
#

alright let me start my pc

slate swan
sage otter
#

notice the location in the error

upbeat gust
#

anyways, @slate swan I cant help with forks of dpy

#

probably something to do with types, ids are ints

#

looks like youre passing strings

slate swan
#

and what is a fork of dpy

upbeat gust
slate swan
upbeat gust
#

bruh

upbeat gust
rare echo
#

so right now I have essentially just

if len(voice_state.channel.members) == 1:``` 
to detect if there's only 1 user (the bot) in a vc, problem is its disconnecting if **any** channel has 1 member, what would I use to detect only the channel the bot is in
sage otter
#

that message wasn’t even for you. :/

slate swan
#

or like what do i do

primal token
slate swan
#

🤔

primal token
#

TL;DR A different irregular instance

slate swan
#

should i try to get a refund from the seller?

primal token
#

If you dont mind, we can also try and troubleshoot it, if it all doesnt work/go well or you make up your mind, you may refund the order.

So, how does that sound?

upbeat gust
#

Str vs int

#

You're passing it as a str

primal token
#

🍿

upbeat gust
#

I don't know how pycord or whatevrt works but it should probably be an int

slate swan
#

if either of u know how, i’d be willing to pay u to do it?

primal token
# slate swan idk how to do that

Well, it looks like chrispy already has the solution so if he can, he can continue helping you with that matter, if not you can refer to me.

slate swan
#

sounds good

slate swan
upbeat gust
#

Not really seeing as you don't know much about coding

primal token
upbeat gust
#

anyways get your money back

#

That's pretty shitty code

primal token
upbeat gust
slate swan
#

i dont think he’d give me a refund tbh

primal token
primal token
upbeat gust
#

and other weird stuff in general

slate swan
upbeat gust
#

😬

primal token
slate swan
#

the thing is, im sure the bot is frowned upon

primal token
#

"decent", i wouldnt call all of them good

slate swan
#

in terms of discord tos

primal token
#

If its not following TOS we can help with that but you still probably couldve found someone

upbeat gust
slate swan
primal token
slate swan
primal token
slate swan
upbeat gust
#

I have given you very clear pointers though-

slate swan
#

also i’d like to point out that im the only person experiencing this issue, other people use the same code but they dont have issues

#

so could it be something with my user or bot settings?

primal token
#

That whole code is garbage from what chrispy has said to me, so i wouldnt take the feedback of other people that dont know what the source code does/works

upbeat gust
#

Can you at least try

#

I've said what I think the issue is

#

And I'm confident it's correct

slate swan
#

i have no knowledge regarding coding or python

#

0

upbeat gust
#

I'd help if you were able to learn from this, but you don't even know python

slate swan
primal token
slate swan
#

alright well thanks for the help guys

primal token
slate swan
#

How do I stop my button from saying "Interaction failed"

#
class Button(discord.ui.View):
    def __init__(self) -> None:
        super().__init__(timeout = None)
    
    # Left
    @discord.ui.button(label = 'Left', style = discord.ButtonStyle.blurple, custom_id = 'Left')
    async def Left(self, interaction: discord.Interaction, button: discord.ui.Button):
        game = OCCUPIED['OWNERS'].get(interaction.user.id, None)
        if game is None:
            return None
        else:
            if OCCUPIED['OWNERS'][interaction.user.id].instance.id == interaction.message.id:
                await OCCUPIED['OWNERS'][interaction.user.id].update_direction('left')
                await interaction.response.defer()
                
    # Up            
    @discord.ui.button(label = 'Up', style = discord.ButtonStyle.blurple, custom_id = 'Up')
    async def Up(self, interaction: discord.Interaction, button: discord.ui.Button):
        game = OCCUPIED['OWNERS'].get(interaction.user.id, None)
        if game is None:
            return None
        else:
            if OCCUPIED['OWNERS'][interaction.user.id].instance.id == interaction.message.id:
                await OCCUPIED['OWNERS'][interaction.user.id].update_direction('up')
                await interaction.response.defer()

    # Down
    @discord.ui.button(label = 'Down', style = discord.ButtonStyle.blurple, custom_id = 'Down')
    async def Down(self, interaction: discord.Interaction, button: discord.ui.Button):
        game = OCCUPIED['OWNERS'].get(interaction.user.id, None)
        if game is None:
            return None
        else:
            if OCCUPIED['OWNERS'][interaction.user.id].instance.id == interaction.message.id:
                await OCCUPIED['OWNERS'][interaction.user.id].update_direction('down')
                await interaction.response.defer()
                
#

When I click the button for the first time, it disables every button for like 3 seconds, says Interaction failed

#

But every button after that works perfectly. Is there any way to fix this?

rare echo
#

read that wrong my b

slate swan
#

Why did you delete? Oh.

rare echo
#

its saying interaction failed because its not responding i believe

slate swan
#

doesnt the defer tak ecar eof that?

rare echo
#

i see that it might, i have yet to play with buttons x)

hollow agate
slate swan
#

huh?

hollow agate
#

Your code could be taking more than 3 seconds from the button press to load to send a message

slate swan
#

What doo you recommend i do about it?

hollow agate
#

Do you want to send a message?

slate swan
#

No.

#

All it does is it updates a direction in a class.

#

it edits 1 boolean

hollow agate
#

Hm, I've never seen it work without sending a message... I would recommend you just send the message and make it ephmeral

#

But again, I've never tried without a message.

slate swan
# unkempt canyon

Hello
I've done as this asked, but I still get the TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents' error.
Any ideas, please?

#

woudlnt that spam chat?

#

its a snake game

hollow agate
#

It may, let me test something really quick

slate swan
#

Alright.

slate swan
hollow agate
#

Do you have an on_error? @slate swan

slate swan
#

no.

hollow agate
#
    @discord.ui.button(label='Eeek', style=discord.ButtonStyle.grey, custom_id='persistent_view:afhnjka')
    async def eeek(self, interaction: discord.Interaction, button: discord.ui.Button):
        print('pp')
        await interaction.response.defer()``` Works fine for me
slate swan
#

hm

hollow agate
#

It's most likely taking more than 3 seconds

primal token
hollow agate
#

You can maybe try to put some print('#1') in the code to see where it breaks too

hollow agate
#

hehe

#

Best kind of debug

sick birch
slate swan
#

Oh

#

So just remove it?

hollow agate
#

Ahh, that makes sense

sick birch
#

No, you might want to send a response if game is None

slate swan
#

Okay.

#

Well thank you robin

sick birch
#

or something similar

slate swan
#

you attractive handsome man.

sick birch
#

sorry i just got this new tool, i love using it to teach

slate swan
primal token
slate swan
#

As it may get a bit too much for this channel.

primal token
hollow agate
#

intents=intents heh

primal token
slate swan
#

This is what I'm trying to say, i did what is in the bloody code block. 😭

primal token
#

You never passes it into the initializer thought ducky_drawing

slate swan
#

@sick birch does no twork 😦

#

no error.

#

nveermind it does error:

Traceback (most recent call last):
  File "C:\Users\toplo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\toplo\OneDrive\Documents\GitHub\Arcade-5.0\main.py", line 75, in Down
    await interaction.response.defer()
  File "C:\Users\toplo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\interactions.py", line 592, in defer
    await adapter.create_interaction_response(
  File "C:\Users\toplo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\webhook\async_.py", line 219, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
#

is it the await interaction.response.defer()

#

I need the defer

#

Its literally just...

#

ITS JUST THAT ONE FIRST BUTTON PRESS, after, the same button and every other button work

#

I dn't get it.

#

God kill me

#

discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

#

I'ma brb.

#

GUYS I FOUND THE BUG

#

I FOUND THE BUG I FOUND THE BUG AFTER ADDUNG PRINTS, IT SEEMS LIKE THE FIRST BUTTON PRESS DOES NOT ACTUALLY TRIGGER ANYTHING

#

it only prints on the second time WHICH MEANS SOMETHING IS OFF

#
game = OCCUPIED['OWNERS'].get(interaction.user.id, None)
        if game is None:
            await interaction.response.send_message('You have no game instance constructed.', ephemeral = True)
        else:
            if OCCUPIED['OWNERS'][interaction.user.id].instance.id == interaction.message.id:
                await OCCUPIED['OWNERS'][interaction.user.id].update_direction('left')
                await interaction.response.defer()
                print('pressed')
#

something here... I just don't know

#

specifically the bottom part below the else

hushed galleon
slate swan
hushed galleon
#

aight cool

slate swan
#

what is wrong 😦

slate swan
slate swan
#

em.set_footer(icon_url = ctx.author.avatar_url, text=f"Requested by {ctx.author.name}")
AttributeError: 'Member' object has no attribute 'avatar_url'

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

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/bot.py", line 1009, in invoke_application_command
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/commands/core.py", line 359, in invoke
await injected(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'

#
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        em = discord.Embed(title=f"Hey, please slow it down!", description=f"Try again in {error.retry_after:.2f}s")
        await ctx.respond(embed=em)


@bot.slash_command(name="randomgif", description="Gets a random GIF from Giphy!")
@commands.cooldown(1, 15, commands.BucketType.user)
async def giphy(ctx) -> None:
    async with aiohttp.ClientSession() as cs:

        async with cs.get(f"https://api.giphy.com/v1/gifs/random?api_key=api keyg=g") as r:
            res = await r.json()

            em = discord.Embed(title="Giphy Gif!")
            em.set_image(url=res['data']['images']['original']['url'])
            em.set_footer(icon_url = ctx.author.avatar_url, text=f"Requested by {ctx.author.name}")

            await ctx.respond(embed=em)```


heres the code
slate swan
#

it works when i use bot commands, but slash command no work

silk fulcrum
#

pycord? 😭

cold sonnet
#

you leaked your api key

#

bru

#

@slate swan

slate swan
#

k

cold sonnet
#

b

silk fulcrum
#

z

#

alphabet

cold sonnet
#

nailed it

slate swan
#

heh

Code:

  File "c:\Users\xrkzl\OneDrive\Desktop\The ASS\main.py", line 32, in <module>
    settings = json.load(open("settings.json", encoding="utf-8"))
  File "C:\Program Files\Python310\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Program Files\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\Python310\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 34 (char 35)
shrewd apex
#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
slate swan
#

so in a command of my bot, i added a select menu, and in that i added options using a for loop, so, any way i can add response of those options using for loop too? help

vocal snow
#

What

slate swan
#

How do i get it to only show to one person?

#

(someone elses bot for referance)

slate swan
slate swan
#

And or chatting

#

oh

slate swan
#

mb

#

i thought it was diffrent

slate swan
tidal hawk
#

await ctx.respond("...", ephemeral=True)

#

ctx is bit cursed to use in slash commands

slate swan
#

Kinda

#

How I learned and I'm just tryna make a stupid bot for me and my friends

tidal hawk
#

okay xd

slate swan
#

Thanks though <3

tidal hawk
#

Np :D

slate swan
#

since when is interaction.respond a thing?

placid skiff
#

tbh interaction.response is weird too

#

How dpy handled slash commands feels a lot like how classes are handled in Java

slate swan
#

i have added options to a select menu using for loops, is it possible to add interactions for every options using loops too, or have my bot respond diffrent msgs to each of those options? help

gaunt briar
#

just made my first discord bot :))

slate swan
#

is there a way to convert a member object to a string so i can replace parts of it?
message.author gives me Rosy#2503, but i cant do .replace("#", '') on it since member object has no attribute replace

placid skiff
#

just use Member parameters D_D
discord.Member.name returns the member name
discord.Member.nick returns the member specific nickname for that guild
discord.Member.discriminator returns the member discriminator, as a string since it can be a string too

slate swan
rugged shadow
#

what if someone changes the channel name 🧍

pulsar solstice
#

I wanna make a dashboard for my bot.
Is there is something that I should learn before getting started?

#

And I know pretty advance html and Javascript

robust fulcrum
#

Maybe learn a good js framework?

pulsar solstice
#

my friend is doing the css for me

robust fulcrum
#

Any good js framework will make your site more good and give good user experience

pulsar solstice
#

from where should I start?

#

or start learning stuff

robust fulcrum
#

I can't tell much as i never did this

robust fulcrum
#

But i have a mid knowledge about react

pulsar solstice
#

Are there any documentations that I should read?

placid skiff
#

You can use Django for the backend, so you will have a better interface between the website and the bot

robust fulcrum
#

Idk
If want to learn react see YouTube

placid skiff
#

unfortunately there aren't a lot of tutorials for those kind of stuff

robust fulcrum
#

Why am I getting this error guys?

placid skiff
robust fulcrum
paper sluice
placid skiff
#

lmao sorry, that traceback is handled somewhere? it is not the full traceback

robust fulcrum
#

I forgot a lot of python and discord.py as i moved to js
😦

robust fulcrum
placid skiff
#

on_ready is a coroutine, it is a method from Bot, so it is async def on_ready()

robust fulcrum
#

Oh k

placid skiff
robust fulcrum
placid skiff
#

?

agile lark
#

Does anyone know if discord supports taking a date as an app_command input? Like, with a date-selection menu?

#

Or should I like, take as input ranges of months (or enums) and days? But what about different days in a month? Should I just report the mistake to the user?

placid skiff
#

Yo who can explain this D_D

agile lark
#

append returns None. The addition is in-place

#

!e

somelist = [1, 2]
ret_value = somelist.append(3)
print(ret_value)
print(somelist)
unkempt canyonBOT
#

@agile lark :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | None
002 | [1, 2, 3]
placid skiff
#

so i have to make two lines to add an element lmao

#

bruh my python knowledge is quite good tbh

agile lark
#

Sending the full error message helps

maiden fable
#

Nice, @placid skiff very nice 👏👏👏

placid skiff
maiden fable
placid skiff
# maiden fable You totally didn't make a joke out of yourself

Bro yesterday i had to regress a Java code from the last version to Java 5, my mind literally blew up
I couldn't even use lists, i had to declare sized arrays but i needed dynamically arrays, so i had to do a sort of workaround and i felt like i was back to coding in C in my first year of high school

slate swan
#
async def send_message():
    #partnership001
    channel = bot.get_channel(971319808719212555)
    with open('/Users/bai/Documents/Personal Things/PythonDiscord/Partnerships/partnership001.txt', 'r') as f:
        msg = f.read()
    await channel.send(msg)
    await asyncio.sleep(10)```

error:
```Unhandled exception in internal background task 'send_message'.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/tasks/__init__.py", line 176, in _loop
    await self.coro(*args, **kwargs)
  File "/Users/bai/Documents/aww pika discord bot v2.py", line 23, in send_message
    await channel.send(msg)
AttributeError: 'NoneType' object has no attribute 'send'```

im using pycord, why does this not work?
paper sluice
paper sluice
pliant gulch
unkempt canyonBOT
#

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

['a', 'b', 'c', 'd', 'e', 'f']
placid skiff
slate swan
#

please help here

tawdry perch
#

I'm assuming you meant m.author, on a side note, I have not touched discord bots for a long time

naive briar
#

Change message.author to ctx.author

upbeat gust
#

if you're having NameErrors you really should make sure you know python

spiral fern
#

what has this become

#

before any questions are asked: yes, the bot is in the guild I mentioned

#

yes, both IDs are correct

vocal snow
#

Make sure the cache is ready

#

!d discord.ext.commands.Bot.wait_until_ready

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.

Warning

Calling this inside [`setup_hook()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.setup_hook "discord.ext.commands.Bot.setup_hook") can lead to a deadlock.
spiral fern
#

would that be a problem?

#

since I'm using asyncio, I can't put my functions inside a command nor an event

#

that's why I'm not using a command

vocal snow
vocal snow
spiral fern
#

i'm not in an async context though

spiral fern
#

for a reason I haven't understood yet

vocal snow
vocal snow
#

Can the function be made async?

paper sluice
spiral fern
#

meaning await can easily replace asyncio.run (inside a coroutine)?

vocal snow
#

asyncio.run should only be called once, to start an event loop and run some coroutine

#

Inside coroutines you should use await or create_task

spiral fern
#

wait guys I think I might be the biggest idiot on the earth

#

cause I was so focused on trying to use asyncio.run that I forgot await was a thing

#

let me see if this is true

#

let me test it rq

ashen perch
maiden fable
placid skiff
slate swan
#
         'It is decidedly so',
         'Without a doubt',
         'Yes, definitely',
         'You may rely on it',
         'As I see it, yes',
         'Most likely',
         'Outlook good',
         'Yes, signs point to yes',
         'Dont count on it',
         'My reply is no',
         'My sources say no',
         'Very doubtful',
         'Reply hazy, try again',
         'Ask again later',
         'Better not tell you now',
         'Cannot predict now',
         'Concentrate and ask again']


@bot.slash_command(name="8ball", description="8ball command")
@commands.cooldown(1, 10, commands.BucketType.user)
async def 8ball(ctx):
    ctx : ApplicationContext,
    question: Option(str,
                    required=True)
):

    if question == anything:
        await ctx.respond(random.choice(8ball))```

how should i make this slash command? for it to work
placid skiff
#

Lmao Application in d.py is some real shit, maybe with interaction.original_response.edit() you can edit the message

paper sluice
slate swan
#
eightball = ['It is certain',
            'It is decidedly so',
            'Without a doubt',
            'Yes, definitely',
            'You may rely on it',
            'As I see it, yes',
            'Most likely',
            'Outlook good',
            'Yes, signs point to yes',
            'Dont count on it',
            'My reply is no',
            'My sources say no',
            'Very doubtful',
            'Reply hazy, try again',
            'Ask again later',
            'Better not tell you now',
            'Cannot predict now',
            'Concentrate and ask again']


@bot.slash_command(name="8ball", description="8ball command")
@commands.cooldown(1, 10, commands.BucketType.user)
async def 8ball(ctx):
    ctx : ApplicationContext,
    question: Option(str,
                    required=True)
):

    if question == anything:
        await ctx.respond(random.choice(eightball))

how should i make this slash command? for it to work

slate swan
paper sluice
slate swan
#

ok

#

if question == anything:

#

what should i write for this

vale wing
paper sluice
#
@bot.slash_command(name="8ball", description="8ball command")
@commands.cooldown(1, 10, commands.BucketType.user)
async def 8ball(ctx):
    ctx : ApplicationContext,
    question: Option(str,
                    required=True)
):

    if question == anything:
        await ctx.respond(random.choice(eightball))

what is this?

vale wing
#

What is that condition for

slate swan
#

then how im supposed to write it

vale wing
#

Just reply without any conditions

slate swan
paper sluice
slate swan
#

i wanna make something like this

paper sluice
# slate swan ?

Did you look at your function? That is not correct syntax.

slate swan
#

thats why im asking cuz i dont know how 😦

paper sluice
#

you should should be familiar with the basics before you start making bots, its not a beginner friendly.

slate swan
#

thanks.

#

Code:

async def send_message():
    #partnership001
    channel = bot.get_channel(971319808719212555)
    with open("/Users/bai/Documents/Personal Things/PythonDiscord/Partnerships/partnership001.txt", "r") as f:
        msg = f.read()
    await channel.send(msg)
    await asyncio.sleep(10)```

error:
```Unhandled exception in internal background task 'send_message'.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/tasks/__init__.py", line 176, in _loop
    await self.coro(*args, **kwargs)
  File "/Users/bai/Documents/aww pika discord bot v2.py", line 23, in send_message
    await channel.send(msg)
AttributeError: 'NoneType' object has no attribute 'send'```

how to fix
silk fulcrum
slate swan
spring needle
#

Does await command() exist in discord py

slate swan
slate swan
silk fulcrum
spring needle
#

Cuz I don’t know how to use invoke

silk fulcrum
#

dpy gives you ctx.invoke

#

!d discord.ext.commands.Context.invoke

unkempt canyonBOT
#

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

Calls a command with the arguments given.

This is useful if you want to just call the callback that a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally.

Note

This does not handle converters, checks, cooldowns, pre-invoke, or after-invoke hooks in any matter. It calls the internal callback directly as-if it was a regular function.

You must take care in passing the proper arguments when using this function...
spring needle
#

It always says NonType is not callable

silk fulcrum
#

what's in it?

#

i mean the txt file

silk fulcrum
slate swan
silk fulcrum
#

you just didnt await fetch for some reason

slate swan
#

channel = await bot.fetch_channel(971319808719212555)

#

like this?

silk fulcrum
#

yes?

spring needle
silk fulcrum
slate swan
# silk fulcrum yes?

no..

File "/Users/bai/Documents/aww pika discord bot v2.py", line 20, in send_message
channel = await bot.fetch_channel(971319808719212555)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 1619, in fetch_channel
data = await self.http.get_channel(channel_id)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/http.py", line 353, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

silk fulcrum
slate swan
#

oh

spring needle
#

So I did await ctx.invoke(command = ‘TheCommandName’)

#

The command has no arg required

#

And it says NoneType not callable

#

The command it tries to invoke is used to create and print an embedded message

placid skiff
#

!d discord.ext.commands.Context.invoke

unkempt canyonBOT
#

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

Calls a command with the arguments given.

This is useful if you want to just call the callback that a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally.

Note

This does not handle converters, checks, cooldowns, pre-invoke, or after-invoke hooks in any matter. It calls the internal callback directly as-if it was a regular function.

You must take care in passing the proper arguments when using this function...
silk fulcrum
placid skiff
#

invoke needs a command object, not the command name

silk fulcrum
#

and this

spring needle
#

just invoke(‘commandname’)?

silk fulcrum
spring needle
silk fulcrum
spring needle
#

My bad

placid skiff
#

args and kwargs are just the arguments of the command, if the command has arguments, you can pass them by positional (*args, so the first one will be the first arg declared) or as keyword (**kwargs, you will set the argument with the key of the argument and assign it to a value arg_1 = "something")

spring needle
#

It has no arg, it is async def CommandName(ctx)

placid skiff
#

then neither args or kwargs are needed

spring needle
#

But if ‘/‘ is nothing, why it appears as an arg in invoke command

silk fulcrum
#

burh

#

* also appears somewhere

#

but it is nothing either

spring needle
#

Fact too…

slate swan
placid skiff
#

Thanks ashley D_D

slate swan
#

:hattip:

#

rip nitro

placid skiff
silk fulcrum
#

ill give you if i do

spring needle
#

Last question, I use invoke as interaction response, and when the invoke was successfully executed, the select option still showed interaction failed

silk fulcrum
#

it expired :bruhness:

slate swan
#

sad

silk fulcrum
#

i think u deserve it

slate swan
#

no wait I though that was a joke

slate swan
placid skiff
#

I don't have a free nitro, but i have a free xbox game pass if you want xD

silk fulcrum
#

why not

#

lmao

slate swan
#

wish I had time to play games 😔

silk fulcrum
placid skiff
#

Coding is a full time job LMAO

#

but I have to rank on rainbow and League so i play anyways D_D

silk fulcrum
#

my school + chess tournament is full time bob for me

slate swan
#

cz no time

silk fulcrum
#

btw im going to the tournament in five mins

slate swan
#

best of luck, Master!

#

wish you good

silk fulcrum
silk fulcrum
placid skiff
#

Trust an old man, the school is usefull untill High School if you study computer sience, literally high school license is enough to find a job as a dev

silk fulcrum
#

my opponent seems to be trash tho

slate swan
silk fulcrum
slate swan
#

depends though, idek how chess is played

placid skiff
#

I used to play chess during lessons with a classmate of mine

silk fulcrum
placid skiff
#

cuz wdgaf about school D_D

silk fulcrum
#

strategy tactics and all that shit

slate swan
silk fulcrum
#

okay gotta hurry up

slate swan
#

oki, good luck!

silk fulcrum
#

or im gonna be late like last time

slate swan
silk fulcrum
slate swan
#

wrong emoji

#

go now

silk fulcrum
#

ok bye

placid skiff
slate swan
#
async def on_member_join(member):
    #main server
    if member.guild.id == 971319429461835836:
        await bot.fetch_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30) #proofs channel
        await bot.fetch_channel(987268323731439646).send(f"{member.mention}, pls check out these giveaway channels!", delete_after=30) #giveaways info channel
        await bot.fetch_channel(971319847352950835).send(f"Welcome to the server! Please do remember to get reaction roles in #⟡💫・reaction-roles channel!") #main chat```

why this not working?
it worked before i changed everything to slash commands, and moved from discord.py to pycord, how to fix?
primal token
slate swan
slate swan
#

what's the error

maiden fable
#

"Do you want a medium burger or large"

slate swan
#

lmao

primal token
slate swan
#

plus I don't necessarily need to work

primal token
#

Yeah its not that bad, quite nice ig

slate swan
slate swan
primal token
slate swan
slate swan
slate swan
#

ok hunter

slate swan
#

wdym

slate swan
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for 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.

slate swan
#

oh

faint sapphire
#

yo, i plan on making this in the near future,
was just wondering if anyone got advice that might be useful

quite frequently i get ppl joining my server and promoting financial nonsense, or ppl who beam/cookie log accounts
ive seen some discord bots that offer to ip ban with premium
i was wondering if banning individual ips is doable, ig id have to store them in a db file

slate swan
#

nice, show the intents

slate swan
slate swan
#

bot = discord.Bot(intents=intents)

like this?

#

yes

#

ok

#

ima test it

#

isnt it commands.Bot

plush rapids
#

Im building a dicord bot for the first time and ive hit a slight snag when i use the bot it will only reply in dm's not on the server i made

slate swan
#

its still not working @slate swan

slate swan
slate swan
slate swan
#

when ppl join there is no message

#

Warning (from warnings module):
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/script/main/aww pika discord bot v2.py", line 43
await bot.fetch_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30) #proofs channel
RuntimeWarning: coroutine 'Client.fetch_channel' was never awaited
Ignoring exception in on_member_join
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/script/main/aww pika discord bot v2.py", line 43, in on_member_join
await bot.fetch_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30) #proofs channel
TypeError: coroutine.send() takes no keyword arguments

slate swan
slate swan
slate swan
slate swan
#

a okay

slate swan
#

error

#

Warning (from warnings module):
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/script/main/aww pika discord bot v2.py", line 43
await bot.fetch_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30) #proofs channel
RuntimeWarning: coroutine 'Client.fetch_channel' was never awaited
Ignoring exception in on_member_join
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/script/main/aww pika discord bot v2.py", line 43, in on_member_join
await bot.fetch_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30) #proofs channel
TypeError: coroutine.send() takes no keyword arguments
Ignoring exception in on_member_join
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/script/main/aww pika discord bot v2.py", line 43, in on_member_join
await (await bot.fetch_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30) #proofs channel
TypeError: coroutine.send() takes no keyword arguments

slate swan
#

?

#
async def on_member_join(member):
    #main server
    if member.guild.id == 971319429461835836:
        await (await bot.fetch_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30) #proofs channel
        await (await bot.fetch_channel(987268323731439646).send(f"{member.mention}, pls check out these giveaway channels!", delete_after=30) #giveaways info channel
        await (await bot.fetch_channel(971319847352950835).send(f"Welcome to the server! Please do remember to get reaction roles in #⟡💫・reaction-roles channel!") #main chat```

this is the code
placid skiff
naive briar
paper sluice
slate swan
#

I need support anyone!? Im new to coding testing and playing around with stuff but i keep getting this error.

#

!indents

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

slate swan
#

also, Discord.py is not really a playing around library

slate swan
#

i dont understand any of that

slate swan
#

no one will do that here

#

y?

#

we are here to make people learn not spoon-feed

#

I am learning but on youtube

#

I just need the tiniest bit of help

#

youtube tutorials are quite outdated y'know, so there's a big chance that things will break every so often

#

can someone please just help me this 1 time

primal token
primal token
#

The only thing that can help your issue is that embed given and your delete key

slate swan
#

whats a tab key

primal token
#

the key under your escape key!

slate swan
#

9?

slate swan
#

im a new coder and im being treated like im the master of python .-.

slate swan
slate swan
slate swan
slate swan
primal token
slate swan
slate swan
#

what does that mean

vocal snow
#

You have a ( but no ) to match it

slate swan
vocal snow
#

The last line is indented incorrectly

slate swan
#

//

slate swan
vocal snow
#

Did you read the error

slate swan
#

ye

#

non of it makes sense to me

#

i started python 11:03 Ago

#

.-.

naive briar
slate swan
hushed galleon
hushed galleon
#

you write it like a second argument, i.e. value="my thing" and a comma inbetween your name= argument so python knows they're separate

slate swan
#

ye idk what that means

hushed galleon
#
def my_function(x, y):
    return x + y

# calling it
my_function(x=123, y=456)```
slate swan
#

whatever u just said

#

isnt that javascript?

hushed galleon
#

this is still python

vocal snow
#

Lmaooo

slate swan
#

oh right

#

ye so if i send u the code u fix it for me?!

slate swan
vocal snow
#

Generally we recommend learning python before trying discord.py

slate swan
#

wasnt talking to u pocoyomad

vocal snow
#

I was talking to you

slate swan
#

Well

#

I actually know python i just paste 🙂

#

Thats a skill right?

eternal fox
slate swan
#

where am i suppost to put that

eternal fox
#

like treat em.add_field as a normal function with parameters and stuff

slate swan
#

@bot.command()
async def luckboost(ctx):
  pfp = 'no'
  em = discord.Embed(color=800000)
  em.set_thumbnail(url=pfp)
  em.set_footer(text="wtv")
  em.add_field(name="Luckboost")
  await ctx.reply(embed=em) ```
slate swan
eternal fox
#

give it a shot

eternal fox
naive briar
eternal fox
#

What languages do u know?

slate swan
#

nun i just paste

#

if pasting is a language i know it

eternal fox
#

i think u should atleast learn python first

slate swan
#

Let a python newbie learn 😦

eternal fox
naive briar
#

Sure Mr. Python expert

slate swan
paper sluice
eternal fox
slate swan
paper sluice
#

This is not funny

vocal snow
#

The number of trolls in here have increased lately, i wonder why that is

slate swan
#

i wasnt trying to be funny.

paper sluice
#

if you here to troll, you should leave

slate swan
#

im not im ownestly just looking for help .-..

paper sluice
primal token
#

Since when was Marceline emo?

slate swan
slate swan
paper sluice
eternal fox
slate swan
#

how do i make a bot ignore dms messages?

eternal fox
slate swan
#

how do i make a bot ignore dms messages?

eternal fox
slate swan
primal token
unkempt canyonBOT
#

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

paper sluice
slate swan
#

see howcomes yall help him but not me

vocal snow
#

Why is this channel unmoderated

naive briar
slate swan
#

ye idk any of it

naive briar
#

You just chose not to understand and wait for them to fix it for you it seems ducky_beer

slate swan
slate swan
paper sluice
#

stack overflow?

primal token
#

Extra lines? Have you ever read the python zen?

slate swan
#

pasting is fun i can sound like ik what to do

#

i want my bot to only work in private channels since i got verify channel

paper sluice
paper sluice