#discord-bots

1 messages · Page 901 of 1

trail oxide
#

like this?

whole shoal
#

If the user you want to ban is in the server, then the code is fine,
If not then you need to take in user id and convert it to user obj via fetch_user

final iron
#

You need to typehint user to discord.User

trail oxide
#

its because i want to blacklist people there isnt in my server

#

with blacklist i mean, do so they cant use my commands.

final iron
#

That's why you're type hinting it to a user object and not a member object

trail oxide
#

can you please change the code for me, i dont know what you mean

final iron
#

No

trail oxide
#

im from denmark, so im not the best for english

#

im using translate

final iron
#

Don't know what to tell you

#

I'm not changing your code for you

sick birch
maiden fable
cold sonnet
#

so I might be a bit crazy

#

but

from disnake import Embed
Embed.add_field = Embed.add_field(inline = False)
```this wouldn't work
#

I thought it would then while writing I realised it wouldn't

#

I can't change a value without calling the func

#
Embed.add_field.inline = False
#

I wanna assign it a False default value

#

!d disnake.Embed.add_field

unkempt canyonBOT
#

add_field(name, value, *, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining.
cold sonnet
#

cuz it's true

final iron
#

You might be able to subclass it and overwrite it or smth

#

Tbh I don't know much about subclassing

junior verge
#

You here?

slate swan
junior verge
#

Alright so

#

What do you need, to try and fix/help me with my problem.

slate swan
junior verge
#

Hm?

slate swan
#

there must be some indentation issue or else?

junior verge
#

Sorry I don't get you

slate swan
junior verge
#

What lol

slate swan
#

the imports

junior verge
slate swan
junior verge
#

How do I, sorry.

#

Thought this was just the list of it

slate swan
junior verge
#

oh..

#

That's in the main btw

slate swan
junior verge
slate swan
junior verge
#

Alright

cold sonnet
final iron
#

Yes

maiden fable
#

Totally not lurking around 👀

junior verge
#

@slate swan I got now like something no clue what but, like all my commands work. Just till when I use my warn command I get this error 1m later.

maiden fable
#

Ayo u tryna convert infinity to an int?

#

Seems like the connection to the db closed

slate swan
#

thanku hunter 😔

final iron
#

Share the code

maiden fable
#

Cool

final iron
#

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

maiden fable
junior verge
final iron
#

Okay?

maiden fable
slate swan
final iron
#

Thats not how it works. You either share the code or not get help

slate swan
final iron
#

Nobody is interested in stealing your code

maiden fable
#

😔

maiden fable
junior verge
#

@maiden fable Everything works fine, but whenever I use my warn command everything just stops

maiden fable
junior verge
final iron
#

Send everything. Something else in the file is wrong

junior verge
maiden fable
#

😔 I will just go away

#

You said u r getting the error on warn command

junior verge
#

Not anymore erm

final iron
#

Why do I get the feeling you're self Botting

junior verge
#

When warning I just get no error at all, And then the bot does not respond anymore for 1m

slate swan
#

okay then dont ask for help ||dont tell am being rude now||

junior verge
#

No clue if you can use this

final iron
#

Nobody is interested in stealing your stinky code

slate swan
#

!pypi motor

unkempt canyonBOT
junior verge
#

Uh okay

junior verge
slate swan
#

!pypi dnspython

unkempt canyonBOT
junior verge
#

What is dnspython?

junior verge
slate swan
slate swan
junior verge
#

But still doesn't work

slate swan
#

show me ur code

junior verge
#

Of what, the warn command?

slate swan
#

also, is the database url correct?(password etc)

junior verge
#

Should be since it worked on my vsc

slate swan
#

alr

junior verge
#

Just copied my code from vsc to replit and now its not working sad

junior verge
#

Not really no

maiden fable
#

It is 🥺

junior verge
#

I am using it

slate swan
#

Hehe smart

junior verge
#

So...?

narrow grail
#

How to make the bot send a random message

buoyant igloo
junior verge
#
import discord
from discord.ext import commands
import pymongo
from pymongo import MongoClient

cluster = MongoClient("mylink")
database = cluster["discord"]
collection = database["warn-database"]

class Warn(commands.Cog):
    def __init__(self, client):
        self.client = client
    
    @commands.command()
    @commands.has_permissions(manage_messages=True)
    async def warn(self, ctx, user:discord.Member=None, *, reason=None):
        id= user.id
        if collection.count_documents({"memberid":id}) == 0:
            collection.insert_one({"memberid":id,"warns": 0})

        if reason==None:
            return await ctx.send("Please mention a reason")
        elif user==None:
            return await ctx.send("Please mention a user!")

        warn_count = collection.find_one({"memberid":id})

        count = warn_count["warns"]
        new_count = count + 1

        collection.update_one({"memberid":id},{"$set":{"warns": new_count}})

        await ctx.send(f"Warned {user.mention} for **{reason}** in **{ctx.guild}** | They now have **{new_count}** warnings!")
 
        

def setup(client):
    client.add_cog(Warn(client))
        


``` Code for my warn command
buoyant igloo
#

!d random

unkempt canyonBOT
#

Source code: Lib/random.py

This module implements pseudo-random number generators for various distributions.

For integers, there is uniform selection from a range. For sequences, there is uniform selection of a random element, a function to generate a random permutation of a list in-place, and a function for random sampling without replacement.

On the real line, there are functions to compute uniform, normal (Gaussian), lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available.

narrow grail
buoyant igloo
#

There r two gud ways to do this

slate swan
# junior verge So...?

idk tbh, i think that u have to fix ur db settings 🤷🏾 (the security system whatever that called)

maiden fable
junior verge
slate swan
maiden fable
#

Lmaoo ig mood swings

narrow grail
slate swan
buoyant igloo
# narrow grail Yeah, but how

For list:

`
import random
list = [“g”, “y”]
G = random.choice(list)
await ctx.send(G)

#I don’t care about the discord modules and how the await is outta async I’m lazy`

