#discord-bots

1 messages · Page 87 of 1

primal token
#

It initiates it, doesnt quite construct it

slate swan
#

generally speaking, __new__() is the allocator, __init__() is the initializer, but both are constructors (__new__() can do __init__()'s job as well).

pliant gulch
#

Initiate is the same thing as construct though

slate swan
#

super simple.

primal token
#

Because in my eyes, constructor is like building a house, while an initater is actually painting and making the house look actually great and "liveable".

slate swan
#

Poor analogy

sick birch
#

Folks I love the discussion but could we move it to either an OT or maybe #internals-and-peps? thanks

slate swan
#

Oh, sorry.

primal token
slate swan
#

Lol that's why it's a poor analogy

#

I do kind of see your point but still not gonna give it to you

primal token
#

ok

valid void
#

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

this is causing a error did i format it wrong?

#

or is it all wrong

slate swan
#

If I needed help with my python discord bot would I get it here?

pliant gulch
# primal token Because in my eyes, constructor is like building a house, while an initater is ...

This analogy does not work, simply for the fact that a “house” is a term which means a collective of other things. A house has plumbing, walls, foundations and rooms. Let’s take this into programming terms, where does dict come into place? Where does the bases come from? Where does the name come from? It comes from new but what are they? They are attributes. Yes crazy the constructor declares variables into the class namespace. What does the init do? It declares variables into the instance namespace. Now what if we take what you said to the extreme? Constructor makes the house, but what is the house without its “attributes”? Is this just foundation, is this just pavement? Can it then be truly called a house?

slate swan
slate swan
slate swan
wanton fractal
#

as they are a new feature in discord's api that allow you to even start the bot

slate swan
#

?

slate swan
#

But I will try, yes :)

primal token
#

Intents dont even exist in the discord REST API

valid void
slate swan
slate swan
slate swan
#

im using VSCode so if you want a Live Share link I can DM you one

wanton fractal
#

what exactly is default_permissions for

wanton fractal
#

that's my question

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.

wanton fractal
#

do you mean to import intents?

slate swan
#

!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
# slate swan What are you trying to do? And why are you trying to do this import?
@commands.cooldown(1,10,commands.BucketType.channel)
@default_permissions(manage_messages=True)
async def purge(ctx, amount_to_delete: int = 0):
    if amount_to_delete < 1 or amount_to_delete > 200:
        await ctx.send('You need to enter a value between 1 and 200')
    else:
        await ctx.channel.purge(limit=amount_to_delete)
        await ctx.response.send_message(content=f"Sucsessfully purged {amount_to_delete} messages!", ephemeral=True)```
slate swan
#

Stuff can go wrong, you can handle permissions wrong, expose secrets/tokens, etc.

slate swan
slate swan
#

That's not the point

valid void
#

idk how to work with intents

wanton fractal
slate swan
#

intents = discord.Intents.all()

slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
slate swan
#

Did you mean to use this instead?

valid void
slate swan
slate swan
valid void
slate swan
#

so from discord.ext.commands import default_permissions?

primal token
slate swan
wanton fractal
#

are you trying to check the permissions of a user

wanton fractal
#

then yes what @slate swan posted above

slate swan
#

I can send you the code part I use it in

wanton fractal
#
@commands.has_permissions(manage_messages=True)
primal token
valid void
pliant gulch
pliant gulch
wanton fractal
#

@valid void

valid void
pliant gulch
slate swan
wanton fractal
slate swan
#

@slate swan

from discord.ext import commands

@commands.has_permissions(...)

Like this.

narrow axle
#

got a question, when I have a discord bot and its coding, there's an API I made with it, am I allowed to ask for help here?

slate swan
slate swan
#

You didn't understand it, so I elaborated.

#

oh

#

ic

slate swan
#

Not sure, you tell me.

#

!d discord

unkempt canyonBOT
#

In order 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
narrow axle
#

this is what they mean

narrow axle
primal token
slate swan
#

I mean that is exactly what __init__() does usually

slate swan
# narrow axle for a slash command, it would be this:

bc this is one of my / commands

@client.slash_command(guild_ids=GIDS, description='Bye-bye, Messages..')
@commands.cooldown(1,10,commands.BucketType.channel)
@commands.has_permissions(manage_messages=True)
async def purge(ctx, amount_to_delete: int = 0):
    if amount_to_delete < 1 or amount_to_delete > 200:
        await ctx.send('You need to enter a value between 1 and 200')
    else:
        await ctx.channel.purge(limit=amount_to_delete)
        await ctx.response.send_message(content=f"Sucsessfully purged {amount_to_delete} messages!", ephemeral=True)```
pliant gulch
#

I’m still wondering what you have to say with “houses” though?

slate swan
#

(I use @client instead of @bot)

primal token
narrow axle
#
import discord
from discord.ext import commands


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

@bot.event
async def on_ready():
  print(f"{bot.user} is ready")
  
  bot.tree.sync()

tree = bot.tree

@tree.command(name="hello")
async def hello(interaction:discord.Interaction):
  await interaction.response.send_message("Hi")
narrow axle
#

bot.tree.sync is to sync all your slash commands so it works

primal token
pliant gulch
narrow axle
pliant gulch
narrow axle
#

there

slate swan
#

like-

#

For the import I have to do?

pliant gulch
# pliant gulch And why is a wall not an attribute??

You can have a house with no plumbing sure, you can have a house with no doors, sure. You can have a house with no walls, no roof sure. Then what is a house exactly? The point I’m asking you is. Is a class really a class without state, without dict without name, etc

narrow axle
pliant gulch
#

My point being a class is not one thing rather a collection of things

#

Hence namespace .

slate swan
narrow axle
#

never heard of "default_permissions"

#

whar are you tryna do

