#discord-bots

1 messages ยท Page 925 of 1

glacial echo
#

all organized and categorized

slate swan
glacial echo
#

rn nothing

#

but it wasnt working for me personally when trying to learn slash commadns

slate swan
#

yesterday i tried the script it worked fine. but today when i tried it it shows alot of errors

#

like idk what wrong

#

it says - "The owner of this website (discord.com) has banned you temporarily from accessing this website"

slate swan
#

i use replit so idk

supple thorn
maiden fable
slate swan
#

maybe after few days it might work :P

inland crest
#

why do i get this error?

slate swan
#

i might use studio code for the period

maiden fable
#

Remove ()

inland crest
#

kk

slate swan
#

bot.event don't need ()

inland crest
#

i didnt know tht srry

#

thanks

slate swan
#

hmmm. ok

boreal ravine
#

why do I subclass commands.Bot everytime I wanna make a discord bot what creating an instance of it doesn't feel good anymore

glacial echo
#

was it a bot or a userbot

slate swan
#

i got ip banned lol

glacial echo
#

rip

#

perhaps you were breakign the TOS

slate swan
#

soo idk really

boreal ravine
boreal ravine
slate swan
#

D:

glacial echo
#

doesnt dpy have built in rate limit protections

boreal ravine
#

it does

slate swan
#

"Currently, this limit is 10,000 per 10 minutes."

boreal ravine
#

but you can still get rate limited

glacial echo
#

i second their statement, get rekt

slate swan
#

10k pet 10m?

#

per*

glacial echo
#

1k per 1m

boreal ravine
#

you can even get rate limited if you're using a host

glacial echo
#

or like 15/s

slate swan
glacial echo
#

where should i host a dsicrd bot?

#

should i just use my rpi

slate swan
glacial echo
#

preferrably free

#

i dont wanna always use my laptop once i get a releasable bot

#

if you noticed, i have premium monetixation listed as a wanted feature

vale wing
glacial echo
#

raspberry pi

vale wing
#

What version

#

I mean rpi 4 or what

glacial echo
#

oh

#

idk tbh it was a bday gift and its been a while since i needed to know

vale wing
#

I can say it is totally possible to host it there

glacial echo
#

haventused it in a year or two

slate swan
#

"user = bot.get_user(user_id)"???

vale wing
#

Don't have personal experience but I know persons that have done it on rpi 4

#

I host bots on VPS cause I don't have physical server

slate swan
inner epoch
#

Hey a que how can I use the bot to delete a message from certain guild?

P.S. I have the message id , guild id and channel id and yea my bot has been authorized to do so

#

@slate swan ?

inner epoch
#

Once I get the message object I can delete it for sure but how to get that

maiden fable
#

Either use fetch message and delete it or use the raw HTTP method (preferred)

slate swan
unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
slate swan
#

use that

maiden fable
#

fetching is an overkill just to delete a message lemon_pensive

slate swan
maiden fable
inner epoch
slate swan
slate swan
#

yeah theyre helpful

maiden fable
inner epoch
inner epoch
inner epoch
maiden fable
inner epoch
#

Aye let me checkout that then

#

Got it thanks!

acoustic sleet
#

apparently discord.py dying so does anyone know any good alternatives?

slate swan
#

it died a long time ago and was resurrected last month PeepoShy

acoustic sleet
#

oh

#

lmao ig im outdated ;-;

formal basin
#

What does this error mean like Iโ€™m pretty sure Iโ€™ve done it right

acoustic sleet
#

u have to do ctx.send

#

u can assign de sent msg to a variable so later u can edit or delete

formal basin
acoustic sleet
#

like message = ctx.send(...)

formal basin
#

Ok

acoustic sleet
formal basin
acoustic sleet
#

did u take ctx as an argument in the function?

acoustic sleet
#

huh

glacial echo
#

cant beleive i almsot left my token on my public github page

#

smh

acoustic sleet
acoustic sleet
formal basin
glacial echo
#

cant wait for a future where token regeneration is a privliged intent and requries approval every time

acoustic sleet
#

ig they figured thats enough security

glacial echo
#

issa joke

#

lol

acoustic sleet
#

oh lol

#

!d discord.ext.commands.Context.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/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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
inner epoch
#

@maiden fable Hey mind if I pm?

glacial echo
#

frick its past midnight

#

i was tryign to go to bed before then dammit

maiden fable
inner epoch
hollow carbon
boreal ravine
#

anyone want to help test my bot

hollow carbon
slate swan
# hollow carbon :(

You need the mark the on_member_join in a @bot.event, and the print("READY") should be in on_ready().

