#discord-bots

1 messages · Page 589 of 1

silent ermine
#

oh

#

ok

slate swan
#

It says right above in the page in the link

The discord.py library has now been discontinued by its maintainer.

slate swan
boreal ravine
#

you can easily fix that by yourself or by reading the "breaking_changes.md" gist

loud junco
#

i dun und why this is not working```py
from discord.ext import commands
import os
import discord
from keep_alive import keep_alive

client = discord.Client()
bot = commands.Bot(command_prefix='rpm' or 'Rpm' or 'RPM')

@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
await ctx.send("Hello, world!")

@bot.command(name="ping")
async def ping(ctx: commands.Context):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")

keep_alive()
client.run(os.getenv('TOKEN'))

#

this is all of them

ornate lichen
#

i dpnt think it works in `client=discord.clien()

boreal ravine
loud junco
#

two bot variable?

#
from discord.ext import commands
import os
import discord
from keep_alive import keep_alive

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

@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
    await ctx.send("Hello, world!")

@bot.command(name="ping")
async def ping(ctx: commands.Context):
    await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")


keep_alive()
bot.run(os.getenv('TOKEN'))
```like this?
loud junco
#

its still not working anyway
the bot doesnt reply to rpm ping

ornate lichen
#
@client.command(name='help')
async def help(ctx):
    page1 = discord.Embed (
        title = 'Page 1/3',
        description = 'Description',
        colour = discord.Colour.orange()
    )
    page2 = discord.Embed (
        title = 'Page 2/3',
        description = 'Description',
        colour = discord.Colour.orange()
    )
    page3 = discord.Embed (
        title = 'Page 3/3',
        description = 'Description',
        colour = discord.Colour.orange()
    )

    pages = [page1, page2, page3]

    message = await client.say(embed = page1)

    await client.add_reaction(message, '⏮')
    await client.add_reaction(message, '◀')
    await client.add_reaction(message, '▶')
    await client.add_reaction(message, '⏭')

    i = 0
    emoji = ''

    while True:
        if emoji == '⏮':
            i = 0
            await client.edit_message(message, embed = pages[i])
        elif emoji == '◀':
            if i > 0:
                i -= 1
                await client.edit_message(message, embed = pages[i])
        elif emoji == '▶':
            if i < 2:
                i += 1
                await client.edit_message(message, embed = pages[i])
        elif emoji == '⏭':
            i = 2
            await client.edit_message(message, embed=pages[i])
        
        res = await client.wait_for_reaction(message = message, timeout = 30.0)
        if res == None:
            break
        if str(res[1]) != '<Bots name goes here>':  #Example: 'MyBot#1111'
            emoji = str(res[0].emoji)
            await client.remove_reaction(message, res[0].emoji, res[1])

    await client.clear_reactions(message)```
#
Ignoring exception in command help:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/Users/aarav/Documents/GitHub/awaffle_bot/main.py", line 129, in help
    message = await client.say(embed = page1)
AttributeError: 'Bot' object has no attribute 'say'

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

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'say'```
ornate lichen
ornate lichen
#

then wht do i replace it with

slate swan
loud junco
#

i typed rpm ping and no reply

boreal ravine
ornate lichen
slate swan
loud junco
#

then whats wrong with my code

boreal ravine
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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/master/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.9)") of [`File`](https://discordpy.readthedocs.io/en/master/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/master/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.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
loud junco
#

=.=

boreal ravine
loud junco
#

no spacing?

boreal ravine
#

No check your prefix

loud junco
#

can i do 'rpm '?

#

lemme try

boreal ravine
loud junco
#

its working now

boreal ravine
#

cool

loud junco
#

thanks

boreal ravine
#

no problem

ornate lichen
boreal ravine
unkempt canyonBOT
#

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

Add a reaction to the message.

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

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
ornate lichen
#

by code thingy i mean :eyes :

boreal ravine
#

I mean read your own code emoji is always gonna be None

slate swan
ornate lichen
#
@client.command(name='help')
async def help(ctx):
    page1 = discord.Embed (
        title = 'Page 1/3',
        description = 'Description',
        colour = discord.Colour.orange()
    )
    page2 = discord.Embed (
        title = 'Page 2/3',
        description = 'Description',
        colour = discord.Colour.orange()
    )
    page3 = discord.Embed (
        title = 'Page 3/3',
        description = 'Description',
        colour = discord.Colour.orange()
    )
    
    pages = [page1, page2, page3]

    message = await ctx.send(embed = page1)
    await message.add_reaction('⏮')
    await message.add_reaction('◀')
    await message.add_reaction('▶')
    await message.add_reaction('⏭')

    def check(reaction, user):
        return user == ctx.author

    i = 0
    reaction = None

    while True:
        if str(reaction) == '⏮':
            i = 0
            await message.edit(embed = pages[i])
        elif str(reaction) == '◀':
            if i > 0:
                i -= 1
                await message.edit(embed = pages[i])
        elif str(reaction) == '▶':
            if i < 2:
                i += 1
                await message.edit(embed = pages[i])
        elif str(reaction) == '⏭':
            i = 2
            await message.edit(embed = pages[i])
        
        try:
            reaction, user = await client.wait_for('reaction_add', timeout = 30.0, check = check)
            await message.remove_reaction(reaction, user)
        except:
            break

    await message.clear_reactions()
#

done

#

its working

#

got it from stack exchange

slate swan
#

Not the best way to learn but good for youshipit

boreal ravine
high pollen
#

In normal code(no cogs) can pop the bots reaction:-

            reacted_users.pop(reacted_users.index(bot.user))```

But in cog there is a error:-
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.ext.commands.bot' has no attribute 'user'```
#

Is there a way to pop my bots reaction from the list of reaction in a cog

hollow agate
#

Is there a way to get deleted images using on_message_delete and send them to a channel, if so how?

hollow agate
high pollen
#

use can send it to a channel too

high pollen
#

use .get()