slate swan
# narrow axle never heard of "default_permissions"
@client.add_command(guild_ids=GIDS, description='Bye-bye, Messages..')
@commands.cooldown(1,10,commands.BucketType.channel)
@default_permissions(manage_messages=True)
async def purge(ctx, amount_to_delete: int = 0):
    if amount_to_delete < 1 or amount_to_delete > 200:
        await ctx.send('You need to enter a value between 1 and 200')
    else:
        await ctx.channel.purge(limit=amount_to_delete)
        await ctx.response.send_message(content=f"Sucsessfully purged {amount_to_delete} messages!", ephemeral=True)```
narrow axle
#

???

slate swan
pliant gulch
#

Exactly why init is a constructor

slate swan
#

that's kind of what "__init__() is not a constructor" sounds like to me

pliant gulch
#

Same with new

slate swan
#

__new__() exists just to shit on __init__() /s

wanton fractal
slate swan
#

it can do everything __init__() can and more kek

wanton fractal
#

you would need to import commands like timtoy said

slate swan
pliant gulch
slate swan
#

immutable ones

pliant gulch
#

Yep or the cursed way. Ctypes

slate swan
#

I don't touch that module, it makes no sense to me

#

I understand C better than the ctypes module

pliant gulch
#

I like touching it, only to say I can

#

The only thing I use it for it to override built ins

slate swan
#

Like wtf is ctypes.py_object

#

why does it exist and what does it do

pliant gulch
#

Make pointers

slate swan
#

ctypes is just a wrapper around c for a language built with c. nice.

narrow axle
# slate swan ```py @client.add_command(guild_ids=GIDS, description='Bye-bye, Messages..') @co...
from discord import app_commands
tree = client.tree

@tree.command(guild_ids=GIDS, description='Bye-bye, Messages..')
@app_commands.cooldown(1,10,commands.BucketType.channel)
@app_commands.has_permissions(manage_messages=True)
@app_commands.describe(
  amount_to_delete = "The amount of messages to purge"
)
async def purge(interaction:discord.Interaction, amount_to_delete: int = 0):
    if amount_to_delete < 1 or amount_to_delete > 200:
        await interaction.response.send_message('You need to enter a value between 1 and 200')
    else:
        await interaction.channel.purge(limit=amount_to_delete)
        await interaction.response.send_message(content=f"Sucsessfully purged {amount_to_delete} messages!", ephemeral=True)
pliant gulch
slate swan
#

hold on my brain is hurting

pliant gulch
#

I know ironic

slate swan
#

I have other commands too

slate swan
#

(trust me)

wanton fractal
#

it'll suck

slate swan
#

and it's going to be in waves

wanton fractal
#

but you'll get the hang of it

slate swan
#

unforgiving and disorienting

wanton fractal
#

absolutely hammering

slate swan
#

i still write terrible code and i've been doing this for long enough

#

AAA it was just working a week ago

primal token
# pliant gulch You can have a house with no plumbing sure, you can have a house with no doors, ...

Ok so let me give an example on my view of my point

class House:
    ...

This is a declaration of the class object House this is the blueprint, while __new__ is like the employees that create the base stucture like walls and the floor and roof etc, while __init__ is like the architect that creates the design of the actual house like its inside stucture and/or the mapping of the rooms which would be the names set to that unique home/instance that point to something like a variable that may contain a container type.

primal token
pliant gulch
#

Is a floor a house?

#

Is a roof a house?

#

Also using your logic, that means the employees create the foundation, the walls etc before an architect even designs them. Devastating

slate swan
pliant gulch
# pliant gulch Okay so answer this for me, is a wall a house?

Let's say I have a "house" with 4 walls, 1 in each direction. What is the wall to the west? Is it a house, no. Is it a wall? Yes. Then what about all the walls in total, are they are house? Sure. My point being here, a wall is not a house but a house is a wall(s) (sounds weird but if you think about it long enough). I'm using this analogy also for classes, you have a class yes py class House: ... so then, let's break this down. py House.__name__ # A name, but not a house House.__mro__ # The bases, but not a house House.__dict__ # The namespace, but not a house So then, what happens if you just do ```py
House

wanton fractal
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
#

a

slate swan
wanton fractal
#

what error is being thrown

slate swan
sick birch
#

Maybe you're looking for @client.command()?

wanton fractal
slate swan
sick birch
slate swan
robust fulcrum
#
url = "https://discord.com/api/v8//users/@me/channels"

Guys i am send dm through api using requests
Where do I need to pass it user id?

sick birch
#

Are you trying to make a slash command or a text command?
From guild_ids I can infer you're making a slash command
From @client.command() I can infer you're making a text commands

pliant gulch
#

That is completely the wrong endpoint to be using for DMs

#

And in fact, that would only make "sense" if you were self-botting

#

Thinking to DM users in your DMs

robust fulcrum
pliant gulch
#

Yes

robust fulcrum
#

I am not self botting and I'll use this api in my website to make a contact page

robust fulcrum
sick birch
pliant gulch
#

I am totally wrong lmao

sick birch
#

Were you talking to me?

pliant gulch
#

No my own message

primal token
# pliant gulch Also using your logic, that means the employees create the foundation, the walls...

That was my fault, let me re word it, The architect would be the person creating the class object, so the blueprint, while the __new__ creates its base structure, which yes, __new__ can make other things as you said, its not always the base structure for a building and then the __init__ method would "hire" the plumbers and electricians that come and make it a functional building and then since you planned out attributes, rooms and other designs, __init__ would hire other employees and to set attributes to that just created building/instance, making it a building/instance with attributes, building as in structure that may have offices/attributes etc

pliant gulch
#

I said that @me/channels was wrong but that creates the DM channel object

#

It's been a while since I touched DAPI

sick birch
pliant gulch
primal token
#

I did, im reading your other message currently

pliant gulch
#

Okay one last analogy then let's switch the perspective into something less abstract than houses okay?

pliant gulch
#

Is a wall, a house?

#

Okay now let's talk OOP

#

OOP consists of a few key points, polymorphism, encapsulation to name a few

#

Now, let's say we have a "class" but it has no __mro__, tell me, is polymorphism still possible?

#

Now lets say we have no methods, no setters, no attributes, is encapsulation still possible?

#

Is this truly what a class is, considering OOP principles?

#

I don't really see the point in saying any more, just know my key point here is, __init__ is a constructor, because: It sets attributes, basically the state of the instance being created, and without that you have lost most of the OOP principles

#

Attributes are very important here, you have no class without attributes really

#