inner epoch
#

Just that......well no worries then ill fix my code

inner epoch
hollow carbon
#

oh

slate swan
hollow carbon
#

oh lol

#

Where i need to put on_ready()

slate swan
#
@bot.event
async def on_ready():
    print("...")
#

!d discord.on_ready

unkempt canyonBOT
#

discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful and the [`Client.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.guilds "discord.Client.guilds") and co. are filled up.

Warning

This function is not guaranteed to be the first event called. Likewise, this function is **not** guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.
slate swan
#

hello, i'd ike to add a profanity check filter but it doesn't seems to work:

@bot.event
async def on_message(msg, ctx):
    if 'word' in msg.content:
        await msg.delete()
        await ctx.send("HUH??!?!/1")
    else:
        pass
#

I don't thing ctx can be passed in there.

#

oh but then how do the other bots do it then?

vale wing
#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your botโ€™s own messages and private messages are sent through this event. This can lead cases of โ€˜recursionโ€™ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
vale wing
#

Only message argument

slate swan
#

D:

vale wing
#

But like cmon look at the docs

slate swan
#

ok then what about send it to the dm?

vale wing
#

Message has channel attribute

slate swan
#

nvm

hollow carbon
#

How can i show the name in the [@member]

slate swan
#

which?

hollow carbon
#

?

slate swan
#

i see

#
@client.event
async def on_member_join(member):
    print(f'{member} Joined the server!')
#

there

#

same thing applies to leave

slate swan
unkempt canyonBOT
slate swan
#

!d discord.TextChannel.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/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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
kindred lodge
#

!d help

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
kindred lodge
#

idk!

slate swan
kindred lodge
# slate swan ?

idk python at all i actually want to make a discord bot so i joined this server

slate swan
#

You might find this usefull:

#

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

kindred lodge
kindred lodge
kindred lodge
slate swan
#

This server doesn't support node.js.

kindred lodge
boreal ravine
#

@slate swan copying features is fun but it's not fun when it doesn't work as intended blob_pain

boreal ravine
#

obviously

#

idk

manic wing
#

thats a discord feature

boreal ravine
#

disable them here ig

kindred lodge
#

its easy

slate swan
#

Doesn't have anything with coding or discord bots to do, please read the channel topic. ๐Ÿคท

kindred lodge
hollow carbon
abstract kindle
#

hello everyone

#

what typically gets stored in the main file of a discord bot?

#

I used to restart my bot every time i ran new code, but im now learning about cogs and reloading them

#

so what should I have in my main file so I don't have to restart the bot

boreal ravine
abstract kindle
#

and I can store everything else in cogs?

boreal ravine
#

yea

#

or another folder/file

abstract kindle
#

that's probably the most efficient way to do it, right?

#

having minimal stuff in the main file

#

Thank you

boreal ravine
unkempt canyonBOT
#

To work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
#

you could send requests directly

abstract kindle
#

question..

#

i have a recursive function in one of my cogs, and when I unload it, the recursive function continues to loop

#

how do I end it?

maiden fable
pliant gulch
# abstract kindle how do I end it?

You should utilise one of the teardown methods of the Cog class, in this case cog_unload. What you can do is have a variable which your loop checks for, if it's False continue, else break. ```py
class Foo:
def init(self) -> None:
self.variable = False

def run(self) -> None:
    for i in range(10000):
        if self.variable is True:
            break
        
         # do stuff

``` Now all you need to do is define cog_unload in the namespace of your cog class, the signature would look like async def cog_unload(self) -> None, inside of this method you'd set self.variable to True

#

!d discord.ext.commands.Cog.cog_unload

unkempt canyonBOT
#

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

A special method that is called when the cog gets removed.

Subclasses must replace this if they want special unloading behaviour.

Changed in version 2.0: This method can now be a [coroutine](https://docs.python.org/3/glossary.html#term-coroutine "(in Python v3.10)").
abstract kindle
#

Ahhh i see

pliant gulch
#

๐Ÿ‘

abstract kindle
#

Oh further question

#

Any way to start it back up? I current have the function set to start running on_ready

#

Any method that's called when the cog is loaded/reloaded?

pliant gulch
#

You can assume setup to be called everytime the cog is loaded, or reloaded

abstract kindle
#

Ohhhh!!!

hollow carbon
#

Did someone know how to use discord API

abstract kindle
#

Dang I'm still learning about all of this and finally understanding what certain parts of the code I've been writing fully do is amazing!

#

Before I had it calling the function on_ready, but now I won't even need that!

pliant gulch
#

Congrats

delicate hornet
#

how do i use threads?

dull sorrel
#

Could anyone help me with my discord python bot project?
I am trying to make a bot that will react with emojis to a specific person only on my command.

drowsy thunder
#

No one asked + No one cares

slate swan
drowsy thunder
#

@slate swan good thing ur here,help me

slate swan
#

Interaction):

drowsy thunder
slate swan
drowsy thunder
#

I am using the new modals to make a application bot lol

final iron
slate swan
#

bro

#

parenthesis huhhh

#

each function declaration needs a colon

drowsy thunder
slate swan
#

but nvm

slate swan
#

this channels slowmode is gonna be 10seconds in 5 more days watch

final iron
hardy yoke
drowsy thunder
#

To stop spam

#

Its their choice

#

Idc

hardy yoke
#

it is indeed discords choice to add discord rate limits

drowsy thunder
slate swan
#

Hey i am making a bot and want to know how to set a var with the response of the user ? thx !

#

uh.

slate swan
#
    @commands.Cog.listener()
    async def on_ready(self):
     interaction = await self.bot.wait_for("button_click", check = lambda i: i.custom_id == "tictrigger")
     await interaction.send(content = "Button clicked!")
     print("testing...")
``` ;-;
drowsy thunder
slate swan
#

no idea pls help

#

AttributeError: 'MessageInteraction' object has no attribute 'custom_id'

slate swan
drowsy thunder
slate swan
#

no

#

:/

#

imagine

drowsy thunder
# slate swan no

Learn it then waht this https://youtu.be/aBm8OVxpJno

Hey!
Thanks for watching todays video, todays video I really hope you enjoyed and join my discorddd :)

