#discord-bots

1 messages · Page 681 of 1

maiden fable
#

Gaining servers --> Good
No response still --> Bad

tawdry perch
#

becoming tech support --> Bad

maiden fable
#

For discord? Yes

tawdry perch
#

no I mean having public bot => you become a tech support

maiden fable
#

Haha true tho

tawdry perch
#

DMs be like: "How to use the bot"

maiden fable
#

Used to get those at the start

#

Not nowadays

leaden cargo
#
async def on_message_edit(before, after):
  await before.channel.send(f"{str(after.content)}\n \n Editado por: {before.author}")```
Can someone help me, its not working...
boreal ravine
#

how do i use a cog_check method for my cog

cerulean canyon
#

why cant i understand any of this code

leaden cargo
cerulean canyon
#

ah i feel like i will never understand it

leaden cargo
#

ahhahahahaha, well im starting to feel that way aswell, i cant make that thing work

cerulean canyon
#

ahh damn im really new to coding so im not good at it

slate swan
#

Hello bro

leaden cargo
cerulean canyon
#

like both

#

were u ever in that situation

leaden cargo
#

ofc we all did at some point

cerulean canyon
#

ah how long did it take for u to master python

leaden cargo
#

im not a master or even close ahahha, but i can handle myself on normal programing

boreal ravine
leaden cargo
maiden fable
boreal ravine
maiden fable
#
async def cog_check(self, ctx):
    return ctx.author.id == 1234
boreal ravine
#

i tried this ```py
async def cog_check(self, ctx):
return ctx.guild.id == ...

maiden fable
#

It does work

boreal ravine
#

it didnt

boreal ravine
maiden fable
#

!d discord.ext.commands.Cog.cog_check

unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
maiden fable
boreal ravine
#

oh

maiden fable
#

Only commands

leaden cargo
#
async def on_message_edit(before, after):
  await before.channel.send(f"{str(after.content)}\n \n Editado por: {before.author}")```
can u help with this?
#

its not working whatsoever

#

i once made it work but not the way i wanted

maiden fable
#

What's the error

leaden cargo
#

it doesnt even give an error

maiden fable
#

Hmm

#

Do u have intents

leaden cargo
#

it was like its not even reacting to the event

maiden fable
#

It needs messages intent

#

!d discord.Intents.messages

unkempt canyonBOT
slate swan
#
<
Can i code a discord bot if I understood basic python?? 
>
leaden cargo
#

so im suposed to use guid_messages?

#

hm

#

thx ill check it out

high pasture
leaden cargo
boreal ravine
#

do custom checks work with events

leaden cargo
#

depending on your objectives ofc

fading harness
#

hi, here is my code:

    @commands.group()
    async def what(self, ctx):
        try:
            await ctx.send()
        except:
            pass
    
    @what.group()
    async def is(self, ctx):
        try:
            await ctx.send()
        except:
            pass```
#
raceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 660, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 839, in exec_module
  File "<frozen importlib._bootstrap_external>", line 976, in get_code
  File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/runner/choithediscordbot-3/cogs/general.py", line 52
    async def is(self, ctx):
              ^
SyntaxError: invalid syntax

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

Traceback (most recent call last):
  File "main.py", line 52, in <module>
    bot.load_extension(f"cogs.{filename[:-3]}")
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 732, in load_extension
    self._load_from_module_spec(spec, name)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 663, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.general' raised an error: SyntaxError: invalid syntax (general.py, line 52)
#

this is my error

boreal ravine
#

!e

def is():
  ...
is()
unkempt canyonBOT
#

@boreal ravine :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     def is():
003 |         ^^
004 | SyntaxError: invalid syntax
fading harness
#

ok

boreal ravine
slate swan
#
@commands.has_role("Owner")
async def reroll(ctx, channel : nextcord.TextChannel , id_ : int):```

What id do i have to use here>??? after the nextcord.Textchannel
lament mesa
slate swan
#

@client.command()
@commands.has_role("Dumb Idiot")
async def reroll(ctx, channel : nextcord.TextChannel , id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
await ctx.send("This was entered incorrectly.")
return

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

winner = random.choice(users)

await channel.send(f"Congratulations! The new winner is {winner.mention}.They won {prize}!")
boreal ravine
slate swan
#

i tried

#

rerolling

boreal ravine
#

whats the error then

slate swan
#

error says argument missing

boreal ravine
#

pass in an argument then

#

!reroll #general 920613916755783730

slate swan
quick gust
#

it's a random message ID

slate swan
#

Hey guys

boreal ravine
#

^^

slate swan
boreal ravine
slate swan
#

raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: IndexError: list index out of range

boreal ravine
#

or the bot didnt react ig

slate swan
#

oh

quick gust
#

yep

slate swan
#

raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'prize' is not defined

#

bot did react

#

i copied the id of the message that has the reaction

boreal ravine
slate swan
#

!paste

quick gust
#

that's why it gave an error

#

nobody else except the bot reacted

slate swan
quick gust
#

no clue then ¯\_(ツ)_/¯

slate swan
#

hmm

boreal ravine
slate swan
boreal ravine
slate swan
#

i think

#

i used the right id

#

extcord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'prize' is not defined

#

what does this mean now??

boreal ravine
#

hm

slate swan
#

do i have to change prize to any other

boreal ravine
slate swan
#

name 'prize' is not defined

boreal ravine
#

!e

print(prize)
``` i dont think i need to help you with this
unkempt canyonBOT
#

