#discord-bots

1 messages ยท Page 859 of 1

slate swan
#

lol

vapid anchor
#

the question is whether the better one is seximal or dozenal

sick birch
#

base 1 ๐Ÿ—ฟ

slate swan
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Pages' object is not iterable
anyone know what this error means?

slate swan
#

how do i resolve it?

pliant gulch
#

!e ```py
[0xfor _ in range(10)]

unkempt canyonBOT
#

@pliant gulch :warning: Your eval job has completed with return code 0.

[No output]
slate swan
neat pagoda
#

How do I fix?
Error Below

[92mBot is online!
172.18.0.1 - - [25/Feb/2022 20:16:55] "GET / HTTP/1.1" 200 -
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 202, in on_message
    bans = json.load(f)
  File "/usr/lib/python3.8/json/init.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.8/json/init.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 45 (char 44)
172.18.0.1 - - [25/Feb/2022 20:16:56] "GET / HTTP/1.1" 200 -
172.18.0.1 - - [25/Feb/2022 20:16:57] "GET / HTTP/1.1" 200 -

Code Below

@client.command()
@commands.check(check_Dev)
async def banlist(ctx):
  with open('bans.json','r') as f:
    users_list= json.load(f) #ahh i see
    text="**All Banned Users Record**\n"
    for i in users_list:
      text+= "<{}\n>".format(i)
    em = discord.Embed(color=discord.Color.red(),description=text)
    await ctx.send(embed=em)
cold sonnet
#

uh

slate swan
slate swan
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: 'type' object is not iterable
slate swan
#

uhhh

#

thanks, i guess

slate swan
slate swan
neat pagoda
#

now my bot wont even work

#

!e

@client.command()
@commands.check(check_Dev)
async def banlist(ctx):
  with open('bans.json','r') as f:
    users_list= json.load(f) #ahh i see
    text="**All Banned Users Record**\n"
    for i in users_list:
      text+= "<{}>\n".format(i)
    em = discord.Embed(color=discord.Color.red(),description=text)
    await ctx.send(embed=em)
unkempt canyonBOT
#

@neat pagoda :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'client' is not defined
neat pagoda
#

ok

slate swan
#

the eval command cant eval dpy code

neat pagoda
#

ok

slate swan
#

!e

@bot.command()
async def accept(ctx, *args):
    if (ctx.message.author.id == 809386625699151892):
        if not args:
            await ctx.send("Username is missing!")
        else: 
            requests = await client.get_friend_requests()

            for request in requests:
                if request.id == args[0]:
                    await client.accept()
            await ctx.send("Friend request was accepted!")
    else: await ctx.send("Only foxx can use this command.", ephemeral=True)```
neat pagoda
#

butwhat's wrong

slate swan
#

what??

slate swan
neat pagoda
#

idk

slate swan
neat pagoda
#

I tried editing what my guy discu did while I ate lunch, got it working, and then I screwed up and now the original code he put doesn't work

slate swan
#

!e

@bot.command()
async def accept(ctx, *args):
    if (ctx.message.author.id == 809386625699151892):
        if not args:
            await ctx.send("Username is missing!")
        else: 
            requests = await client.get_friend_requests()

            for request in requests:
                if request.id == args[0]:
                    await client.accept()
            await ctx.send("Friend request was accepted!")
    else: await ctx.send("Only foxx can use this command.", ephemeral=True)```
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'bot' is not defined
slate swan
slate swan
#

lol

slate swan
slate swan
#

momento

#

!e

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

@bot.command()
async def accept(ctx, *args):
    if (ctx.message.author.id == 809386625699151892):
        if not args:
            await ctx.send("Username is missing!")
        else: 
            requests = await client.get_friend_requests()

            for request in requests:
                if request.id == args[0]:
                    await client.accept()
            await ctx.send("Friend request was accepted!")
    else: await ctx.send("Only foxx can use this command.", ephemeral=True)```
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'commands' is not defined
slate swan
#

you have to include the modules

#

like watch

#

!e ```python
from discord.ext import commands

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

@bot.command()
async def accept(ctx, *args):
if (ctx.message.author.id == 809386625699151892):
if not args:
await ctx.send("Username is missing!")
else:
requests = await client.get_friend_requests()

        for request in requests:
            if request.id == args[0]:
                await client.accept()
        await ctx.send("Friend request was accepted!")
else: await ctx.send("Only foxx can use this command.", ephemeral=True)

bot.run(os.getenv('TOKEN'))

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'discord'
slate swan
#

as said the eval command cant execute dpy code

#

Yeah, well, I have a idea

#

!e

import discord
from discord.ext import commands


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

@bot.command()
async def accept(ctx, *args):
    if (ctx.message.author.id == 809386625699151892):
        if not args:
            await ctx.send("Username is missing!")
        else: 
            requests = await client.get_friend_requests()

            for request in requests:
                if request.id == args[0]:
                    await client.accept()
            await ctx.send("Friend request was accepted!")
    else: await ctx.send("Only foxx can use this command.", ephemeral=True)```
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'discord'
slate swan
#

the eval command doesnt have dpy as a module

#

so pls stop

neat pagoda
#

oh dangit

slate swan
#

im using pycord

neat pagoda
#

I forgot, my json database for bans from the bot

slate swan
neat pagoda
#

has {"id": "",}

slate swan
#

!e

import os

try:
  os.system('pip install discord')
except:
  print('Sorry, but that is a invalid module!')

import discord
from discord.ext import commands


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

@bot.command()
async def accept(ctx, *args):
    if (ctx.message.author.id == 809386625699151892):
        if not args:
            await ctx.send("Username is missing!")
        else: 
            requests = await client.get_friend_requests()

            for request in requests:
                if request.id == args[0]:
                    await client.accept()
            await ctx.send("Friend request was accepted!")
    else: await ctx.send("Only foxx can use this command.", ephemeral=True)

bot.run(os.getenv('TOKEN'))
#