LINKS -
Join my Discord - https://discord.gg/twHW4UUJGq

Nextcord Server - https://discord.gg/Ucmae5Kbwb

Developer Portal - https://discord.com/developers/applications

Anyways Thanks if you read all of this and I hope you...

โ–ถ Play video
slate swan
#

fork

drowsy thunder
#

*watch

hardy yoke
slate swan
#

discord ๐Ÿด py

drowsy thunder
slate swan
drowsy thunder
copper gulch
hardy yoke
maiden fable
slate swan
#
disnake.ui.Button(style=disnake.ButtonStyle.blurple, label="Create ticket",custom_id = "tictrigger"))
final iron
slate swan
#

..

hollow badger
slate swan
#

mods late

#

11min

#

anyone help me?

hollow badger
#

Moderators are volunteers, too.

hardy yoke
#

That on_ready will only run when the cog is loaded, I take it you want it to run whenever the button is clicked? @slate swan
also if the button is defined in cog x, cog y won't see it unless you import the button over.

slate swan
junior verge
#

What does this mean?

slate swan
slate swan
slate swan
junior verge
#

Want my code?

slate swan
#

Sure

junior verge
slate swan
#

๐Ÿ˜ถ

slate swan
hardy yoke
# slate swan ok how do i import

depends on your file structure and how the button is defined (you won't be able to import it if you're defining it into the .send like that, check out button classes)

but in either case, this won't work via on_ready. You need to find what your libraries event is called for button clicks (disnake uses on_button_click I think) or learn how button callbacks work.

slate swan
junior verge
slate swan
junior verge
slate swan
#

How I can make a bot send message upon joining a guild?

slate swan
slate swan
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") join or leaves 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.
slate swan
#

use this event

#

ash h

#

The bot

slate swan
hardy yoke
slate swan
#

Not member

slate swan
#

nvmd

slate swan
junior verge
slate swan
#

!e

for i in range(3):
  print(i)
  continue
unkempt canyonBOT
#

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

001 | 0
002 | 1
003 | 2
slate swan
#

!d continue

unkempt canyonBOT
#

7.10. The continue statement


continue_stmt ::=  "continue"
``` [`continue`](https://docs.python.org/3/reference/simple_stmts.html#continue) may only occur syntactically nested in a [`for`](https://docs.python.org/3/reference/compound_stmts.html#for) or [`while`](https://docs.python.org/3/reference/compound_stmts.html#while) loop, but not nested in a function or class definition within that loop. It continues with the next cycle of the nearest enclosing loop.

When [`continue`](https://docs.python.org/3/reference/simple_stmts.html#continue) passes control out of a [`try`](https://docs.python.org/3/reference/compound_stmts.html#try) statement with a [`finally`](https://docs.python.org/3/reference/compound_stmts.html#finally) clause, that `finally` clause is executed before really starting the next loop cycle.
slate swan
unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

slate swan
#

!e ```py
while True:
print("a")
continue
print("b")

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 143 (SIGTERM).