You can argue all you want and say, okay well __new__ allocates memory for the class, but then if you really go to that level, the class is really no longer a class in OOP but rather just allocated heap memory

primal token
pliant gulch
#

You have to use __new__ and __init__ together by design

#

But you're missing a lot without __init__ so thats enough for me to call it a constructor

slate swan
#

(i can’t type in on a phone lol give me a break)

slate swan
#

and please not the house analogy, it’s been going on for too long lol

#

this madness has been going on for 1.5 hrs

#

stahp

pliant gulch
#

I've had enough of programming talk for a night lol

#

I'm ready to put this to a close

primal token
primal token
#

😔

slate swan
primal token
#

fight me👊

slate swan
#

they are both constructors

pliant gulch
#

I'm not arguing towards the __init__ specifically, rather closer to the abstraction of setting state

#

Without state you have no OOP, therefor you have no class

slate swan
#

especially if you’ve used languages where the constructor itself doesn’t handle the creation of the object

pliant gulch
#

C be like ```py
malloc(sizeof Struct FOO)

slate swan
#

python simply gives you more control over that process

pliant gulch
#

😩

slate swan
#

which is why new exists

pliant gulch
#

C

#

unless you were responding too yourself

#

In which case I am sorry kek

slate swan
#

init and new are both constructors, end of discussion i think

pliant gulch
#

Yes

primal token
#

Anyways thanks for the discussionducky_beer

slender scarab
slender scarab
sick birch
#

Nope

slender scarab
#

i distinctly remember that can be done

sick birch
#

You've never been able to edit other user's message, manually or via bot

slender scarab
#

mandela effect?

sick birch
#

Probably :P

slender scarab
#

how is a timeout removed though

vale wing
# slender scarab manually, that can be done, right?

Imagine what kind of hell would happen if everyone was able to edit anyone's message — clowns and selfbots would start to edit all the messages to like "I have an attraction to cheese"; such ability makes no sense

slender scarab
vale wing
#

Why not just delete them

vale wing
#

That's what I did for my word filter, for example if someone says "this fricking thing is stupid" and "stupid" and "frick" are blacklisted, it will resend author's message like "this #####ing thing is ######"

wanton fractal
#

like edit other peoples messages?

#

if so, that fortunately cannot be done

wanton fractal
brazen stag
#

Can anyone could help me with some errors?

#

Well i have a similar error with it Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000017DFFA45F30> Got this message after intents = discord.Intents.all()

vale wing
#

You can interaction.followup.send only after interaction.response.send iirc

vale wing
brazen stag
#

ok.

vale wing
#

This isn't the full code

#

And the problem is not in intents

brazen stag
#

It is,

vale wing
#

Do you use a database

naive briar
brazen stag
#

This is the error.

vale wing
#

Nah instead of interaction.followup.send do interaction.response.send

vale wing
brazen stag
#

What's a database?

vale wing
#

Seems like you don't

#

This error commonly occurs if you have unclosed connections when shutting down the bot

vale wing
# brazen stag

But this code is definitely not a full one because the bot doesn't even get run here

brazen stag
#

It is a full code, only to make the bot online.

slate swan
#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
naive briar
#

Put the interaction.response.defer at the top of the command

slate swan
#

or, edit_response if it was deferred

naive briar
#

And use interaction.followup.send to respond

naive briar
#

Yup 🫠

slate swan
brazen stag
#

Wait,

brazen stag
slate swan
#

and reset your token because it appears in the error above

brazen stag
#

ok

#

Worked, ty.

gusty shard
#
@commands.cooldown(1,10,commands.BucketType.user)
@bot.command(aliases=["coinflip"])
async def cf(message, sayi=int):
    id = str(message.author.id)
    if id in data:
        if data[id]['cash'] < sayi:
            await message.reply("You don't have that much money.")
        elif sayi <= data[id]['cash']:
            data[id]['stats']['gamble'] += 1
            sonuc = random.randint(1,2)
            if sonuc == 1:
                embed=discord.Embed(color=0xfbff00)
                embed.add_field(name=f"Coin landed on head!", value=f"You won $**{sayi}**.", inline=True)
                await message.reply(embed=embed)
                data[id]['cash'] += sayi
                data[id]['sccsgamble'] += 1
                data[id]['max money'] += sayi
            else:
                embed=discord.Embed(color=0x740202)
                embed.add_field(name=f"Coin landed on tail!", value=f"You lost $**{sayi}**.", inline=True)
                await message.reply(embed=embed)
                data[id]['cash'] -= sayi
                data[id]['losted money'] += sayi

            with open("values.json", "w") as f:
                json.dump(data,f,indent=4)
    else:
        await message.reply("You dont have an account yet, you can start your journey with `.start`")
@cf.error
async def cf_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.reply(f'Command is on timeout, you have to wait `{round(error.retry_after * 1)}` more seconds.',delete_after=error.retry_after)```

that command is not working, im not getting any errors but bot does not respond with anything, can somebody help me please?
native reef
#

whtas problem ?

glad cradle
slate swan
# native reef whtas problem ?

you have the external asyncio lib that was for python versions when it didn't even have the async and await keywords, that is what's causing the issue