Okay welp

#

bro

neat pagoda
#

lol, , that was the problme

slate swan
#

i told you guys already

#

but im not using d.py

slate swan
# slate swan bro

Ik now, I was wondering if I can use a try and os.system to import the module

#

but Ig os.system doesn't work

slate swan
slate swan
#

!e

import os
unkempt canyonBOT
#

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

[No output]
slate swan
#

doesnt matter it wont let you lol

#

Okay jeez

#

for safety

slate swan
#

UTILS?

#

that's the only way

pliant gulch
#

discord.utils.get takes an iterator, and the kwargs you give it are the attributes it needs to follow

slate swan
#

that..... is not a good way though?

pliant gulch
#

For an example, utils.get(members, name="foo") would get the member named foo inside of members

#

For roles, you'd iterate the guild's roles, then pass name=

slate swan
#

utils does the same thing-

#

!d discord.Member.ban

unkempt canyonBOT
#

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

Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
slate swan
#

None

pliant gulch
#

Returns None

#

Which is falsey

slate swan
#

falsey

kindred epoch
#

lmao

slate swan
#

๐Ÿ‘๏ธ๐Ÿ‘๏ธ

#

๐Ÿ‘๏ธ๐Ÿ‘๏ธ

cold sonnet
#

warn's not a thing on discord

kindred epoch
#

nah bro it only works on mac

slate swan
#

yes it does work its a coroutine of Member class of the discord package

#

why wouldnt it work

kindred epoch
#

my brother, it doesnt matter if its vscode windows or nokia vscode, it would work on any ide's

slate swan
#

Basic python lol

#

guys pls stop trolling

#

its a beginner set an example

#

listen to me i dont troll lol

#

you can warn users with a db for a user history btw

vale wing
#

Anyone here familiar with lichess API, I can't decode its resp tho it goes fine

vale wing
#

Just that stupid jsondecode error

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

vale wing
slate swan
vale wing
slate swan
#

๐Ÿ˜ณ

slate swan
vale wing
slate swan
vale wing
#

Aiohttp req

slate swan
vale wing
#

The content type is html for some reason

slate swan
#

they why are you decoding html does it even return data formatted in json?

vale wing
#

But the docs say it should return json

slate swan
#

๐Ÿ—ฟ

vale wing
#

I get 200 response code

slate swan
vale wing
#

Yes

slate swan
#

can i see the response body?

cold sonnet
vale wing
#

Okok chill out

vale wing
#

You don't really need to

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.

vale wing
#

Maybe I should just try to provide params to data or to json param not to params

slate swan
#

some apis have this header

"Content-type": "application/json"

so it returns json

unkempt canyonBOT
slate swan
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
#

stop

#

stop going ot

#

๐Ÿ—ฟ

final iron
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
#

stop

#

what you get when all you do is spam ot commands๐Ÿ—ฟ

final iron
slate swan
#

๐Ÿ˜ผ

slate swan
#

!ot

unkempt canyonBOT
slate swan
#

pls go back to topic๐Ÿ™„

cold sonnet
#

I got pinged

heavy belfry
#

@bot.command(name="shop")
async def shop(ctx: commands.Context):
await ctx.send("Welcome to the shop!\n")
strange thing is everything else with this line and dif name works fine
async def shop(ctx: commands.Context):
AttributeError: 'Command' object has no attribute 'Context'

cold sonnet
#

you probably have overwritten commands

#

do you have a command named commands?

heavy belfry
#

yea

cold sonnet
#

rename that function

#

use the name keyword-argument in @bot.command()

heavy belfry
#

yayy, it works now, tyvm :D

cold sonnet
#

yw

fresh orchid
#

I have this json file

{"695229647021015040": {"warning_count": 1, "warn 1": "yes2"}}

and this code

warn_count = 1

            warns[str(member.id)] = {}
            if str(member.id) in warns:
                warns[str(member.id)]["warning_count"] += warn_count

When I run it I get

Key error warning_count

Why is this happening and how to fix it

slate swan
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | KeyError: 'lmao'
fresh orchid
#

?

#

how to fix it

slate swan
#

an example on how the error gets raised

fresh orchid
#

i know

#

but I want to fix it and i dont know how to

slate swan
#

bro its basic python

#

the key doesnt exist.

kindred epoch
#

you cant use "WHERE" in inserts pretty sure

#

are you trying to update a row or insert a row?

pliant gulch
#

You cannot use WHERE clause with INSERT

#

You can however use it with UPDATE

#

Like, UPDATE users WHERE id = ...

kindred epoch
#

then its

("UPDATE table_name SET cloumn_name = $1 WHERE column_name = $2",i,o)
``` something like that
#

wait no

pliant gulch
slate swan
#

hog riders is better tho

kindred epoch
#

yea

#

i get a little confused with fetching and updating

manic wing
#

no

#

would you show your mum the picture

#

if no, its nsfw

#

then its fine

unkempt canyonBOT
#

Qt Style Sheets support various properties, pseudo-states, and subcontrols that make it possible to customize the look of widgets.

vast gale
#

off topic for this channel and I have no idea what I just read

slate swan
final iron
#

Same

vast gale
#

check if the nick is in the list of stars

neat pagoda
#

Hi

#

can anyone help me?

#

I need to be able to ban people from the bot

slate swan
neat pagoda
#

here's my code, I need to unban tho

unkempt canyonBOT
#

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

Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
neat pagoda
#

no like different

slate swan
#

!d discord.Member.unban

unkempt canyonBOT
#

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

Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
slate swan
#

!d discord.Guild.ban

unkempt canyonBOT
#

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

Bans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
slate swan
#

!d discord.Guild.unban

unkempt canyonBOT
#

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

Unbans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
neat pagoda
#

not from a server

#

from a bot like

#
@client.command(pass_context=True)
@commands.check(check_Dev)
async def ban(ctx, banns): #command: bl!changeprefix ...
    
    with open('bans.json', 'r') as f:
      bans = json.load(f)

    bans[str(banns)] = banns
    with open('bans.json', 'w') as f: #writes the new ban into the .json
      
      json.dump(bans, f)
    await ctx.send(f"!!! Banned {banns}")      
   
@client.command()
@commands.check(check_Dev)
async def unban(ctx,banns):

  with open('bans.json', 'r') as f:
    prefixes = json.load(f)
    

  with open('bans.json', 'w') as f: 
    prefixes[str("unbanned")] = banns
    json.dump(prefixes, f)
  
  await ctx.channel.send(f'Unbanned {banns}')
#

where it'll log the ban to a data base

#

so they can't use the bot

slate swan
#

json isnt a db lol

slate swan
neat pagoda
#

but, it works fine with the ban, not the unban

neat pagoda
#

don't mind the id,

slate swan
#

!d discord.ext.commands.Bot.check

unkempt canyonBOT
#

@check```
A decorator that adds a global check to the bot.