001 | a
002 | a
003 | a
004 | a
005 | a
006 | a
007 | a
008 | a
009 | a
010 | a
011 | a
... (truncated - too many lines)

Full output: too long to upload

slate swan
#

See it doesn't say b.

#

huhh

slate swan
#

useless keyword

junior verge
#

So how do I fix my code though

slate swan
slate swan
#

!d discord.on_guild_join

unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
junior verge
slate swan
junior verge
#

Alright, let me try

slate swan
#

Why do you even have them?

junior verge
#

Wait so how do I fix the indentation

#
elif command.parent != None:
``` Remove that line then too?
slate swan
junior verge
#

Not to sure

#

Was a while ago

hardy yoke
#

a lesson in why you should always comment your code

junior verge
#
for cog in neededCogs:
            commandList = ""
            for command in self.client.get_cog(cog).walk_commands():
                if command.hidden:

                    

                    commandList += f"**{command.name}** - *{command.description}*\n"
            commandList += "\n"

            helpEmbed.add_field(name=cog, value=commandList, inline=False)
``` like that
slate swan
#

Why the if command.hidden:?

junior verge
#

Also not sure xD

slate swan
#

Do you have any hidden commands?

junior verge
slate swan
junior verge
#

I wanted it to remove the commands I did not want

slate swan
junior verge
#
for cog in neededCogs:
            commandList = ""
            for command in self.client.get_cog(cog).walk_commands():
                
                    commandList += f"**{command.name}** - *{command.description}*\n"
            commandList += "\n"

            helpEmbed.add_field(name=cog, value=commandList, inline=False)

        await ctx.send(embed=helpEmbed)
``` so just that?
slate swan
#

Seems better

junior verge
#

Would that work?

slate swan
#

Test it

junior verge
#

I mean it works I guess, it sends only 4 though and .help 2 doesn't show a 2nd page

slate swan
#

๐Ÿคท

junior verge
#

nvm thats my fault

#

nope its not

#

it just doesn't work

slate swan
#

!d discord.ext.commands.Bot.commands

unkempt canyonBOT
slate swan
#

why not just use this?

#

which it does include commands in cogs

junior verge
#

Uh dunno

#

I am just confused why it only shows that it has 1 page

#

When it should have 2

#

Got any idea

#

I think it was a typo

#

Getting this error now when doing .help 2

slate swan
#

@junior verge

embed = discord.Embed(title="My Commands", description="", color=inter.author.color)
        for i in os.listdir("./cogs"):
            if not i.endswith(".py"): continue
         
            cog = self.bot.get_cog(i[:-3])
            if not cog: continue
            cog_commands = cog.get_commands()
            if not cog_commands: continue
            embed.description += f"**{i[:-3]}**\n"
            for j in cog_commands: embed.description += f"`{j.name}`  "
            embed.description += "\n"
        embed.add_field(name="Total Commands", value=len(self.bot.all_commands))
        await ctx.send(embed=embed)

this is a simple help command though ๐Ÿ˜” you could make it work if you want

#

do

slate swan
junior verge
#

I did

#

But I have a value

slate swan
#

the event if the button is event is clicked has a member arg?

pliant gulch
slate swan
#

to show who the button is clicked by

slate swan
slate swan
slate swan
#

!d discord.Interaction.user

#

no i want the event

unkempt canyonBOT
slate swan
#

ok

slate swan
pliant gulch
slate swan
#

!d disnake.on_interaction

#

i want the event + asking

unkempt canyonBOT
#

disnake.on_interaction(interaction)```
Called when an interaction happened.

This currently happens due to application command invocations or components being used.

Warning

This is a low level function that is not generally meant to be used.

New in version 2.0.
junior verge
pliant gulch
#

Where you pass value