hollow agate
#
@client.event
async def on_message_delete(message):
    if message.guild:
        b = DT.datetime.now().timestamp()
        b = int(b)
        with open("data.json") as f:
            data = json.load(f)
        if message.author.id == 503641822141349888:
            return
        if message.author.bot:
            return
        if len(message.content) < 1600:
            time = datetime.now(tz=pytz.timezone('America/Tijuana'))
            formatted = time.strftime("%I:%M %p")
            msgtime = (time - message.created_at).total_seconds()
            logchannel = client.get_channel(872911089258598421)
            am = discord.AllowedMentions(
                users=False,
                roles=False,
                everyone=False,
                replied_user=False,
            )
            await logchannel.send(f'<t:{b}:t> Message by `{message.author}` `({message.author.id})` in {message.channel.mention} has been removed. ({round(msgtime, 2)} seconds after being sent) \n**Content**: {message.content}', allowed_mentions=am)
        if len(message.content) > 1600:
            time = datetime.now(tz=pytz.timezone('America/Tijuana'))
            formatted = time.strftime("%I:%M %p")
            msgtime = (time - message.created_at).total_seconds()
            logchannel = client.get_channel(872911089258598421)
            em = discord.Embed(
                description=f'<t:{b}:t> Message by `{message.author}` `({message.author.id})` in {message.channel.mention} has been removed. ({round(msgtime, 2)} seconds after being sent) \n**Content**: {message.content}',
                color=0x00a8ff)
            await logchannel.send(embed=em)
    else:
        return``` This is my current, and it doesn't seem to send any images-
high pollen
#

u cant send images like that

high pollen
boreal ravine
unkempt canyonBOT
slate swan
#

Bot, not bot when you define it

high pollen
slate swan
#

And since it's in a cog, self.bot

high pollen
#

ohk

high pollen
thick rampart
#

ok so question.....does anybody know a decent line for if someone joins any channel non voice channels for the bot to welcome them?
Like if a user pops into my server I want them to see a greeting page but say they run into a channel like rules or something...is it possible for the bot to greet them on popping into the channel?

dapper cobalt
thick rampart
#

oh yeah I guess that would be simpler xD

#

Sorry my brain sometimes overcomplicates things

dapper cobalt
#

!d discord.on_member_join you can use that event and get the channel you want the message to be sent to using bot.get_channel(id) and send the message there.

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
thick rampart
#

ah thank you!

lament mesa
#

Also enable the member intents

thick rampart
#

oh but one more question
I was doing this

@tasks.loop(seconds=10) # '300' is the time interval in seconds.
async def send_message():
    """Sends the message every 300 seconds (5 minutes) in a channel."""
    channel = client.get_channel(902885682488422471)
    await channel.send('This is a test')

But I get this as an error
Unhandled exception in internal background task 'send_message'.
Traceback (most recent call last):
File "C:\Users\abrod\PycharmProjects\Discord_Bot_Phantom\venv\lib\site-packages\discord\ext\tasks_init_.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "C:\Users\abrod\PycharmProjects\Discord_Bot_Phantom\discord_bot_phantom.py", line 10, in send_message
await channel.send('This is a test')
AttributeError: 'NoneType' object has no attribute 'send'

thick rampart
#

you mean the thing on the dev portal?

boreal ravine
#

channel wasnt cached I guess

dapper cobalt
boreal ravine
dapper cobalt
#

!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.
dapper cobalt
#

Use that before starting your loop.

slate swan
#

Doesnt client.get_channel()need to be awaited too?

boreal ravine
#

only coro's need to be awaited

thick rampart
#

so put await command so it has a moment to wake up?

slate swan
slate swan
thick rampart
#

Oh im a total idiot lmao....I put it before the on_ready

slate swan
boreal ravine
#

yeah

lament mesa
slate swan
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 the Members and Presences intents, which are needed for events such as on_member 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.

boreal ravine
thick rampart
#

holy crap more imports xD

slate swan
boreal ravine
#

^

slate swan
#

I still import it tho but its all preference nothing wrong about importing it

thick rampart
boreal ravine
slate swan
thick rampart
# slate swan K

Ah the potassium monster strikes again xD Sorry...I put that up there I was going to ask if I did that right lmao but brain forgot you are not telepathic...

thick rampart
#

(>.<) I need money to open a coding dojo.....tell me the winning numbers

thick rampart
#

I swear to python jesus if that ends up being anywhere near the winning numbers in my local lottery....for the next month I am buying you ice cream

slate swan
#

Only an ice cream? damn...

slate swan
#

how do we use custom emojis with our bot?

boreal ravine
stark hearth
slate swan
#

no

#

what about emojis from other servers

boreal ravine
#

the bot needs to be in the server to access the servers' emojis

slate swan
#

😐 what about gif links

boreal ravine
#

what do you think

slate swan
#

like this

boreal ravine
#

a gif ink is a message innit

slate swan
#

🤔

boreal ravine
#

sure i guess ¯_(ツ)_/¯

stark hearth
#

you can add the gif as an emoji to the server and do <a:emojiname:emojiid>

#

unless if you dont have the perms to add emojis

torpid dew
#
@client.command()
async def note(ctx, message=None):
  await ctx.send('msg.')
  msg1 = await client.wait_for("message")
  msg2 = msg1.content
  msg5 = msg2.lower()
  await ctx.send("anothermsg*")

  msg = await client.wait_for("message")
  msg3 = msg.content
  msg4 = msg3.lower()
  channel = discord.utils.get(client.get_all_channels(), name=f"{msg5}-{msg4}-notes")
  await channel.send(message)
  channel_id = channel.id
  await ctx.send(f'**CONFIRMATION** The note has been added to \n<#{channel_id}>')
#

when the message sends to the channel, it is only the first word, why

high pollen
#

discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward. What is this?? and how to solve it

#

i was using vscode and it worked fine

slate swan
#

you are ratelimited

high pollen
#

just as i pasted the code in replit and ran i got this error

high pollen
#

i have 2 other bots working fine on replit

slate swan
#
async def note(ctx , * , message.....```
slate swan
covert igloo
slate swan
#