@boreal ravine :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 'prize' is not defined. Did you mean: 'print'?
slate swan
velvet tinsel
#

Where’s the code 😳

valid barn
#
@client.command(name='shop')
async def shop(ctx):
  embed = discord.Embed(description = "Here are the items available in the shop.", color = 0xF5F5DC)
  for item in shopp:
    name= item["name"]
    price= item["price"]
    desc= item["description"]
    embed.add_field(name = f"{name}{price} :cherries_:", value=f"{desc}", inline = False)
  embed.add_field(name="", value = "Not sure how to earn :cherries_:? run `m.help`", inline = False)
  embed.set_footer(text="Do you know you can earn 1000 cherries just by subscribing to milkylatte on YouTube?")
  await ctx.channel.send(embed=embed)

this gives an error, why doesnt it work :(

boreal ravine
#

it cant be an empty string

boreal ravine
velvet tinsel
#

Hi kayle

valid barn
#

oh

velvet tinsel
valid barn
#

ty

small igloo
#

why my code send CommandNotFound error message when there is a comand about that and why when my code not found it send the message twice...?

dapper cobalt
#

Can you show the command's code and how you defined your Bot instance?

small igloo
dapper cobalt
#

In other words, your bot might be hosted twice.

velvet tinsel
#

Nice undertale fan

small igloo
velvet tinsel
#

And you use scratch

small igloo
velvet tinsel
#

😭

#

Anyways show code

#

We can’t help you if you show no code

small igloo
# velvet tinsel Anyways show code

import discord
import requests
import youtube_dl
from discord.ext import commands
from discord.ext.commands import CommandNotFound
bot = commands.Bot(command_prefix="sal! ", help_command=None)

@bot.event
async def on_command_error(ctx, error):
if isinstance(error, CommandNotFound):
not_found = discord.Embed(title="command not found!", description="command not found! might be in progress, check sal! help for the available commands", color=ctx.author.color)
await ctx.send(embed=not_found)
raise error

@bot.event
async def on_ready():
print("ready")

@bot.command()
async def help(ctx):
help = discord.Embed(title="all the commands available",description="",color=ctx.author.color)
help.add_field(name="help", value="shows this message",inline=True)
await ctx.channel.send(embed=help)

#nvm the closed code below, just some ytdl stuffs
||@bot.command()||
||async def play(ctx, url: str, channel=None):||
||if channel == None:||
||channel = 'General'||
||else:||
||channel=channel||
||voice_channel = discord.utils.get(ctx.guild.voice_channels, name=channel)||
||voice = discord.utils.get(bot.voice_clients, guild=ctx.guild)||
||await voice_channel.connect()||

bot.run("token")

copper gulch
#
@commands.command(pass_context=True)
    async def join(self, ctx):
        channel = ctx.message.author.voice.channel
        voice = get(client.voice_clients, guild=ctx.guild)

        if voice and voice.is_connected():
            await voice.move_to(channel)
        else:
            voice = await channel.connect()

            await voice.disconnect()

        if voice and voice.is_connected():
            await voice.move_to(channel)
        else:
            voice = await channel.connect()
            print(f"The bot has connected to {channel}\n")

        await ctx.send(f"Joined {channel}")

this is on cogs, anyone help me, Im getting red lines in the part:

voice = get(client.voice_clients, guild=ctx.guild)
velvet tinsel
#

Why are you using spoilers

small igloo
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.

velvet tinsel
#

If it’s breaking TOS

copper gulch
dapper cobalt
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

Ok I’m gonna go back to class bye~

small igloo
maiden fable
#

Do u have bot.process_commands in your on_message?

small igloo
maiden fable
#

Nvm

#

What's being sent twice

small igloo
copper gulch
#

Im so lost with cogs xd

maiden fable
#

U got two instances of your bot running tbh

maiden fable
valid barn
#

why doesnt this work? it doesnt show an error either

@client.command(name="give", aliases = ('send','dash'))
@commands.cooldown(1, 30, commands.cooldowns.BucketType.user)
async def give(ctx, user : discord.Member, amount = 0):
  await register(ctx.author)
  await register(user)
  users = await get_bank_data()
  bal = users[str(ctx.author.id)]["balance"]
  if amount > bal:
    await ctx.send(embed=discord.Embed(":( poor child. You don't have enough money to give out", color = 0xf5f5dc))
  elif amount <= 0:
    await ctx.send(embed=discord.Embed("Don't be selfish! No negative numbers >:(", color = 0xf5f5dc))
  else:
    await update_bank(user, amount, "balance")
    await update_bank(ctx.author, -1*amount, "balance")
    await ctx.send(embed=discord.Embed(f"Done! {ctx.author.mention} just gave {user.mention} {amount} :cherries_:", color = 0xf5f5dc))
copper gulch
maiden fable
#

U do amount: int = 0 @valid barn

copper gulch
#

hmmmm

maiden fable
craggy cloak
#

What is this lol?

maiden fable
#

Also

upbeat otter
valid barn
#

the default amount is 0 tho @upbeat otter

maiden fable
#

!d discord.Guild.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
maiden fable
#

U already have it @copper gulch

small igloo
#

;-; pls help

upbeat otter
upbeat otter
maiden fable
#

ctx.guild.voice_client will return the voice client of the current guild (;

craggy cloak
valid barn
#

lemme try it

small igloo
copper gulch
upbeat otter
copper gulch
#

wherein this is on cogs

small igloo
upbeat otter
small igloo
copper gulch
#

ok lemme try

boreal ravine
maiden fable
valid barn
#

@upbeat otter@maiden fable still doesnt work, no error

copper gulch
maiden fable
#

No*

upbeat otter
maiden fable
#

voice = ctx.guild.voice_client

copper gulch
#

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Guild' object has no attribute 'voice_clients'

maiden fable
#

client*

upbeat otter
#

typehinting always doesnt work

copper gulch
#

ohh

small igloo
valid barn
# upbeat otter huhhh, show code again
@client.command(name="give", aliases = ('send','dash'))
@commands.cooldown(1, 30, commands.cooldowns.BucketType.user)
async def give(ctx, user : discord.Member, amount = 0):
  await register(ctx.author)
  await register(user)
  users = await get_bank_data()
  bal = users[str(ctx.author.id)]["balance"]
  if amount > bal:
    await ctx.send(embed=discord.Embed(":( poor child. You don't have enough money to give out", color = 0xf5f5dc))
  elif amount <= 0:
    await ctx.send(embed=discord.Embed("Don't be selfish! No negative numbers >:(", color = 0xf5f5dc))
  else:
    await update_bank(user, amount, "balance")
    await update_bank(ctx.author, -1*amount, "balance")
    await ctx.send(embed=discord.Embed(f"Done! {ctx.author.mention} just gave {user.mention} {amount} :cherries_:", color = 0xf5f5dc))
upbeat otter
upbeat otter
craggy cloak
upbeat otter
boreal ravine
valid barn
craggy cloak
upbeat otter
craggy cloak
maiden fable
#

use discdb

upbeat otter
upbeat otter
valid barn
#

but it still doesnt work

maiden fable
unkempt canyonBOT
maiden fable
#

Also it's Beautifulsoup4

#

!pypi beautifulsoup4

unkempt canyonBOT
upbeat otter
maiden fable
#

bs4 is just a dummy package, just like discord

maiden fable
upbeat otter
valid barn
#

..elp-

maiden fable
#

Lol

valid barn
#

i

maiden fable
# valid barn ..elp-

Try adding dummy print statements in every other line and see which lines are being executed

upbeat otter
#

@valid barn print something after every step and see where the text stops printing, thats where the erorr will be

#

wow

valid barn
#

kk

boreal ravine
# craggy cloak

i have no idea, thought it was a version problem. Maybe some packages are outdated

ruby lion
#

I came across a problem with my discord bot... when I am trying to active "respond to keywords" it is printing a message of putting it off... here is the screenshot

velvet tinsel
#

Tbh you should have just done the @ bot.command() stuff

boreal ravine
velvet tinsel
#

Eh

boreal ravine
#

commands require a prefix

ruby lion
#

hmmm... so how can I fix it ...???

velvet tinsel
boreal ravine
ruby lion
velvet tinsel
#

I don’t think there is one

ruby lion
#

this is what it is printing

#

when said true

#

it is showing off...

velvet tinsel
#

I would have just used async def but ok

boreal ravine
boreal ravine
ruby lion
#

I printed the value... but the value is 'true' but still it is showing keywords is off

velvet tinsel
leaden cargo
#

this doesnt work

async def on_message_edit(before,after):
  if before.channel_id == 917179419255250974:
    await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )```
this works
```@client.event
async def on_message_edit(before,after):
    await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )```
can someone help me, i want it to only react to messages that are  on a specific channel
boreal ravine
velvet tinsel
#

Alright

tawdry perch
#

if I make a remind command, can I just make it wait a delay with asyncio.sleep?

boreal ravine
unkempt canyonBOT
ruby lion
#

I have used async in the top of the code...

velvet tinsel
#

Ok

boreal ravine
tawdry perch
dapper cobalt
quick gust
boreal ravine
boreal ravine
quick gust
velvet tinsel
#

What did it return

tawdry perch
boreal ravine
ruby lion
#

it returned true

tawdry perch
velvet tinsel
#

Try using an if statement to check if it is db[“responding”] is True

ruby lion
#

but the output in discord is not what i am expecting... yeah I know it is weird it has not happened before...

#

ok...

tawdry perch
valid barn
#

@upbeat otter @maiden fable elp i realized i didnt put 'description' before writing the desc of embed in the last line, everything printed correctly but my balance and the bal of person i give to didnt change >:/

@client.command(name="give", aliases = ('send','dash'))
@commands.cooldown(1, 30, commands.cooldowns.BucketType.user)
async def give(ctx, user : discord.Member, amount : int = 0):
  await register(ctx.author)
  print(1)
  await register(user)
  print(2)
  users = await get_bank_data()
  print(3)
  bal = users[str(ctx.author.id)]["balance"]
  print(4)
  if amount > bal:
    await ctx.send(embed=discord.Embed(":( poor child. You don't have enough money to give out", color = 0xf5f5dc))
    print (6)
  elif amount <= 0:
    await ctx.send(embed=discord.Embed("Don't be selfish! No negative numbers >:(", color = 0xf5f5dc))
    print(7)
  else:
    await update_bank(user, amount, "balance")
    print(8)
    await update_bank(ctx.author, -1*amount, "balance")
    print(9)
    await ctx.send(embed=discord.Embed(description = f"Done! {ctx.author.mention} just gave {user.mention} {amount} :cherries_:", color = 0xf5f5dc))
    print(10)
velvet tinsel
#

This definitely is a swas.py tutorial

ruby lion
#

wait no... I am trying to take the input from the user after the command !respond... so.. then I am setting db['responding'] = True.

velvet tinsel
#

Try checking if that is True then send the message

ruby lion
#

hmmm ok...

velvet tinsel
#

Otherwise send the other message

leaden cargo
velvet tinsel
#

I think?

#

Show code

leaden cargo
#

so rn its like

async def on_message_edit(before,after):
  if before.channel.id == 917179419255250974:
    await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )```