junior verge
#
commandList = ""
``` there
#

or where I add the field

pliant gulch
#

No, where you pass value to add_field

junior verge
#
helpEmbed.add_field(name=cog, value=commandList, inline=False)
#

What do I change there?

pliant gulch
#

This just ensures you donโ€™t send the API an invalid payload

vale wing
#

Why the lowerCamelCase in python

pliant gulch
#

In your case, an empty string

junior verge
#

ye?

#

I don't get to what I change it to sorry

junior verge
#

value=default?

latent anchor
#

im trying to make the bot add role and ive seen the api reference but i still dont get it

#

how do i do it?

vale wing
#

Are you using a library

latent anchor
#

what library

vale wing
#

Because if you do you need library docs not the API reference

vale wing
junior verge
#

@pliant gulch this is probably not it, but I just don't get it>

helpEmbed.add_field(name=cog, value=default, inline=False)
latent anchor
#

im using replit

vale wing
#

Raw requests?

latent anchor
#

yes

vale wing
#

Well that's interesting but why not use the lib

azure scroll
#

i am making a music but but i am getting an error when i try to get the voice channel id from mongodb and connect to the channel.
Code:

@commands.command()
    async def play(self, ctx, url : str, *, channelIndex):
        vc = col.find_one({"_id" : ctx.author.id}, {"_id":0, "voiceChannels":1})

        voiceChannels = await discord.utils.get(ctx.guild.voice_channels, name = vc['voiceChannels'][channelIndex])
        if (voiceChannels is None):
            return await ctx.send("There is no vc set")
        voice = await discord.utils.get(self.client.voice_clients, guild = ctx.guild)
        await voiceChannels.connect()```
error:
```python
voiceChannels = await discord.utils.get(ctx.guild.voice_channels, name = vc['voiceChannels'][channelIndex])
TypeError: 'NoneType' object is not subscriptable
vale wing
#

vc is None most likely

junior verge
#

Does anyone else know what I need to do

azure scroll
vale wing
#

Print the vc

latent anchor
azure scroll
junior verge
vale wing
vale wing
junior verge
latent anchor
vale wing
#

Your commandList is an empty string most likely and that's not allowed

latent anchor
#

from linux

vale wing
junior verge
#

But i don't know what to put in it?

vale wing
#

Put anything but not empty

junior verge
#

Like what

latent anchor
vale wing
#

"word"

latent anchor
#

should i use it

junior verge
vale wing
junior verge
#

I will try

vale wing
#

And you can develop locally

slate swan
vale wing
#

If you still would like to use replit, run pip install discord.py in its terminal

slate swan
#

"are you using a library" ofc he is where else is he checking the libraries docs?

azure scroll
junior verge
vale wing
#

Turns out he didn't use a library

vale wing
azure scroll
junior verge
vale wing
#

Then just provide it?

junior verge
#
for cog in neededCogs:
            commandList = ""
            for command in self.client.get_cog(cog).walk_commands():

                    commandList += f"**{command.name}** - *{command.description}*\n"
            commandList += "\n"

            helpEmbed.add_field(name=cog, value=commandList, inline=False)

        await ctx.send(embed=helpEmbed)
junior verge
vale wing
#

You just gotta make sure you don't set an empty string

rustic coral
#

Guys, my bot is only online when I run. When I looked uptimerobot, it show this. someone pls help

junior verge
#

Yeah but what do I put in it then?

vale wing
#

And I am not sure I can help with that

#

Whatever you want lol

junior verge
#

What

#

Then it will do this

rustic coral
rustic coral
#

Yea

vale wing
#

Use VPS

dusky pine
#

oh god damn replit

junior verge
#

Don't use replit

slim ibex
#

replit ๐Ÿ˜ข

dusky pine
#

replit is blocked from uptimerobot now

rustic coral
junior verge
latent anchor
#

why not using replit

vale wing
#

Virtual Private Server

slim ibex
vale wing
rustic coral
vale wing
#

Btw should I post a tutorial here of how to setup ubuntu server for hosting bots

slim ibex
#

make a server, push the files to the servers file system and run

junior verge
slim ibex
#

vultr is a cheap and very good VPS

slate swan
slim ibex
#

used it for my old bot

latent anchor
slate swan
#

how much

vale wing
#

I use amazon aws (free year xd)

slim ibex
junior verge
#

I use heroku with git and github

vale wing
slate swan
#

ok

vale wing
slate swan
junior verge
slate swan
#

im getting error

azure scroll
vale wing
junior verge
rustic coral
#

Can I use heroku then instead of replit?

junior verge
#

if you want

vale wing
junior verge
#

A vps would be better though

slate swan
#

@junior verge@azure scroll

slim ibex
#

Heroku is bad for bots

vale wing
#

Check these two messages everyone who uses heroku/replit

slate swan
slim ibex
#

Yes

junior verge
slate swan
junior verge
#

you need one

slate swan
#

oh whats inside it

slim ibex
#

It spins up a web server and it gets hairy from there on out

junior verge
#

pip freeze and put it in a requirements.txt

slate swan
junior verge
#

go dms

slim ibex
#

๐Ÿ—ฟ

azure scroll
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)
azure scroll
#

i want the bot to be able to enter and exit vcs only

oak warren
#

well we dont know the source of the music

#

thats why !ytdl

rustic coral
#

Guys, I don't have money to buy a vps. What will I do?

oak warren
rustic coral
velvet compass
slate swan
oak warren
boreal ravine
slate swan
slate swan
slate swan
#

sure

azure scroll
#

and which ToS breaking project are you talking about?

slate swan
azure scroll
boreal ravine
azure scroll
slate swan
unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.

This requires [`voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
slate swan
#