You can't do anything else

slate swan
torpid dew
#

thanks

slate swan
#

it does.

#

ye

high pollen
#

how long?

slate swan
#

no idea , i've never been ratelimited

high pollen
#

ohk

#

ty

#

bruh

#

it works on vscode

#

only on replit

#

@slate swan ^^

#

just problem with replit

slate swan
#

the code has no issue

#

your bot is ratelimited

high pollen
#

what do u mean?

#

i can use the bot rn

slate swan
#

same bot ?

high pollen
#

yes

slate swan
#

the same token which shows error in replit?

high pollen
#

yes

#

only difference is there is a website in that code to keep the bot alive 24/7

#

does it have to do anything?

#

@slate swan

slate swan
#

no

#

its replit issue

high pollen
#

oh

slate swan
#

it uses shared ips

high pollen
#

ok

#

so what to do?

slate swan
#

wait

high pollen
#

other than replit

slate swan
#

you can use webservers

#

some services provide them for free

high pollen
#

like?

slate swan
slate swan
#

thats not a host

high pollen
#

can host now from replit

stark hearth
#

but very limited

slate swan
stark hearth
# high pollen like?

heroku is also a great service, but it is supposed to be used on websites and there is like limited hours per month

slate swan
#

both of them suck if your bot is in over 100 guilds

stark hearth
#

of course

#

i was a former user of both services but as my bot joined more guilds, i just started using a vps

stark hearth
stark hearth
high pollen
boreal ravine
high pollen
#

other bots are in like 10

stark hearth
stark hearth
slate swan
stark hearth
slate swan
high pollen
slate swan
stark hearth
high pollen
#

its fine

#

like 10 servers

slate swan
#

yeah it should be fine then

high pollen
#

will switch over when goes over 50

boreal ravine
slate swan
#

yea

#

that sucks fr

stark hearth
slate swan
#

and poetry often installs wrong modules

boreal ravine
#

^

stark hearth
#

i use vultr for hosting but its not free

slate swan
#

galaxygate and digitalocean are also good

#

if looking for a paid one

#

any idea what's wrong here?

#

it shows line 46 syntax error

boreal ravine
#

replit being slow ¯_(ツ)_/¯

#

wait your missing a colon*

stark hearth
stark hearth
slate swan
stark hearth
#

every if statement ends with a colon

slate swan
#

thanks!

stark hearth
#

mine is basically half of that (1 core, 2 gb ram, 2 tb bandwidth for $10)

stark hearth
slate swan
#

so if i wanna put 10 minute mute

#

what am i supposed to type?

boreal ravine
#

what is this cringe rate limiting

boreal ravine
slate swan
#

when someone uses a banned word

#

3 times

boreal ravine
#

well whats seems to be the problem

slate swan
#

like

#

i was following an article

#

so they didnt actually tell

#

where to put that value

boreal ravine
#

What value

boreal ravine
# slate swan

!d discord.Embed.timestamp its a kwarg, add it in the embed instance

unkempt canyonBOT
#

The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.

slate swan
#

10 minutes mute

boreal ravine
slate swan
#

it shows that line 54

#

datetime is not defined

slate swan
boreal ravine
unkempt canyonBOT
#

Source code: Lib/datetime.py

The datetime module supplies classes for manipulating dates and times.

While date and time arithmetic is supported, the focus of the implementation is on efficient attribute extraction for output formatting and manipulation.

boreal ravine
#

!pypi datetime

unkempt canyonBOT
#

This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.

boreal ravine
#

wrong one oops

slate swan
#

@boreal ravine how can i give it a value now

#

of 10 min

boreal ravine
slate swan
#

yes

boreal ravine
#

dont think you can but try google

slate swan
slate swan
#

any idea how to do that

boreal ravine
#

nope

slate swan
#

yes

#

and

#

i want it to mute for 10 minutes and only mute some roles

#

you can use asyncio.sleep to remove the role after adding it

#

!d asyncio.sleep

unkempt canyonBOT
#

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

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

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

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

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

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

delay must be in seconds so it would be 60*10

glass forge
#

hi pls can helpme with discord bot how i can fix it?

The conflict is caused by:
The user requested pynacl==1.2.1
discord-py[voice] 1.2.5 depends on PyNaCl==1.3.0; extra == "voice"

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip attempt to solve the dependency conflict
slate swan
#

!pypi PyNaCl install this

unkempt canyonBOT
#

Python binding to the Networking and Cryptography (NaCl) library

glass forge
#

im working in root

slate swan
#

voice is dependent over this lib so it wont work without it

pliant gulch
#

If your only user is root, then you don't need to worry about that warning

glass forge
#

The conflict is caused by:
The user requested pynacl==1.2.1
discord-py[voice] 1.2.5 depends on PyNaCl==1.3.0; extra == "voice"

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip attempt to solve the dependency conflict
#

🤦‍♂️

pliant gulch
#

Have you read what it says

#

You're trying to install version 1.2.1

glass forge
pliant gulch
#

Are you using poetry? At least from what I'm seeing the error says

glass forge
pliant gulch
#

How are you installing packages?

glass forge
pliant gulch
#

Ok, so go into your requirements.txt

#

And change the pynacl part

#

"pynacl==1.3.0"

glass forge
#

yep

#

O_O

#

thx

pliant gulch
#

No problem, but keep in mind music bot's break ToS

#

Had I known that's what you were making I wouldn't had helped

glass forge
tawdry perch
#

That as well

glass forge
#

Traceback (most recent call last): File "run.py", line 438, in <module> main() File "run.py", line 347, in main finalize_logging() File "run.py", line 179, in finalize_logging dlh.setFormatter(logging.Formatter('.')) File "/usr/lib/python3.8/logging/__init__.py", line 580, in __init__ self._style.validate() File "/usr/lib/python3.8/logging/__init__.py", line 433, in validate raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0])) ValueError: Invalid format '.' for '%' style

