#discord-bots

1 messages · Page 111 of 1

slate swan
#

Why does my bot answer 2 times

brazen raft
#

I think embeds' description is a required argument

#

Which you don't pass to the constructor

brazen raft
slate swan
#

how to get animated emoji id?

zealous jay
#

I don't have it rn but its long af

#

The rate limit one

mighty pilot
#

Do cogs need to be formatted as a class to work as intended?

#

I avoided this by putting this in my on_message

#

That'll prevent it from logging any bot messages to begin with

north escarp
#

@slate swan And how did you make a message counter ??

shrewd apex
#

dpy has an is animated check for emojis

mighty pilot
#

Did you add the command to your bot tree?

north escarp
#

how can I make it so that the profile displays how many messages you wrote during the time the bot is on the server ?

#

I know what needs to be used there before and after

honest shoal
mighty pilot
#

Just use return. It shouldn't continue any of the on_message if the message comes from a bot

slate swan
#

can someone help me

hushed galleon
# slate swan

apparently you have a previous command that already used the name "commands"

slate swan
#

nah i dont, when i remove the "rules" part everything works fine

#

when i remove this

sick birch
#

You did have a commands command unless you removed it

slate swan
slate swan
#

yk how i can fix it? @sick birch

slate swan
#

yo anyone wanna help me?

#

my bot doesnt respond when i do a command like "!version"

cloud dawn
slate swan
#

when it should respond to !version and send an embed it doesnt

#

i think i need to add awat smt

#

await

cloud dawn
#

!paste Could you paste your code here?

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
#

from cgi import test
from email import message
from math import degrees
from multiprocessing.sharedctypes import Value
import site
from unicodedata import name
import discord
import http
from discord.ext import commands

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

@bot.command(name='version')
async def version(context):

myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
myembed.add_field(name="Site", value="", inline=False)
myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
myembed.set_footer(text="Made by Splunk#1157")
myembed.set_author(name="Made by Splunk#1157")
await message.channel.send(embed=myembed)

await context.message.channel.send(embed=myembed)

@bot.event
async def on_ready():

test_channel = bot.get_channel(1032312979594682491)
await test_channel.send('Hello')

@bot.event
async def on_disconnect():
test_channel = bot.get_channel(1032312979594682491)
await test_channel.send('Hello')

@bot.event
async def on_message(message):

if message.content == "What day is it?":
    test_channel = bot.get_channel(1032312979594682491)
    await test_channel.send("The day is the 21th")

if message.content == "Thank you for telling me!":
    test_channel = bot.get_channel(1032312979594682491)
    await test_channel.send("No Problem AnyTime :)")

    myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
    myembed.add_field(name="Site", value="s", inline=False)
    myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
    myembed.set_footer(text="Made by Splunk#1157")
    myembed.set_author(name="Made by Splunk#1157")
    await message.channel.send(embed=myembed)

    await bot.process_commands(message)

bot.run('')

#

there

cloud dawn
#

unindent await bot.process_commands(message)

main junco
#

Hello !

I'm a Raspberry Pi 4 user and I want to create a bot with Python with the help of this video :

https://www.youtube.com/watch?v=i7aYBB3znMI

My first code is that ( it's a simple code because I'm a beginer ) :

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='>')

@bot.command()
async def ping(ctx):
await ctx.send('pong')

bot.run('<MYTOLKEN>')

Thene, when I realized it don't work I try that :

import discord
from discord.ext import commands

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

@bot.command()
async def ping(ctx):
await ctx.send('pong')

bot.run('<MYTOLKEN>')

And in the console it's tell me that :

WARNING discord.ext.commands.bot Privileged message content intent is missing, commands may not work as expected.
INFO discord.client logging in using static token
INFO discord.gateway Shard ID None has connected to Gateway.

Sorry for my bad english.
So if you can help me, thank you !

Discord is a fantastic tool to speak with your community (gamers at first, but now more open to other types). You can use web hooks and bots to interact with a server.
Today, we'll see how to do this on a Raspberry Pi with Python.

How to make a Discord bot on Raspberry Pi?
A bot is seen almost as a normal user on Discord, and it's possible to ...

▶ Play video
cloud dawn
#

Guys please...

cloud dawn
#

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

slate swan
#

ok

cloud dawn
zealous jay
cloud dawn
#

It's better to use a listener anyways.

cloud dawn
#

I mean

slate swan
zealous jay
#

If already checks if its True

cloud dawn
#

!indention

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
#

bruh which code

#

man i will go crazt

cloud dawn
#

await bot.process_commands(message)

#

Still the same code.

slate swan
#

right?

cloud dawn
#

No you need to unindent that piece of code.

zealous jay
#

remove one tab

slate swan
wary shadow
#

bot.run('<MYTOLKEN>')
And my Axe! darkoLUL