Ig you're looking for this

azure scroll
#

thanks

velvet compass
# azure scroll not now

So you used ytdl to get your music for your music bot....and now you want help with that music bot.

slate swan
#

then what do u use

velvet compass
#

In your own words "not now" implying that it was used previously.

azure scroll
#

no

slate swan
#

@azure scroll you should just tell, in reagarding what you need help for
if it's against Tos, they'll say to stop ;-;

slate swan
azure scroll
#

in the past or present

#

and i won't be asking ytdl help here

slate swan
#

no need of arguing with the mod?

azure scroll
#

and this is my first project. u r probably mistaking me for someone else

slate swan
#

@slate swan how to get req for my current project

slate swan
#

i have a folder

azure scroll
slate swan
slate swan
slate swan
dull sorrel
slate swan
#

..

slim ibex
#

it isnโ€™t hard to make a requirements.txt ๐Ÿ—ฟ

slate swan
#

lol

slate swan
#

so i need to write

slim ibex
#

literally do pip freeze requirements.txt

slate swan
latent anchor
#

how do i download python on chromebook

slate swan
#

it show error

#

ERROR: No matching distribution found for pywin32==303
! Push rejected, failed to compile Python app.

slate swan
#

ok

slim ibex
#

Oh wait no

#

You should use a venv if you arenโ€™t already doing so

slate swan
#

?

#

.

slate swan
#

huh/.

#

ok so tell the steps

slim ibex
#

pip freeze > requirements.txt

slate swan
slim ibex
#

rip

#

yeah this is why you want a venv

#

!pip pipenv

unkempt canyonBOT
slate swan
slate swan
#

i.e aiohttp == "0.0.0"

boreal ravine
slate swan
#

railway station

slate swan
boreal ravine
slate swan
#

try it, it would probably raise a unknown module error or missing import

#

python3 -m venv env-env

#

try and except blocks always need to be a pair

slate swan
#

Idkidk

boreal ravine
slate swan
#

so a try statement needs a except hence the name try except code blocks

#

indents

boreal ravine
#

Unindent except

slate swan
#

...

#

a fellow sublime userworksonmymachine

#

lol

#

yall mad sublime takes 40mb of ram

#

we dont talk about it

slate swan
slate swan
#

same goes for you

#

the spacing

slate swan
#

try except

#
  • you can install pyright to sublime ;))
#

idk ask okimii, I'm gonna cry

slate swan
#

!try

unkempt canyonBOT
#

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

A full traceback could look like:

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

If the traceback is long, use our pastebin.

boreal ravine
boreal ravine
slate swan
#

i thought it was the alias smh

#

!indents

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

slate swan
#

it should be in the same level

boreal ravine
#