A global check is similar to a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.

Note

This function can either be a regular function or a coroutine.

Similar to a command [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check"), this takes a single parameter of type [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").

Example...
slate swan
#

Is it possible to make sure that after restarting the bot, the variables are not reset, but there was that value before the restart?

slim ibex
#

๐Ÿ—ฟ

slate swan
neat pagoda
#

like

slate swan
#

yes its a database

neat pagoda
#

I neec oto have the unbanned

#

first, then the id

#

not vice versa, and not not at all

slate swan
neat pagoda
#

this is for an economy bot, that's why I need it

slate swan
slate swan
#

Ok

#

json isnt a database, it cant really store data

slim ibex
#

^

neat pagoda
#

I can ban

neat pagoda
#

but, I can't unban I don't why it don't work

slate swan
#

i recommend you use a database and then just use the global bot check

slim ibex
#

!d discord.Member.unban

unkempt canyonBOT
#

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

Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
slate swan
neat pagoda
slim ibex
#

oh

slate swan
#

lol

neat pagoda
#

yeah, thx anyways

slate swan
#

why is the slowmode so big 6s?

neat pagoda
#

lol idk

slim ibex
#

well he said unban ๐Ÿ—ฟ

slate swan
neat pagoda
#

rn my friend Guigui (the id)

slim ibex
#

just say blacklist lol

slate swan
#

ikr

neat pagoda
#

cannot use the bot as an example

#

but, when U unban her, she still cannot, because the json is logging new data

#

when i invert it do it's

prefixes[str(banns)] = "Unbanned"
#

it works, but it won't log to the first one

#

is there any way to just get the "id" and nothing else?

silent ermine
#

for cogs is it recommended to have super().__init__

silent ermine
manic wing
final iron
silent ermine
silent ermine
manic wing
#

w h a t

final iron
#

Nor is it recommended

silent ermine
slim ibex
versed shell
#

can someone help me figure out why I'm getting this error: Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "hello" is not found

manic wing
#

thats what super does

#

super().__init__() just calls the __init__ of the parent class

slim ibex
#

it calls the init method of the other class iirc

#

wait I just realized you were asking that guy if he knows what it is ๐Ÿ’€

silent ermine
slim ibex
#

^

versed shell
#

it's there tho

silent ermine
#

and if in cog did you load cog

versed shell
#
async def on_message(ctx, arg):
    if ctx.author == bot.user:
        return
        
    if ctx.content.startswith('hello'):
        await ctx.channel.send(arg)```
final iron
#

pain

slim ibex
#

bruh

final iron
slim ibex
#

holy fucking shit ๐Ÿ’€

final iron
#

Wait

versed shell
#

rip

final iron
#

They made a command called on_message ๐Ÿ—ฟ

manic wing
#

very confused

versed shell
#

so how should this look then

slim ibex
final iron
#

This confused me a lot

slim ibex
#

probably learn Python first and then how to use dpy or whatever fork you are using

final iron
#

It's like a mix between making commands in an on_message event and using the commands extension

slate swan
slim ibex
#

!d discord.on_message

unkempt canyonBOT
#

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

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

Warning

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

is this right ```@bot.command()
async def on_message(message):
if message.author == bot.user:
return

if message.content.startswith('$hello'):
    await message.channel.send('i')```
manic wing
#

sort of

versed shell
#

what does that mean

#

because I still get the error

final iron
slim ibex
#

not a command ๐Ÿ’€

wicked atlas
#

on_member_join

#

Well event's don't have context

manic wing
#

you dont call event

#

and there is no ctx

wicked atlas
#

You should only have the member parameter

manic wing
#

idk why people just chuck ctx everywhere

#

its not going to spawn out of nowhere

wicked atlas
#

you dont call event
and there is no ctx

#

No, you just don't call it

@client.event
hoary cargo
#

MR_uncanny_10 so you don't know python

wicked atlas
#

This is pretty basic programming stuff, ngl```py
@client.event() # calling it
@client.event # not calling it

#

Then why are you making discord bots

hoary cargo
wicked atlas
#

it's not really a beginner thing, there are many concepts that become super confusing unless you know at least an intermediate level of python

hoary cargo
#

you won't go too far without any basics in python

#

it's like you want to write in chinese just for fun but you have no knowledge about chinese alphabet

pliant gulch
#

There isn't even an alphabet in chinese

final iron
#

๐Ÿ—ฟ

rotund frigate
#

i tried to make a command where if this author sends this embed
Image
it would say 'HEY ITS A RAT'
i want to identify it with the image url

slate swan
#

you cant log everything as said to you.

tawdry plover
#

Yeah, events.

manic wing
#

If you do, I will make you a Discord server in return.

slim ibex
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

manic wing
#

i can make a server with the + icon

slate swan
tawdry plover
tawdry plover
slate swan
tawdry plover
#

Many bots have logging features.

slate swan
tawdry plover
#