((couldn't help myself))

zealous jay
#

in that line

slate swan
#

unindent

slate swan
cloud dawn
#

Okay now you're good.

mighty pilot
slate swan
#

ohhhh ok

zealous jay
#

oh ok, just saying

cloud dawn
slate swan
#

still doesnt work

cloud dawn
#

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

slate swan
#

liek when i do !version

#

it doesnt send the embed

cloud dawn
#

tb or if it even reaches ready event.

slate swan
#

like theres no error or anything

cloud dawn
#

Show your on_message please.

slate swan
#

its just not sending my embed when i do "!version"

zealous jay
#

btw make the on_message a listener instead of an event because you overwrite the original event, that's why you need to add the process thing

slate swan
#

ok i did get errors

cloud dawn
slate swan
#

ok sorry xd

cloud dawn
#

Could you paste that here using Discord code format?

slate swan
#

sync def on_message(message):

#

yea chill

#
async def on_message(message):
#

there

mighty pilot
#

I think they were asking for the whole code block under on_message lol

slate swan
#
from cgi import test
from email import message
from math import degrees
from multiprocessing.sharedctypes import Value
import site
from unicodedata import name
import discord
import http
from discord.ext import commands

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

@bot.command(name='version')
async def version(context):
   

    myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
    myembed.add_field(name="Site", value="", inline=False)
    myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
    myembed.set_footer(text="Made by Splunk#1157")
    myembed.set_author(name="Made by Splunk#1157")
    await message.channel.send(embed=myembed)

    await context.message.channel.send(embed=myembed)

@bot.event
async def on_ready():

  test_channel = bot.get_channel(1032312979594682491) 
  await test_channel.send('Hello')

@bot.event
async def on_disconnect():
 test_channel = bot.get_channel(1032312979594682491) 
 await test_channel.send('Hello')
  
@bot.event
async def on_message(message):

    if message.content == "What day is it?":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("The day is the 21th")

    if message.content == "Thank you for telling me!":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("No Problem AnyTime :)")

        myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
        myembed.add_field(name="Site", value="", inline=False)
        myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
        myembed.set_footer(text="Made by Splunk#1157")
        myembed.set_author(name="Made by Splunk#1157")
        await message.channel.send(embed=myembed)

    await bot.process_commands(message)




bot.run('')
#

there @cloud dawn

mighty pilot
#

What's the error you get when trying your command

slate swan
#

022-10-21 17:13:33 ERROR discord.ext.commands.bot Ignoring exception in command version
Traceback (most recent call last):
File "R\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "\OneDrive\Skrivbord\Disocrd bots\Discord bot.py", line 22, in version
await message.channel.send(embed=myembed)
AttributeError: module 'email.message' has no attribute 'channel'

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

Traceback (most recent call last):
File R\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'email.message' has no attribute 'channel'

#

there

mighty pilot
#

Use context.channel.send instead of message.channel.send

slate swan
mighty pilot
#

line 22 in version

#

For your !version command

slate swan
#

ye

#

ok ty

round lily
#

Hello everyone im new to python and i wanted to learn to make a bot

#

this is my error

#

any help greatly appreciated

cloud dawn
#

.event no () needed. @round lily

slate swan
slate swan
#

why it doesnt work

mighty pilot
#

What's the new error message

honest shoal
#

Show xode

slate swan
slate swan
#

like theres is not any error

round lily
slate swan
mighty pilot
#

If there's no error message in your command prompt then it's doing what you told it to do

slate swan
#

when i say !version it should send an embeded text but it doesnt do it

round lily
#

: pain

slate swan
mighty pilot
slate swan
honest shoal
#

The line where u have message.channel.send

slate swan
slate swan
#

still doesnt work

honest shoal
#

Line 22

round lily
#

if so no

slate swan
#

cant you like just copy the code and fix it bc i think that is easier

slate swan
honest shoal
#

Copy pasting on mobile is hard

slate swan
#

ok wait

#
from cgi import test
from email import message
from math import degrees
from multiprocessing.sharedctypes import Value
import site
from unicodedata import name
import discord
import http
from discord.ext import commands

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

@bot.command(name='version')
async def version(context):
   

    myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
    myembed.add_field(name="Site", value="", inline=False)
    myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
    myembed.set_footer(text="Made by Splunk#1157")
    myembed.set_author(name="Made by Splunk#1157")
    context.send()
    await context.message.channel.send(embed=myembed)

@bot.event
async def on_ready():

  test_channel = bot.get_channel(1032312979594682491) 
  await test_channel.send('Hello')

@bot.event
async def on_disconnect():
 test_channel = bot.get_channel(1032312979594682491) 
 await test_channel.send('Hello')
  
@bot.event
async def on_message(message):

    if message.content == "What day is it?":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("The day is the 21th")

    if message.content == "Thank you for telling me!":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("No Problem AnyTime :)")

        myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
        myembed.add_field(name="Site", value="", inline=False)
        myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
        myembed.set_footer(text="Made by Splunk#1157")
        myembed.set_author(name="Made by Splunk#1157")
        await message.channel.send(embed=myembed)

        await bot.process_commands(message)




bot.run('')
cloud dawn
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.

honest shoal
#

Fill the embed kwarg and await it

slate swan
#

ehhhhhhhh

#

how do i do that xd

#

sorry if i am annoying i am just an noob

round lily
#

wait

mighty pilot
mighty pilot
#

You're not telling it to send anything

slate swan
#

but didnt i try that

round lily
#

there we go

honest shoal
slate swan
#

where do i put await

mighty pilot
#

Yea await. I have a habit of missing that and fixing after error lol

#

await context.send(embed=myembed)

slate swan
#

oghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

ok tysm

#

bruhhhhhhh whatttttt

#

it still doesnt send my embed text

honest shoal
#

How are u invoking

slate swan
#

invoking?

honest shoal
#

Using

slate swan
#

the code?

honest shoal
#

Command

slate swan
#

i say in my server "!version"

honest shoal
#

On discord

slate swan
#

it should send embed text when i do it

honest shoal
#

Then u are doing a silly mistake somewhere

slate swan
#

bruh whereeeeeeee then

mighty pilot
#

Still no error messages?

slate swan
#

from cgi import test
from email import message
from math import degrees
from multiprocessing.sharedctypes import Value
import site
from unicodedata import name
import discord
import http
from discord.ext import commands

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

@bot.command(name='version')
async def version(context):

myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
myembed.add_field(name="Site", value="", inline=False)
myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
myembed.set_footer(text="Made by Splunk#1157")
myembed.set_author(name="Made by Splunk#1157")
await context.send(embed = myembed)
await context.message.channel.send(embed=myembed)

@bot.event
async def on_ready():

test_channel = bot.get_channel(1032312979594682491)
await test_channel.send('Hello')

@bot.event
async def on_disconnect():
test_channel = bot.get_channel(1032312979594682491)
await test_channel.send('Hello')

@bot.event
async def on_message(message):

if message.content == "What day is it?":
    test_channel = bot.get_channel(1032312979594682491)
    await test_channel.send("The day is the 21th")

if message.content == "Thank you for telling me!":
    test_channel = bot.get_channel(1032312979594682491)
    await test_channel.send("No Problem AnyTime :)")

    myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
    myembed.add_field(name="Site", value="", inline=False)
    myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
    myembed.set_footer(text="Made by Splunk#1157")
    myembed.set_author(name="Made by Splunk#1157")
    await message.channel.send(embed=myembed)

    await bot.process_commands(message)

bot.run('')

#

see the code

slate swan
honest shoal
#

• Are intents turned on, on dashboard?
• Is the bot having permissions wherever you're testing?
• Is the code being updated properly?

cloud dawn
slate swan
slate swan
#
user = ['1031053618008301588']

  for member in user:
    await user.send(f"Bot has joined {invite}")
Traceback (most recent call last):
  File "/home/runner/funny-bot/venv/lib/python3.8/site-packages/discord/client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 514, in on_guild_join
    await user.send(f"Bot has joined {invite}")
AttributeError: 'list' object has no attribute 'send'
#

but i think so yea

round lily
#

that monster

slate swan
mighty pilot
#

Try send_message( instead of send( I had to do that with my slash commands

honest shoal
slate swan
cloud dawn
round lily
#

im on a mac...what

mighty pilot
round lily
#

oh so im just assed out

slate swan
#

oh

slate swan
cloud dawn
slate swan
#

line 22?

mighty pilot
honest shoal
slate swan
#

didnt work

mighty pilot
round lily
#

oh wait

slate swan
#

bruh what should i do

mighty pilot
#

await context.send("this is a test")

honest shoal
# slate swan bruh what should i do

Add this in your code py @bot.listen('on_command_error') async def error_handler(ctx,  error):     raise error, we can catch error with this probably

mighty pilot
#

On a new line, then restart your bot and try again it should spit out an error for you

slate swan
#

oo

#

bruh what

#

i didnt get any error msgs

honest shoal
#

Use the command on Discord

slate swan
#

kk

#

i still dont get it

mighty pilot
#

One sec I'm gonna get on my computer and see if I can replicate the problem on my bot

slate swan
#

ok

#

heres the code

honest shoal
mighty pilot
#

You've pasted it enough lol

slate swan
#
from cgi import test
from email import message
from math import degrees
from multiprocessing.sharedctypes import Value
import site
from unicodedata import name
import discord
import http
from discord.ext import commands

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

@bot.command(name='version')
async def version(context):
   

    myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
    myembed.add_field(name="Site", value="s", inline=False)
    myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
    myembed.set_footer(text="Made by Splunk#1157")
    myembed.set_author(name="Made by Splunk#1157")
    await context.send("this is a test")
    await context.message.channel.send(embed=myembed)

@bot.event
async def on_ready():

  test_channel = bot.get_channel(1032312979594682491) 
  await test_channel.send('Hello')

@bot.event
async def on_disconnect():
 test_channel = bot.get_channel(1032312979594682491) 
 await test_channel.send('Hello')
  
@bot.event
async def on_message(message):

    if message.content == "What day is it?":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("The day is the 21th")

    if message.content == "Thank you for telling me!":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("No Problem AnyTime :)")

        myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
        myembed.add_field(name="Site", value="", inline=False)
        myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
        myembed.set_footer(text="Made by Splunk#1157")
        myembed.set_author(name="Made by Splunk#1157")
        await message.channel.send(embed=myembed)

        await bot.process_commands(message)




bot.run('')
#

there

honest shoal
#

You didn't add error handler?

slate swan
#

i did but removed it

pastel basin
#

i cant put custom emoji in embed title

#

is it possible to do that?

#

i thought that its not possible to put in embed titles..

lost yoke
#
discord.ext.commands.errors.CommandNotFound: Command "marcar" is not found```
honest shoal
lost yoke
#

whats wrong?

pastel basin
round lily
lost yoke
#

how do you solve?

round lily
#

do i need to do something with the permission integer

honest shoal
slate swan
#

@mighty pilot you done?

blazing star
#

"@bot.command(aliases=["streaming"])
async def stream(ctx, *, message):
await ctx.message.delete()
stream = discord.Streaming(
name=message,
url=" had to remove this because of bot",
)
await bot.change_presence(activity=stream)", the activity is still green for the bot

mighty pilot
slate swan
#

ok

#

ty

lost yoke
#

ok

slate swan
#

i may not respond asap

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

blazing star
#
async def stream(ctx, *, message):
    await ctx.message.delete()
    stream = discord.Streaming(
        name=message,
        url="",
    )
    await bot.change_presence(activity=stream)```
lost yoke
#
async def marcar(ctx):
        await ctx.send('hi')```
#

correct?

blazing star
#

yes

honest shoal
blazing star
#

@honest shoal can u pls help

cloud dawn
honest shoal
blazing star
#

wait what, how do i change it

honest shoal
#

Wait a min, are u getting any error@blazing star

pastel basin
#

how can i add two images in the same embed?

sick birch
#

2 per 10 minutes i believe

round lily
#

kicked and added the bot again but same error

blazing star
#

@honest shoal can u pls help me fixing it

cloud dawn
honest shoal
# blazing star no

stream=discord.ActivityType.Streaming, name=message, url=""
&
activity=discord.Activity(type=stream)

sick birch
#

sure if you want to think of it that way

#

that's still about 1 edit per 30 seconds on aveage

round lily
#

error says to try"disabling privileged intents"

honest shoal
#

Hold on

blazing star
mighty pilot
#

With discords move to slash commands did they stop bot commands entirely?

round lily
#

why is this so hard the guys on yt make it look so easy

sick birch
#

the tutorials on youtube are usually wrong

blazing star
#

@honest shoal

cloud dawn
sick birch
#

... horrifically garbage?

pastel basin
#

how can i add two images in the same embed?

round lily
#

bot youre already an admin how many more privileges do you want from me

sick birch
#

who?

#

the bot?

#

or you

round lily
#

my bot

sick birch
#

just enable the intents it's asking

#

it's in the dev portal

#

it should be under the "bot" section

honest shoal
#

@blazing star this will work for youpy await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.streaming, name=message, url=""))

honest shoal
cloud dawn
cloud dawn
slate swan
#

its for ids

#

so when my bot joins a server it will message mods the invite

#

for certain ids in a list

glad cradle
#

having a list of member object you could use discord.Member.send

#

!d discord.Member.send

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

Sends a message to the destination with the content given.

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

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

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

wdym by that can you like send the code

mighty pilot
#

Hold on I found something let me try it

slate swan
honest shoal
#

@slate swanchange your @bot.events to @bot.listen() (and remove that bot.process thing obv)

honest shoal
slate swan
#

one second. ill show

honest shoal
#

isn't that only for twitter embeds

slate swan
#

nah someones got an example

honest shoal
#

show pls

slate swan
#
URL = 'https://www.google.com/'
IMAGE_1 = 'https://cdn.discordapp.com/embed/avatars/1.png'
IMAGE_2 = 'https://cdn.discordapp.com/embed/avatars/2.png'

# embeds must have the same url
# works with more up to 4(?) embeds on desktop, might not work at all on mobile

embed1 = discord.Embed(
    title='TITLE 1',
    description='DESCRIPTION 1',
    url=URL # <<< same url as other embeds
)
embed1.set_image(url=IMAGE_1)

embed2 = discord.Embed(
    title='TITLE 2', 
    description='DESCRIPTION 2', 
    url=URL # <<< same url as other embeds
)
embed2.set_image(url=IMAGE_2)
await channel.send(embeds=[embed1, embed2])
#

@honest shoal

honest shoal
#

that's a nice hack I believe

round lily
#

@sick birch ok so its at least online now but i assume this is abnormal

mighty pilot
# slate swan ok

since your command overrides your on_message event you need to tell it to check for commands first. so in the on_message event you need to add await bot.process_commands(message) in the first line under async def on_message(message)

sick birch
#

yup

mighty pilot
slate swan
#

AYYYYYYYYYY

#

letsssss goooooooo it is fixed now

slate swan
mighty pilot
# slate swan yes pls
from email import message
from math import degrees
from multiprocessing.sharedctypes import Value
import site
from unicodedata import name
import discord
import http
from discord.ext import commands

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

@bot.command(name='version')
async def version(context):


    myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
    myembed.add_field(name="Site", value="", inline=False)
    myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
    myembed.set_footer(text="Made by Splunk#1157")
    myembed.set_author(name="Made by Splunk#1157")
    await context.send(embed = myembed)

@bot.event
async def on_ready():

  test_channel = bot.get_channel(1032312979594682491) 
  await test_channel.send('Hello')

@bot.event
async def on_disconnect():
 test_channel = bot.get_channel(1032312979594682491) 
 await test_channel.send('Hello')

@bot.event
async def on_message(message):
    await bot.process_commands(message)

    if message.content == "What day is it?":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("The day is the 21th")

    if message.content == "Thank you for telling me!":
        test_channel = bot.get_channel(1032312979594682491)
        await test_channel.send("No Problem AnyTime :)")

        myembed = discord.Embed(title="Made by Splunk#1157", description="Nice", color=0x00ff00)
        myembed.add_field(name="Site", value="", inline=False)
        myembed.add_field(name="Date released", value="october 21th, 2022", inline=True)
        myembed.set_footer(text="Made by Splunk#1157")
        myembed.set_author(name="Made by Splunk#1157")
        await message.channel.send(embed=myembed)





bot.run('')```
#

try that

slate swan
mighty pilot
round lily
#

commands still wont work

#

this is frustrating

mighty pilot
sick birch
slate swan
#

2022-10-21 18:36:31 ERROR discord.ext.commands.bot Ignoring exception in command version
Traceback (most recent call last):
File "C:\Users\getbe.R\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\getbe.
await context.send(embed = myembed)
File "C:\Users\getbe.e 841, in send
return await super().send(
File "C:\Users\OR\AppData\Roaming\Python\Python310\site-packages\discord\abc.py", line 1536, in send
data = await state.http.send_message(channel.id, params=params)
File "C:\Users\g\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 744, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required

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

Traceback (most recent call last):
File "C:\Users\R\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required

#

that was ur error

naive briar
slate swan
#

and it worked

#

BRUHHHHHHHHHHHHHHHHHHHHHH

mighty pilot
slate swan
#

now it doesnt send the respond to thank you for telling me or what day is it and when i turn the bot online it doesnt just automaticly say hello

#

like it should

mighty pilot
#

where did you put it

slate swan
#

under async def on_message(message):

mighty pilot
#

move it below your if statements

slate swan
#

again xd

mighty pilot
#

theres 2 if statements in your on_message, put it below them

#

if message.content==

slate swan
mighty pilot
#

Below both of those blocks, so it executes the if statements before looking for commands

mighty pilot
#

if i take a screenshot itd be of my code and it would be very out of context for you, im not on computer anymore

slate swan
#

i am dizzy what do i put under what

mighty pilot
slate swan
#

ok

#

should i remove this then await message.channel.send(embed=myembed)

mighty pilot
#

Below that

slate swan
#

ok

#

didnt work

#

i dont see hello from myu bot

slate swan
#

me?

round lily
#

my commands should be here correct

mighty pilot
slate swan
#

kk

round lily
#

is there anything wrong here im not getting errors but i cant interact w/ bot

round lily
#

nextcord

honest shoal
#

Can't help with that ghast

round lily
#

whats something you can do because clearly this isnt working for me

honest shoal
#

Is command not getting registered?

round lily
#

its not

#

all i get is the print message in my ide

#

not even in the server 10/10

honest shoal
#

I hope you have enabled application.commands scope while inviting the bot

round lily
#

i did im trying so hard

#

this so much more complicated than java

#

brain literally not big enough

honest shoal
#

It's not if you understand

#

I have no idea how u register in nextcord

honest shoal
round lily
mighty pilot
#

i have a button menu that pops up for members to select a role after sending so many messages, is there a way to check for interaction.user to be the same user that sent the message which triggered the view?

#

nvm i have something to try first

vocal plover
glad cradle
#

disnake >>

vocal plover
#

agree

#

but since I'm quite close with nextcord I have to like it kek

glad cradle
#

understandable

vocal plover
#

that said, disnake's soon-to-be new docs are ChefKiss

#

api reference has been broken into smaller parts that dont take 15 seconds to load in browser

mighty pilot
round lily
#

i figured out my issue and it pissed me off immensely

slate swan
#

so i will remove the things ok

#

tysm for the help i will try to start from the beginning

round lily
#

apparently i have to also enable bot permission in my server settings even if i already did it in dev portal

#

:annoyed

mighty pilot
#

yea thats an important step and why i asked if your bot had permissions in your server

round lily
#

it had me give permissions in the dev portal i though it carried over if it doesnt why even put that step there

mighty pilot
round lily
#

whatever it works so thanks for the help 10/10 people all of you

mighty pilot
trim ginkgo
#

banana

vocal plover
slate swan
#

yo anyone here i need help

#

bot = commands.Bot(command_prefix="!", case_insensitive=True, help_command=None)
^^^
SyntaxError: invalid syntax

#

what did i do wrong here?

#

@mighty pilot

#

do you know?

mighty pilot
#

Nope

#

anyone familiar with interaction_check inside views for buttons?

glad cradle
kind trellis
#

Anyone have any idea why my bot won't ping roles even though it has the perm to do so?

vocal snow
slate swan
#

how can i create a channel with a 'everyone read_messages' false ? and another role has a 'read_messages' true

mighty pilot
kind trellis
kind trellis
#

I should mention that it is a slash command

slate swan
#

can u show the code?

#

@kind trellis

kind trellis
#
    @app_commands.command(name="docket", description="Has the bot announce the next item on the city council docket.")
    @app_commands.guild_only()
    @app_commands.checks.has_any_role(646549322682466305, 646551227626160139, 673008336010084378)
    @app_commands.describe(first="True of False: This is the first item on the docket for the session.", docket_item = "The name of the item on the docket.", docket_link = "The Trello link to the item on the docket.")
    async def docket(self, interaction:discord.Interaction, first:Literal["True", "False"], docket_item:str, docket_link:str):
        if interaction.channel.name.startswith("council-session"):
            if first == "True":
                await interaction.response.send_message(f"The first item on the docket is *\"{docket_item.title()}\"*. \n\n{docket_link} \n\n Floor is open for debate. Say \"I\" to be recognized. (<@&646549329493884929>)")
            else:
                await interaction.response.send_message(f"The next item on the docket is *\"{docket_item.title()}\"*. \n\n{docket_link} \n\n Floor is open for debate. Say \"I\" to be recognized. (<@&646549329493884929>)")
        else:
            raise commands.UserInputError("The docket can only be announced in a session channel.")
            pass
        pass
#

@slate swan

vocal snow
#

there's no &

#

oh wait a role mention

#

does it not render the mention?

kind trellis
#

Nope, only displays the role

slate swan
#

only thing that would be causing it not to mention is permissions

kind trellis
#

Perms are fine

#

It has admin and mention all roles

#

I checked myself

austere vale
#

Sometimes when I start up my bot, I get this error, and Im not sure what is causing it. It doesn't happen every time I start my bot. I think it happens when my bot is in the middle of starting up and someone sends a message in the server? Im not sure.

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\kouxi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 502, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\kouxi\Runa\cogs\leveling.py", line 27, in on_message
    async with self.bot.db.cursor() as cursor:
AttributeError: 'Bot' object has no attribute 'db'

This is the error

  #add xp on message and checking for leveling up
  @commands.Cog.listener()
  async def on_message(self, message):
    if message.author.bot or message.guild is None:
      return
    author=message.author
    guild=message.guild
    async with self.bot.db.cursor() as cursor:
      await cursor.execute('SELECT levelsys FROM levelSettings WHERE guild = ?',(guild.id,))
      levelsys=await cursor.fetchone()
      if levelsys and not levelsys[0]:
        return
      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()
      if not xp or not level:
        await cursor.execute('INSERT INTO levels (level, xp, user, guild) VALUES (?,?,?,?)',(0,0, author.id, guild.id))
      try:
        xp=xp[0]
        level=level[0]
      except TypeError:
        xp=0
        level=0
      if level < 5:
        xp+=random.randint(1,3)
        await cursor.execute('UPDATE levels SET xp = ? WHERE user = ? AND guild = ?',(xp,author.id,guild.id))
      else:
        rand=random.randint(1,(level//4))
        if rand==1:
          xp+=random.randint(1,3)
          await cursor.execute('UPDATE levels SET xp = ? WHERE user = ? AND guild = ?',(xp,author.id,guild.id))
      if xp >= 100:
        level +=1
        await cursor.execute("UPDATE levels SET level = ? WHERE user = ? AND guild = ?",(level,author.id,guild.id))
        await cursor.execute("UPDATE levels SET xp = ? WHERE user = ? AND guild = ?",(0,author.id,guild.id))
        await message.channel.send(f'{author.name} has leveled up to level {level}!')
    await self.bot.db.commit()

This is the block of code, in my Cogs under leveling.py. I have bot.db=await aiosqlite.connect('level.db') in my main.py file under on_ready().
Thank you!

vocal snow
kind trellis
vocal snow
kind trellis
#

Yes

vocal snow
#

that toggle is on?

slate swan
slate swan
mighty pilot
#

can someone help me with a problem in my view for a button menu? i have interaction_check working properly, but i want to send a message when it returns False but cant figure it out. theres no errors happening so i cant use on_error

austere vale
#

also what is the difference between using on_ready and setup_hook?

sick birch
grand willow
#

Can someone exlain how I can use the class discord.AllowedMentions on a message for it not to ping @ everyone if it has the perms to do it. I have no clue how I would should use it

austere vale
#

can someone show me how to pull up SQLite so i can view my database tables? ive seen videos where its supposed to be on this tab but i dont know how to get it there

primal token
austere vale
primal token
#

Not sure, maybe look for an extension

dull terrace
#

QQ: can you edit an ephemeral message, does it have to be a response?

minor totem
#

Do you have admin in the server? Are you sure you can see the channel?

slate swan
#

guys

#

my slash commands are not showing up and i have no errors in my code

slate swan
#

missing a @ before the commands.slash_command

royal wind
#

I have a question. Watching tutorial on YT, it's so often to see people use ctx. They call it context. But what does that actually mean? Does that mean the same thing as self?

hushed galleon
#

ctx refers to the commands.Context object that is typically passed around in commands, checks, converters, etc.

royal wind
#

Yeah, I've read the docs. It pretty much says that, but conceptually, I don't really get it

#

That definition feels too high class for me to understand. Do you think you can give me something like an analogy?

hushed galleon
#

its separate from self because self is often the instance of the class that methods are defined within, although the purpose is similar

#

the actual word context means information that is needed to fully understand something

#

so in this case, that Context object provides you various attributes like the message that triggered the command (.message), the Command object that was invoked (.command), the specific name used to invoke that command (.invoked_with), etc.

royal wind
#

ctx.message returns the message object?

hushed galleon
#

yes

#

its information related to who used the command and how they used it

royal wind
#

So I can do ctx.message.author

#

or something else

hushed galleon
#

yes, if you wanted to

royal wind
#

Now, I see ctx.send() and the function is self explanatory. But I just don't understand why do we need to have this when we have await send blablabl

#

Because I know sometimes we use the latter

hushed galleon
#

several of the context's properties/methods are just shortcuts for common things developers use

#

why write ctx.send() when you can write message.channel.send()? because its more convenient

royal wind
#

If they're just shortcuts, there should be absolutely zero frowns if one wants to use the longer one for, say, consistency?

hushed galleon
#

the two methods work equivalently but you might get frowned upon for not taking advantage of the "simpler" method

royal wind
#

I see

#

So in conclusion, just to make sure I understand this properly:

#

ctx basically says SOMETHING that triggers this command (only a method decorated by @client.command() will have ctx). ctx.author means return the author (<name>#<identifier>) of the user that just invoked this command. ctx.message means return the message object that was sent by a user that caused this command to be invoked.

That being said, not all methods available are for checking what triggered this command. For example, ctx.send() is a method that serves as a shortcut to do quick reply back.

hushed galleon
#

you could think of the context as being provided in the event that someone uses a command

#

an on_message event is triggered when someone sends a message and you're given a Message object with information about that message

#

and in the event someone invokes a command, you're given a Context object with information about the invocation of that command

pallid vigil
#

Hello everything is fine? can anyone help me on how to handle an api via python to send the response via webhook?

wary crystal
zealous jay
#

Using non async code could make my bot get ratelimited?

#

Message: 'Shard ID %s heartbeat blocked for more than %s seconds

#

Found this on the traceback

hushed galleon
#

that doesnt mean being ratelimited, but that your bot was prevented from sending a heartbeat to discord to keep its websocket connection alive

#

but non async (or more accurately, blocking) code would cause that to occur

hushed galleon
zealous jay
#
[2022-10-21 08:13:37] [INFO    ] discord.gateway: Shard ID None has connected to Gateway (Session ID: 82f5d315e4cdf95e9424f225e719837c).
[2022-10-21 08:13:37] [WARNING ] discord.gateway: WebSocket in shard ID None is ratelimited, waiting 59.31 seconds
[2022-10-21 08:14:37] [WARNING ] discord.gateway: WebSocket in shard ID None is ratelimited, waiting 0.01 seconds
#

Also this

[2022-10-21 08:30:30] [WARNING ] discord.state: Shard ID 0 timed out waiting for chunks for guild_id guild_id_here.
#
[2022-10-21 10:22:26] [INFO    ] discord.gateway: Shard ID None has successfully RESUMED session session_id_here.
untold iron
#

anytime i run my python code, i get a error saying

#

Any idea what causes this? Is it the roles i have assigned not allowing the script to perform its task

zealous jay
#

In your bot's class

#

Instead of using discord.Client use commands.Bot

wispy spade
mossy jacinth
#

Hello! I want to actively check if a variable is 1 or not and then send a message in the chat but it doesnt work quite right
(I'm using replit temporarily dont worry :)! )

zealous jay
#

😄

zealous jay
#

Is the channel ID correct?

mossy jacinth
#

yes

wispy spade
zealous jay
#

yup

wispy spade
zealous jay
#

I don't know if thats related 🤔

mossy jacinth
#

made it fetch_channel now this came

zealous jay
#

Still returning None

#

try printing the channel

mossy jacinth
#

printed channel

torn sail
zealous jay
#

didn't see that 🤦‍♂️

torn sail
#

you can remove the fetch_channel entirely if you wait_until_ready in the tasks before loop

@tasks.loop()
async def task():
    ...

@task.before_loop
async def wait_until_ready():
    await bot.wait_until_ready()
mossy jacinth
#

yup thanks guys

untold iron
#

Do i switch client to client = bot.commands?

sick birch
untold iron
#

Perfect ty, how can i declare a prefix though now?

full lily
#

and where it wants it placed

untold iron
#

Thank you, i got it working now

maiden hatch
#

Is there some kind of a example with: slash commands, tasks, commands in a pretty class?
I have tons of examples but combined it's a bit of a pain.

lost yoke
#
AttributeError: 'Bot' object has no attribute 'commmand'. Did you mean: 'command'?``` whats arrong?
sick birch
maiden hatch
#

triple m in command?

maiden hatch
#

Yes

sick birch
maiden hatch
#

Just need a starting point. Thx

untold iron
#

What does an unknown interaction error indicate?

wicked atlas
#

You're probably trying to respond to the interaction too late. Make sure you're deferring before doing anything else.

#

whatcha doin with paypal though?

untold iron
#

Im trying to get it to read a users paypal history to give them a role based on their recent transaction

#

From a github repo

swift heron
#

how cogs in 2.0?

#

like how to add and load them

pearl fjord
#

i tried this

attachments = message.attachements
temp = []
for attachment in attachments:
    temp.append(attachment.url)
print(''.join(temp))

can someone tell me where i went wrong?

#

@full lily hey, would you know anything about this?

round lily
#

ok so i dont understand fundamentals of bots is there anything good to teach me what goes into making a bot

zealous jay
#

has some events

#

although I didn't use async for the db

#

idk if its related

#

im working on it tho

slate swan
zealous jay
#

mongodb

slate swan
#

oh. yea i would say thats whats blocking the heartbeats. I had a similiar issue

zealous jay
#

is there any good tutorial for using async with mongodb?

zealous jay
#

thanks

slate swan
#

yup

upbeat gust
#

Make sure you're familiar with python before attempting to use discord.py

hushed galleon
#

perhaps they mean the actual API provided by discord, though you dont need to know too much about it before using an API wrapper

rugged shadow
#

you only have to know guilds are servers /j

toxic turtle
#

Hi hello all, I have a question maybe it's easy but I haven't been able to figure it out.

#

I want bot to look for occurrences of a substring in a string then responses, so I used "substring" in "string", it worked, but I want look for more substring, so I made a list or [ ] and ( ) containing the substrings to look for , but when I look for more than 1 substring it doesn't work, when I running not come out any error idk why ?
Is it that does not work look for more than 1 or needs to use other codes?

#

This is what I tried

sick birch
upbeat gust
#

You need to loop through your list of words and check if each is in the message

sick birch
#

For instance:

words = ["apple", "banana", "orange"]

The if statement would only work if the user's message contains one of those words?

upbeat gust
#

You can do this with a for loop,

Or a more advanced (but shorter and cleaner) list comprehension, and the any() function

toxic turtle
upbeat gust
upbeat gust
toxic turtle
sick birch
sick birch
upbeat gust
sick birch
#

No spoonfeeding. Giving them a general skeletal structure, like I always do 🙂

#

They'll still have to take the concept and figure out how to incorporate it into their own code

upbeat gust
sick birch
#

Yes, that's what I'm using

#

The list is empty if a word in words was not found

#

The list can contain the words that appeared in the message.content, if they want to store that and use it for anything else

#

But if they're just checking if it's empty/not, a list comp without being assigned a variable will do

upbeat gust
#

actually alright that works

sick birch
#
@bot.listen()
async def on_message(message: discord.Message) -> None:
  words = ["apple", "banana", "orange"]
  present_words = [word for word in words if word in message.content]
  if present_words
    print("These words were present in your message:", ", ".join(present_words)) # or ctx.send, you get the idea
#

confused with print statement :p

#

either way i don't think this is their usecase

#

it's there if you need it

upbeat gust
sick birch
upbeat gust
sick birch
#

More than likely they don't have typehints or a listener rather than an event

#

So they'd need to adapt it to their own

toxic turtle
#

If I'm just looking for string

sick birch
toxic turtle
#

a list like this will work

#

Just put if p_message in list >> if list in p_message . it will be useless

sick birch
upbeat gust
#

They can just copy the list comp and if statement

hushed galleon
# upbeat gust How so?

spoonfeeding would imply that you could just copy paste it into your code and it would work, but even the substrings are just examples that the OP wouldnt want;
if the OP were to correct the code to serve their desired purpose, that would demonstrate at least a basic understanding of how the code works

sick birch
#

Copy pasting this really wouldn't do what they want. The if statement body is commented out, so syntax error as well

hushed galleon
upbeat gust
sick birch
#

True, we would have to create our own generator or is there something built in I'm not aware of?

hushed galleon
#

nah just a generator expression is good enough

sick birch
#

I must admit I haven't gotten around to those yet :p

hushed galleon
#

any(w in s for w in seq)

sick birch
#

didn't know that was a generator 🤔

#

I was under the impression it created a list and spread it using * internally

hushed galleon
#

the explicit syntax would look like any((w in s for w in seq)), with the extra parentheses turning into a genexpr object

sick birch
#

interesting

#

not a tuple then?

toxic turtle
#

thanks a lot suggestions I will try again m(_ _)m

hushed galleon
#

nah, for that you have to pass to the tuple constructor

upbeat gust
primal token
#

The whole term spoonfeeding is subjective in a sense of level of what you consider it being "spoonfeeding", i would say starting a discussion about it would be a waste of time, but be my guest

hushed galleon
# upbeat gust So doing 95% of it for them isn't spoonfeeding?

i dont think its 95% of the work because while it shows a technique for finding one of multiple substrings, robin fabricated a basis to demonstrate the technique (listener, message variable, 3 fruits, missing block after if), which is nowhere close to the original snippet

sick birch
#

Yup. The point is to take away the important concepts, I don't even intend for them to copy and paste it. I would prefer they don't, and use it as a structure. I can't force what they do, and I don't want to make things confusing to force them either. If they want to copy and paste and fill in the placeholders - that's fine. That's their call to make. If they want to take away the concepts - that's fine too.

upbeat gust
#

and why not just give pseudocode/similar explaining how to do this?

#

I doubt they understand what that list comp or later suggested generator is even doing

sick birch
#

That's on them to to research or ask questions if they don't understand

#

It's their job to take responsibility for their own learning. We just provide the necessary resources and help

#

I've done what I judged is to be the best course to provide assistance, now it's up to them to take that where they will

upbeat gust
#

why not explain it and teach them instead of giving answers and leaving it up to them to figure it out

sick birch
#

I don't believe in that level of hand holding. If they're confused, I would be more than happy to explain and help out. This isn't middle school. The resources are all here - it's up to them to utilize it however they wish

toxic turtle
#

sorry Im silly, asked a stupid question like I just said it could be as easy as
I also tried googel to find what I wanted to know before asking a question here or try to read some official api and something..., but Ive been stuck here for 1~2days, maybe I should learn it all over again

upbeat gust
#

what

prisma prism
#

Can someone help with discord.py?
I just want to know what's causing this error TypeError: 'Guild' object is not iterable
py role = discord.utils.get(ctx.guild, name='Muted') await user.remove_roles(user, role)

upbeat gust
#

ctx.guild is a Guild object

#

guild.roles is a list of Role objects

upbeat gust
prisma prism
#

Thank you!!

sterile sigil
#

I'm not sure why I did the instruction correctly but my bot don't online on my private server:

import discord
from discord.ext.commands.core import commands
from discord import permissions



bot = commands.Bot(commands_prefix='.')

#run bot
bot.run("")```
torn sail
#

It’s probably because from discord.ext.commands.core import commands try changing it to from discord.ext import commands

sterile sigil
#

okay mate

torn sail
sick birch
sterile sigil
#

oh okay

#

thanks a lot guys!!!

torn sail
#

👍

sterile sigil
#

or i can stay commands

sterile sigil
#

i see

sick birch
sterile sigil
torn sail
#

from discord.ext import commands for the import and remember it’s command_prefix=

sterile sigil
#

oh sorry my bad read

slate swan
#
async def talker():
    get_channel_id = hariku_client.get_channel(ctx.channel_id)```

```py
ctx isnt defined```
slate swan
sterile sigil
#

i rerun and it showed this

slate swan
shrewd apex
#

dont put help_command=None before atleast making ur custom impl

#

also to be explicit its better to use discord.Intents.all() but totally up to u

slate swan
#

yeah, i do that alot tho

sterile sigil
sterile sigil
slate swan
#
async def talker():
    get_channel_id = hariku_client.get_channel(ctx.channel_id)```

```py
ctx isnt defined```

how do i fix this?
shrewd apex
#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!", intents=discord.Intents.all()) # u have to enable all intents in dev portal as well


@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}")


bot.run('YOUR_TOKEN')
sterile sigil
#

ohhhh

shrewd apex
sterile sigil
#

so that's how it work

shrewd apex
#

pass it as a parameter

sterile sigil
sterile sigil
# shrewd apex ```py import discord from discord.ext import commands bot = commands.Bot(comman...

it sent me this
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

shrewd apex
#

it just literally said what u have to do

swift heron
#

can someone help me add and load cogs in 2.0, and respond to this message with pings so i can see it

sterile sigil
slate swan
# shrewd apex pass it as a parameter

alright, i did that, theres one small error again lol!

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'

Code:

await get_channel_id.send(message)```
shrewd apex
#

get_channel_id is None

slate swan
#

ah i forgot, also, im trying to fetch the guild channel id its currently talking in, and it keeps saying its invalid.

#

ctx.channel_id

#

correct?

#

@shrewd apex

vocal snow
#

you can see the possible attributes of ctx in the docs

#

!d discord.ext.commands.Context

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
pastel mist
#

How do I make my bot say something in a voice channel (For example, a simple message like "Hello") in a TTS voice without downloading any audio files?

upbeat gust
#

.send has a kwarg to enable it

upbeat gust
upbeat gust
glad glen
#

Maybe this is a little too open ended: I am completely new to python (and code in general) but I am trying to make a bot that will manage a spreadsheet. I havent had much luck so far as I cant even get the bot to respond to a message. Any advice would be appreciated :)

upbeat gust
#

discord.py is not for beginners, and id assume so with any spreadsheet lib

glad glen
#

I see

#

Any recs for learning then outside of data camp?

upbeat gust
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

upbeat gust
glad glen
#

Thank you

upbeat gust
glad glen
#

Keeping track of a count for a small group of people across timezones is boring and Id rather have people be able to tell a bot to update the spreadsheet for me

upbeat gust
#

If you want to store data, you'd use a database

vale wing
#

I think there are some

upbeat gust
#

aiogtts looks good

glad glen
upbeat gust
glad glen
#

thanks for the advice, I will go read things now

upbeat gust
#

If it's because you don't want to keep actual files in your machine, you can use an io buffer

#

(BytesIO)

vale wing
#

You can just stream them into discord from URL

upbeat gust
pastel mist
# upbeat gust (BytesIO)

yeah but then how to convert it to an AudioSource ? Cuz VoiceClient object's play method only accepts an AudioSource object. I tried directly passing in a BytesIO object but it doesn't work

pastel mist
white citrus
#
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 390, in _scheduled_task
    await item.callback(interaction)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\information\cog.py", line 191, in button_callback
    await interaction.edit_original_message(embeds=[userinfo, embed_roles], view=self)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 451, in edit_original_message
    params = handle_message_parameters(
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 537, in handle_message_parameters
    payload["components"] = view.to_components()
AttributeError: 'Informations' object has no attribute 'to_components'
vale wing
#

Ok and what is Informations

white citrus
vale wing
#

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

vale wing
white citrus
vale wing
#

Yeah examples to look at

white citrus
#

You can also use the way I use

vale wing
#

You should subclass instead of setting callbacks

vale wing
white citrus
#

But in this case it is easier

vale wing
#

And anyways that's not the definition of Informations I asked for

white citrus
#

Informationens is the class not more

vale wing
#

That's what I need

#

Show it please

white citrus
#

it is obvious that the button is failing

vale wing
#

What

white citrus
white citrus
vale wing
#

@white citrus

await interaction.edit_original_message(view=self)```
Causes the problems, in your case the `self` is the cog, this is why you should subclass views
silent portal
#

Is there a way I can sync only role perms of a channel to it's category without overwriting user specific perms?

vale wing
# white citrus Okay and?

You are parsing object of wrong type to the kwarg, isn't it obvious? Wdym "okay and?", do you expect me to send the complete code or smth

slate swan
#

i want it to auto do it

white citrus
slate swan
#

guys , can someone give me a overwrite code for :
everyone : read_messages = false
a role : read_messages = true

upbeat gust
#

Do it yourself

vale wing
#

If you don't want to create a separate class for everything you could do sort of generic class, I can send you the example as well

slate swan
#

how to remove timeout?

vale wing
unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") to do this.

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
rugged shadow
#

sup brother

cloud dawn
#

You aren't commiting it.

#

yep

#

I said yep to cursor btw you don't commit to conn.

#

Any errors?

timber wharf
#

Hi can i get user info source?

feral frost
#

how can i check a json file for members ?

#

or how can i print all of those members in a message

#

?

cloud dawn
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
timber wharf
feral frost
#

i just want to add something like a word to a json file and than with another command i want to send that in a message

#

but that with multiple things

swift heron
feral frost
#

here is the json file code

{
    "userid": {
        "Kicked": true,
        "Name": "Someoneelse"
    },
    "userid2": {
        "Kicked": true,
        "Name": "Someone"
    }
}
``` so the userid is the user its id and than some info about it now my question is how can i send that info in a message ?
swift heron
#

you used to be able to load them without having async and nkw you do. and i don't know how i should approach that

feral frost
#

of all of the user ids

#

if you do not understand what i mean pls tell me i just want to know HOW i do it

slate swan
#

if "ticket-"+ member.name +"." in ctx.channel.name: why this dont work

obtuse blaze
#

is it possible to delete last message on specific channel?

slate swan
#

no error

#

but dont work

vocal magnet
#

where you create your invites table, you have set the id column to be an integer, but invite.id is not an integer

unkempt canyonBOT
vocal magnet
#

Then check their docs for what type it is

#

go to the place in your code you are creating the invite table

#

and change the column type

#

you maybe need to write a migration to change any existing databases, if you don't want to delete the database and start over

dry fox
#

How long does it take to these goddamn slash commands to appear?

vocal magnet
#

I don't know what program that is, but you should be able to google "<program name> change mysql column to string" to get the answer

#

depends, did you create the database in your code?

vocal magnet
vocal magnet
#

which part of that is setting the id column to bigint?

#

cool, and how would you change that to make it text?

#

yup

#

but that will only work the next time the database is created

#

CREATE TABLE IF NOT EXISTS means it will only run if a database doesn't already exist

#

Sure

brazen raft
dry fox
brazen raft
#

Can you tell me what library are you using

dry fox
brazen raft
#

Uh, hold on

vocal magnet
#

!d discord.app_commands.CommandTree.sync

unkempt canyonBOT
#

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

Syncs the application commands to Discord.

This also runs the translator to get the translated strings necessary for feeding back into Discord.

This must be called for the application commands to show up.
brazen raft
# unkempt canyon

@dry fox you got to pass a discord.Object object with the id of the guild (if you have a discord.Guild object, that works too) and await it

hushed galleon
brazen raft
dry fox
#

I have both slash command and echo And The slash commands doesn't show up but the echo works so the bot works

hushed galleon
brazen raft
#

Is it just an automated thing done by the library

hushed galleon
#

the synchronization?

vocal magnet
#

Add some debug logging to your command that adds the invite to see what's going on

brazen raft
#

Yes

hushed galleon
feral frost
#

pls help

dry fox
#

NameError: name 'bot' is not defined

slate swan
#

if "ticket-"+ member.name +"." in ctx.channel.name: why this dont work

#

hello who can help me for my bot please

feral frost
#

can someone help me pls

#

?

feral frost
#

Question:
How can i send a message that contains all the data from a json file in little pieces?

Example:

{
    "16131694321986341": {
        "Kicked": true,
        "Name": "Albert"
    },
    "6546541454857564": {
        "Kicked": true,
        "Name": "Bert"
    }
}``` How can i make it so that i get the information from "Albert" and "Bert" in 1 message ?

**My code that doesnt work:**
```python
def add_kick(member: discord.Member, id: int):
    if os.path.isfile(f"servers/kick{id}.json"):
        with open(f"servers/kick{id}.json", "r") as fp:
            data = json.load(fp)
        try:
            data[f"{member.id}"]["Name"] = member.name
            data[f"{member.id}"]["Kicked"] = True
        except KeyError:
            data[f"{member.id}"] = {"Name": member.name}
            data[f"{member.id}"] = {"Kicked": True}
    else:
        data = {f"{member.id}": {"Name": member.name}}
        data = {f"{member.id}": {"Kicked": True}}

    with open(f"servers/kick{id}.json", 'w+') as fp:
        json.dump(data, fp, sort_keys=True, indent=4)

@bot.command()
async def kick(ctx, member: discord.Member):
    add_kick(member, ctx.guild.id)
    add_kick(member, ctx.guild.id)
    await ctx.send(f"ok")

@bot.command()
async def getkick(ctx):
    with open(f"servers/kick{ctx.guild.id}.json", "r") as fp:
        data = json.load(fp)
        
    name = data[f"{ctx.author.id}"]["Name"]

    kicked = data[f"{ctx.author.id}"]["Kicked"]
    
    await ctx.send(f"{name} {kicked}")``` Please help me
silent portal
#

hi, is there a way to @mention someone without him getting a notification? (In normal messages, not embeds)

feral frost
#

i think for the bot you can just do somthing like this (f"@{user.name}")

#

i dont think that will mention the user

vale wing
#

!d discord.abc.Messageable.send

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

Sends a message to the destination with the content given.

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

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

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

!d discord.AllowedMentions

unkempt canyonBOT
#

class discord.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)```
A class that represents what mentions are allowed in a message.

This class can be set during [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") initialisation to apply to every message sent. It can also be applied on a per message basis via [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for more fine-grained control.
vale wing
#

Or you could screen the mention

#

Like @unkempt canyon

#

🦶

slate swan
cloud dawn
vale wing
# slate swan

Make sure you used the same env for installing and running, you can check it at the bottom right corner

vale wing
#

That's gonna look funny tho

feral frost
#

pls can someone pls pls pls just help me

cloud dawn
cloud dawn
#

I recommend getting started with databases, your code looks fine so I don't think it should be an issue for you.

feral frost
#

what can i use as databases ?

cloud dawn
#

I personally recommend postgresql paired with asyncpg or a file based sql called sqlite paired with aiosqlite.

#

If you are more fan of the 'json' syntax I recommend mongoDB paired with motor.

feral frost
#

i do not understand what you are saying but uhm where can i begin ?

cloud dawn
#

I'm saying that you shouldn't use JSON to store data.

feral frost
#

ah ok

feral frost
cloud dawn
#

I got docs :3

feral frost
#

nah i suck at reading them i cant figure out what they mean in that

cloud dawn
feral frost
#

ok

vale wing
#

Why yall watching vids 😩

#

That's way too slow information gathering method

silent portal
#

everybody has a different preference on learning stuff

slate swan
#

what is intensts

cloud dawn
#

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

feral frost
zealous jay
#

Started using async with mongodb and suddenly the 300k lines tracebacks disappeared

feral frost
#

lol

zealous jay
#

Can blocking code end up causing ratelimits?

#

Maybe the bot tries to reconnect too many times?

feral frost
#

maybe

sick birch
#

It'll block things like heartbeats and get you disconnected

zealous jay
#

yeah that used to happen

#

but reconnecting too many times can cause ratelimits?

sick birch
#

possibly

zealous jay
#

Im trying to understand what was happening

#

anyways now it seems to work fine

vale wing
feral frost
#

ok

#

HELP

slate swan
feral frost
# slate swan ?

Code:

@commands.group(invoke_without_command=True)
async def welcome(self, ctx):
    await ctx.send("Allowed: \nchannel <#channel> \ntext <message>")

@welcome.command()
async def channel(self, ctx, channel: discord.TextChannel):
    if ctx.message.author.guild_permissions.manage_messages:
        db = sqlite3.connect("main.sqlite")
        cursor = db.cursor()
        cursor.execute(f"SELECT channel_id FROM main WHERE guild_id = {ctx.guild.id}")
        result = cursor.fetchone()
        if result is None:
            sql = ("INSERT INTO main(guild_id, channel_id) VALUES(?)")
            val = (ctx.guild.id, channel.id)
            await ctx.send(f"Channel is set to {channel.mention}")
        elif result is not None:
            sql = ("UPDATE main SET channel_id = ? WHERE guild_id = ?")
            val = (channel.id, ctx.guild.id)
            await ctx.send(f"Channel is updated to {channel.mention}")
        cursor.execute(sql, val)
        db.commit()
        cursor.close()
        db.close()

Error:

discord.ext.commands.errors.CommandNotFound: Command "welcome" is not found
feral frost
slate swan
#

how are you invoking the command

feral frost
slate swan
#

how are you using the command

feral frost
slate swan
#

never mind then

feral frost
#

what do i dooo

slate swan
#

that should be invoked like ?welcome channel channel

feral frost
#

uhm

#

wait i have image of what it would look like

#

some other words but you see it

slate swan
#

try doing ?welcome channel #somechannel

feral frost
#

why ?

#

why the " ?"

slate swan
#

that's how your code is supposed to work

feral frost
#

oh ok

slate swan
feral frost
slate swan
#

send the terminal

feral frost
slate swan
#

did you call your bot commands ?

feral frost
#

no

slate swan
#

What did you call the class

feral frost
feral frost
#

ah ok

#

ill give it a try hang on

slate swan
#

this might be too advanced for you.

#

do you understand oop?

feral frost
#

oop?

#

ok so i inputted this

slate swan
#

object oriented programming

slate swan
feral frost
#

and got this

feral frost
slate swan
# feral frost no ?

It's recommended you understand it before trying to make discord bots, they aren't beginner level projects

feral frost
#

?

slate swan
#
async def channel(self, ctx, *, channel: discord.TextChannel):
#

try that in the channel command

feral frost
#

ok

feral frost
slate swan
#

send the code u used now

feral frost
#

is this right ?

slate swan
#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
feral frost
slate swan
feral frost
slate swan
#

nothing

feral frost
#

ok so uhm ?

slate swan
#

uhhh

feral frost
#

but

#

is it normal that @bot.group that the bot is in blue and group in yellow ?

slate swan
#

Ive never used subcommands

feral frost
#

same

slate swan
#

send ur code again

feral frost
#

maybe we can make it 1 command

slate swan
#

no

feral frost
#

no

#

ok no it is

feral frost
slate swan
#

what happens when you do ?welcome

feral frost
honest shoal
slate swan
#

it it?

feral frost
#

it worked BUT BUT BIG BUT

slate swan
#

calm down

feral frost
honest shoal
#

it should not have the @bot decorators, if in cog

slate swan
honest shoal
feral frost
#

ok

slate swan
#

and that's probably sql error idk how to fix

feral frost
slate swan
#

Idk how to fix

honest shoal
feral frost
slate swan
feral frost
#

ok

#

ill move on to the database channel

#

thanku for helping

honest shoal
feral frost
#

ok

honest shoal
#

how are u defining announcementchannel

#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
honest shoal
#

define it like this

#

send entire autopublish cmd code

#

paste here if it's too big