but still doesnt work
velvet tinsel
#

So what’s wrong?

velvet tinsel
#

Hunter!!! Hi

valid barn
#

..

quick gust
maiden fable
#

No

quick gust
#

yeah that's probably the issue then

maiden fable
#

Only fetch methods need to be awaited

quick gust
#

yeah I thought so too

#

@leaden cargo

valid barn
#

help

velvet tinsel
#

Ok

quick gust
#

create a seperate channel variable

velvet tinsel
#

What do you need help with

leaden cargo
quick gust
#

and then send it

#

no

#

but if u remove await, it won't send so, create a seperate channel variable and then send the message

valid barn
#

how to make my bot randomly say something at a random time

leaden cargo
#

but like, i put the variable before the "if before.channel.id == 917179419255250974:" or " await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )" and for what

async def on_message_edit(before,after):
  if before.channel.id == 917179419255250974:
    await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )```
velvet tinsel
leaden cargo
#

like this? @quick gust

 if before.channel.id == variable```
velvet tinsel
#

I should probably start doing discord bots again

#

enough adventuring on Tkinter for a day

leaden cargo
#

or like

 await variable.send(f'{after.content}\n \n Editado por: {before.author}' )```
quick gust
leaden cargo
velvet tinsel
#

I need help

quick gust
#

No keep the if

#

change it after the if

leaden cargo
#

no

velvet tinsel
#

how do you think the xp levelling system should work

ruby lion
#

@velvet tinsel It is working... I changed the code a little bit... though... This is the code ^

leaden cargo
#

let me show what i meant

quick gust
#

well I have to go right now

leaden cargo
#

this works

async def on_message_edit(before,after):
    await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )```