hasty bison
#
 await ctx.send(" **You do not have the required permissions to use this command.**")``` How can i mention the author of the command?
gusty shard
#

(sorry for ping)

#

thats what cash looks like

#

isnt it int too?

gusty shard
#

sayi=int

#

its already an int isnt it

slate swan
#

typehint

gusty shard
#

what is that

slate swan
#

hinting types

#

sayi is literally an int class holder

#

!e

def uwu(_=int):
  print(_)

uwu()
unkempt canyonBOT
#

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

<class 'int'>
gusty shard
#

data[id]['cash'] < int(sayi)

slate swan
unkempt canyonBOT
#

Type Hints

A type hint indicates what type a variable is expected to be.

def add(a: int, b: int) -> int:
    return a + b

The type hints indicate that for our add function the parameters a and b should be integers, and the function should return an integer when called.

It's important to note these are just hints and are not enforced at runtime.

add("hello ", "world")

The above code won't error even though it doesn't follow the function's type hints; the two strings will be concatenated as normal.

Third party tools like mypy can validate your code to ensure it is type hinted correctly. This can help you identify potentially buggy code, for example it would error on the second example as our add function is not intended to concatenate strings.

mypy's documentation contains useful information on type hinting, and for more information check out this documentation page.

slate swan
#

sayi: int
and not sayi=int

#

sayi=int will assign a default value to it

gusty shard
#

oh

slate swan
#

typehinting is a must to learn because even dpy expects typehints to parse arguments into specific objects

#

for example

@bot.command()
async def uwu(ctx: commands.Context, member: discord.Member):
  ...

where dpy will convert member to Member if applicable, if member was not typehinted with Member, member would have been an str

gusty shard
#

so what should i do now

slate swan
#

guys I need help

#

I did async def topic and wrote a massive list of responses

#

how do I make it send a random sentence from that list?

gusty shard
#

try random.choice(list)

slate swan
gusty shard
#

yes ig

slate swan
#

await ctx.send(random.choice(responses))

#

Aborting automatic restart, last crash occurred less than 60 seconds ago.

#

didn't work

#

lemme send the full code @gusty shard

gusty shard
#

!e

import random
list = ["a","b"]
print(random.choice(list))```
unkempt canyonBOT
#

@gusty shard :white_check_mark: Your 3.11 eval job has completed with return code 0.

a
slate swan
#
async def topic(ctx, *):
    responses = ["What songs do you like?", "What is your favorite movie/film/series?", "What was the most embarrassing thing you have ever done?", "What's one thing that can instantly make your day better?", "What's the best joke you've ever heard?", "What's the phone app you use most?", "What was the craziest thing you have ever done?", " Is there one job you’d never ever do?", "Do you play any games?", "What time do you sleep?", "What do you like the most about naruto?", "who's the best girl in naruto?", "What is your favorite character in naruto?", "What is your favorite Ninjutsu?", "What is your favorite Dojutsu?", "What was the funniest thing in naruto?", "Do you like boruto?", "Do you like any animals?", "What's the most expensive thing you have bought?", "What's the cheapest thing you have bought?"]
     await ctx.send(random.choice(responses))```
#

@gusty shard

gusty shard
#

can you send the error?

slate swan
#

I cant

#

but why

#

I did it on daki.cc so that I didn't waste time

native reef
#

plz Help meee

gusty shard
#

!e

import random
responses = ["What songs do you like?", "What is your favorite movie/film/series?", "What was the most embarrassing thing you have ever done?", "What's one thing that can instantly make your day better?", "What's the best joke you've ever heard?", "What's the phone app you use most?", "What was the craziest thing you have ever done?", " Is there one job you’d never ever do?", "Do you play any games?", "What time do you sleep?", "What do you like the most about naruto?", "who's the best girl in naruto?", "What is your favorite character in naruto?", "What is your favorite Ninjutsu?", "What is your favorite Dojutsu?", "What was the funniest thing in naruto?", "Do you like boruto?", "Do you like any animals?", "What's the most expensive thing you have bought?", "What's the cheapest thing you have bought?"]
print(random.choice(responses))```
unkempt canyonBOT
#

@gusty shard :white_check_mark: Your 3.11 eval job has completed with return code 0.

who's the best girl in naruto?
gusty shard
#

whats the problem

slate swan
gusty shard
#

dang

slate swan
#

!e

def _(arg, *):
  ...
_()
unkempt canyonBOT
#

@slate swan :x: Your 3.11 eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     def _(arg, *):
003 |                ^
004 | SyntaxError: named arguments must follow bare *
slate swan
slate swan
#

alr

#

I did but still crash

#

@slate swan

slate swan
#

I edited it to this

async def topic():
    responses = ["What songs do you like?", "What is your favorite movie/film/series?", "What was the most embarrassing thing you have ever done?", "What's one thing that can instantly make your day better?", "What's the best joke you've ever heard?", "What's the phone app you use most?", "What was the craziest thing you have ever done?", " Is there one job you’d never ever do?", "Do you play any games?", "What time do you sleep?", "What do you like the most about naruto?", "who's the best girl in naruto?", "What is your favorite character in naruto?", "What is your favorite Ninjutsu?", "What is your favorite Dojutsu?", "What was the funniest thing in naruto?", "Do you like boruto?", "Do you like any animals?", "What's the most expensive thing you have bought?", "What's the cheapest thing you have bought?"]
     await message.send(random.choice(responses))```
gusty shard
#

just change print into ctx.send

#

or message.send

slate swan
gusty shard
slate swan
slate swan
gusty shard
#

remove the *

slate swan
#

I removed that already

#

remove the asterisk after ctx in the parameter definition

slate swan
gusty shard
#

async def topic(ctx):

slate swan
#

^

slate swan
#
async def topic(ctx):
    responses = ["What songs do you like?", "What is your favorite movie/film/series?", "What was the most embarrassing thing you have ever done?", "What's one thing that can instantly make your day better?", "What's the best joke you've ever heard?", "What's the phone app you use most?", "What was the craziest thing you have ever done?", " Is there one job you’d never ever do?", "Do you play any games?", "What time do you sleep?", "What do you like the most about naruto?", "who's the best girl in naruto?", "What is your favorite character in naruto?", "What is your favorite Ninjutsu?", "What is your favorite Dojutsu?", "What was the funniest thing in naruto?", "Do you like boruto?", "Do you like any animals?", "What's the most expensive thing you have bought?", "What's the cheapest thing you have bought?"]
     await ctx.send(random.choice(responses))```
#

so like this

gusty shard
#

yea

slate swan
#

yes that will work

#

Aborting automatic restart, last crash occurred less than 60 seconds ago.

#

still crashed

#

error.

#

there is no error tho, I'm on daki.cc

#

why don't you debug and then deploy apps

gusty shard
#

can you make sure this line is correct

slate swan
#

@bot.command 😔

#

imagine defining static variables inside commands

slate swan
gusty shard
slate swan
#

ehm wat?

gusty shard
#

change bot.command into @bot.command

slate swan
#

OH YES

#

IM SO DUMB

#

that shouldn't cause a crash though

#

yeah

#

unless the servers are quite shit