tawdry perch
#

Music bots breaks ToS on many services

pliant gulch
#

And youtube has a part in their ToS where it says not to bot them

tawdry perch
#

Per rule 5 we can't help you

glass forge
tawdry perch
#

How come?

pliant gulch
#

Rule 5 in this server has been here way, way before Rythm got shutdown

tawdry perch
#

The rule aply even if that bot exists

tawdry perch
boreal ravine
#

or just get a music bot that doesnt use youtube 😎

glass forge
glass forge
slate swan
#

best idea is to use spotify

glass forge
#

I'll just change the variable to spotify

slate swan
#

spotify as in normal spotify

glass forge
boreal ravine
#

now 😎

pliant gulch
#

Otherwise that would break copyright laws

tawdry perch
lament depotBOT
#
**What's one feature you wish more developers had in their bots?**

Suggest more topics here!

boreal ravine
#

cooler commands

tawdry perch
boreal ravine
#

idk

slate swan
tawdry perch
#

I made a ban command that if it was invoked by non moderator, it temp banned that user for 1 day

#

command author was banned*

slate swan
#

😂 interesting

tawdry perch
#

indeed, veri useful

#

normally antispam mutes a person, but I once made it kick them (they receive a invite to rejoin ofc)

#

But it was only for random testing

slate swan
tawdry perch
slate swan
#

How do I get the picture of the song and the duration of the song?
in command to play

boreal ravine
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

dont use f strings in sql

#

and its WHERE , not WERE

boreal ravine
#

WERE

#

show the full traceback

merry pulsar
#

probably who worked with Genius Api?
I want make command in my bot to get lyrics from track name
my problem: I can`t get lyric,but on local machine all works ok,I need in order to it works on hosting,my code:

def get_lyric(self,track_name):
    genius = lyricsgenius.Genius(await self.get_token())
    song = genius.search_song(track_name)
    return song.lyrics

On hosting I get Error : **403 client error: forbidden for url genius **

slate swan
#

yes

#

how to create command handler

#

!commandhandler

#

Hell

#

I want to create command handlwr

#

Handler

#

ok

fringe briar
#

The error is clear, you're missing the reason parameter, you're probably not invoking the command right

boreal ravine
#

!code your supposed to add an argument

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.

boreal ravine
#

Also don't ping people for help especially moderators.

#

Whats the error now

fringe briar
#

That line indicates a command not properly configured

#

I can't deduce since you didn't paste any code

#

There are lots of posts on SO that covers this

fringe briar
#

If you're trying to get a "ban reason", you should use this following syntax when defining the command... ```py
@bot.command()
async def kick(ctx, user: discord.Member, *, reason):
await user.kick(reason=reason)

#

I don't know if pass_context=True would be required inside the bot.command decorator tho...

boreal ravine
#

It's useless after v1.0

fringe briar
#

Anyway... how can i implement custom UI for my discord bot?

boreal ravine
#

Do you mean like a dashboard or something

fringe briar
#

Like, those fancy custom widgets, that bots can use to get input from buttons or whatever

boreal ravine
#

Custom Widgets..? You mean buttons?

fringe briar
#

Like a mini window inside discord chat, that has buttons and/or input fields... for taking user interactions, some uses reactions for this... But sometimes i get to see some bots that render this kind of page on chat...

fringe briar
slate swan
fringe briar
#

I wonder if it is possible for other type of inputs, like text fields...

slate swan
#

what am I doing wrong?

fringe briar
#

Missing indent after line 53 -> else

slate swan
#

ohhh

#

wtf is a indent

fringe briar
#

Indents are generally 4 spaces, or tabs ( of 4 spaces )

slate swan
#

okay

fringe briar
#

Bro, stop trolling, indents are like the mantra of python

slate swan
#

or 4 spaces before else?

slate swan
#

I am fucking new to this shit nocap

fringe briar
#

ok ok sorry

slate swan
#

hahah

supple thorn
slate swan
#

my friend made it and I just want to correct it

fringe briar
#

valid indentation py if: if_indented else: else_indented not valid ```py
if:
if_indented
else:
else_not_indented

slate swan
#

ohhh

#

okayy wait

#

hi anyone can turn exe to dmg?

#

got it, thanks buddy! :)

#

or uses an autotyper

slate swan
fringe briar
#

I don't know if you're familiar with other languages such as Java, they use curly brackets {} to wrap the statements, while python don't have them and uses indentations.

slate swan
maiden fable
#

!indent @slate swan

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

boreal ravine
slate swan
#

could you help with it

boreal ravine
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
boreal ravine
fringe briar
# unkempt canyon

When was this feature released?... I come from the 0.16 version...

boreal ravine
fringe briar
#

ok thanks

#

They improved a lot the API over the course of a year...

boreal ravine
#

ig

sage otter
#

I mean you have all the information right there. It creates a guild.

sage otter
#

that’s really all

tiny ibex
#

Can it like transfer ownerships?

#

:\

boreal ravine
#

afaik you can't, rtd though :)

pliant gulch
#

Yes you can

boreal ravine
#

what andy said

tiny ibex
pliant gulch
#

Using discord.Guild.edit it has an owner kwarg

#

!d discord.Guild.edit

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

Edits the guild.

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

Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.

Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.

Changed in version 2.0: The newly updated guild is returned.
boreal ravine
#

why is there a kwarg for that

pliant gulch
#

Because the API allows for it

boreal ravine
#

why not make it another function for that

tiny ibex
pliant gulch
tiny ibex
#

Well it doesn't

pliant gulch
#

On the API there is no separate endpoint for transferring

tiny ibex
#

But okay

pliant gulch
#

They all go under PATCH /guilds/guild_id

pliant gulch
#

Like i said earlier, no other endpoint to transfer guild owner

#

Its all done in PATCH /guilds/guild_id

pliant gulch
#

Where the rest of guild editting is done...

#

So yes, it makes total sense

tiny ibex
#

I see 👀

boreal ravine
#

haven't really used discord's api much except for sending messages 😂

tiny ibex
#

```What does this mean👀?
pliant gulch
#