quick gust
#

okay then what's the problem?

leaden cargo
#

this doensnt work

async def on_message_edit(before,after):
  if before.channel.id == 917179419255250974:
    await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )```
#

thats the problem

quick gust
#

then the channel ID is probably not that

leaden cargo
#

it is

quick gust
#

the one u set it as

leaden cargo
#

k

tawdry perch
#

print the both of IDs before if statement as well?

quick gust
leaden cargo
#

still doesnt

quick gust
#

do that

leaden cargo
#

ill try it out

#

thats the problem

tawdry perch
#

!indent

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

velvet tinsel
valid barn
slate swan
unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

leaden cargo
#

idk i cant still do this sht

#

i still dont understand the error

velvet tinsel
ruby lion
#

when I am running my bot i am getting this error... I am new to discord bots... so... can anyone help me with this? I am not able to run my bot...

leaden cargo
#
  if str(before.channel) in channel2: ```
this worked in a message event, but its not working on a message edition event, and its exactly the same
visual island
ruby lion
#

hmm so what should I do?

boreal ravine
#

im using replit right now, im not banned though

maiden fable
maiden fable
visual island
#

like google has like hundreds of machine in your country

boreal ravine
maiden fable
ruby lion
visual island
boreal ravine
#

since it has lots of databases

maiden fable
#

if one person gets banned on a machine, everyone on that machine will get banned

visual island
ruby lion
#

hmmm another ide? that will alter the code... like.. I mean I am using database in replit... so..

visual island
boreal ravine
#

hm

visual island
boreal ravine
#

machines i meant

visual island
#

ah yea

ruby lion
#

in replit?

boreal ravine
#

i dont think that'll solve it

ruby lion
#

hmmmm

#

then? how to solve it?

visual island
leaden cargo
#

Can someone help me its giving me this error

async def on_message_edit(before,after):
 await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )
 channel2 = [":page_with_curl:・central"]
  if str(before.channel) in channel2: 
  if before.channel.id == 917179419255250974:```
#

i cant still find out whats the error there

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

lone basin
#

your indent

leaden cargo
#

since i used the same method on message event

dapper cobalt
leaden cargo
ruby lion
dapper cobalt
#
print("Hello") # Correct
  print("World") # Unexpected indentation
# However...
if True:
  print("World") # This is correct
leaden cargo
#

i have the same thing on my program above and it works so idk why

dapper cobalt
#

I just explained it twice.

visual island
leaden cargo
#

it works here

async def on_message(message):
  channel1 = [":page_with_curl:・central"]
  content = message.content
  author = str(message.author)

  if message.author == client.user:
    return
(the rest off the program wich includes more if's)```
dapper cobalt
#

Just loop through it using a for loop.

dapper cobalt
#

!e

print("Hello")
 print("World")
unkempt canyonBOT
#

@dapper cobalt :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print("World")
003 | IndentationError: unexpected indent
dapper cobalt
#

!e

print("Hello")
print("World")
unkempt canyonBOT
#

@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.

001 | Hello
002 | World
dapper cobalt
dapper cobalt
boreal ravine
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