#

lets see now

#

OK DIDNT CAUSE A CRASH

#

nextcord.ext.commands.errors.CommandNotFound: Command "topic" is not found

#

it shows this tho why, @slate swan

#

code

#

@bot.command
async def topic(ctx):
responses = ["What songs do you like?", "What is your favorite movie/film/series?", "What was the most embarrassing thing you have ever done?", "What's one thing that can instantly make your day better?", "What's the best joke you've ever heard?", "What's the phone app you use most?", "What was the craziest thing you have ever done?", " Is there one job you’d never ever do?", "Do you play any games?", "What time do you sleep?", "What do you like the most about naruto?", "who's the best girl in naruto?", "What is your favorite character in naruto?", "What is your favorite Ninjutsu?", "What is your favorite Dojutsu?", "What was the funniest thing in naruto?", "Do you like boruto?", "Do you like any animals?", "What's the most expensive thing you have bought?", "What's the cheapest thing you have bought?"]
await ctx.send(random.choice(responses))

#

you're missing () after command, and bad indentation for the await ctx.send

#

I don't even want to comment at this point

#

works!!

#

thanks a lot! @slate swan and @slate swan

gusty shard
#

bro..

slate swan
#

and you too @gusty shard

gusty shard
slate swan
feral frost
#

guys

#

anyone knows how to make an is_owner command in slash bot ?

native reef
feral frost
#

code?

native reef
feral frost
#

yes

native reef
#

code is currect

feral frost
#

you sure ?

native reef
#

yes bro

#

send code again ?

feral frost
#

yes

native reef
#

i have token but not coded in vs

feral frost
#

ye its not safe if you put it in here

native reef
feral frost
native reef
native reef
feral frost
#

ok well smth wrong with importing discord

#

try uninstalling it and reinstalling

feral frost
tidal hawk
#

npc talk

feral frost
#

ok

native reef
feral frost
#

why do you want to know ?

#

its prob the latest

#

idk

tidal hawk
feral frost
tidal hawk
#

well i'm not sure if you can hide the command from others, but you can do a check inside slash command

feral frost
#

for text commands it is @commands.is_owner() can it be that simple in slash commands ?

#

ok

feral frost
#

ow

tidal hawk
#

There's some stuff there regarding the permissions

feral frost
#

ok thanks

tidal hawk
#

But you can always do a is_owner check inside the command

feral frost
#

ye

#

i thought it was possible to hide it for others

#

guess not

slate swan
#

you can hide it from everyone but not server owners & admins

feral frost
#

k

slate swan
#

guys I want to code an op economy bot, anyone wants to help?

gusty shard
#

its not that easy

#

you should improve your python skills first

slate swan
tidal hawk
#

What are you going to use as database?

slate swan
#

btw should I learn js?

#

or stick with python

tidal hawk
#

Depends what do you want to do in the future

slate swan
#

naruto economy bot

tidal hawk
#

I'd use Python for that

slate swan
#

can u help me to make it?

gusty shard
#

no one will write code for your bot

slate swan
#

no I mean help

gusty shard
#

code as much as you can and come here when you get stuck

slate swan
#

or wait

#

I got another idea

native reef
#

Whats Wrong ?

gusty shard
glad cradle
#

and what's the error that you're getting

native reef
gusty shard
#

did you install discord?

native reef
slender stirrup
#

how can i log timeout event

#

i need to get time and reason

quick brook
slate swan
quick brook
slender stirrup
quick brook
slate swan
quick brook
thorn seal
#

what is a good and cheap hosting service?

slate swan
#

wtf

slate swan
#

nice, ash

#

lmao why'd you see that

quick brook
slate swan
#

make an API instead

quick brook
slate swan
#

by api i mean a simple local interface, not a web tool

tidal hawk
slate swan
#

but still 3-6 months seem excessive if you got experience with python ¯_(ツ)_/¯

tidal hawk
#

Mhm

slate swan
#

lmao

brazen stag
#

I got a yellow line beneath the client, how can I fix? async def my_background_task(): await client.wait_until_ready() channel = discord.Object(id='992654876989460484') while not client.is_closed: await client.send_message(channel, "Task") await asyncio.sleep(5)

slate swan
#

i can see 3 clients there, which one are you talking about

brazen stag
#

All

#

Should i do pip install?

slate swan
#

is "client" variable defined above that function?

#

wtf no why would u pip install it

brazen stag
#

its not defined

slate swan
#

how did you get that code then?

#

client there should be ur discord.Client or commands.Bot object

wanton fractal
slate swan
#

client.send_message is not a thing anylonger tho

#

totally stackoverflowed code

limber bison
wanton fractal
slate swan
#

instead, create button classes inside the loop

#

how would i check

#

say like a string is 5e712ecf-2fbb-4f37-a462-155917378803 , how would i check how many "-" are in said string

limber bison
wanton fractal
limber bison
#

me blank

wanton fractal
#

see how many strings are separated using .split("-")

slate swan
unkempt canyonBOT
#

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

4
wanton fractal
#

well yes then you ave that too

slate swan
#

but i want the bot the bot to say its invalid when are three or less -

#

wait actual you need the number of occurrences

#

you should use badboom's method

wanton fractal
#

thank you sarth

slate swan
#

or count function exists too

wanton fractal
#

probs count

wanton fractal
slate swan
wanton fractal
#

but they're a pain in the ass ic so you would want to check how many there are

limber bison
#

then how can i call loop ?

wanton fractal
#

so my idea around going about it would be ```py
whatever = "fufu-f-e-fefe--fe".split("-")

if len(whatever) <= 3:
... # you can figure out the rest

slate swan
#

!e print("yes" if "text with ---".count("-") > 3 else "invalid") #something like this

unkempt canyonBOT
#

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

invalid
wanton fractal
#

yes or use a ternary operator

toxic bluff
#
intents.typing = False
intents.presences = False
intents.message_content = True

client = commands.Bot(
    command_prefix="!",
    help_command= None,
    intetns= intents,
    sync_commands_debug= True
)```Why do I still get this warning: *MessageContentPrefixWarning: Message Content intent is not enabled and a prefix is configured* I also can't use the Prefix Commands on discord servers anymore, only in DM channels they're still working. I'am using disnake version 2.5.2 I also set the Privileged Gateway Intents in the discord developer Portal
wanton fractal
wanton fractal
slate swan
wanton fractal
#