maiden fable
maiden fable
#

Hahahaha my code do be worse than yours

buoyant igloo
slate swan
#

yeah id is a built in

junior verge
maiden fable
#

@slate swan gonna explain u. Me tired

junior verge
slate swan
maiden fable
buoyant igloo
austere smelt
#

Any way to make ai for discord so my guests can generate their own images for fun? I have the ai models saved in my google drive

junior verge
narrow grail
junior verge
#

That might be my problem then

buoyant igloo
#

Replit doesn’t save things about it stops running

slate swan
vast gale
#

@maiden fable

slate swan
#

hello, how can i do that the bot set the channel permissions to the user can see them? now its works for the user who click the button.

maiden fable
#

OOOOO BYEEEEE THEN

junior verge
#

@buoyant igloo Do you know if you can host a free bot on vsc

maiden fable
#

I am also going. @vast gale honor all yours

vast gale
#

my nitro had expired yesterday and someone gifted me it again

maiden fable
#

😔

buoyant igloo
vast gale
#

anyways I gtg cya later

slate swan
buoyant igloo
maiden fable
narrow grail
daring olive
#

so for disnake, there's an option to install disnake[voice] for "voice support"

slim ibex
#

ye

daring olive
#

but what does "voice support" entail?

slim ibex
#

idk i never looked into it

maiden fable
daring olive
#

oh to get my bot to actually join a vc

#

so not things like listening for when users join a vc

maiden fable
#

Well u can join a VC without the voice one iirc

quick gust
#

joining can be done without the voice addon or whatever u call it

maiden fable
daring olive
#

gotcha ok

slate swan
#

hello, how can i do that the bot set the channel permissions to the user can see them? now its works for the user who click the button.

sick birch
#

w/o voice support it can join but you won't be able to play any audio

#

I think you need PyNaCl as well

maiden fable
#

Yea

#

That is included in the voice subpackage

daring olive
#

cool cool. that wasn't obvious to me at all

maiden fable
sick birch
#

I haven't gotten an error but with logging enabled it does say something like "PyNaCl is not installed, voice is NOT supported"

slate swan
maiden fable
pliant ocean
#

list= ["file=discord.File('outlaw.jpg')","file=discord.File('outlaw2.jpeg')"] basically i want to add the images without the links to the list which i later call using random but it is not working can anyone help me

full lily
#

would you not just have a list of discord.File objects?

#

and then do something like this ```py
await ctx.send(file=random.choice(your_list))

buoyant igloo
pliant ocean
slate swan
#

Im making so when a member joins is shows the invite code, ive imported from discord import invite, but im getting the error: and i dont know how to fix it
AttributeError: 'Command' object has no attribute 'code'

@bot.event
async def on_member_join(member):
  print(f"Member {member.name}")
  print(f"Invite {invite.code}")
  print(f"Inviter {invite.inviter}")```
buoyant igloo
narrow grail
#