001 | Hello
002 | World
dapper cobalt
#

PythonScript? Haha

boreal ravine
#

lmao

shadow wraith
#

!e

exec("print('saves nothing')")
unkempt canyonBOT
#

@shadow wraith :white_check_mark: Your eval job has completed with return code 0.

saves nothing
shadow wraith
#

:skull;

boreal ravine
#

Failed attempt to use an emoji

shadow wraith
#

say "aye" if you use await bot.get_channel or say "cool" if you use bot.get_channel

leaden cargo
#
async def on_message_edit(before,after):
 channel2 = [":page_with_curl:・central"] 

 if str(before.channel) in channel2: 
   await client.get_channel(918425787420508170).send(f'{after.content}\n \n Editado por: {before.author}' )```
shadow wraith
#

cool

ruby lion
leaden cargo
#

then explain me why this doesnt work

#

idk what else 2 do, i tried so much things and still doesnt work

shadow wraith
#

without the await

leaden cargo
#

rly

shadow wraith
#

it's still awaited

leaden cargo
#

let me try

shadow wraith
#

but the .send() won't work, but ngaf so make your client.get_channel() into a var

#

and then do <variablename>.send("msg here")

leaden cargo
#

still doesnt work

#
async def on_message_edit(before,after):
 channel2 = [":page_with_curl:・central"] 

 if str(before.channel) in channel2: 
   channel3 = client.get_channel(918425787420508170)
   channel3.send(f'{after.content}\n \n Editado por: {before.author}' )```
leaden cargo
#

does it have to await before "channel3.send()"?

boreal ravine
#

should i make a leaderboard command for my xp system

slate swan
velvet tinsel
#

?

boreal ravine
dapper cobalt
velvet tinsel
#

I don’t know how it should work

slate swan
leaden cargo
boreal ravine
velvet tinsel
#

I was thinking of adding 10 xp each time you comment but that doesn’t work I think

boreal ravine
#

its pretty simple

dapper cobalt
velvet tinsel
boreal ravine
#

you could in theory use replit db for a levelling system too 🤔

velvet tinsel
boreal ravine
leaden cargo
#
async def on_message_edit(before,after):
 channel2 = [":page_with_curl:・central"] 

 if str(before.channel) in channel2: 
   channel3 = client.get_channel(918425787420508170)
   await channel3.send(f'{after.content}\n \n Editado por: {before.author}' )```
dapper cobalt
#

before.channel.name

boreal ravine
#

and i dont really think spamming is much of an issue tbh

velvet tinsel
#

How does yours work

sick veldt
velvet tinsel
#

RIP your nitro

boreal ravine
velvet tinsel
#

Ok

sick veldt
leaden cargo
dapper cobalt
velvet tinsel
#

Me too

leaden cargo
#

😭

dapper cobalt
#

Print before.channel.name.

sick veldt
leaden cargo
sick veldt
#

any error?

leaden cargo
#

thats the problem

#

it doesnt show anything

sick veldt
#

hmm

leaden cargo
#

an error or whatsoever

dapper cobalt
#

And I prefer you change channel2 to a string that's equal to what you have there, and check if before.channel.name == channel2.

dapper cobalt
velvet tinsel
#

What’s wrong

leaden cargo
#

still not working

dapper cobalt
#

What is not working?

sick veldt
#

Hmm

#

Any error in client?

#

recheck the bot token

leaden cargo
#

like it doesnt register the edited message from the specific channel in the channel i want

velvet tinsel
#

What’s wrong 😭

boreal ravine
# velvet tinsel Ok
db = {}
db['levels'] = {}

@bot.event
async def on_message(msg):
  db['levels'][str(msg.author.id)] = {}
  db['levels'][str(msg.author.id)]['xp'] += 10

``` ~~not a good way to make a level system but eh~~
velvet tinsel
#

No

dapper cobalt
#

Add a print system at the start of your event, see if your event is triggered at all.

velvet tinsel
#

I know how to do it

#

It’s just I’m not creative

leaden cargo
#

ahahah

velvet tinsel
#

And print what’s happening if it does it

boreal ravine
dapper cobalt
#

You need to check first whether they already exist in the db or not.

velvet tinsel
#

Add 10xp each time someone comments?

#

🤔 or what

leaden cargo
#

it did respond

#

in the comand bar

boreal ravine
velvet tinsel
#

Ok then

leaden cargo
#

but didnt register it

boreal ravine
dapper cobalt
#
try:
  db["levels"][str(msg.author.id)]["xp"] += 10
except KeyError:
  db["levels"][str(msg.author.id)] = {}
  db["levels"][str(msg.author.id)]["xp"] = 10
velvet tinsel
#

Except KeyError 😳

#

KeyError: “life” 😳

#

Why do people use single quotes 🤔

leaden cargo
boreal ravine
leaden cargo
#

it does print the "a"

dapper cobalt
leaden cargo
#

but doesnt respond to the if comand

velvet tinsel
dapper cobalt
unkempt canyonBOT
#

@dapper cobalt :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | KeyError: 'life'
leaden cargo
#

im tryin this for hours

leaden cargo
#

im still cant do this thing...

tough lance
#

Single quotes look ugly

velvet tinsel
tough lance
#

And even the shift key is near the quote key so yh

velvet tinsel
#

Yeah

#

Double quotes is yes

tawdry perch
slate swan
#