I'm only going to log when messages are deleted, when a member leaves etc

slate swan
#

!d discord.on_message_delete

unkempt canyonBOT
#

discord.on_message_delete(message)```
Called when a message is deleted. If the message is not found in the internal message cache, then this event will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_delete "discord.on_raw_message_delete") event instead.

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

Of what.

slate swan
#

!d discord.on_member_join

unkempt canyonBOT
#

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

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

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

ah remove

wicked atlas
#

It's as it says

#

Either do it outside the fstring, or use format

#

which is outside the fstring...

manic wing
#

you have the \n

wicked atlas
#

Yes you do, the newline character

pliant gulch
#

!e ```py
f"{\n}"

manic wing
#

it is the issue

unkempt canyonBOT
#

@pliant gulch :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     f"{\n}"
003 |            ^
004 | SyntaxError: f-string expression part cannot include a backslash
pliant gulch
#

Your join

#

Is using a newline

quaint epoch
#

is this a bug? - i added soul music bot to my server, made sure that it can't see any messages except in the bots channel, so when i ran /play and joined a voice channel (that it was not suppsosed to see) it joined it somehow?

pliant gulch
#

which is in the f-string expression..

kindred epoch
quaint epoch
slate swan
#

give it to your mompithink

#

as a mothersday gift

#

i think ash is asleep lol

manic wing
#

its only 11

slate swan
#

yeah๐Ÿ’

#

yeah dont

#

self bots lol

manic wing
#

nitro is way too overpriced

slate swan
#

yeah classic should be 2$

#

wow

#

thats allot

manic wing
#

defo fake

hazy scaffold
#

wait its real

slate swan
manic wing
#

nothing is ever free

#

and it if is free, it shouldnt be.

slate swan
#

especially when it costs a few bucks for each

hazy scaffold
slate swan
hazy scaffold
#

well yeah-
but its legit?

slate swan
#

credit card theft

manic wing
hazy scaffold
#

;-;
||gimme nitro||

slate swan
#

thats nice saw his badge get added lol

kindred epoch
#

if that server exists why not just join and win one

slate swan
#

i didnt say youre a liar pithink

manic wing
#

i think giving away scam nitro is probably against the tos of this server

#

reptile

#

where do you think they got the nitro from?

#

๐Ÿคฆ

slate swan
hazy scaffold
#

how was that real

#

didnt remember

kindred epoch
slate swan
#

i saw the badge get added lol

manic wing
#

okimii wants that nitro now

slate swan
#

cuz it wont go through and i cant get it since discord doesnt accept that method of payment๐Ÿ˜”

hazy scaffold
slate swan
#

kinda dumb imo

manic wing
#

discord out here ripping off naive kids

slate swan
#

lol i just want it because of the 100mb upload limit

#

since the defualt is 8

#

i hate it its so tiny

manic wing
#

you're paying $100 a year to be able to upload a larger file once in a blue moon

#

great investment

rotund frigate
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.

rotund frigate
#

what is that?

slate swan
#

and embed is a string

slim ibex
#

make code blocks

manic wing
rotund frigate
final iron
slate swan
#

basically

silent ermine
#

So i have a leveling module and I want a disable/enable command. I was able to put a new column thats called leveling_is_active but when I enable it it keeps saying that it isnt enabled.

Here is my code and there is no error message py @commands.command() async def rank(self, ctx, user:nextcord.User=None): db = sqlite3.connect('main.sqlite') cursor = db.cursor() cursor.execute(f"SELECT leveling_is_active FROM levels WHERE guild_id = '{ctx.guild.id}'") result1 = cursor.fetchone() if result1 == 1: if user is not None: db = sqlite3.connect('main.sqlite') cursor = db.cursor() cursor.execute(f"SELECT user_id, exp, lvl FROM levels WHERE guild_id = '{ctx.message.guild.id}' AND user_id = '{user.id}'") result = cursor.fetchone() if result is None: await ctx.send("That user is not yet ranked!") else: await ctx.send(f'{user.name} is currently level `{str(result[2])}` and has `{str(result[1])}` XP!') cursor.close() db.close() elif user is None: db = sqlite3.connect('main.sqlite') cursor = db.cursor() cursor.execute(f"SELECT user_id, exp, lvl FROM levels WHERE guild_id = '{ctx.message.guild.id}' AND user_id = '{ctx.message.author.id}'") result = cursor.fetchone() if result is None: await ctx.send("That user is not yet ranked!") else: await ctx.send(f'{ctx.message.author.name} is currently level `{str(result[2])}` and has `{str(result[1])}` XP!') cursor.close() db.close() else: return await ctx.reply("Leveling is not enabled.")
0 = False
1 = True

slate swan
#

yes False is 0 and True is 1

silent ermine
#

flabber gasted

final iron
#

!pypi aiosqlite

unkempt canyonBOT
silent ermine
#
  1. so replace sqlite3 with aiosqlite?
final iron
#

That's not the point

slate swan
silent ermine
final iron
slate swan
#

and follow pep8๐Ÿ’

silent ermine
slim ibex
#

!sql-fstrings

unkempt canyonBOT
#

SQL & f-strings
Don't use f-strings (f"") or other forms of "string interpolation" (%, +, .format) to inject data into a SQL query. It is an endless source of bugs and syntax errors. Additionally, in user-facing applications, it presents a major security risk via SQL injection.

Your database library should support "query parameters". A query parameter is a placeholder that you put in the SQL query. When the query is executed, you provide data to the database library, and the library inserts the data into the query for you, safely.

For example, the sqlite3 package supports using ? as a placeholder:

query = "SELECT * FROM stocks WHERE symbol = ?;"
params = ("RHAT",)
db.execute(query, params)

Note: Different database libraries support different placeholder styles, e.g. %s and $1. Consult your library's documentation for details.

See Also
โ€ข Extended Example with SQLite (search for "Instead, use the DB-API's parameter substitution")
โ€ข PEP-249 - A specification of how database libraries in Python should work