there would be no need to define every other intent again

edgy tundra
wanton fractal
slate swan
slate swan
limber bison
glad cradle
wanton fractal
#

maybe something to do with the command's checker aswell

glad cradle
toxic bluff
#

I thought I already have the message_content intent by disnake.Intents.all

wanton fractal
#

yes

#

.all() will enable every single one

toxic bluff
#

but it's not working

wanton fractal
#

would you do me a favor and show me your code real quick

toxic bluff
#

with all intents enabled

wanton fractal
#

like the entire file without the token

toxic bluff
#

Can I send the code in this channel?

wanton fractal
#

yes

glad cradle
#

!d disnake.Intents.all

unkempt canyonBOT
#

classmethod all()```
A factory method that creates a [`Intents`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents "disnake.Intents") with everything enabled.
slate swan
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.

toxic bluff
wanton fractal
#

which command are you trying to call

limber bison
# slate swan they need to set a callback to each of them as well so i didn't do that
class PanelView(discord.ui.Select):
    def __init__(self):

        options = []

        for panel in config["Reaction Role Settings"]["Reaction Role Panels"]:
            options.append(discord.SelectOption(label=panel["Name"]))


        super().__init__(placeholder="Select a panel", options=options)
    
    async def callback(self, interaction: discord.Interaction):
        global currentpanel
        currentpanel = self.values[0]
        await interaction.response.send_message(f"Selected {self.values[0]}")

        for panel in config["Reaction Role Settings"]["Reaction Role Panels"]:
            if panel["Name"] == self.values[0]:
                actualview = discord.ui.View()
                roles = config["Reaction Role Settings"]["Reaction Role Panels"][panel]["Role ID List"]
                for key in roles.keys():
                    actualview.add_item(label=key)```

this will work for buttons callback to ?
wanton fractal
#

a slash command or just a regular command

#

@toxic bluff

glad cradle
slate swan
toxic bluff
#

for example the !help command is not working

wanton fractal
#

well

#

like me and sarth said intents is spelt differently

#

it wouldnt be intetns

toxic bluff
#

okay haha

wanton fractal
#

it would be intents=

edgy tundra
wanton fractal
#

if issues still persist come back here and i'll try to help

toxic bluff
#

Okay thank you its working now 🙂

limber bison
#

how can h create buttons in loop and also define callback for each ?

wanton fractal
slate swan
limber bison
wanton fractal
#

i'm confused, what exactly you are trying to do

limber bison
#

how can i share my long code ?

#

here ?

wanton fractal
#

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

wanton fractal
#

using this tutorial

#

or send me the file in dms and i'll try to help you

limber bison
#

this is my code

#

help if u can

wanton fractal
#

you have two poll classes defined

#

oh

#

thats an update, okay

limber bison
#

this a 4 ppl poll but i want to make it dynamic sooo

#

pls

#

how i start ?

wanton fractal
#

i don't really work with interactions/slash commands you should ask snipy or sarth as they have more knowledge

glad cradle
#

to add a callback to buttons of a list it should be

buttons_list = [buttonObj1, ...]
for i in button_list:
    i.callback = your_function

idk if that works properly but you can try it, if there's an error we'll fix it later

wanton fractal
#

was he just trying to add callback buttons to a list?

#

if so what you can do is you can just use snipy's method

glad cradle
#

from what I 've understood yes

wanton fractal
#

okay were you trying to loop over buttons and store them in a list? @limber bison

limber bison
wanton fractal
#

use snipy's method then

limber bison
glad cradle
#

btw there's a limit on how much buttons you can have

limber bison
#

🤔

wanton fractal
#

i defo need to learn how to use buttons and interactions

#

but what you could do is

#

you could just loop over the list of buttons

glad cradle
#

it's 5 buttons per Action Row, you can have a maximum of 5 Action Row per message

#

so it's 0 <= n <= 25

limber bison
slate swan
#

and a select menu counts as 5 buttons

edgy tundra
#

i stuck here

slate swan
cosmic anvil
#

So if I don’t need to read/react to a channel, but only to send text into a channel from time to time, I don’t need a bot? Just some code to make a post to some discord url? If so, can someone point me to examples in python please?

glad cradle
#

you could use webhooks

slate swan
cosmic anvil
slate swan
#

you just need a webhook and the rest api tbf

cosmic anvil
unkempt bone
#
        e = await ctx.respond(embed=discord.Embed(description="**Checking the API**",color=0x81fe8f))
        e = await message.delete()
#

why this doesn't work?

slate swan
unkempt bone
unkempt bone
slate swan
unkempt bone
unkempt bone
slate swan
#

You need message in .delete()

unkempt bone
#

????

slate swan
#
        message = await ctx.respond(embed=discord.Embed(description="**Checking the API**",color=0x81fe8f))
        await message.delete()
unkempt bone
#

lemme test

#
  File "C:\Users\i\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\i\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
    await injected(ctx)
  File "C:\Users\i\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 135, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Interaction' object has no attribute 'delete'
glad cradle
#

it's not commands.Context, he's using ctx for interaction

shrewd apex
#

is it some other api wrapper pithink not dpy

#

i don't think interaction has a respond either

glad cradle
#

maybe it's disnake

unkempt bone
#

no

shrewd apex
#

u can just use m = interaction.response.send_message()

unkempt bone
shrewd apex
#

then m.delete()

unkempt bone
#

thanks!

shrewd apex
#

f whats discord.Bot?

glad cradle
#

sus

unkempt bone
#

its needed for my bot

shrewd apex
#

use this

glad cradle
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
shrewd apex
#

its discord.Client -_-

#

and all its subclasses

unkempt bone
#

only discord.Bot

shrewd apex
#

🙏

glad cradle
shrewd apex
#

?

glad cradle
#

he's using discord.Bot and it's not a thing on discord.py, or am I wrong?

shrewd apex
#

nope its not a thing

unkempt bone
#