It means from py try: ... except Exception: ... you do ```py
try:
...
except Exception:
...

slate swan
#

sublime wont let you know the errors without extensions until the runtime

slate swan
#

nope

boreal ravine
#

No

#

move it backwards, not forwards

slate swan
cold sonnet
#

thanks for the token

spring flax
#

delete this

maiden fable
slate swan
#

like this

slate swan
cold sonnet
#

good

spring flax
#

there's no way to check if a member has DM's closed without DMing him right?

boreal ravine
slate swan
#

no need of all that env i just removed the error causing requirement

slate swan
slate swan
slate swan
slim ibex
#

That if statement should be in the try block

slate swan
#

again, read the chats above.

slate swan
#
try:
   print("hi")
except:
   print("hello")
slate swan
spring flax
cold sonnet
#

indents and await sent.delete()

slate swan
slate swan
#

try if except huh?

#

new syntax?

#

You can't have a if statement between the try and except.

slate swan
# slate swan intellisense*
slim ibex
#

๐Ÿ’€

#

Move the if inside the try

cold sonnet
#

send undefined

#

await sent.delete()

slate swan
#

meh, sublime is still trash

#

no reason lmao

cold sonnet
#

did u say meh

slate swan
#

What's that random \ฬ€ on line 26?

slate swan
cold sonnet
#

meh

slate swan
#

Doesn't it give you an error?

#

its just not highlighted because of his color theme

#

deployed now how to run on heroku

cold sonnet
#

what

#

I pointed out it's undefined

slate swan
#

What is it?

cold sonnet
#

I just pointed it out!

slate swan
slate swan
vale wing
#

The token

slate swan
#

youre trying to call a set obj

cold sonnet
slate swan
vale wing
#

Also @bot.commands wut

slate swan
slate swan
vale wing
#

Oh k

slate swan
#

what do i need to put in

slate swan
# slate swan no.

U need it, it tells heroku to use "the language inside the file" whatever that is

slate swan
#

ok

#

language + version

#

python-3.10.3

cold sonnet
#

doesn't heroku only need procfile

slate swan
slate swan
cold sonnet
unkempt canyonBOT
#

Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
#

@slate swan i have deployed it but??

#

how to remove??

#

or somethnh

#

remove wut the rep?

#

ye

#

eh just click on diconnect?

#

alr

#

huh?

#

lemme show u

#

no

slate swan
#

Mmm

#

i was not telling "huh?" to u

#

Ohjoe_salute

#

a guy just camed

#

and doing "!await channel"

#

so i reacted

#

!await sparky.ban(reason="idk")

#

Failed to build backports.zoneinfo
ERROR: Could not build wheels for backports.zoneinfo, which is required to install pyproject.toml-based projects

#

hu

slate swan
#

bruh?

#

Are u usinf cogs?

slate swan
#

Then remove self

#

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

tf

cold sonnet
#

too late

slate swan
#

what was that

slate swan
slate swan
#

Can i see wut ur Procfile and requirements files look like?

#

@junior verge

#

why u added?

#

"anything happen"?

#

๐Ÿ˜

cold sonnet
#

hate to see it

slate swan
#

+old video

#

omg i used to do that

#

bruh????

#

show ur whole python file

#

its 2022

slate swan
slate swan
#

@slate swan add backports to your requirements.txt

unkempt canyonBOT
#

Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

cold sonnet
slate swan
#

whats that

#

?

cold sonnet
#

god zaidorox how many times

slate swan
slate swan
slate swan
#

yes lol

slate swan
cold sonnet
#

your prefix is +

slate swan
#

what are they

cold sonnet
#

not _

slate swan
#

where do i get them!??!

#

ok

cold sonnet
#

try +name

slate swan
#

rip yt + stack overflow = ๐Ÿ’€

cold sonnet
#

such false naming

slate swan
#

nice

#

@slate swan

#

what do i put?

cold sonnet
#

and it's member.add_roles, not role

slate swan
slate swan
cold sonnet
#

didn't even remove self

#

did u

slate swan
cold sonnet
#

nah

slate swan
#

๐Ÿคฃ

#

jk

cold sonnet
#

no

#

I see it

#

async def name

paper sluice
#
def name(self, ctx)```
unkempt canyonBOT
#

Hey @slate swan!

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

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

dont mind ik many useless

#

@slate swan

#

MASS PING

#

Wait lemme get my glasses i cant see ur codes

#

looking for my glasses

cold sonnet
#

cap

slate swan
#

..

#

@slate swan dont read that

#

i just copied whole github website

#

there

#

Oh thank god lmao

#

read this

#

It looks ight751522536704966877

#

i did this lmao

slate swan
slim ibex
#

is that all your dependencies?

slate swan
#

lol

slim ibex
#

you probably donโ€™t even use 1/4 of those for the project

#

this is why you need a venv

slate swan
#

do this cause error?

slim ibex
#

?

slim ibex
#

You are basically saying those packages are required but they arenโ€™t used in the project

#

you are going based off your globally installed packages

#

You need to isolate your dependencies to one encironment

slate swan
#

ok

slim ibex
#

!pip pipenv

unkempt canyonBOT
slate swan
#

i cant find virtual env commands

#

@slate swan do u mean

slate swan
slim ibex
#

does requirements.txt support semantic versioning?

slate swan
#

some complex words

slate swan
#

IM RATE LIMITED!!

slim ibex
slate swan
slate swan
#

..

#

np gg

#

deploying\

slate swan
#

๐Ÿ˜ก

#

๐Ÿฅฒ ๐Ÿ’€

slate swan
#

do some web search ๐Ÿ˜”

gaunt ice
#

hm

slate swan
#

๐Ÿ™Œ

slim ibex
#

What are you deploying on?

slate swan
#

googling errors is very bad expe for me

slate swan
slim ibex
#

Donโ€™t host bots on herokuโ€ฆ

slate swan
#

stop

#

my wish!!!

slim ibex
#

?

slate swan
#

Not even matching the search stack overflow god

#

google

paper sluice
#

does type hinting this, change the type?