slate swan
#

and you can do

if not result:

over

if result is None:
silent ermine
kindred epoch
silent ermine
#

got it

slate swan
#

youre ok because youre not getting user input so sql injection is not possible but its good practice

final iron
silent ermine
#

instead of in a command?

final iron
#

No

slate swan
final iron
#

!bot-var

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

final iron
silent ermine
final iron
#

No

slate swan
#

its a global variable bound to your bot obj

silent ermine
#

ok

slate swan
#

html isnt a programming language

silent ermine
left crater
manic wing
slate swan
left crater
#

i know that

slate swan
#

?

silent ermine
#

o-o you can code in html toopid
you can use js in it

left crater
#

but if it doesn't count as a programming language then what is it

pliant gulch
#

How is html not a programming language

silent ermine
left crater
#

^

manic wing
#

okimii trying to shitstir

silent ermine
manic wing
#

!ot

unkempt canyonBOT
manic wing
#

still off topic

#

go to an off topic channel

slate swan
unkempt canyonBOT
slate swan
#

yeah change the topic after you read that page๐Ÿ˜”

tacit storm
#

dude

#

stop.

silent ermine
#

well so

slate swan
#

.topic

lament depotBOT
#
**What feature would you be the most interested in making?**

Suggest more topics here!

slate swan
#

more topics for this bot

silent ermine
#

on a command, after (under it) @client.command() or @commands.command()
@commands.has_permissions(permission here)
so if you wanted admin perm
@commands.has_permissions(Administrator=True)

tacit storm
#

if you want one to check if the bot has perms

manic wing
#

not exactly

pliant gulch
#

It would be easier just to check view_audit_log of Member.guild_permissions

#

Checking if this is either True or False

silent ermine
tawdry plover
#

:O

silent ermine
tawdry plover
silent ermine
manic wing
#

its the magical time

#

00:00

tawdry plover
#

Wdym

pliant gulch
#

I guess it depends on the channel, cause guild_permissions as the name suggests, would be guild wild

silent ermine
#

coding is annoying when you have to rewrite the code

silent ermine
final iron
#
await import aiosqlite
#

๐Ÿ—ฟ

slate swan
#

depends on the method

#

most methods are coroutines yes

rotund frigate
#

if (message.author.id == '77432345678') {
message.embeds.forEach(function(e) {
console.log(e);
if (e.title && e.title.startsWith('New Meme Post')) {
message.channel.send('thats a meme lol}');
}
});
}
i saw this and i wanted to do something like it but instead of the title i want the image url

slate swan
#

why is their js

silent ermine
#

why not just put it at the top

slate swan
silent ermine
slate swan
#

youre comparing an int to a str

rotund frigate
#

wait thats js?

slate swan
#

javascript

manic wing
rotund frigate
#

0-o

manic wing
#

we dont use {}

rotund frigate
#

no i cant go back to it, i swore not to

slate swan
#

you have

console.log
rotund frigate
#

please can it be converted to python?????

rotund frigate
#

WHYYY!Y!!!!!

manic wing
#

we dont convert code, we assist not do it for you

lyric tusk
#

how can i remove the 00:07;34.... i am using datetime

rotund frigate
#

but can it be done?

slate swan
#

pov: caeden doesnt know js

manic wing
slate swan
#

how do i fix this?

rotund frigate
slate swan
#

even the love language ๐Ÿ˜ณ

manic wing
#

js is basically python but they ripped off our syntax

manic wing
slate swan
slate swan
manic wing
#

;)

slate swan
#

yea just realized always happen after i ask

slate swan
slate swan
#

discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "minutes".

#

oof

slate swan
#
min: int = 1
silent ermine
slate swan
silent ermine
tacit storm
#

youโ€™re missing an โ€œ:โ€

slate swan
slate swan
tacit storm
#

ah

slate swan
#

how would i make it so after they click the button the button is then disabled using discord.py

native wedge
#

how do i change bot status when it loads

tacit storm
unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

slate swan
tacit storm
manic wing
unkempt canyonBOT
#

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