single quotes are meant for character type data in many languages lol , they look good with them

slate swan
leaden cargo
#

I made a test and

async def on_message_edit(before,after):
 print('a')
 channel2 = [":page_with_curl:・central"] 
 channel3 = client.get_channel(918425787420508170)
 await channel3.send(f'{after.content}\n \n Editado por: {before.author}' )```
that part works wonders but this doenst

```@client.event
async def on_message_edit(before,after):
 print('a')
 channel2 = [":page_with_curl:・central"] 
 channel3 = client.get_channel(918425787420508170)
 await channel3.send(f'{after.content}\n \n Editado por: {before.author}' )

 if str(before.channel.name) in str(channel2): 
   channel3 = client.get_channel(918425787420508170)
   await channel3.send(f'{after.content}\n \n Editado por: {before.author}' )```
small igloo
#

eh... this is about sqlite
how to create a row with system like...
def add(name):
conn.execute("INSERT INTO users data (NAME,COIN,EXP,MAX_EXP)
VALUES ('(that name from def)', 25, 0, 125 )");

velvet tinsel
#

I’m having a headache looking at all the code

#

My mobile phone is too small

#

I can’t wait to play splitgate 😩

dapper cobalt
small igloo
velvet tinsel
#

Holidays are soooo near

velvet tinsel
dapper cobalt
#

\📃

small igloo
dapper cobalt
#

That's the emoji you'd need.

leaden cargo
velvet tinsel
tawdry perch
#

I saw it after it got fixed path

leaden cargo
#
async def on_message(message):
  channel1 = [":page_with_curl:・central"]
  content = message.content
  author = str(message.author)

  if message.author == client.user:
    return
  #other ifs in between
  if str(message.channel) in channel1:
    message.channel = client.get_channel(918425787420508170)
    await message.channel.send(f"{str(content)}\n \n Escrito por: {author}")```
dapper cobalt
small igloo
leaden cargo
#

like i dont get it

velvet tinsel
#

Windows

small igloo
velvet tinsel
dapper cobalt
small igloo
dapper cobalt
velvet tinsel
leaden cargo
dapper cobalt
#

Also, why do you have channel2 as an array and not just a string?

leaden cargo
small igloo
leaden cargo
#

yes XD

sick veldt
small igloo
tough lance
#

Why aren't you using id of channel2 instead of its name?

leaden cargo
#

because it didnt work asweel

leaden cargo
small igloo
# leaden cargo why?

bhre too much error and the database don't even friggn support url smth (i quit yesterday)

leaden cargo
dapper cobalt
#
@client.event
async def on_message_edit(before,after):
 channel2 = "📃・central"
 channel3 = client.get_channel(918425787420508170)

 if before.channel.name == channel2: 
   await channel3.send(f'{after.content}\n \n Editado por: {before.author}' )
small igloo
leaden cargo
#

oh lmao

#

im fckng dumb then

#

so how can i make my bot run permanently?

dapper cobalt
#

Host it.

leaden cargo
#

without replit

#

and on ccloud?

tough lance
#

Yes

leaden cargo
#

and it does work

dapper cobalt
#

Use a hosting service, or buy a vps.

small igloo
tough lance
#

Every free hosting service is trash

small igloo
leaden cargo
#

yep

leaden cargo
#

but smh it doesnt work

#

asdmasmdaskasfkskak

dapper cobalt
leaden cargo
#

my brain is dying atm

small igloo
leaden cargo
#

idk what 2 do

slate swan
#

Self h0st

tough lance
leaden cargo
#

i use a portable computer, and im on college so its rly anoying

#

i need it running perm.

dapper cobalt
#

Then, use a hosting service.

small igloo
tough lance
#

The problem was something else now we're taking about something else

leaden cargo
#

yep XD

velvet tinsel
#

I came back

#

What did I miss

#

Ducks?

#

😳

tough lance
#

Yes

leaden cargo
#

im brainless rn

#

aff

#

so

small igloo
leaden cargo
#

@dapper cobalt can u help me wth the free host? and explain me how it works?

#

or how could i make it work

dapper cobalt
#

They have a full guide.

leaden cargo
#

hm...

dapper cobalt
fluid harbor
#

Can anyone tell me what is this

tawdry perch
leaden cargo
velvet tinsel
#

What was the epikhost you were talking about cyberweapon?

dapper cobalt
slate swan
#

I personally prefer sneakyhub as host

fluid harbor
#

Uh help?

velvet tinsel
#

It’s not related to discord bots

fluid harbor
#

What is this?

boreal ravine
#

rate my replit uptime

velvet tinsel
#

It’s not related to discord bots

velvet tinsel
#

And it’s not related to discord bots

fluid harbor
#

I did. Not working

dapper cobalt
sick veldt
#

lol

small igloo
slate swan
tough lance
dapper cobalt
#

Ah, I did not see that at the bottom. You need to verify your email address.

sick veldt
#

use Flask

fluid harbor
velvet tinsel
sick veldt
#

My bot is online from 2 weeks'

boreal ravine
slate swan
velvet tinsel
#

I can’t join lmao

#

I was banned

sick veldt
#

why?

velvet tinsel
#

Don’t ask how though

tough lance
#

What

velvet tinsel
#

😳 we don’t talk about that

sick veldt
#

k

small igloo
# velvet tinsel Replit lmao