Exactly what it says

tiny ibex
#

so how is this even useful

pliant gulch
#

To allow guild transfer if the bot made the server

tiny ibex
#

Just completely a shit endpoint

pliant gulch
#

What

#

You want to get rid of the whole endpoint because a bot in more than 10 servers can't transfer ownership

tiny ibex
#

Well most of the times bots will be in more than 10 guilds

pliant gulch
#

Lmao, brilliant

tiny ibex
#

They should keep it a 1000

pliant gulch
#

If your bot is gonna be that big, it shouldn't be meant to create guilds

#

The only way for the bot to transfer ownership, is if it was owner in the first place

#

Your argument makes no sound sense

tiny ibex
#

Copy a guild then invite the owner then transfer the ownership

pliant gulch
#

That could work, just make the bot leave the server afterwards

#

So that its always under 10 servers

tiny ibex
pliant gulch
#

Do some max concurrency

#

Easy fix

slate swan
#

wait for it to get removed from one of the guilds maybe

tiny ibex
pliant gulch
tiny ibex
#

lol

pliant gulch
#

None the less, copying guilds through a bot is completely useless

#

With the existences of templates you just need a link to it

#

And the whole guild layout is copied

tiny ibex
#

¯_(ツ)_/¯

pliant gulch
#

And so the bot would need admin to see all the channels, etc

#

Also while copying the guild its likely to be ratelimited

#

Due to the channel and role ratelimits

tiny ibex
#

And why will someone invite it at the 1st place

#

They can instead create a template

pliant gulch
#

That's what I'm saying

tiny ibex
#

¯_(ツ)_/¯

ebon plank
#

Error Anyone Can Fix It?

dusk dust
#

can anyone send a role_add example?

tiny ibex
# dusk dust can anyone send a role_add example?
@slash.slash(
    name='giverole',
    description='Gives a role to user.',
    options=[
        create_option(
            name='user',
            description='Choose the user you want to give role.',
            required=True,
            option_type=6
        ),
        create_option(
            name='role',
            description='Choose the role you want to give.',
            required=True,
            option_type=8
        )
    ]
)
@commands.has_permissions(
    manage_roles=True
)
async def giverole(ctx:SlashContext,user:discord.Member,role:discord.Role):
    if user.id==ctx.author.id:
        embed=discord.Embed(
            title='Error!',
            description='You can\'t give role to yourself.',
            colour=discord.Colour.green()
        )
        await ctx.send(
            embeds=[embed]
        )
    else:
        await user.add_roles(role)
        embed=discord.Embed(
            title=title_x,
            description=f'Succesfully given role to {user.mention}',
            colour=discord.Colour.green()
        )
        await ctx.send(
            embeds=[embed]
        )
valid niche
dusk dust
ebon plank
tiny ibex
#

You want me to send you everything?

valid niche
tiny ibex
#

👀

dusk dust
#

i will test

valid niche
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

bot.add_cog(Some Commands(bot)) This Was There In Line No.13

#

Where Is The Soace?

#

Pls Say @valid niche

sage otter
#

You can’t be serious right now….

valid niche
# ebon plank space where?

A class name in python must be one single word, with the definition of a word being a piece of text surrounded by white spaces and no white spaces in between

#

You can ofc have underscored or CamelCase to make it seem like 2 words

valid niche
pliant gulch
valid niche
#

There is a space, and a cog name must be a single word

pliant gulch
#

add_roles takes in snowflakes, you just need to create a Object

#

add_roles(discord.Object(id=...))

valid niche
pliant gulch
#

Its more preformant, and if your using ID its already pretty specific enough to where you 100% know the role exists

valid niche
#

add_roles only gets the ID of the role instance to pass it to the payload data, which is why an object would work too, but it just doesn’t look as clean, and if there is an issue where the role is invalid it will catch it much earlier

pliant gulch
#

They catch at the same spot basically

ebon plank
#

New Error Pls Fix It?

valid niche
ebon plank
#

@valid niche

valid niche
pliant gulch
#

None has no attr, and then you would raise an error in HTTP for the other

ebon plank
valid niche
#

A discord.Object will always work and will never be None

pliant gulch
#

Yes, and I said for that it raises an error in HTTP

valid niche
#

@ebon plank okay so let me get this straight with you, how long have you been doing python for?

valid niche
#

Because it really feels like you never did python before

ebon plank
#

Its Saying Every Letter

#

.........

valid niche
# ebon plank 0

Okay so you are aware that discord bots are ultimately super complex and really Ill advised for any beginner? It’s bound to trip them up and show errors, and you won’t really learn much from it

#

The official d.py discord doesn’t support anyone who shows a lack of basic python skills

ebon plank
#

pls fix that error @valid niche

#

i trust you

tiny ibex
#

😂🤣

valid niche
#

I won’t stop you from doing this project, but after having to tell you how to fix 3 basic errors that you really should’ve known how to fix yourself, I am kind of done with it and I won’t help anymore

valid niche
valid niche
dusk dust
loud junco
#