Changes the clientโ€™s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
silent ermine
# slate swan show
    @commands.command()
    async def rank(self, ctx, user:nextcord.User=None):
        db = sqlite3.connect('main.sqlite')
        cursor = db.cursor()
        cursor.execute(f"SELECT leveling_is_active FROM levels WHERE guild_id = '{ctx.guild.id}'")
        result1 = cursor.fetchone()
        if result1 == int(result1[0]):
            if user is not None:
                db = sqlite3.connect('main.sqlite')
                cursor = db.cursor()
                cursor.execute(f"SELECT user_id, exp, lvl FROM levels WHERE guild_id = '{ctx.message.guild.id}' AND user_id = '{user.id}'")
                result = cursor.fetchone()
                if result is None:
                    await ctx.send("That user is not yet ranked!")
                else:
                    await ctx.send(f'{user.name} is currently level `{str(result[2])}` and has `{str(result[1])}` XP!')
                cursor.close()
                db.close()
            elif user is None: 
                db = sqlite3.connect('main.sqlite')
                cursor = db.cursor()
                cursor.execute(f"SELECT user_id, exp, lvl FROM levels WHERE guild_id = '{ctx.message.guild.id}' AND user_id = '{ctx.message.author.id}'")
                result = cursor.fetchone()
                if result is None:
                    await ctx.send("That user is not yet ranked!")
                else:
                    await ctx.send(f'{ctx.message.author.name} is currently level `{str(result[2])}` and has `{str(result[1])}` XP!')
                cursor.close()
                db.close()
        else:
            return await ctx.reply("Leveling is not enabled.")```
tacit storm
slate swan
silent ermine
#

e

slate swan
silent ermine
slate swan
silent ermine
slate swan
#

and inefficient

silent ermine
slate swan
#

im just saying bad practice isnt goodpithink

silent ermine
slate swan
silent ermine
slate swan
#

im just suggesting you it if you dont follow it not really my problem but im doing it so you dont end up with bad habits.

slate swan
#

its for your sake after all

final iron
silent ermine
final iron
slate swan
#

how do i fix this break? error saying "break can be used only within a loop"

#

after i was told to add int = 1

slate swan
uncut zephyr
#

Hey guys, I hope I can ask my question here, I get this error very often and dont know how it gets triggert.

slate swan
slate swan
uncut zephyr
#

Yeah I know, But my bot has no contact with other bots

slate swan
#

what?

uncut zephyr
#

Can you name an example of how this could get triggert?

rotund frigate
#

How do i detect if an embed message has the title "a new meme appeared"

slate swan
slate swan
sick birch
uncut zephyr
slate swan
slate swan
sick birch
slate swan
uncut zephyr
uncut zephyr
#

bro just respond normal xD

slate swan
#

its basic oop the User class doesnt have that attribute

rotund frigate
#

so like this? if message.embeds -> List[.title == new meme!] await message.channel.send('thats funny')

uncut zephyr
#

yes user has no attr "roles" course bots are "user". I get this... But this is not my question

sick birch
#

What is your question?

sick birch
slate swan
#

Robin was juat saying what the attr returns

sick birch
#
for embed in messsage.embeds:
  # loops through each embed in a given message
slate swan
#

what would i have to install to fix ImportError: cannot import name 'Embed' from 'discord.embeds' (/home/runner/rewardbot/venv/lib/python3.8/site-packages/discord/embeds.py)

silent ermine
uncut zephyr
final iron
slate swan
final iron
#

Quite simple

sick birch
#
"a new meme appeared" in map(lambda emb: emb.title, message.embeds)

^ something like this would work

sick birch
rotund frigate
sick birch
#

sure that would work

rotund frigate
#

what is lambda btw

sick birch
#

Though I would suggest try to understand what it does instead of copy-pasting it

sick birch
slate swan
#

ImportError: cannot import name 'Embed' from 'discord.embeds' (/home/runner/rewardbot/venv/lib/python3.8/site-packages/discord/embeds.py)

could anyone help i'm so confused i'm using replit.com rn

pliant gulch
#

functions can be one line as well

pliant gulch
#

lambdas are just anonymous functions

slate swan
sick birch
#

!e

x = [1, 2, 3, 5]
print(list(map(lambda x: x*2, x)))
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

[2, 4, 6, 10]
sick birch
#

hopefully that helps you understand

#

both map + lambda since often they are used together

slate swan
#

!e

print(list(map(str, [n for n in range(101)])))

i.e

tacit storm
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']
slate swan
#

lol

tacit storm
uncut zephyr
sick birch
sick birch
tacit storm
rotund frigate
tacit storm
silent ermine
tacit storm
#

ill dumb it down, replit is by far the worst host and is even worse for discord bots

sick birch
tacit storm
sick birch
#

And those guys are used everywhere, very reliable and have a wide variety of tools for you in the future

tacit storm
#

^^

uncut zephyr
sick birch
#

700 free hours of t2.micro instances per month for a full year

tacit storm
#

using replit for your bot is basically shooting your bot in the head

uncut zephyr
brave vessel
#

I think they're trying to say don't use repl.it to host your bots, it would be fine if you coded in it I suppose because it's not a horrible IDE but it's not a great host

sick birch
uncut zephyr
#

yeah sure

sick birch
uncut zephyr
#
@client.event
async def on_message(message):
    if message.author.bot or client.emergency == True:
        if client.emergency == False and client.guess >=0 and client.mchannel == message.channel and len(message.content.split()) == 5:
            client.remove.append(message.id)
        elif client.emergency == False and client.guess >= 0 and client.mchannel == message.channel and message.author.bot and len(message.content.split()) != 5:
            client.remove.append(message.id)
        elif discord.utils.get(message.guild.roles, name=client.rolename) in message.author.roles and message.content ==(str(client.command_prefix) + "stopemergency"and client.mchannel == message.channel):
            await client.process_commands(message)
tacit storm
sick birch
#

"good free host" is a bit of an oxymoron

rotund frigate
uncut zephyr
#

ahhh looks bad

sick birch
brave vessel
tacit storm
#

also, dont use heroku either, jsyk

sick birch
#

that's just as bad yeah

brave vessel
#

.topic

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

uncut zephyr
#

Yeah these lines are so long ๐Ÿ˜‚ ๐Ÿ™ˆ

brave vessel
# lament depot

hm, pretty much all of them are unique because I made my bot for a specific purpose

sick birch
tacit storm
# lament depot

most unique by far is my bot logging videos and images without discord deleting it off of their database

#

like 0.1 of all logging bots log videos as far as i know which makes if special as is

final iron
tacit storm
pliant gulch
#

inb4 bot downloads copyrighted material

tacit storm
#

ah

pliant gulch
#

Logging is kinda scummy anyways imo

brave vessel
# manic wing what specific purpose?

so i do student council, and i made a bot to organize things like meetings and events and what not, so it could be organized rather than manually counting it

untold anchor
#

Ok so I made a giveaway command but I was wondering how to make it first of all so if no one wins the bot sends a msg saying like No one has won the giveaway plus so it doesn't send a error in console,
how to make it so the bot can't win

manic wing
pliant gulch
#

And downloading all this stuff just means extra bandwith being used

final iron
sick birch
manic wing
#

thought so but didnt work in that context

tacit storm
sick birch
native wedge
#

is it safe to do Bot.change_presence during on_ready?

sick birch
#

No

final iron
pliant gulch
native wedge
tacit storm
rotund frigate
untold anchor
#

@sick birch yeah

sick birch
rotund frigate
#

12 months and all my work is reset?????

tacit storm
untold anchor
#

So like if no one enters aka no one wins how to do I make it send a msg instead of sending a error in console

sick birch
rotund frigate
#

so its not free?

pliant gulch
sick birch
final iron
sick birch
#

You will either have to pay to keep using their servers or find a different host

tacit storm
#

it downloads it for like a brief second and gets rid of it

sick birch
#

Which is what hosting is anyway

tacit storm
final iron
pliant gulch
native wedge
#

how do i do change_presence automatically but not on_ready

uncut zephyr
# sick birch What exactly are you trying to do here?

good question tbh.

the second "if" adds the current message to a list -> This message will be deleted after the game ends.

3 if (elif):
same, just with some little extras

4 if (elif) (the error line)
If someone wants to stop the Bot, he (if he s an admin) can type this "stop..." stuff. Then the Bot will skip the "on_message" code below

So the first "if" statements are like always False when the error gets triggert. So they are not important.
And the "if" statement on line 859 checks, if the person has an admin role, if someone writes "stopemerg...." and the last part is useless lol. Its hard to explain tbh.
I can understand if you cant help me with this one, in connection with this answer ๐Ÿ™ˆ

sick birch
#

!d discord.ext.commands.Bot

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.
pliant gulch
#

Probably not

native wedge
tacit storm
#

no, if it was the case, bots like dyno or mee6 would be gone already.

pliant gulch
#

mee6 should be deleted anyways

tacit storm
#

true

sick birch
lost lichen
#

How can i make it so that it doesnt time out even tho it works, make the bot react to the embed with the emojis (so that users can easily react) and make it so only one emoji can be reacted to so that it doesnt accept other inputs? and how can i make it only "listen" to the user who executed the command?

uncut zephyr
#

@sick birch I think I will just delete this lines, they are even pointless, but would be still cool to know why this error occurs.

But in general this question is done, thanks

pliant gulch
#

Looks weird, never seen bot path before and I've done a lot of stuff with DAPI, an in any other case discord uses /science endpoints for metrics

untold anchor
#

@sick birch

sick birch
#

Yes?

untold anchor
#

So with the giveaway command I only need help with 2 things

#
  1. How do I make it so the bot doesn't win and if the bot picks itself it rerolls and picks a actual user
  2. How do I make it so if no one enters it doesn't send a error in console saying the giveaway winner list was empty
sick birch
untold anchor
#

yeah

#

You react to the bots msg to enter the giveaway

sick birch
lost lichen
#

How can i make my reaction roles only listen to the command executor? currently it accepts any user..

list_of_emojis = ['๐Ÿ”ด','๐ŸŸก','๐ŸŸข']

def check(reaction):
    if reaction.emoji not in list_of_emojis:
        return

    elif reaction.emoji == "๐ŸŸข":
        print('green')
        return
        

    elif reaction.emoji == "๐ŸŸก":
        print('yellow')
        return
        

    elif reaction.emoji == "๐Ÿ”ด":
        print('red')
        return
        


try:
    await ctx.bot.wait_for('reaction_add', timeout=15.0, check=check)
except asyncio.TimeoutError:
    print('timed out')
else:
    await ctx.send('API Call sent!')
untold anchor
#

or well how would I enter it

sick birch
untold anchor
#

if len(users) == 0:
await ctx.send("No winner was decided")

lost lichen
sick birch
untold anchor
#

that is what I have that makes the bot send a msg if no users enter

untold anchor
#

So those 3 lines of code should make it so 1. the bot can't win and 2. if no one enters no error is sent in console

#

I removed the : from the 1 because I got a syntax error in console

untold anchor
#

await ctx.send("No winner was decided")โ€Š
^
SyntaxError: invalid syntax

#

the ^ is below the a in await

#

though I don't see anything wrong with await ctx.send("No winner was decided")

sick birch
#

What's around it?

#

Sometimes other lines can cause that issue

untold anchor
#

um

subtle kindle
#

Guys

untold anchor
#

do you care if I dm you a picture of all the code around it

subtle kindle
#

how do I learn discord bot coding

untold anchor
#

cause the picture also has other tabs I have open in it

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.

sick birch
#

Just copy paste the 4 or 5 lines around it

slim ibex
subtle kindle
untold anchor
#

users = await new_gaw_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))

winner = random.choice(message.reactions[1:]

if len(message.reactions) == 1
await ctx.send("No winner was decided")

await ctx.send(f"Congratulations {winner.mention}! Yuo have won the giveaway for **{prize}**!")
slate swan
untold anchor
#

where

untold anchor
#

when I put 1: it said syntax error

sick birch
slate swan
#

how i fix this?

slate swan
subtle kindle
untold anchor
#

@sick birch I removed the : there because it gave me a syntax error

#

now it's giving me a syntax error for the code directly below that

sick birch
#

Well : is important

slate swan
subtle kindle
#

which does what?

sick birch
#

If it's giving you an error directly below that it might be your indentation

untold anchor
#

Is there anything i could put around the 1 so it doesn't give a error

slate swan
sick birch
#
users = await new_gaw_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))

winner = random.choice(message.reactions[1:]

if len(message.reactions) == 1:
  await ctx.send("No winner was decided")โ€Š

  await ctx.send(f"Congratulations {winner.mention}! Yuo have won the giveaway for {prize}!")

is this how your code looks like?

slate swan
#

!resources @subtle kindle

unkempt canyonBOT
#
Resources

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

slate swan
subtle kindle
#

So ik when I'm not one

slate swan
#

?

slate swan
slim ibex
#

bro said google beginner ๐Ÿ’€

slate swan
#

bro what

#

it wasnt closed

untold anchor
#

@sick birch the way you had it before

slate swan
subtle kindle
untold anchor
#

with the code above if len indentended to the right

slate swan
slate swan
subtle kindle
#

I mean in here

slate swan
subtle kindle
#

So none are more important then others?

slate swan
unkempt canyonBOT
#

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

001 |   File "<string>", line 1
002 |     print(len("lol")
003 |          ^
004 | SyntaxError: '(' was never closed
untold anchor
#

yeah whenver I add a : next to the 1 it gives me a syntax error

sick birch
untold anchor
#

I put a : next to the 1 and it gave me a syntax error

sick birch
#

Send a picture this time, instead of a code block

untold anchor
subtle kindle
untold anchor
#

@subtle kindle ?\

subtle kindle
#

I mean nice that you can code python

untold anchor
#

Half of this is from tutorials and the other half is primarly me learning how to code

sick birch
# untold anchor

I'm not seeing any squiggly lines? Unless your IDE or whatever that is doesn't show it

subtle kindle
#

still

untold anchor
#

@sick birch wym

#

squiggly lines?

sick birch
#

IDEs usually show squiggly lines underneath where exactly the error happens

slate swan
unkempt canyonBOT
#

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

001 |   File "<string>", line 1
002 |     print(len("i hate you!")
003 |          ^
004 | SyntaxError: '(' was never closed
slate swan
#

figured it out though

slate swan
untold anchor
#

I don't think that shows it

sick birch
#

just like this for example

untold anchor
#

I have my code viewer thing set tto Python

slate swan
subtle kindle
sick birch
#

Right

slate swan
untold anchor
#

@sick birch do you see anything wrong with that code?

sick birch
# untold anchor

Delete the code and try to write it yourself without copy/pasting, that sometimes fixes it since whitespaces from copy pastes can get messed up

slate swan
untold anchor
#

Would me using nextcord mess up that code

slate swan
slate swan
subtle kindle
#

okimii

slate swan
subtle kindle
#

If you have been learning python for 4 months should you be good at it?

subtle kindle
#

depends on me lol

slate swan
#

depends on your learning speed passion time etc

subtle kindle
#

I'm not a quick learner

sick birch
#

Took me ~2 years to actually get decent at it and have the confidence in my skills to put it to good use

slate swan
#

took me about 7 months

#

im a fast learner btw

subtle kindle
#

what programs

#

so I can know what level you were on I guess

slate swan
sick birch
#

What do you expect in this channel

subtle kindle
slate swan
#

i dont do them anymore tho pithink

sick birch
subtle kindle
#

My account got disabled 3 times in the past 2 days for nothing

slate swan
#

i make api wrappers and i wrap robins apis๐Ÿ˜ณ

subtle kindle
#

I think A discord mod doesn't like me

sick birch
sick birch
#

the only one :p

subtle kindle
#

What age did you guys start learning at

tacit storm
unkempt canyonBOT
sick birch
#

Hmmm

slate swan
slate swan
tacit storm
subtle kindle
slate swan
#

seen people start at 13 tho

slate swan
#

lol

sick birch
slim ibex
#

I started coding at 5๐Ÿ—ฟ

slate swan
#

if you can make a subclass with multiple inheritance i think youre good

tacit storm
kindred epoch
slate swan
slim ibex
#

dang bro that was funny

slate swan
#

binds is a big boy now ๐Ÿ˜ค

kindred epoch
slim ibex
#

๐Ÿ—ฟ

tacit storm
#

!ot

unkempt canyonBOT
subtle kindle
tacit storm
#

stop fucking talking off topic here.

slim ibex
slate swan
#

math๐Ÿ˜ก

subtle kindle
kindred epoch
tacit storm
subtle kindle
slim ibex
#

!ot

slate swan
#

๐Ÿ˜”

#
c:\Users\Andrew\Desktop\a\main.py:4: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils import command
``` whats this?
tacit storm
slate swan
subtle kindle
#