that is litteraly the longest uptime i ever seen (my bot just can run for littraly 20 minutes and boom "working (rwplit user must be know what is this about)")

velvet tinsel
#

But I should look at the disnake server

slate swan
#

Getting banned in discord.py server is easier than adding python to PATH,bet

boreal ravine
#

i think i was banned for shitposting

velvet tinsel
#

It’s easier than just printing hello world

#

I didn’t even last 3 hours in that server lmao

#

I should join disnake server ;; they may be nicer

tawdry perch
small igloo
velvet tinsel
#

Oh sh

sick veldt
#

No

dapper cobalt
#

We do not have a panel yet, so you'd have to join anyway.

tawdry perch
#

can I deny their access to my profile after?

velvet tinsel
boreal ravine
dapper cobalt
velvet tinsel
#

😳 probably

boreal ravine
velvet tinsel
slate swan
#

for points

tawdry perch
#

I need points to host..?

velvet tinsel
#

Ok

sick veldt
#

I need help

velvet tinsel
#

Nice

small igloo
#

.... no one helping me, now my question burried up there

sick veldt
#

what is it?

slate swan
small igloo
#

wait a minute 🙂 burried in the air lol

small igloo
sick veldt
#

k

slate swan
boreal ravine
#

or you could use railway

velvet tinsel
#

What’s your thing you need help with @sick veldt

#

I need help as well lmao

tawdry perch
fluid harbor
#

Can anyone send me more coding related servers in my dms

boreal ravine
velvet tinsel
#

Sweet

velvet tinsel
fluid harbor
#

.bm

lament depotBOT
#
I can't believe you've done this

Your input was invalid: You must either provide a valid message to bookmark, or reply to one.

The lookup strategy for a message is as follows (in order):

  1. Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')
  2. Lookup by message ID (the message must be in the context channel)
  3. Lookup by message URL