look

#

its not working

shrewd apex
#

u are not using dpy even

unkempt bone
#

with discord.Client

shrewd apex
#

bruh

#

discord.Client has nothing to do with this

#

thats just declaring a bot instance

#

its the command thats problematic ie u are not responding to the interaction

#

i suggest u learn some python before attempting advanced projects such as discord bots

unkempt bone
#

😢

shrewd apex
shrewd apex
limber bison
#

how can i accsess this leng in for loop

shrewd apex
#

that code wont even get executed as u want it to

#

its better to put it in a function and acess it using the class instance

short silo
#

How would i check if a message exists only through its ID ?

shrewd apex
#

u want to fetch the message?

limber bison
#

this way ?

shrewd apex
#

yeah

short silo
shrewd apex
#

in the class

limber bison
shrewd apex
#

depends on what u are doing in the function

#

if u need to use await then make it async

#

if not just def is enough

limber bison
#

class instance?

short silo
#

if it cannot be done with only message id, i should store channel id as well ?

shrewd apex
shrewd apex
faint sapphire
#

yo, this bot event doesnt allow any other comands to work
discord.py docs dont mention how to integrate it

faint sapphire
#

ok thanks

slate swan
#

hey hey I need help on one thing

#

I want my bot to send a message from the list but send it at random time

#

like send it every 2-5 hours

unkempt bone
#

how to tag the user who used a slash command

slate swan
#

how do i make my bot say in terminal logged in as bots name

#

#bot-commands

#

nvm i did it

tidal hawk
tidal hawk
slate swan
#

??

slate swan
tidal hawk
#

oh

slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

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

how can i tigger this view ? so it add buttions to message ?

#

i hv 2 fun

#

only

limber bison
#

@glad cradle@wanton fractal

slate swan
#

that's such a messy impl ngl

wanton fractal
shrewd apex
#

mhm

wanton fractal
#

hey how did the code go, does it work? @shrewd apex

shrewd apex
#

i think he pinged by mistake 👀

shrewd apex
wanton fractal
#

that's good

#

i don't know the lib you were using very well but it was similar to sqlite3

shrewd apex
#

kek its their in my repo u can take a look

wanton fractal
#

okay sure thing

shrewd apex
#

tell if u have any suggestions its apiprojects

wanton fractal
#

i upgraded to 16 gigs of ram

#

alright i'll take a look

shrewd apex
shrewd apex
short silo
#

error: discord.Option does not exist.

#

nor OptionChoice

wanton fractal
#

code looks great @shrewd apex

#

i see nothing wrong with it

#

you did good bro, i'm proud of you

slate swan
#

does anyone knows why my bot wont send a embed after i put a on_message command below it

#

is there reason?

unkempt canyonBOT
#
Did you mean ...

» windows-path
» relative-path
» pathlib

wanton fractal
#

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

wanton fractal
#

paste it onto there and we can help

slate swan
#

@client.event
async def on_message(message):

if message.content == ("hello"):
   if message.channel != 1021057023955181678:
    await message.channel.send("wrong channel ")

@client.command(aliases=['do'])
async def d(ctx):
embedVar = discord.Embed(title="TESTING AUTOMAION BOT", description="**this is a test embed by magic", color=0x0096FF)
await ctx.send(embed=embedVar)

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.

wanton fractal
#
async def on_message(message):


    if message.content == ("hello"):
       if message.channel != 1021057023955181678:
        await message.channel.send("wrong channel ")


@client.command(aliases=['do'])
async def d(ctx):
    embedVar = discord.Embed(title="TESTING AUTOMAION BOT", description="**this is a test embed by magic", color=0x0096FF)
    await ctx.send(embed=embedVar)
#

well

#

on_message isnt really necessary if you are registering client.command()

#

it's only needed if you want to use chain commands

#

aka if/else chains

#

client.command() is better to use

#
@client.command(aliases=['do'])
async def d(ctx):
    embedVar = discord.Embed(title="TESTING AUTOMAION BOT", description="**this is a test embed by magic", color=0x0096FF)
    await ctx.send(embed=embedVar)
``` your code would look like this
#

you would just need this

#

not the on_message event

wanton fractal
slate swan
wanton fractal
slate swan
#

alr ty

wanton fractal
#

let me know if there's any errors

slate swan
#

there isnt

wanton fractal
#

does the command run perfectly?

slate swan
wanton fractal
#

glad i could help man!

slate swan
#

@wanton fractal

#

how do u get the curved F

wanton fractal
#

curved f?

#

italics

slate swan
#

yah like in ss

wanton fractal
#

italic font, do you want a visual studio font?

#

question, do you have any eye problems?

wanton fractal
#

yes

#

the curved f is apart of what i said

#

would you like a visual studio code theme?

slate swan
#

no im asking is that like something speical in python

wanton fractal
#

oh no no it depends on the theme

slate swan
#

oh alr

wanton fractal
#

if you want that i have one for you

slate swan
wanton fractal
#

i like ayu or github

#

dark mode ofc

short silo
#

i cant import Options, any fix ?

wanton fractal
#

or are you importing something else

short silo
wanton fractal
#

maybe use from?

short silo
wanton fractal
#

hmm well are you trying to do anything specific or?

short silo
wanton fractal
#

i have no idea, i don't use slash commands

#

i'm gonna learn how to implent them tho

short silo
#

ic

wanton fractal
#

well do you need some assistance?

short silo
#

indeed

shrewd apex
#

!d discord.SelectOption

unkempt canyonBOT
#

class discord.SelectOption(*, label, value=..., description=None, emoji=None, default=False)```
Represents a select menu’s option.

These can be created by users.

New in version 2.0.
short silo
short silo
shrewd apex
#

then?

short silo
#

i updated the version to fix TextChannel doesnt have news attribute error and now it doesn't exist meanwhile the docs say it does

shrewd apex
#

first check ur version of dpy and if its up to date then use dir to print all methods of the object and see if it exists or not

shrewd apex
#

smh use print(dir(object)) and send the ss here

#

and send the link where it exists in docs

slate swan
#

anyone please help me

#

how do I make it send message from my list like every 2 hours?

#