what does this means ```py
, *, text: str

valid niche
sage otter
pliant gulch
#

Repl.it is the worst site for discord bots

#

Fine service, just used for the wrong purpose

valid niche
pliant gulch
#

Am I wrong?

valid niche
tiny ibex
valid niche
#

It’s just so underpowered and mainly used wrongly which just annoys me a lot

tiny ibex
#

¯_(ツ)_/¯

valid niche
pliant gulch
tiny ibex
valid niche
valid niche
tiny ibex
#

¯_(ツ)_/¯

valid niche
#

Why not use heroku or replit

tiny ibex
valid niche
unkempt canyonBOT
#

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

valid niche
#

Means you won’t get support here either

valid niche
#

Have a tasks loop run every minute or so, then have it check the time and if it’s correct send the message

tiny ibex
pliant gulch
#

Is there some sort of benchmark I haven't seen

#

Or their specs?

tiny ibex
#

BAHHA he prolly has a Ryzen Threadripper

#

😂🤣

valid niche
valid niche
tiny ibex
#

Use code blocks please

pliant gulch
valid niche
#

Well that’s just an example structure. You will need to code it to your own specs

pliant gulch
strong kettle
#

How do I insert a bot into an voice channel?

valid niche
valid niche
#

This also returns a voice client used for sending audio and such

tiny ibex
strong kettle
pliant gulch
valid niche
strong kettle
#

How

slate swan
#

😐

tiny ibex
# strong kettle ch : discord.VoiceChannel await ch.connect()??
async def _join(self, ctx: commands.Context):
        """Joins a voice channel."""

        destination = ctx.author.voice.channel
        if ctx.voice_state.voice:
            await ctx.voice_state.voice.move_to(destination)
            return

        ctx.voice_state.voice = await destination.connect()```
I have this shit code may help you
#

¯_(ツ)_/¯

valid niche
# strong kettle How

You’re just saying variable ch should be of type VoiceChannel. You need to define what voice channel

boreal ravine
#

spoonfeeder!!

slate swan
#

All How To make a discord Button

boreal ravine
boreal ravine
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
valid niche
loud junco
#
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str):
  """Set the bot's status."""
  await self.bot.change_presence(activity=discord.Game(name=text))
```why is this not working
loud junco
#

its not showing status on my bot

tiny ibex
#

Maybe try this

valid niche
loud junco
#

im thinking where to put it

#

replace await?

slate swan
#

and everone how Change bot status ==> to Watching Example (32342) members

tiny ibex
# loud junco im thinking where to put it
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str):
  """Set the bot's status."""
  await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))```
loud junco
#

alright

slate swan
loud junco
#

?

tiny ibex
slate swan
loud junco
#

i think can

calm swallow
#

when did discord.py die??
i just found out about it right now

tiny ibex
slate swan
tiny ibex
tiny ibex
loud junco
#

no error but not showing

loud junco
slate swan
loud junco
#

idk what am i doing wrong

tiny ibex
loud junco
#
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
  """Set the bot's status."""
  await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))
tiny ibex
#

And BTW you replaced the message with your message right?

loud junco
#

the message in name=message?

tiny ibex
#

Try this

loud junco
#

i change the text to my status?

#

or what

tiny ibex
loud junco
#

name=my status))

#

is this how i do it

tiny ibex
#

Can you tell me your bot's prefix please

loud junco
#

rpm

tiny ibex
loud junco
#

oo

tiny ibex
loud junco
#

name= rpmsetstatus Like This!

#

like this right?

tiny ibex
loud junco
#

oo

tiny ibex
#

How are you so dumb

loud junco
#

;-;

tiny ibex
#

I am just telling you to run the bot

#

And type rpmsetstatus Like This! in the chat

loud junco
#

oo

tiny ibex
#

And it will work

#

You don't need to do anything with the code

#

Is your bot in this server?

loud junco
#

but why @commands.commands

#

i thought its bot.commands

slate swan
#

in cogs , its commands.command

loud junco
#

oo

tiny ibex
loud junco
#

now im changing to bot = commands.Bot()

tiny ibex
merry pulsar
loud junco
#

...

#

dont ping

#

u will regret

tiny ibex
boreal ravine
slate swan
#

ping a moderator mb

boreal ravine
#

Access the URL?

tiny ibex
#

How to fucking clear the cache on heroku

#

Someone please

maiden fable
#

Idk

tiny ibex
maiden fable
#

I don't use heroku

tiny ibex
#

Heroku is dual hosting my bot

loud junco
tiny ibex
#

IDK why

loud junco
#

are u kidding me

maiden fable
#

.....

loud junco
#

bruhhhh

#

i swear to god

#
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
  """Set the bot's status."""
  await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))
#

this is in my code

maiden fable
#

Are you loading the cog

tiny ibex
#

Just a really simple thing

loud junco
#
import discord
from discord.ext import commands
import os
from keep_alive import keep_alive

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

@bot.event
async def on_ready():
    print('We have logged in as {0.user}'.format(bot))

@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
  """Set the bot's status."""
  await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))

@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
    await ctx.send("Hello, world!")

@bot.command(name="ping")
async def ping(ctx: commands.Context):
    await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")

keep_alive()
bot.run(os.getenv('TOKEN'))
tiny ibex
#

What an amazing person

#

😂🤣

maiden fable
#

Why you ain't using bot.command deco 😐

loud junco
#

i dun even know how this thing works

#

its like a total different thing with client

maiden fable
#

Bruh

tiny ibex
loud junco
#

im fking learning

#

so how do i fking fix that thing

tiny ibex
#

Not even loading cogs

loud junco
#

class SomeCommands(commands.Cog):
"""A couple of simple commands."""

#

this?

dapper cobalt
loud junco
#

sherlock tells me heroku is veryyyy good

tiny ibex
#

Heroku is literally dual hosting my bot

dapper cobalt
merry pulsar
dapper cobalt
dusk dust
boreal ravine
boreal ravine
valid niche
dusk dust
#
import discord
from discord import Embed
import asyncio
import os
import string
import random
from discord import Intents
import discord.utils
from discord.utils import get
from asyncio import sleep
from discord.ext import commands, tasks
from discord.ext.commands.errors import CommandInvokeError, CommandNotFound, CommandOnCooldown, MissingRequiredArgument, MissingPermissions
from discord.ext.commands.cooldowns import BucketType
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionEventType
``` i imported all this... was there an error for some wrong library?
loud junco
#
class SomeCommands(commands.Cog):

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

  @commands.command(name="setstatus")
  async def setstatus(self, ctx: commands.Context, *, text: str, message):
    """Set the bot's status."""
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))
```what is fucking wrong im very mad now
boreal ravine
#