I might go now wish me luck that my account doesn't get disabled

slate swan
#

i need that module

#

was just working now it isnt

subtle kindle
#

thanks

tacit storm
slate swan
slim ibex
subtle kindle
#

geometry

#

really.........

slim ibex
#

๐Ÿ—ฟ

slate swan
slim ibex
#

true though

slate swan
slim ibex
#

trig is nice too

subtle kindle
slate swan
#

see what i did their ;))

subtle kindle
#

python

manic wing
tacit storm
#

!ot

unkempt canyonBOT
tacit storm
#

stop talking here about unrelated shit or ill get mods

slate swan
subtle kindle
#


a = input("What's your favourite subject?")

if a != 'Math':
     print("You're normal")
else:
     print('Damn really')
#

how do you guys get used to putting code in perfect space

hoary yacht
#

someone linked me here?

tacit storm
#

i use tab to space it for me in my IDE

subtle kindle
#

without it how would you guys know

#

practice I guess ???

thick sigil
#

1 tab 4 spaces

slate swan
#

afaikpithink

thick sigil
#

ye but i dont remember you sorry ๐Ÿ˜จ

slate swan
tacit storm
#

!ot

unkempt canyonBOT
slate swan
#

we should listen to poor sawshapithink

thick sigil
#

๐Ÿ˜ด

tacit storm
slate swan
#

are there any benefits of using the raw discord api in python?

final iron
#

But not worth the headache

slate swan
#

my bot which is 150 servers uses raw api for some stuff cause it's faster

slate swan
#

Yeah I know, it feels odd

#

and youll have to make endpoints manually which is allot

#

Yeah was a pain in the head

slate swan
slate swan
slate swan
slate swan
#

Thanks for Letting me know, cheers

slate swan
winged crane
#

how can I use a loop to make my bot repeat the result until it gets the desired reply? for example: a random number generator, how could i make it generate a number until the the number 78 is selected

kindred epoch
winged crane
#

yes, but how....

kindred epoch
#

if statements?

winged crane
#

No?

kindred epoch
#

huh?

winged crane
#

how would I make the process repeat with a if statement.

rotund creek
#

!pastebin

#

@slate swan , hey, so I used interaction.followup.send() and I get a unknown webhook error

kindred epoch
pliant gulch
#
while random.randint(0, 78) != 78:
    ... # do stuff

print("finished")
```would probably be better
#

The loop ends and calls print after random.randint returns 78