it wont send anything when someone joins

#

I need my bot to send message from the list every 2 hours

#

but I don't know how

short silo
slate swan
#

??

primal token
#

🤔

slate swan
#

so how do I d o it?

primal token
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

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

reminds me of the function symbol in meths which looks like the symbol of integration but strikethrough version

primal token
#

kek

slate swan
honest shoal
primal token
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

oh wait

primal token
#

oh and its not a command kek

slate swan
#

yah just realised

slate swan
honest shoal
#

intents

slate swan
#

i already added them all

primal token
#

Can you show your code?

slate swan
#

everything?

#

or just the on join?

honest shoal
#

intents and join

slate swan
#

@client.event
async def on_member_join(member):

channel = member.guild.system_channel
await channel.send(f"{member.mention} hello welcome to my server")
primal token
#

Your intents are all messy

slate swan
#

how so

primal token
#

remove the value that overwrites the variable

slate swan
primal token
#

yes

slate swan
#

lemme try it now

honest shoal
#

Intents.all() is better, reduces no. of lines

slate swan
#

works ty 👏

slate swan
honest shoal
#

yes

slate swan
#

alr

#

thinking about that is simpler 💀 im new to py tho sorry for the slowness

primal token
honest shoal
#

well yes

slate swan
#
from discord import Intents

intents = Intents.default(); intents.members = True; intents.message_content = True

reduced the number of lines too

primal token
#

But cant you do

discord.Intents(members=True, message_content=True)

?

slate swan
#

yes you can, surely

slate swan
primal token
#

I love C++ so i dont hate semi colons muchpithink

honest shoal
#

laughs with HTTP bot

slate swan
#

http and cpp and js are so different

#

http is literally a protocol

honest shoal
#

what

#

I'm talking about;
HTTP bots = No intents

slate swan
#

wha-

ornate sorrel
#

Can Anyone help me?

slate swan
#

I don't even wanna discuss that ngl

primal token
#

Hes talking about HTTP interactions only

slate swan
slate swan
primal token
#

HTTP is 😎

#

all protocols should be written in caps lol

slate swan
#

noid you're annoying for no reason lmao

primal token
#

skill issue

slate swan
#

please anyone

#

how to make the bot send a message from the list every 2 hours?

primal token
slate swan
unkempt canyonBOT
#

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

can u show an example please?

slate swan
#

there's plenty examples in the docs idk

#

thanks!

#

oh btw @slate swan what should I import?

slate swan
#

thanks

#

ehm @slate swan

AttributeError: 'str' object has no attribute 'send'```
slate swan
#

Yo I need some help

honest shoal
unkempt canyonBOT
slate swan
#

OH RIGHT

#

WITHOUT THIS "

#

await channel.send(random.choice(bot.responses))
AttributeError: 'int' object has no attribute 'send'

#

Can you someone help me use cryptlex API

#

I’m confused by it

slate swan
#

@honest shoal could you help me rq

honest shoal
slate swan
honest shoal
honest shoal
slate swan
#

and now shows this await channel.send(random.choice(bot.responses))
AttributeError: 'NoneType' object has no attribute 'send'

#

@honest shoal

honest shoal
slate swan
# honest shoal show code
import discord
import random
from discord.ext import tasks

intents = discord.Intents.all()

bot = commands.Bot(command_prefix='2?', intents=intents, help_command=None)
bot.responses = ["WRHEGIRHGH", "GRWHUGRHEAGUH", "FHSUGHUAGU", "FREHUGHEU", "RWGHUEHGU", "GREHIUGHA", "RIGEWFWUAN",
                 "GHERIGHWOD", "GERIAGHI", "GHDIAGH", "GHFDSIGH", "GREGQJOF", "GWEGHUSI", "GWRHGUIHA", "HGIHIGRIS"]


@tasks.loop(hours=2)
async def drops():
    channel = bot.get_channel(986712676019359835)
    await channel.send(random.choice(bot.responses))

drops.start()```
#

I’m trying to use that API to create keys, I am not understanding it

honest shoal
slate swan
slate swan
honest shoal
slate swan
slate swan
#

uhh I'm a little dumb today

#

does anyone know how i can make the bot stauts watch the time

honest shoal
#

which is done by fetch

slate swan
#

so how do I do that

#

I'm real tired so plz just tell

honest shoal
slate swan
slate swan
#

ohh

#

like this

#

add bot.wait_until_ready() in the first line of the task loop

slate swan
honest shoal
slate swan
#

I haven't coded in a while.. and now trying to add new thing to bot

slate swan
slate swan
slate swan
#

like this?

#

yeah, await it tho

#

and now it shows this

#
C:\Users\hp\PycharmProjects\Dragon_Bot\venv\lib\site-packages\nextcord\health_check.py:23: DistributionWarning: discord.py is installed which is incompatible with nextcord. Please remove this library by using `pip3 uninstall discord.py`
  warn(message, DistributionWarning, stacklevel=0)
C:\Users\hp\PycharmProjects\Dragon_Bot\main.py:15: RuntimeWarning: coroutine 'Client.wait_until_ready' was never awaited
  bot.wait_until_ready()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Unhandled exception in internal background task 'drops'.
Traceback (most recent call last):
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\venv\lib\site-packages\nextcord\ext\tasks\__init__.py", line 156, in _loop
    await self.coro(*args, **kwargs)
  File "C:\Users\hp\PycharmProjects\Dragon_Bot\main.py", line 17, in drops
    await channel.send(random.choice(bot.responses))
AttributeError: 'NoneType' object has no attribute 'send'```
#

read what it says

#

you can either use dpy or nextcord

#

ughhh my brain not working today

#

just please tell me how I'll gtg after few mins

#

@slate swan

#

you sure that the channel id is correct? also you didn't await the bot.wait_until_ready 🗿

slate swan
#

just please tell me already I'm really hurrying up

#

ughh why everyone in this server likes to do this.. @slate swan

#

??????

slate swan
slate swan
lament mesa
slate swan
#

whats so confusing with adding an await before a statement???

#

oh that just say that

#

ALR WORKS NOW

#

why didnt u just say so

slate swan
#

thanks a lot everyone!