async def func(ctx, member: discord.Member):
  ...
#

cool

slate swan
velvet compass
#

Type hints are just hints, it won't convert something

slate swan
#

they are just for the readability

#

you need to use converters

#

for actual conversion of data types

#

;-;

paper sluice
#

ok

slate swan
#

ash i cant find something

paper sluice
#

the ones where they tag

slate swan
#

sadly

velvet compass
#

That is saying that func is expecting an input of a discord.Member

slate swan
#

dpy converts the string to the obj

slate swan
dense swallow
#

if a server doesnt have an avatar it returns None.. so how can i display another image in place of that in set_thumbnail

slate swan
dense swallow
#

i cant use or ?

slate swan
#

no

dense swallow
#

url = ctx.guild.icon.url or "link"

slate swan
#

Like```py
if member.avatar:
embed.set_thumbnail()
else:
embed.set_thumbnail()

#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar```
Returns the memberโ€™s display avatar.

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

New in version 2.0.
dense swallow
#
        if ctx.guild.icon.url is None:
            em.set_thumbnail(url="https://logos-world.net/wp-content/uploads/2020/12/Discord-Logo.png")
        else:
            em.set_thumbnail(url=ctx.guild.icon.url)
``` this works too right?
slate swan
#

Sure, test it.

#

I don't think ctx.guild.icon.url is a thing, but alright.

#

it is

#

Great

#

.

boreal ravine
#

it is in v2.0 and above

#

@unkempt canyon's doc command uses master docs

#

icon_url was deprecated in 2.0

slate swan
#

That's sad.

dull sorrel
dull sorrel
slate swan
placid skiff
outer flint
#

can I manipulate the size of the embedMaker?
for example I would like to make so the image is bigger and maybe accept .dds imagesthinko

dull sorrel
placid skiff
#

D_D

outer flint
placid skiff
dull sorrel
outer flint
#

ok handscry

dull sorrel
#

This is all I wrote lol.

slate swan
#

!d discord.Guild.emojis

unkempt canyonBOT
placid skiff
#

if it will be bot you'll need a lot of checks, you will need to use regex to check for custom emoji

dull sorrel
#

This is what I want to do.

placid skiff
#

Yeah but server emojis and unicode emojis are completely two different things

dull sorrel
#

Not server emojis.

#

Unicode.

slate swan
#

iara_smart_smirk_smug then make a list? And use random.choice? Idk what you really want

fresh iron
#

Traceback (most recent call last): line 2, in <module> from discord.ext import commands ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

dull sorrel
placid skiff
#

lol making a list of all unicode emoji will be a very long list
There are some package which implements unicode emoji, he could find one of them

dull sorrel
#

I just want to send 1 emoji. ;-;

dull sorrel
#

Just tell me this, how do I make the bot to respond to someone with my command?

fresh iron
#

does anyone know why i keep having this error Traceback (most recent call last): line 2, in <module> from discord.ext import commands ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

placid skiff
dull sorrel
placid skiff
#

i will do a test now

#

!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/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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
placid skiff
#

Sorry master xD

placid skiff
slate swan
fresh iron
#
import discord 
from discord.ext import commands

bot = commands.Bot(command_prefix="!")

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

whats wrong with this code??

dull sorrel
placid skiff
#

!d discord.Message.reply then this

unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.

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

i wanna see what he will do with this so don't reply to him with the code please D_D

dull sorrel
placid skiff
slate swan
fresh iron
#

pip install discord

slate swan
fresh iron
#

hmmm

slate swan
unkempt canyonBOT
hoary cargo
#

hmm wonder what you installed

fresh iron
#

then wtf did i install instead

slate swan
hoary cargo
#

!pypi discord

unkempt canyonBOT
slate swan
#

virus

#

Mirror

fresh iron
#

C:\Users\ramzi>pip install discord.py
Requirement already satisfied: discord.py in c:\users\ramzi\appdata\local\programs\python\python310\lib\site-packages (1.7.3)

#

i believe i have that installed too

slate swan
#

Well idk

#

Ur code is fine

hoary cargo
#

Uninstall both and install dpy again CatAwk

slate swan
fresh iron
#

Traceback (most recent call last): File "c:\Users\ramzi\OneDrive\Desktop\Ramsaist.py", line 2, in <module> from discord.ext import commands ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

#

okay

dull sorrel
hoary cargo
fresh iron
#

do you know what that can be fixed through

jolly basalt
#

not really a discord.py question but, can anybody suggest some nice math solving api's

#

and preferably, it should be free

velvet compass
#

Wolfram Alpha maybe