you have self.bot but ur not even using it smh 🤦‍♂️

slate swan
#

or use ctx.bot

dapper cobalt
slate swan
#

i dont think typehinting it is a bad practise ( in contrast its better )

slate swan
#

^ , also the command can make your bot ratelimited if the users try to do something mischievous with it

loud junco
#
class SomeCommands(commands.Cog):

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

  @commands.command(name="setstatus")
  async def setstatus(self, ctx: commands.Context, *, text: str):
    """Set the bot's status."""
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))
```bruh
boreal ravine
#

especially in dpy

slate swan
#

typehinting makes python look like a programming language

boreal ravine
#

why is ur setup function

#

inside the cog

#

ok

dapper cobalt
boreal ravine
dapper cobalt
#

I know, but I don't have enough time to fix it. So just waiting for a kind person to do it and submit a pull request.

boreal ravine
#

Maybe

hearty dragon
#

does anyone know how do i run this file

slate swan
#

Basic Python knowledge...

boreal ravine
slate swan
#

Oh yeah and this is not good

client = commands.Bot(...)
#

Should be

bot = commands.Bot(...)
hearty dragon
#

this is what it says when i type it

boreal ravine
slate swan
#

cd PathToFile

dusk dust
#

when on_ready start event_math... how can i do this?

slate swan
#

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

#
async def edit(inter):
    message = await inter.response.send_message("edit")
    await asyncio.sleep(3.0)
    await message.edit(content="edited")```
#

thats not how you edit a interaction message

#

thats disnake so it must be inter.response.edit_response iirc

#

thanks

#
has_emote_status = any([a.emoji.is_custom_emoji() for a in user.activities if getattr(a, 'emoji', None)])
if has_emote_status is None:
  #do something```
#

is this formatted properly?

#

im not sure wether to do py if has_emote_status: #or if has_emote_status != None: #or if has_emote_status == True:

#

all of them function same

#

so they will all work?

#

but the 1st one is most preferable

#

oh, alright

#

first one works if the value is not None ( it does not check if its true or not ) , same for second one
the third one makes sure its True

dense swallow
#

when i do cog.get_all_commands() i get some weird format.. like <discord.ext.commands.core.Command object at .....>
how to fix?

sage otter
#

because it’s a list of objects

dense swallow
#

so how do i convert it/

sage otter
#

Use list comprehension

slate swan
#

you can iterate thru them

tiny ibex
#

How to get the email address of an user

slate swan
#

and use .name

tiny ibex
slate swan
dense swallow
#

you cant

slate swan
#

it would have been really abused if something like that existed :p

dense swallow
#

imagine..

tiny ibex
#

I forgot that I logged on their website

dense swallow
#

yeah i think oauth2 can do that

tiny ibex
#

Yup it can and I totally forgot that

sage otter
#

That column simply just doesn’t exist in that table.

random sleet
#

does someone have a vote kick command. so if 4 users vote against a user then the user gets kicked?

dense swallow
# slate swan and use .name

like this?

        title = cog.qualified_name or "No"
        all_cmds = cog.get_commands()
        for command in all_cmds:
            cmds = command.name
        em = discord.Embed(
            title=f'{title} Category',
            description=f"{cog.description}\n\n`{cmds}`",
            color=bot.color
        )
        await self.send(embed=em)
#

also cog is an arg..

#

@sage otter ..

sage otter
#

What are you trying to do

#

Also like I told you. Use list comp.

#

cmds = [cmd.name for cmd in cog.get_commands()]

dense swallow
dense swallow
#

can u show us how u created the table

sage otter
#

Are you even executing and commiting to the db

surreal sierra
#

quick question, this is how u ping a specific user in a msg right? @surreal sierra

boreal ravine
dense swallow
#

yes, <@id>

surreal sierra
#

okay ty

sage otter
#

bot_id INTEGER PRIMARY KEY, count INTEGER

dense swallow
sage otter
#

Wait you’re using SQLite right?

slate swan
#

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

boreal ravine
sage otter
#

Same thing

#

Then yes. Fix your schema.

boreal ravine
#

remove message

#

you already have inter as a param

#

no need for message

sage otter
#

is "int" even a valid data type in sqlite. I’m pretty sure it’s only bigint and integer

boreal ravine
sage otter
#

Wait a second. Did you try to create a column for the table when the table already existed???

#

That’s probably why the column didn’t exist because you can’t do that.

#

Unless you alter the table

sage otter
boreal ravine
#

he iterated it the wrong way then

boreal ravine
slate swan
#

is ti possible to get if a member is in a certain guild but without the bot being into that guild?

dense swallow
boreal ravine
feral jacinth
#

k

boreal ravine
#

Your iterating it wrongly I guess

dense swallow
#

huh

slate swan
# feral jacinth send ur line
async def edit(inter):
    message = await inter.response.send_message("edit")
    await asyncio.sleep(3.0)
    await message.inter.response.edit_response(content="edited")``` this?
sage otter
#

Just don’t iterate it that way

#

In the embed description just do this

boreal ravine
#

^

boreal ravine
sage otter
#

"\n".join([i.name for i in cog.get_commands()])

dense swallow
sage otter
#

Show full command code

dense swallow
#
    async def send_cog_help(self, cog):
        title = cog.qualified_name or "No"
        em = discord.Embed(
            title=f'{title} Category',
            description=f"{cog.description}\n\n'`\n`'".join([i.name for i in cog.get_commands()]),
            color=bot.color
        )
        await self.send(embed=em)
shadow wraith
#

hey i was wondering how do you send an embed with ctx

#

im tryna learn how to make embeds

dense swallow
#

await ctx.send(embed=embed)

sage otter
#

ctx.send(embed=discord.Embed)

shadow wraith
#

thx

sage otter
#

Do this

keen talon
unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
sage otter
#

description = f"{cog.description}\n\n" + "\n".join([i.name for i in cog.get_commands()])

shadow wraith
dusk dust
#

if i place this in my code:

@bot.event
async def on_message(message):
    member = message.author

    if message.content == 'other':
        await member.send('text')
``` the bot don't respond other commands... there are some error?
slate swan
sage otter
dense swallow
#