@buoyant igloo is it also possible to mention someone in a list? Something like: list=["yes {author.mention}", "no]

buoyant igloo
#

you have to put the list in an async function

junior verge
#
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv

client = commands.Bot(command_prefix = ".")

load_dotenv()

@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs/'):
    if filename.endswith('.py'):
            client.load_extension(f'cogs.{filename[:-3]}')

TOKEN = os.getenv("DISCORD_TOKEN")

client.run(TOKEN)

``` Why doesn't this work?
pliant ocean
#

i dont want to use the image link but the actual image in the list

#

can anyone help how to do that

slate swan
junior verge
#

I made a variable for it?

slate swan
slate swan
#

oh nvm, sarthak god here

#

daxles, show that variable.. with your token removed

pliant ocean
slate swan
narrow grail
slate swan
junior verge
pliant ocean
junior verge
slate swan
pliant ocean
#

list= ["outlaw.jpg","outlaw2.jpeg"]
item=random.choice(list)
user_id="545503381700214801"
await ctx.reply(f"<@{user_id}>",item)

#

this was my command

slate swan
junior verge
pliant ocean
cold sonnet
#

await ctx.reply("@buoyant badge",file=discord.File(item))
no spoonfeed

junior verge
#

Anyone, please?

lethal urchin
#

what does the time argument in Tasks.loop do?
how do i use it?

final iron
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
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/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
lethal urchin
#

no i dont get how to use that argument what does it do like provide a timestamp abt when the loops gon execute?

junior verge
#
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv

client = commands.Bot(command_prefix = ".")

load_dotenv()

@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs/'):
    if filename.endswith('.py'):
            client.load_extension(f'cogs.{filename[:-3]}')

TOKEN = os.getenv("DISCORD_TOKEN")

client.run(TOKEN)
``` Anyone, please?
lethal urchin
#

or sumn?

sick birch
junior verge
sick birch
#

Make sure your token is set up properly

junior verge
#

This is my env: ```py
DISCORD_TOKEN=mytoken

sick birch
#

Environment variables... pain in windows

#

Where did you set it?

junior verge
#

Ow, did not do that.

#

Do I need to?

sick birch
#

Yeah os.getenv() gets it from your operating system's environment variables

junior verge
#

rip

#

Mind explaining maybe how to do that :0

sick birch
#

I would love to but I'm not exactly sure on how you would add environment variables on windows

#

Though I think if you look up "how to add environment variables on windows" there are plenty of articles

slate swan
junior verge
# sick birch I would love to but I'm not exactly sure on how you would add environment variab...
sick birch
#

No, but os.getenv() gets a value from your environment variable as the name implies

#

Right now you don't have your token set in your environment variables, hence the error

sick birch
#

Well that's the whole point of os.getenv()

junior verge
#

No clue, that's what the website said.

sick birch
#

That would be like do I need to have a json file to use json.load()

#

So yes, you do

#

Just putting it out there but it's probably not the best idea to follow random stackoverflow answers with 8 upvotes

junior verge
#

Yeah okay xD

#

So, what to do to fix it? Add a environment variables

slate swan
sick birch
#

I would not be a happy camper

slate swan
junior verge
sick birch
#

Well make sure you have a .env in the root of your directory

slate swan
#

oh nvm then

sick birch
#

And make sure the syntax is correct

junior verge
#

It should be

junior verge
sick birch
#

And the main file is in the root of your project directory?

narrow grail
#

@buoyant igloo do you know how to make a command which tells something from an website like random quotes?

buoyant igloo
sick birch
#

Hm, perhaps try a config.json file or something of the sort if .env isn't working out for you

narrow grail
sick birch
narrow grail
sick birch
#

Does it have an API?

narrow grail
#

Idk, it‘s called Joke Api when you translate it

sick birch
#

I see

junior verge
#

So what should I do?

sick birch
#

Try to debug .env but if it doesn't work out a config.json file would work

dapper cobalt
# junior verge

Not the best idea to make a file for each command. This is not discord.js, cogs are for categories not commands.

sick birch
#

One of the things I hate about discord.js, yeah

junior verge
#

oh

sick birch
junior verge
#

Alright

sick birch
#

For example, moderation commands like warnings, warn, ban, kick, delwarn, can all be grouped into one moderation.py cog

junior verge
#

Like the delwarn and warn in 1

#

But still my .env doesn't work sad

sick birch
#

@unkempt canyon's sourcecode is an excellent learning resources to structure your bot

junior verge
#

Oh it's open source

sick birch
junior verge
#

Damn that is cool

junior verge
sick birch
#

Most of our applications are open source

#

I've never used .env, only json files as javascript and json work very nicely together

#

That's why I'm saying you could use a .json file for your tokens and other secrets

#

I can't attest to it's security

fresh orchid
#

So I have a discord bot that stores things in a JSON file. Is it possible that when users spam the command or two users try to use the command at the same time that I the file gets reseted?

And is it possible that a file gets reseted because of 600MB storage left

sick birch
#

Yes, very possible that the file gets corrupted and you lose all your data

#

I strongly recommend not using json as a database, rather use a proper database like sqlite or postgres

narrow grail
sick birch
junior verge
#

Yeah I just got no idea on how to do that uh

slate swan
#

Is there a correct way to make a bot get an invite? I tried this:

invite = await guild.get_invite```
sick birch
#

config.json:

{
  "bot_token": "some token"
}

bot.py

import json

with open("config.json", "r") as f:
  config = json.load(f)

print(config["bot_token"]) # prints bot token

very simple but works

sick birch
slate swan
sick birch
#

You'll have to implement that logic yourself, since there's no native way to tell

junior verge
#

never used json before

sick birch
#

How are you saving user warns?

junior verge
#

Mongodb

sick birch
#

I see, nice

junior verge
#

ty

#

I prefer database since it's online

sick birch
#

json is decent for startup configs or static content like this

junior verge
#

Just still need to fix my warns it now only warns in like all servers. for example I warn someone and I will check in another server it will still do the same if you get me

junior verge
junior verge
sick birch
#

Get the contents of the config file at the top of your file

#
with open(...) as f:
  config = ...

bot = commands.Bot(...)

# commands here

bot.run()
#

But probably better if you use a subclass

junior verge
#

Yeah I have that

sick birch
#

And override the default run() method

honest shoal
#

env files are good for storing tokens...

junior verge
#

It wouldn't work

sick birch
#

Yes but we were having trouble with them

honest shoal
#

oh

junior verge
#

How do you get the bot token from the json to the client.run?

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

client = commands.Bot(command_prefix = ".")

with open("config.json", "r") as f:
  config = json.load(f)

@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs/'):
    if filename.endswith('.py'):
            client.load_extension(f'cogs.{filename[:-3]}')

client.run()

sick birch
#

The bot token would be something like config["bot_token"]

honest shoal
#

client.run(config["bot_token"])

junior verge
#

Alright it works yay

junior verge
left crater
#
            return str(payload.emoji) in ['✅']
        payload = await bot.wait_for("raw_reaction_add", check=check)
        await payload.member.send("hey")``` this does nothing for some reason
honest shoal
junior verge
candid veldt
#
@commands.command()
@commands.has_permissions(administrator=True)
async def suggest_off(self,ctx):
        db = sqlite3.connect("Suggest.db")
        cursor = db.cursor()
        cursor.execute(f"SELECT schannel FROM suggestion WHERE guildid='{ctx.message.guild.id}'")
        res = cursor.fetchall()
        if not res:
            return await ctx.send("На этом сервере и так отключены идеи")
        else:
            cursor.execute(f"DELETE FROM suggestion WHERE guildid='{ctx.message.guild.id}'")
            db.commit()
            await ctx.send("Идеи успешно отключены")
                    
                    
def setup(bot):
    bot.add_cog(suggest(bot))

wanted to start with a new command suggest but one error came up: discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.suggest' raised an error: TypeError: cogs must derive from Cog sys:1: RuntimeWarning: coroutine 'Command.__call__' was never awaited
And yes I have sqlite3 installed

#
import discord,sqlite3
from discord.ext import commands

class suggest(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
        print('Module {} is loaded'.format(self.__class__.__name__))
 
db = sqlite3.connect("Suggest.db")
cursor = db.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS suggestion(
    schannel BIGINT,
    guildid BIGINT)""")
db.commit()
db.close()
    
@commands.command()
async def suggest(self,ctx,*,sugest = None):
        if sugest == None:
            return await ctx.send("Указывайте идею обязательно") 
        db = sqlite3.connect("Suggest.db")
        cursor = db.cursor()
        cursor.execute(f"SELECT schannel FROM suggestion WHERE guildid='{ctx.message.guild.id}'")
        res = cursor.fetchall()
        if not res:
            await ctx.send("На этом сервере идеи отключены.\n Включить можно командой `suggest_set`")
        else:
            for i in cursor.execute(f"SELECT schannel FROM suggestion WHERE guildid='{ctx.message.guild.id}'"):
                suggest = i[0]
                sug = self.Bot.get_channel(suggest)
                emb = discord.Embed(title=f"{ctx.message.author}",description=f"{sugest}",color =0x26bbe0)
                mesage = await sug.send(embed = emb)
                await mesage.add_reaction(":heavy_check_mark:")
                await mesage.add_reaction(":heavy_minus_sign:")
                await mesage.add_reaction(":heavy_multiplication_x:")
        db.close()

sick birch
#

You're aware sqlite3 is blocking?

candid veldt
#
@commands.command()
@commands.has_permissions(administrator= True)
async def suggest_set(self,ctx,id:int):
        db = sqlite3.connect("Suggest.db")
        cursor = db.cursor()
        cursor.execute(f"SELECT schannel FROM suggestion WHERE guildid='{ctx.message.guild.id}'")
        res = cursor.fetchall()
        if not res:
            cursor.execute(f"INSERT INTO suggestion VALUES('{id}','{ctx.message.guild.id}')")
            await ctx.send("Канал для идей успешно установлен")
            db.commit()
        else:
            cursor.execute(f"UPDATE suggestion SET schannel='{id}' WHERE guildid='{ctx.message.guild.id}'")
            await ctx.send("Канал идей успешно обновлен")
            db.commit()
        db.close()
@commands.command()
@commands.has_permissions(administrator=True)
async def suggest_off(self,ctx):
        db = sqlite3.connect("Suggest.db")
        cursor = db.cursor()
        cursor.execute(f"SELECT schannel FROM suggestion WHERE guildid='{ctx.message.guild.id}'")
        res = cursor.fetchall()
        if not res:
            return await ctx.send("На этом сервере и так отключены идеи")
        else:
            cursor.execute(f"DELETE FROM suggestion WHERE guildid='{ctx.message.guild.id}'")
            db.commit()
            await ctx.send("Идеи успешно отключены")
                    
                    
def setup(bot):
    bot.add_cog(suggest(bot))
sick birch
#

Your class name is suggest and so is the function name, it's getting confused on what to add

#

Classes should always be PascalCased so change your class name to Suggest

candid veldt
#

thank you!

cold sonnet
#

I'm not sure if sqlite also uses parametrized queries

#

asyncpg definitely does

slate swan
cold sonnet
quick gust
#

can, you can also do it without parameterized queries but then there's the risk of sql injection

#

if you're working with user input

fervent surge
#

I dont really get the docs, but basically, given a message ID, I want to get the amount of ⬆️ reactions and ⬇️ reactions, how can I do this?

unkempt canyonBOT
#

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

Add a reaction to the message.

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

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

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function no-longer raises `InvalidArgument` instead raising [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)").
fervent surge
#

I get that

slate swan
#

its a method of the Message class

fervent surge
#

i get that, but, i want to see who else reacted

#

so, given a message and a reaction, I want to know the count

quick gust
#

!d discord.Message.reactions

unkempt canyonBOT
slate swan
#

lol

fervent surge
#

thank you very much

quick gust
#

np!

slate swan
fervent surge
#

so, just for clarity, the code would look like this?:```python
message = <The message>

reactions = message.reactions

for i in reactions:
if i.emoji == '⬆️':
upvoteCount=i.count
else if i.emoji == '⬇️':
downVoteCount=i.count```

#

ok, thx!

fervent surge
slate swan
fervent surge
slate swan
unkempt canyonBOT
#

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

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
fervent surge
slate swan
#

why not use it do you not know the exact syntax?

fervent surge
#

!e print([a for a in range(101) if a == 21 else print('no')])

fervent surge
#

ok, thx

quick gust
#

wrong ping?

slate swan
#

yep

#

and that whole error gave me a stroke cuz of my mobile client

fallow mauve
#

hey so im trying to make an avatar command that sends an embed with the image as the persons pfp, but it wont work, theres no error it just doesnt do anything. heres code:

@commands.command(name="avatar", aliases=["av"])
  async def avatar(self, ctx: commands.Context, target=Optional):
    if target == None:
      image = await self.get(ctx.author.avatar_url)
      embed = discord.Embed(title=f"{ctx.author.username}'s Avatar:", description="** **")
      embed.set_image(url=image)
      await ctx.send(embed=embed)

and yes the cog is set up right

silent ermine
#

So Im trying to do a massban for a list of users
heres my code

@bot.command()
async def massban(ctx, *, users):
    await ctx.send("Starting to ban, this might take a while.")
    newVar = users
    for user in newVar:
        banUser = int(user)
        print(banUser)
        await ctx.guild.ban(user=banUser, reason='Massbanned on {} in UTC Timezone.'.format(datetime.utcnow()))```
and the error is

```py
    await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
AttributeError: 'int' object has no attribute 'id'```
slate swan
silent ermine
fallow mauve
slate swan
#

youll get ratelimited and the code can be used for malicious stuff

silent ermine
vale wing
#

@silent ermine why not do it like this

async def massban(ctx, *members: discord.Member):
    for member in members:
        await member.ban(...)```
slate swan
slate swan
vale wing
#

Greedy is for middle args

slim ibex
#

oh

silent ermine
vale wing
fallow mauve
slate swan
slate swan
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.

silent ermine
#

but alright

fallow mauve
#

!paste

slate swan
fallow mauve
quick gust
fallow mauve
slate swan
#

lmaooo

quick gust
#

oh nice

silent ermine
quick gust
#

just, asyncio.sleep()

slate swan
quick gust
#

in your for loop or whatever

slate swan
quick gust
fallow mauve
slate swan
undone tartan
#

what is discord.User.colour and discord.User.accent_colour?

vale wing
#

Sus thing I haven't heard about

slate swan
undone tartan
#

i see lmao

vale wing
#

!d discord.User.colour

unkempt canyonBOT
#

property colour```
A property that returns a colour denoting the rendered colour for the user. This always returns [`Colour.default()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour.default "discord.Colour.default").

There is an alias for this named [`color`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.color "discord.User.color").
vale wing
#

What the heck

undone tartan
vale wing
#

What kind of color does it access fr

undone tartan
#

dumb docs

vale wing
#

One sec ima check dev portal

slate swan
#

the apis ratelimits are dynamic for http requests so you would get ratelimited yes it will work for the default limit

quick gust
#

I'm guessing the prominent one in their avatar, like how they do it with the default banner

undone tartan
#

this is apparently it

slate swan
#

well thats just a comment

undone tartan
slate swan
#

it would be None because nothing was given

vale wing
#

@undone tartan turns out this is somehow related to banner

quick gust
#

your's will 90% be yellow, I'm guessing | try it

undone tartan
#

an integer?

#

huhhh

#

that dont make sense to me

fallow mauve
undone tartan
#

does it mean this thing?

quick gust
#

yeah see, the default one!

undone tartan
#

ah

quick gust
#

that's the one rendered by discord by default

#

discord.User.color will return the default one

undone tartan
#

but how would it be an integer representation of a hexadecimal colour code

undone tartan
quick gust
slate swan
undone tartan
#

default just seems to be #000000

slate swan
undone tartan
#

wdym

slate swan
#

if its 000000 in py it would be 0x000000

undone tartan
#

ohhhh that

#

ok that clears it up

slate swan
#

0x iirc means the base of hex codes which are ints

undone tartan
#

i mean it returned as a string

slate swan
undone tartan
#

like this is what i put

#

i didnt put a # there

slate swan
#

well that would send a string but the base is an int

undone tartan
#

hm ok

slate swan
#

0x000000 is an int lol

undone tartan
#

but it still doesnt explain why it gave 000000 when the banner clearly isnt black

slate swan
#

thats the default value of it right?

undone tartan
#

no clue

slate swan
#

well check source code in dpy and check its default return value its probably 000000

fallow mauve
#

i followed a tutorial i was given

slate swan
slate swan
fallow mauve
#

i was given to it by people in this server

undone tartan
#

im so confused

slate swan
#

well you didnt followed it right to have 2 dunders

fallow mauve
#

ok

#

ooohhh

#

that was the point where i took a break from coding bcs of my headache

slate swan
undone tartan
#

alr

fallow mauve
#

musta been that, yeah i should seen that

undone tartan
#

so itll always be the default?

slate swan
#

yeah

undone tartan
#

i dont understand why that is a thing but alr

slate swan
#

you have members intents i suppose yes as your member join got triggered

undone tartan
#

kinda makes sense ig

slate swan
#

guys

undone tartan
#

yeah i have that intent on

slate swan
slate swan
slate swan
# slate swan ?

please ive been sobbing for the past 5 minutes now pycontainer@pterodactyl~ Server marked as running... Traceback (most recent call last): File "/home/container/peperun.py", line 34, in <module> client.run(TOKEN) File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 723, in run return future.result() File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 702, in runner await self.start(*args, **kwargs) File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 665, in start await self.login(*args, bot=bot) File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) AttributeError: 'NoneType' object has no attribute 'strip'

undone tartan
#

no cos it sounds confusing

slate swan
#

but

#

regenerate your token and add it again

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
#

oop

#

bro

slim ibex
#

change it

undone tartan
#

heh

slate swan
#

okay i reset it

undone tartan
#

doesnt discord reset it itself tho

slate swan
#

no.

slim ibex
undone tartan
#

or how does that work now since they changed it

slate swan
#

only if you pushed on github

slim ibex
#

I’ve accidentally pushed my token to GitHub 🗿

slate swan
#

So do I just insert the new one in

TOKEN = os.getenv('tokenid')
#

since discord and github have a system that searches tokens

slate swan
slate swan
#

on the value of the var

undone tartan
#

went to check the "leaked token" message and i saw like 100 of these and they are only in this server, a bit weird imo

fallow mauve
#

lol

tardy atlas
#

How to make tables in postgresql? (heroku and git)

slim ibex
#

you can make database tables in PgAdmin

slate swan
# slate swan no in the variable

i..

import discord
import os
import time
import discord.ext
from discord.utils import get
from discord.ext import *
from discord.ext.commands import has_permissions,  CheckFailure, check
from dotenv import load_dotenv
load_dotenv('---.env')

TOKEN = os.getenv('OTA3MjMyMTI4NjE2NTEzNTU2.**')
print("hi")
client = discord.Client()

client = commands.Bot(command_prefix = '!')

@client.event
async def on_ready():
    print("this bitch is in") 
    
    
@client.command()
async def ping(ctx):
    await ctx.send("Pong!")

client.run(TOKEN)``` where would that be located
slim ibex
#

Or through queries

undone tartan
#

that is not how dotenv works-

slate swan
#

fuck

slim ibex
#

Why do you have a client and bot initialized

undone tartan
#

its os.getenv('NAME_OF_THING_IN_ENV_FILE')

slate swan
#

stop 😭 stackoverflow got me

#

isnt that a botnet?

slim ibex
#

bro don’t copy from stackoverflow unless ur a pro

#

you learn nothing from copying

undone tartan
#

for example:

in dotenv file
TOKEN=HDJKFHKSEGskseahgv.srghshgsbsBYgwEV

in bot
os.getenv('TOKEN')

slim ibex
undone tartan
slate swan
slim ibex
#

There is actually a discord announcements thing

undone tartan
slim ibex
#

But idk if it has an ID or multiple IDs

undone tartan
#

i mean you can look for yourself

tardy atlas
slim ibex
#

I think it’s just an admin thing

slate swan
undone tartan
slate swan
slim ibex
undone tartan
slim ibex
#

git is a version control system, Postgres is a database

undone tartan
#

youll see the list

#

all of em is the same

slim ibex
#

Learn SQL before using databases. Then you can checkout ORMs, and other database stuff

slim ibex
undone tartan
fallow mauve
# slate swan no pterodactyl

ok, so then make a new file and call it .env, the in it put the following:

TOKEN=#your token here

then put this at the bottom of your main file:

bot.run(os.getenv("TOKEN"))
slim ibex
#

The discord announcements one has the discord logo

undone tartan
#

mhmn

slate swan
undone tartan
#

the announcements one is @Discord#0000

slate swan
#

no reptile. sed

undone tartan
#

client?

slate swan
#

oh

slate swan
undone tartan
#

ive never done it that way before

slate swan
#

why use the Client class

undone tartan
#

ive only ever done bot = commands.Bot(...) lmao but thats just me

slim ibex
#

That’s what you should do

slate swan
fallow mauve
slim ibex
#

(subclassing it is best)

slate swan
#

!d discord.ext.commands.Bot you guys ever read docs?

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

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

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

sorry, bot is way less confusing to use so i use it instead but you use client so use that

undone tartan
#

should be able to if you have members intent

honest lintel
#

Heeelp Stackoverflow is down

undone tartan
#

no clue, id love to know too

slate swan
#

not sure what it would be called tbh

unkempt canyonBOT
#

class discord.User```
Represents a Discord user.

x == y Checks if two users are equal.

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

hash(x) Return the user’s hash.

str(x) Returns the user’s name with discriminator.
undone tartan
#

it might not

#

does it not have access lmao

#

hm but ive seen so many people with their name as everyone

#

does the api just not have a bot endpoint thingy for bios

slate swan
#
Traceback (most recent call last):
  File "/home/container/peperun.py", line 24, in <module>
    bot.run(os.getenv("TOKEN"))
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'```
slate swan
#

a friend tried to help me

import discord
import os
import time
import discord.ext
from discord.utils import get
from discord.ext import commands, tasks
from discord.ext import *
from discord.ext.commands import has_permissions,  CheckFailure, check
from dotenv import load_dotenv
load_dotenv('---.env')

print("hi")
bot = commands.Bot(command_prefix = '!')

@bot.event
async def on_ready():
    print("this bitch is in") 
    
    
@bot.command()
async def ping(ctx):
    await ctx.send("Pong!")

bot.run(os.getenv("TOKEN"))```
slate swan
undone tartan
#

its just load_dotenv()

slate swan
#

ok uhm
regarding the token, i've just reset it yet the error is pretty much the same py Traceback (most recent call last): File "/home/container/peperun.py", line 24, in <module> bot.run(os.getenv("TOKEN")) File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 723, in run return future.result() File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 702, in runner await self.start(*args, **kwargs) File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 665, in start await self.login(*args, bot=bot) File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) AttributeError: 'NoneType' object has no attribute 'strip' are there any other reasons for that

undone tartan
#

try without dotenv for a sec

slim ibex
#

It isn’t a string

undone tartan
#

just put your token as a string as a test

slim ibex
#

that’s why it’s raising

slim ibex
#

strip() is a string method

slate swan
#

if it werent a string it would raise an attr error

slate swan
undone tartan
#

remove os.getenv bit

slate swan
#

k

#

since the token is wrong it would be None and the method cant parse None only strigs

slate swan
slate swan
slate swan
# undone tartan remove `os.getenv` bit
Traceback (most recent call last):
  File "/home/container/peperun.py", line 23, in <module>
    bot.run(os.getenv("TOKEN"))
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'```
#

dont call me that. and why are you using an env just set your token directly if youre using an editor.

#

no i mean, i'm using pterodactyl

undone tartan
#

im so confused at this point

slate swan
#

an editor? or an online editor?

undone tartan
#

my friend just checked, bio's just arent a thing on the api

slate swan
#

its a docker server appliance

undone tartan
#

he knows what hes doing considering he wrote a library so i feel like he would know lmao

brazen raft
undone tartan
#

this is so weird

slate swan
slate swan
brazen raft
#

I have

undone tartan
#

i think he just checked the user object to see

slate swan
#

oh i put dotenv back in and it worked

#

ye she's all up

undone tartan
#

how come youre using docker

#

for something like this

sick birch
#

Why not?

#

Docker is awesome for most things

slate swan
undone tartan
#

i mean aint it a bit overkill for something you arent sure works fully yet

undone tartan
sick birch
#

One should always dockerize applications when deploying to production

slate swan
#

it is 💀 i use that docker for mc servers tho

undone tartan
slate swan
#

imagine refering your bot as a she

slate swan
#

mhm uhh

#

i dont even refer my bots as any gender i refer to them as an obj

undone tartan
#

docker once made me have to reinstall my entire os so like

#

never again 😃

brazen raft
brazen raft
#

That was a joke

slate swan
#

ik

undone tartan
#

is it just me who finds it kind of weird that you can get someones email from the discord api?

#

like it feels kinda icky

undone tartan
brazen raft
#

Bruh

#

Show me mine

#

In a direct message

slate swan
#

discords security smh

undone tartan
#

i cant be bothered figuring out how to use endpoints and shit

slate swan
undone tartan
#

huhh

#

where would i look

#

im on the network tab

slate swan
undone tartan
fervent surge
#

i forget how, but im sure theres a way to instaantly register a slash command (using discord-py-slash-command)

slate swan
#

it should be an int or atleast set 2 different versions

fervent surge
#

other than kicking and reinviting the bot

slate swan
undone tartan
brazen raft
undone tartan
#

21?

slate swan
brazen raft
#

I.. do not know

undone tartan
#

000000000000000000000
thats so long

brazen raft
#

My own user ID is 350619697231691776

undone tartan
#

urs is 18

slate swan
#

i doubt the length matters

fervent surge
#

the problem isnt the library tho, its the registration of the command

brazen raft
undone tartan
fervent surge
#

ive used it before, and i remeber doing something to make it instant

slate swan
undone tartan
#

at the start of every slash command decorator youd put it in there

fervent surge
#

yeah!

brazen raft
undone tartan
#

uhhh no clue at all, havent used the library in half a year

#

i moved to novus

slate swan
#

just use dpy 2.0.

fervent surge
#

geez, a lot has happened in a year

undone tartan
slate swan
#

clone the repo

undone tartan
#

i wanna use smth stable

slate swan
#

disnake

undone tartan
#

hm?

slate swan
#

!pypi disnake

unkempt canyonBOT
undone tartan
slate swan
#

never heard of it

brazen raft
undone tartan
slate swan
#

can anybody send me the src code of how dpy connects to websockets and how the bot acknowledges hb?

undone tartan
#

its not very big but its useful

#

has support for everything atm

slate swan
undone tartan
#

ok but it works so like

slate swan
#

like pycord copies everything and renames everything

undone tartan
#

pycord is amazing !

slate swan
#

doesnt even rename dirs

slate swan
undone tartan
#

@polar lodge good peopl;e right?

#

huh hes not here, why did it let me ping

undone tartan
slate swan
undone tartan
#

it showed tho

undone tartan
#

and he aint in this server

#

bookmarks?

slate swan
manic wing
#

you making a discord wrapper?

undone tartan
slate swan
undone tartan
#

i forgot why i came to this channel now

#

oh yeah for colours and bios

undone tartan
#

figured them both out

bios are on the api but return empty string
colours and accent colours are weird just ignore them

slate swan
#

silly me

undone tartan
#

whats going on lmao

manic wing
slate swan
#

sure. You look like a clown tho you cant even contribute to projects because you lack skill.

undone tartan
#

@manic wing can i just say ur pfp doesnt look cool, just makes you look like an edgy 14 year old who drinks monster in their room alone watching tiktok cos they have nothing to do

slate swan
#

lmaooo

undone tartan
#

with that im not going off topic anymore

slate swan
#

same here

undone tartan
#

@slate swan how do i use your discordheximals thing?

#

it looks cool and the default colours are boring

slate swan
undone tartan
#

oh thats simple

#

how do i import it its not like other things im used to

slate swan
#

yeah maybe ill work on it to make it better and i couldve made it better with dynamic attrs but it is what it is lol

slate swan
unkempt canyonBOT
undone tartan
#

oh

#

The author of this package has not provided a project description

slate swan
#

just pip install it and import it

slate swan
undone tartan
#

alr

slate swan
#

and im going to rename the package aswell

#

so maybe dont use it until tomorrow or later on today

undone tartan
#

too late lmao

slate swan
#

then upgrade it later on today

uncut portal
#

is there anything about it that is specific to discord?

slate swan
#

nothing i was just lacking knowledge at that time.

#

so yeah thats why im renaming it

undone tartan
#

i mean its just hex codes under names lmao

#

vscode isbeing a bitch and wont import it

slate swan
undone tartan
#

reportMissingImports my balls

slate swan
slate swan
#

thats why i said to install it later

undone tartan
#

ah

#

dm me when you do it so i can upgrade thing

slate swan
#

its horribly done

daring olive
unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @undone tartan.

undone tartan
#

and they mayve felt attacked from the other guys comment?

polar lodge
undone tartan
#

oh

daring olive
#

@manic wing i do remember a couple times you went out of your way to critique some people's projects in a less than constructive way, but didn't have a chance to say anything.. if it's becoming a habit pls keep that in check.

manic wing
daring olive
#

just something from memory, it was quite a ways back and in an off-topic channel

manic wing
#

okimii always feels attacked

desert badger
#

Hey i just have a question rq, im at a friends pc rn, were trying to make a bot but we get that no file or directionary error, even tho our file is in the same folder as the python file...

desert badger
#

shaky pic but still, how do we fix that?

final iron
#

Fix what

uncut portal
desert badger
slate swan
#

ello

slate swan
#

ohhhh its running in the random stuff folder

uncut portal
#

alright I see whats going in

slate swan
#

only on interactions

#

wait how do i make it run inside the folder inside random stuff folder 💀 i feel dum rn

uncut portal
#

I would get set the path to be "Python/token.txt"

slate swan
#

or just use a period lol

#

ah oke

#

but the period sometimes gives an error unlike the way he suggested

#

how can i just like run it inside the python folder

#

so its just C:\Users\Lukas\Desktop\random stuff\Python

uncut portal
#

I'm unsure about doing it through vscode specifically but if you run cd Python in the terminal and try it again it may work

leaden umbra
#

is there some way to use member.add_roles() to add more than one role at a time? If I use a list it gives AttributeError: 'list' object has no attribute 'id'

leaden umbra
#

ok

slate swan
uncut portal
#

solarized dark

slate swan
#

cheers

alpine furnace
tacit token
#

hello guys how can i grab my emoji to this code c emoji="\U0001f468\u200D\U0001f3eb

#

or how to use custom emoji

torn sail
slate swan
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 610, in on_message
    await self.process_commands(message)
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 607, in process_commands
    await self.invoke(ctx)
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 570, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 912, in invoke
    await self.prepare(ctx)
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 833, in prepare
    if not await self.can_run(ctx):
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 1159, in can_run
    return await disnake.utils.async_all(predicate(ctx) for predicate in predicates)  # type: ignore
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\utils.py", line 567, in async_all
    for elem in gen:
  File "C:\Users\Saad\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 1159, in <genexpr>
    return await disnake.utils.async_all(predicate(ctx) for predicate in predicates)  # type: ignore
  File "c:\Users\Saad\Desktop\Files\test\mymindisdead.py", line 30, in __call__
    raise commands.CommandOnCooldown(bucket, retry_after)
TypeError: CommandOnCooldown.__init__() missing 1 required positional argument: 'type'```
#

any idea?

#

bucket is the type idk

broken plinth
#

Hello!

hushed galleon
slate swan
hushed galleon
#

the cooldown object thats being applied

broken plinth
#

Hey so I am trying to get premium and normal commands for my bot anybody has ideas

hushed galleon
#

basically what get_bucket() returns

slate swan
hushed galleon
slate swan
#

how would i use if certain element is 0

broken plinth
hushed galleon
#

oh, then you can just use the builtin @commands.has_role(<role id>) check then

broken plinth
#

that was already done

#

I just need normal and premium command ideas

hushed galleon
#

iunno think of stuff that matters most to your server

broken plinth
#

hmmm

#

Ok thanks for help!

slate swan
#

!pypi aiohttp

unkempt canyonBOT
slate swan
slate swan
#

ok

hushed galleon
slate swan
#

o

#

uh whoops

narrow grail
#

How a welcome message code looks like?

#

Mine is not working

slim ibex
#

then fix it

slate swan
unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

narrow grail
slate swan
#

show code and error

narrow grail
# slate swan show
async def on_member_join(member):
  wEmbed = discord.Embed(title="test",description=f"{member} test :white_check_mark:",color=0x55cc55)
  await client.get_channel(834899978131472429).send(embed=wEmbed)```
narrow grail
slate swan
#

caeden it had .send method lol

manic wing
#

i wasnt paying attention

slate swan
#

happens

slate swan
narrow grail
slate swan
slate swan
narrow grail
slate swan
slate swan
slate swan
narrow grail
#

oh

sick birch
#

Bot, it should be bot

slate swan
#

bad idea but anyway

sick birch
#

Yes, I'm saying use bot

#

Too many people name bot client which makes no sense

narrow grail
sick birch
#

That's better

narrow grail
sick birch
narrow grail
rocky trench
#

@sick birch may I ask what the difference between commands.Bot and discord.Client is?

hushed galleon
#

commands.Bot has support for message commands, event listeners, and cogs/extensions

slate swan
#
ide = str(r.content)
    for i in ide.split(','):
        if "element" in i:
          await ctx.send("element found")
        else:
            await ctx.send("element not found")
            await bot.process_commands(ctx)``` how to fix else statment wont work
#

ignore syntax

rocky trench
slate swan
rocky trench
#

I'd like to see the params and the variable named 'element'

slate swan
#
@bot.command()
async def checker(ctx, *, element):
    r = requests.get("website")
    #print(r.content)
    ide = str(r.content)
    for i in ide.split(','):
        if "element" in i:
          await ctx.send("found")
        else:
            await ctx.send("not found")
            await bot.process_commands(ctx)```
slate swan
#

yes

slate swan
manic wing
#

r.content

#

returns str anyway

slate swan
#

that was print for test

#

o u mean ide variable

#

Anyway, not the problem

#

the problem is else statment doesnt work

manic wing
#

what about it doesnt work

#

ps it will process multiple times

slate swan
#

await bot.process_commands(ctx)

#

@manic wing when element doenst exist it still sends found

manic wing
slate swan
manic wing
slate swan
#

lol

#

@manic wing summary: if element doesnt exist it still says it does due to if statment not working

rocky trench
#

Oh nvm

slate swan
#

lol

rocky trench
#

Its not a variable

slate swan
#

no its part of command

rocky trench
#

Can u show me the print?

slate swan
#

wym

rocky trench
#

The output of the print r.content

slate swan
#

what website example shall i use

#

im using personal one rn

slate swan
#

and its not even indented properly

slate swan
slate swan
slate swan
slate swan
#

went from spamming to 1 message

rocky trench
#

Send me the output please, it can help

slate swan
#

and python?

slate swan
rocky trench
slate swan
#

kk

#

!d break

unkempt canyonBOT
#

7.9. The break statement


break_stmt ::=  "break"
``` [`break`](https://docs.python.org/3/reference/simple_stmts.html#break) 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 terminates the nearest enclosing loop, skipping the optional `else` clause if the loop has one.

If a [`for`](https://docs.python.org/3/reference/compound_stmts.html#for) loop is terminated by [`break`](https://docs.python.org/3/reference/simple_stmts.html#break), the loop control target keeps its current value...
rocky trench
#

@slate swan please send me the output

slate swan
#

break just sends element 2x

rocky trench
slate swan
#

ok

slate swan
slate swan
# slate swan are you running 2 instances ?

@bot.command()
async def checker(ctx, *, element):
    r = requests.get("website")
    #print(r.content)
    ide = str(r.content)
    for i in ide.split(','):
        if "element" in i:
          await ctx.send("found")
        else:
            await ctx.send("not found")
            break
#

?

rocky trench
#

God

slate swan
#

wait

rocky trench
#

That's not an instance

slate swan
#

i forgot to change break

rocky trench
#

I'm still waiting for r.content

#

I already know what your issue is

slate swan
#

ok sorry

rocky trench
#

I already found the reason it isn't working

#

U got a param element in ur command, u check for the word 'element' and not for the param. 'Element' will always be returned, str(element) not

slate swan
rocky trench
slate swan
#

ok

rocky trench
#

U are checking for the word element

slate swan
#

yes

rocky trench
#

Not for the element parameter

slate swan
#

are else statments even possible on requests

rocky trench
#

Remove the " " from element and ur issue is fixed

slate swan
#

ok

slate swan
rocky trench
# slate swan ⁉️

How come he doesn't get that he checks for the word element and not his parameter element

somber sky
#

trying to make a ticket dropdown command

error is discord has no attribute to Select

rocky trench
#

That's literally his only issue

slate swan
#

yes

rocky trench
#

@slate swan is it fixed?

somber sky
cold sonnet
#

and you define a class every time the command's called??

sick birch
rocky trench
slate swan
#

no point

cold sonnet
#

incase you don't wanna use commands

slate swan
#

?

cold sonnet
#

so you don't want to waste memory for it either

rocky trench
#

A bot without commandsWhat

sick birch
#

If you're just doing a quick testing project with no commands or anything it it I guess you could use discord.Client

slate swan
#

dont use commands. continues to do if message.content.startswith()

cold sonnet
#

hehe

#

my type of programming

slate swan