Usage:```
.bookmark [target_message] [title=Bookmark]

tough lance
#

I can't believe

small igloo
velvet tinsel
#

Lmao

fluid harbor
#

Can anyone send me more coding related servers in my dms??

boreal ravine
small igloo
#

there we go

sick veldt
slate swan
boreal ravine
#

sarthak pro sql'er

small igloo
sick veldt
#

@client.command(aliases=['rules'])
async def rule(ctx,*,number):
await ctx.send(rules[int(number)-1])

slate swan
#

user's data is the table name?

sick veldt
#

@client.command(aliases=['rules'])
async def rule(ctx,*,number):
await ctx.send(rules[int(number)-1])

#

any mistake in this?

small igloo
dapper cobalt
small igloo
#

@slate swan's pfp is an nsfw, why not banned-

small igloo
dapper cobalt
#

You pay 0 cents and get free service, meanwhile they still get money.

sick veldt
#

I am working hard to make a Whitelist bot

slate swan
sick veldt
tawdry perch
sick veldt
#

If anyone knows about it Can you help me complete it?

small igloo
small igloo
sick veldt
#

Product whitelisting

dapper cobalt
sick veldt
dapper cobalt
#

Anyhow, if you want to ask a question about that, just ask it in their support server and not here.

dapper cobalt
sick veldt
#

ok

slate swan
#

It was for cyber

sick veldt
#

Anyone knows about Roblox????

small igloo
sick veldt
#

And in that MSI?

sick veldt
#

Like, I need help lol

#

I am kinda new to python

small igloo
#

u wanna make a roblox game?

sick veldt
#

no

small igloo
#

with python?

sick veldt
#

Product securing bot

final iron
sick veldt
#

Not roblox game

sick veldt
sick veldt
small igloo
final iron
sick veldt
dapper cobalt
small igloo
small igloo
dapper cobalt
#

Roblox uses Lua.

sick veldt
#

Ik

sick veldt
#

Like podtech and Msi bot.

small igloo
sick veldt
small igloo
final iron
small igloo
#

roblox can secure products?

bank be like:

small igloo
brazen raft
brazen raft
#

It's a programming language

small igloo
#

oh

small igloo
brazen raft
#

Nah

#

It has do and end keywords for loops and statements in general

#

Other than that it's similar to Python

#

Of course there are differences

#

for loops aren't trivial

small igloo
#

conn.execute("UPDATE users data set coin = ? where NAME = ?",(amount),(name)) @slate swan is this right?

small igloo
brazen raft
#

Put amount and name in the same iterable

small igloo
brazen raft
slate swan
#

sussy

small igloo
small igloo
slate swan
#

ello

brazen raft
#

I believe it will raise an exception

small igloo
brazen raft
#

Lua has multi line comments

sick veldt
brazen raft
#

With --[[ and --]] or ]]-- I forgot

brazen raft
small igloo
brazen raft
#

Oh and one thing that makes Lua unique is that index starts at 1

brazen raft
#

But I believe 0 is understood and interpreted the same

small igloo
brazen raft
#

Nearly every language does

#

It's a convention based of pointer math (first element is pointed to by ptr, so to access it you will just dereference which 0 has no effect on)

#

But 1 will move to the next element

small igloo
small igloo
brazen raft
#

Yes but validate the name of the table matches what you have

brazen raft
#

Do you have a table named exactly users_data

brazen raft
#

Then

#

👍

small igloo
#

oh, so it will work like:

#

update coin amount in users_data by coin+amount

this?

#

hmm @west shuttle is this new guy?

west shuttle
#

Im trying to do thanks system:

thanks = await self.db.execute("SELECT thanks FROM thxcounter WHERE user_id = ?", (member.id,))
await self.db.execute("INSERT INTO thxcounter (thanks, user_id, guild_id) VALUES (?, ?, ?)", (thanks + 1, ctx.member.id, ctx.guild.id))

Its giving me this error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for +: 'Cursor' and 'int'
west shuttle
small igloo
west shuttle
#

Oh lol

small igloo
west shuttle
#

whats your problem

small igloo
west shuttle
brazen raft
sick veldt
#

in Roblox

west shuttle
#

Bruh

brazen raft
#

Probably not

sick veldt
#

So, yea

sick veldt
# brazen raft Probably not

Like, you are a dev and you sell stuff But you fear about If the product leaks so, I am trying to develop a product securing and whitelist system.

#

I need help making a bot like this.

brazen raft
small igloo
sick veldt
#

To understand more better I can show you some videos.'

brazen raft
brazen raft
west shuttle
valid barn
#

heres my code

for i in range(len(users[str(ctx.author.id)]["inventory"])):
        if things in users[str(ctx.author.id)]["inventory"][i]["name"]:
          users[str(ctx.author.id)]["inventory"][i]["count"] += 1
          break

and heres the error it shows:
i think i understand why it says this, but how else can i rephrase it so the error doesnt show

brazen raft
#

After you set it to the query's cursor, obviously

small igloo
# brazen raft Pseudo translation

ehhhh
this is from code:
def add_coin(name, amount):
conn.execute("UPDATE users data set coin = ? where NAME = ?", (coin+amount, name))

brazen raft
#

Oh so you want to increment that field by amount?

small igloo
#

yes

small igloo
#

where is @upbeat otter he's often active at this time

brazen raft
#

In the query, use SET coin = coin + ?, and only put amount (without coin+) in the first query variable

small igloo
brazen raft
#

Yes

small igloo
#

ok, thanjs :3

west shuttle
valid barn
brazen raft
brazen raft
valid barn
brazen raft
west shuttle
upbeat otter
upbeat otter
brazen raft
# valid barn kind of

What's the right operand in the if statement? A value? Maybe you need to switch them

upbeat otter
small igloo
brazen raft
upbeat otter
#

hehe am happy someone atleast remembers me

upbeat otter
#

anyways, You dont need an API if you are smart enough

brazen raft
upbeat otter
brazen raft
#

I have a math test in two days

#

I wish luck for the both of us

small igloo
upbeat otter
upbeat otter
small igloo
small igloo
valid barn
strong shale
#

Anyone using py-cord here

upbeat otter
small igloo
upbeat otter
valid barn
small igloo
upbeat otter
small igloo
#

also need help this

upbeat otter
upbeat otter
small igloo
upbeat otter
brazen raft
#

You can't just type hint command parameters as you like, you need to provide an interface to convert the values to the type you need yourself

strong shale
upbeat otter
brazen raft
small igloo
# upbeat otter code?

@bot.command()
async def start(ctx):
name = ctx.author
database.add(name)
await ctx.send(f"added {ctx.author} C:")
^ start (for register)

def add(name):
conn.execute("INSERT INTO users_data (NAME,COIN,EXP,MAX_EXP)
VALUES (?, 25, 0, 125 )", (name))
^database, add name

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.

strong shale
small igloo
upbeat otter
upbeat otter
strong shale
brazen raft
# small igloo what?

Are you doing something like

def cool_command(ctx, param: MyOwnCoolClass):
   ...
small igloo
upbeat otter
small igloo
upbeat otter
small igloo
upbeat otter
strong shale
upbeat otter
small igloo
upbeat otter
#

ss

small igloo
upbeat otter
#

send an ss of that

small igloo
#

part 2

#

sup @quick gust

small igloo
brazen raft
small igloo
quick gust
#

in your name function...

brazen raft
#

Tuple literals with one item must have a comma

quick gust
#

the last word

small igloo
strong shale
# upbeat otter huh

I asked 1 to 2 contributers in that repo
But, they said it will become easy to all coders, and some will use it blindly not knowing how it works

brazen raft
#

!tag tuple

#

Aw

small igloo
quick gust
#

!tuple

#

Nope

small igloo
#

lol

brazen raft
#

At the end of your add function

small igloo
quick gust
#

are you just blindly copying some code?

small igloo
brazen raft
#

Yes

small igloo
brazen raft
#

You need another comma inside the parentheses of name in order to make it a valid tuple, otherwise it's just the string expression it is

small igloo
quick gust
#

lmao

brazen raft
#

Just Google about one item long tuple literals

strong shale
upbeat otter
#

anyways, why use pycord when you can use disnake or nextcord

brazen raft
upbeat otter
small igloo
strong shale
visual island
strong shale
#

Oh

small igloo
upbeat otter
small igloo
visual island
#

nothing

upbeat otter
visual island
small igloo
upbeat otter
small igloo
upbeat otter
#

will other libs have to write the whole dpy again :/

brazen raft
#

They can fork this one

#

And make changes for their forks

#

It's open source

upbeat otter
#

Icy writing an essay?

small igloo
# upbeat otter this is the reason

hmmm, ig i started to understand what happen

danny make discord.py, but discord creator (or smth) wanna update the discord's api with replaced all of the API that kinda oppositing discord.py's system, then Danny ragequit and never work on it again

is that true?