ok let me try

tiny ibex
#
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Connect call failed ('162.159.128.233', 443)]
>>>```
#

Why TF?

#
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
dense swallow
tiny ibex
sage otter
#

According to official d.py. They said it’s just a "asyncio/windows" bad

#

As well as asyncio and aiohttp internals

tiny ibex
#

How to solve it?

sage otter
#

You only get it when you close the bot

tiny ibex
sage otter
#

You don’t

tiny ibex
#

AAAAAAAAAAAA someone please tell me some good places to host bots for free

#

Please

#

Heroku doesn't fucking work for me

visual island
#

normal Command doesn't have any attribute regarding filenames

tiny ibex
#

The main problem is they are not free

visual island
#

you can see the Cog name but not the file

tiny ibex
#

I don't want good hosting

tiny ibex
#

I just want hosting

visual island
#

if ctx.command.cog == bot.get_cog(...):

tiny ibex
visual island
#

^^ @dusk dust

dusk dust
dusk dust
visual island
#

call get_cog for each cog, not directly pass all of it in the args

#

if ctx.command.cog not in [bot.get_cog(...), bot.get_cog(...), ...]

keen talon
#

which one do u find better aws or google cloud ?

#

what is the ec2 micro

#

I will try google for now ig

crystal wind
#

Is there a limit for bots when it comes to commands/time in general? For instance 8 commands per second is allowed?

crystal wind
#

I have no idea, I was wondering what exactly is the limit in case my bot is being overloaded with commands. Especially in multiple servers

boreal ravine
slate swan
#
if discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == True:
  listening = "Listening to"
elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == False:
  listening = ""
elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == None:
  listening = ""``` is this valid?
boreal ravine
#

why do you need a lambda

slate swan
#

should i remove it..

crystal wind
slate swan
#

!d lambda

unkempt canyonBOT
#

An anonymous inline function consisting of a single expression which is evaluated when the function is called. The syntax to create a lambda function is lambda [parameters]: expression

boreal ravine
keen talon
unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
boreal ravine
slate swan
#

okay

vernal osprey
#

How do I start I live ongoing timer in python? Coz I'm coding an auction bot.

calm swallow
#

what am i supposed to do with my bot now that discord.py is dead?

calm swallow
#

i've been hearing that discord.py isn't being updated anymore

#

basically dead

vernal osprey
#

O

crystal wind
calm swallow
#

i've heard about nextcord, pycord, and hikari but i don't know which one to migrate everything to

gray gazelle
calm swallow
#

how much of my current code would have to change if i migrated it to pycord?

slate swan
#

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'

slate swan
#
            acts = member.activities
            act = [i for i in acts if isinstance(i, discord.CustomActivity)]
            if act:
                act = act[0]


            elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == True:
                listening = "Listening to Spotify ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")"
                act = ""
            elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == False:
                listening = ""

            elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities) == True:
                playing = "Playing A Game ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")"
                act = ""
            elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities) == False:
                playing = ""

            elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities) == True:
                streaming = "Streaming on Twitch ![rich_presence](https://cdn.discordapp.com/emojis/907387984226173008.webp?size=128 "rich_presence")"
                act = ""
            elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities) == False:
                streaming = ""

            else:
                act = 'None'``` where did i go wrong
slate swan
#

oh nevermind

#

i forgot i removed variables

boreal ravine
slate swan
#

actually nevermind i didnt remove them

#

so somethings actually wrong :/

gray gazelle
boreal ravine
#

Your trying to send something to a channel that doesnt exist or isnt in the cache

ornate lichen
#

how to self-host

#

a bot

slate swan
#

run the file?

ornate lichen
#

like 24/7

boreal ravine
#

weren't you trying heroku yesterday

#

🤨

gray gazelle
ornate lichen
#

its says not supported

boreal ravine
ornate lichen
#

i did

#

3.8.9

boreal ravine
#

use 3.8.10

ornate lichen
#

didnt work

boreal ravine
ornate lichen
#

isnt self-hosting easier?

ornate lichen
#

not supported

boreal ravine
#

then use

#

a version heroko supports

#

heroku*

ornate lichen
#

its said it supports 3.10.0

boreal ravine
coarse shore
ornate lichen
coarse shore
#

Yes

ornate lichen
#

tysm

#

ill try

boreal ravine
coarse shore
#

Well they offer hosting

#

In a better way

#

than heroku

#

without downtime

#

100% uptime

boreal ravine
#

Does it use pyterodactle or whatever it's called?

coarse shore
#

they earn from thier higher paid plans

coarse shore
#

it isnt a hosting service

boreal ravine
#

Whats the catch

coarse shore
#

Similar to cpanel , vistapanel and direct admin

#

Open source panel (dashboard)

river kindle
#

how can i create a command only IF REQUESTED for logs?

for example !setlogs and the bot asks what channel, after which it does everything, that is it will say which user used that command, user deleted the message etc.

does anyone know how to help me?

coarse shore
# river kindle how can i create a command only IF REQUESTED for logs? for example !setlogs and...

Welcome to the updated discord.py series - the series where I teach you how to build a discord.py bot for your server! Below are some links to get you started.

Series requirements can be found here:
https://files.carberra.xyz/requirements/discord-bot-2020

You'll also need an IDE; I use Sublime Text in this series:
https://www.sublimetext.com/
...

▶ Play video
ornate lichen
ornate lichen
coarse shore
ornate lichen
#

nope

#

need to?

coarse shore
#

U need atleast 10% of coding knowledge to use it

river kindle
boreal ravine
#

knowledge