#discord-bots

1 messages · Page 742 of 1

slate swan
#

So yes, I am sure :)

tender estuary
#

nvm its client = commands.Bot

slate swan
#

As I said :)

tender estuary
#
client = commands.Bot(command_prefix = 'v!', case_insensitive=True, intents=intents)
slate swan
#

It's like doing

my_int = "hello"
tender estuary
#

Oh

#

welp I thought you meant

bot = commands.Bot(command_prefix = 'v!', case_insensitive=True, intents=intents)
slate swan
#

it was an example

#

Well, that's a better variable naming :p

#

greenapple = redapple()

#

doesnt make sense does it

#

Holy............

#

It's so easy

tender estuary
#

client actually does makes sense

slate swan
#

ikr

slate swan
slate swan
tender estuary
slate swan
#

yes bot is the subclass of Client but the whole framework is called bot

slate swan
unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
tender estuary
slate swan
#

it has the .mention attr

slate swan
slate swan
unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

slate swan
#

and no

tender estuary
slate swan
#

Hello @tender estuary, time to grow your army?

tender estuary
#

Uhm what

slate swan
slate swan
tender estuary
#

it depends actually.

slate swan
#

member: discord.Member
and use the .mention attr

slate swan
slate swan
slate swan
#

so you say ;hunt

tender estuary
slate swan
#

and the bot responds

slate swan
#

ctx.author.mention

#

put it in a f string if you wanted it in a str

slate swan
slate swan
slate swan
tender estuary
#
await ctx.send(f'{ctx.author.mention} your-text-here')
slate swan
#

did you just said how to make a string🧍‍♂️

tender estuary
#

😄

slate swan
#

how is that hardpithink

tender estuary
#

well it was hard for me a week ago

slate swan
tender estuary
slate swan
tender estuary
#

Learn python first, it will be hard to understand discord.py

slate swan
#

!resources

unkempt canyonBOT
#
Resources

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

slate swan
spring flax
#

also, why does my bot.get_emoji(id) not embed an emoji? it just shows :checmark: instead

slate swan
#

i understand now

tender estuary
spring flax
#

No, I used bot.get_emoji

tender estuary
#

can you give the code here

#
await message.channel.send(f'{message.author.mention} Don\'t send gifs here! :monkaStab:')
``` This is what I used.
#

it sends the emoji.

slate swan
#

he got the emoji from cache but it is not displaying it in a embed that is his problem

spring flax
#
@bot.event
async def on_ready():
  bot.emoji = bot.get_emoji(id)```
slate swan
#

:monkaStab:

tender estuary
slate swan
#

I'm doing hunt command

#

use id

tender estuary
slate swan
#

and idk how to make a string command

#

for animals

tender estuary
slate swan
slate swan
#

string for variables

tender estuary
#

oh sh- ok.

slate swan
#

wdym?

tender estuary
#

var = "text"

slate swan
zealous dagger
#
  File "main.py", line 11, in <module>
    from discord import has_permissions
ImportError: cannot import name 'has_permissions' from 'discord' (/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/__init__.py)```
slate swan
#

i want a rabbit

zealous dagger
#

How to fix this

slate swan
#

and more animals

slate swan
#

thank you

tender estuary
slate swan
#

I've got quite a big problem with my bot, if anyone has like 5-10min dm me

slate swan
slate swan
tender estuary
slate swan
slate swan
slate swan
zealous dagger
#

@tender estuary

tender estuary
slate swan
tender estuary
slate swan
#

you dont need to import it

tender estuary
#

decorate the command with that

zealous dagger
#

Ok

slate swan
#

its a decorator smh

tender estuary
#

but wait

#

that's not it, has_permissions takes arguments

#

ban_members=True or whatever

slate swan
#

it takes a kwarg

zealous dagger
#

Ok

slate swan
#

and its the permission you want

zealous dagger
#

thanks

slate swan
#

exshplain

tender estuary
# slate swan

that is basically like first I named you rabbit then deer

spring verge
#

has anyone used postgres for discord bots?

tender estuary
slate swan
# slate swan

your spacing and why are you setting a value after you already have?

tender estuary
tender estuary
slate swan
# slate swan so var2

!e

a = "first value"
def function():
    a = "second value"
    print(a)

print(a)
function()

makes sensepithink

unkempt canyonBOT
#

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

001 | first value
002 | second value
spring verge
#

Oh no just learnt it cuz heard its good for discord bots

spring verge
#

I was recently making discord bot for someone and was thinking if I should create different username for him?

tender estuary
zealous dagger
#

hey now its showing

slate swan
zealous dagger
#

Traceback (most recent call last):
File "main.py", line 60, in <module>
@command.has_permissions(administrator=True)
NameError: name 'command' is not defined

slate swan
tender estuary
#

not command

zealous dagger
#

Ok

slate swan
tender estuary
slate swan
tender estuary
slate swan
#

wont affect it in anyway and context is a positional argument

slate swan
#

!pep 484

unkempt canyonBOT
#
**PEP 484 - Type Hints**
Status

Provisional

Python-Version

3.5

Created

29-Sep-2014

Type

Standards Track

slate swan
tender estuary
#

I meant its not necessary

tender estuary
slate swan
#

dont seem why not use itpithink

spring verge
slate swan
tender estuary
#

tbh I'd avoid postgreSQL and all.. just stick to aiosqlite...

slate swan
tender estuary
#

Don't expect to make multi server bots

tender estuary
slate swan
tender estuary
#

yea ik

slate swan
#

really no difference

#

and pg isnt bad you just have to know how to use it popular bots use it as it uses a server

tender estuary
#

postgreSQL for a single server is a poor choice

heavy folio
#

in the default help command (subclassed), is there a way to get required roles/checks, e.g. eval wjll show "Requires bot owner", role will show "Manage Roles/@somerole", etc

tender estuary
#

you mean !help?

slate swan
#

no

tender estuary
#

I still don't know my way around default help command...

slate swan
#

he ment he subclassed the default help command

tender estuary
#

Is it a good choice to create a different table for a warn command or just put it in json?

slate swan
#

another table

slate swan
unkempt canyonBOT
zealous dagger
#

how to send custom emojis

slate swan
#

or do you mean getting roles required to run the command?

slate swan
zealous dagger
#

like I want this

#

one dice_1

slate swan
zealous dagger
#

to be sent by my bot

#

It i not working

slate swan
zealous dagger
#

ok

#

so how do I sent

#

It does not wo`rk

#

i have tried

slate swan
#

you can get elasped name by doing \:emoji: and use it

zealous dagger
#

but how to sent

#

I am mkaing a command

#

dice roll

#

I want to sent one of the six dices

#

how to do that

slate swan
#

use .send() ...

zealous dagger
#

like this

slate swan
#

use .choice with random and send the random emoji

zealous dagger
#

Ok

#

Like this @slate swan

#
await ctx.send(:python:286529073445076992)
slate swan
#

Νο

#

dont you have to incase it in <>

#

?

zealous dagger
#

ok

slate swan
#
await ctx.send(emoji)  #Define the emoji 
#

its a custom emoji

tender estuary
zealous dagger
#

:dice1:

slate swan
#
await ctx.send("![dice_1](https://cdn.discordapp.com/emojis/755891608859443290.webp?size=128 "dice_1")")
unkempt canyonBOT
#
Did you mean ...

» string-formatting
» f-strings

vale wing
#

You could also get it by id and call str method on Emoji object

slate swan
#

!string-formatting

unkempt canyonBOT
#

String Formatting Mini-Language
The String Formatting Language in Python is a powerful way to tailor the display of strings and other data structures. This string formatting mini language works for f-strings and .format().

Take a look at some of these examples!

>>> my_num = 2134234523
>>> print(f"{my_num:,}")
2,134,234,523

>>> my_smaller_num = -30.0532234
>>> print(f"{my_smaller_num:=09.2f}")
-00030.05

>>> my_str = "Center me!"
>>> print(f"{my_str:-^20}")
-----Center me!-----

>>> repr_str = "Spam \t Ham"
>>> print(f"{repr_str!r}")
'Spam \t Ham'

Full Specification & Resources
String Formatting Mini Language Specification
pyformat.info

slate swan
#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

vale wing
#

!d discord.ext.commands.Bot.get_emoji <- this

unkempt canyonBOT
slate swan
slate swan
slate swan
#

why can't I

#

i used it to help youpithink

vale wing
#

If you are doing many commands for personal purpose, better go to that channel

slate swan
vale wing
#

That counts as personal purpose :)

slate swan
slate swan
#

f-string

#

with variables

#

not numbers

vale wing
#
user_id = 69
print(f'This user has ID {user_id}')```
slate swan
vale wing
#

!e

user_id = 69
print(f'This user has ID {user_id}')```
unkempt canyonBOT
#

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

red apple
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

This user has ID 69
slate swan
#

exenifix bro🧍‍♂️

vale wing
#

At the same time troll

slate swan
vale wing
#

Yeah

slate swan
slate swan
#

🧍‍♂️

vale wing
#

Um

slate swan
vale wing
#

Really lol

slate swan
slate swan
vale wing
#

Yeah I just did

slate swan
slate swan
slate swan
#

with anything its a variable

vale wing
#

You can even put code expressions to there

#

!e

print(f'{2*10} number')```
unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

20 number
slate swan
vale wing
#

Yeah those are code expressions as well

slate swan
vale wing
#

The thing you put inside {} will be called str method on and inserted into the string

spring flax
#

can anyone suggest any app commands to do? User/message

slate swan
#

!e

import random

print(f"okimii is {random.randint(1, 101)} % cool")

@slate swan

unkempt canyonBOT
#

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

okimii is 85 % cool
slate swan
manic wing
#

!e

import random

print(f"okimii is {random.randint(1, 101)} % cool")
unkempt canyonBOT
#

@manic wing :white_check_mark: Your eval job has completed with return code 0.

okimii is 55 % cool
slate swan
manic wing
#

!e

import random

print(f"okimii is {random.randint(1, 2)} % cool")

@slate swan

unkempt canyonBOT
#

@manic wing :white_check_mark: Your eval job has completed with return code 0.

okimii is 1 % cool
vale wing
slate swan
manic wing
#

truly meticulous banter

spring flax
slate swan
vale wing
#

Ok could you specify what you want?

slate swan
#

yeah^

manic wing
#

i assume you need help so @slate swan

slate swan
manic wing
#

what do you need help with? ❤️

slate swan
manic wing
#

i wouldnt trust what okimii says

slate swan
#

so technically i don't need help anm

slate swan
slate swan
#

because

#

you said the same thing she/he said

manic wing
#

its a she

vale wing
#

@spring flax you want like fun command?

slate swan
#

big brain play from caeden init

slate swan
slate swan
spring flax
vale wing
#

Btw is inviting people to collaborate on closed source projects (no paid work) against the rules?

vale wing
slate swan
slate swan
#

happens when you dont use the module

slate swan
spring flax
slate swan
#

the random in {random.randint(1, 2)} is the one you import

slate swan
#

you do

import random
slate swan
vast gale
#

@slate swan smh I couldn't help but read your about me and notice that career is an unused variable

#

same with love too

vast gale
#

you probably already know-- lol

slate swan
slate swan
slate swan
#

lol

vast gale
#

ahhh, right

slate swan
#

.topic

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

Suggest more topics here!

slate swan
# lament depot

can take any amount of submissions from any subreddit 🚶

tawdry perch
vast gale
#

definitely not heavily inspired by @unkempt canyon :)

slate swan
#

!e os.system('shutdown')

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 | NameError: name 'os' is not defined
slate swan
#

fuck

vast gale
slate swan
#

!e
import os
os.system('shutdown')

unkempt canyonBOT
#

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

[No output]
slate swan
#

ez

#

like dank memer

vast gale
#

name your variables with letters

slate swan
#

!e
import os
os.system('reboot')

unkempt canyonBOT
#

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

[No output]
quick gust
slate swan
#

bro hello

quick gust
#

stop trying it wont work

slate swan
#

y bro

quick gust
quick gust
#

sandboxed environment

slate swan
#

cringe bro

slate swan
quick gust
#

okay and

quick gust
slate swan
#

.topic

lament depotBOT
#
**What feature would you like to see added to the library? What feature in the library do you think is redundant?**

Suggest more topics here!

slate swan
slate swan
tender estuary
vast gale
slate swan
vast gale
#

and like, no features will be added

slate swan
vast gale
#

What's a feature that you wish was in all forks or really like about a fork you use?

slate swan
#

defined as*

slate swan
tender estuary
#

random.randint(a,b) won't work if they are assigned to a string...

slate swan
tender estuary
#

use random.sample

slate swan
#

randint

#

not str

slate swan
#

yes

#

thats why u cant have str

tender estuary
slate swan
#

a, b needs to be int if u wanna use randint

slate swan
#

thing

#

randint gives a random int from a range of ints

slate swan
#

you use .choice for a random element from a tuple or list

slate swan
slate swan
#

i hate when i get ignored

tender estuary
slate swan
tender estuary
#

Ok @slate swan tell me what are you actually trying to do

slate swan
tender estuary
slate swan
#

so you can hunt a rabbit, deer, or bear

slate swan
slate swan
tender estuary
slate swan
#

your pfp isnt great anyways but are we judging nopithink

slate swan
#

do you have a problem

tender estuary
vast gale
slate swan
slate swan
#

a lot

slate swan
#

nice

#

but it looks goodpithink

vast gale
#

oh that's where I know you from

tender estuary
#

Just type whatever comes in your mind who cares about the size for a single server discord bot tbh

slate swan
#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

tender estuary
slate swan
slate swan
slate swan
slate swan
vast gale
slate swan
vast gale
#

disnake server from a few days back in help channel

slate swan
#

animals is

#

they r strings

#

''

slate swan
slate swan
tender estuary
slate swan
#

No it's not wrong though.

vast gale
tender estuary
#

Its more efficient... given its size.

slate swan
#

!e
import random
print(f"You huntet {random.choice(['x', 'y'])}")

unkempt canyonBOT
#

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

You huntet x
slate swan
#

My typing is perfect

#

!e

import random

print(f'You hunted {random.choice(['rabbit', 'deer', 'bear'])}')

@slate swan

unkempt canyonBOT
#

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

001 |   File "<string>", line 3
002 |     print(f'You hunted {random.choice(['rabbit', 'deer', 'bear'])}')
003 |                                         ^^^^^^
004 | SyntaxError: f-string: unmatched '['
unique tendon
#

@client.command(aliases=["rockpaperscissors"])
async def rps(ctx):
    rpsGame = ['Rock', 'Paper', 'Scissors']
    await ctx.send(f"Rock, paper, or scissors? Choose wisely... Remember to start your answer with a Capital letter!")

    def check(msg):
        return msg.author == ctx.author and msg.channel == ctx.channel and msg.content.lower() in rpsGame

    user_choice = (await client.wait_for('message', check=check)).content

    comp_choice = random.choice(rpsGame)
    if user_choice == 'Rock':
        if comp_choice == 'Rock':
            await ctx.send(f'Well, that was weird. We tied.\nYour choice: {user_choice}\nMy choice: {comp_choice}')
        elif comp_choice == 'Paper':
            await ctx.send(f'Nice try, but I won that time!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
        elif comp_choice == 'Scissors':
            await ctx.send(f"Aw, you beat me. It won't happen again!\nYour choice: {user_choice}\nMy choice: {comp_choice}")

    elif user_choice == 'Paper':
        if comp_choice == 'Rock':
            await ctx.send(f'The pen beats the sword? More like the paper beats the rock!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
        elif comp_choice == 'Paper':
            await ctx.send(f'Oh, wacky. We just tied. I call a rematch!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
        elif comp_choice == 'Scissors':
            await ctx.send(f"Aw man, you actually managed to beat me.\nYour choice: {user_choice}\nMy choice: {comp_choice}")

    elif user_choice == 'Scissors':
        if comp_choice == 'Rock':
            await ctx.send(f'HAHA!! I JUST CRUSHED YOU!! I rock!!\nYour choice: {user_choice}\nMy choice: {comp_choice}')
        elif comp_choice == 'Paper':
            await ctx.send(f'Bruh. >: |\nYour choice: {user_choice}\nMy choice: {comp_choice}')
        elif comp_choice == 'Scissors':
            await ctx.send(f"Oh well, we tied.\nYour choice: {user_choice}\nMy choice: {comp_choice}")
tender estuary
unique tendon
#

It’s not showing an error, but the bot doesn’t respond once i put rock, paper or scissors

tender estuary
slate swan
unique tendon
#

It just doesnt answer

slate swan
#

make it .lower so u aint gotta use capital

unique tendon
slate swan
#

message.content = message.content.lower()

unique tendon
slate swan
#

no need for it

#

idk

unique tendon
#

Im so confused

#

Idk how to make the cmd work

slate swan
slate swan
spring flax
#
def trial_moderator_only():
    def predicate(ctx):
        list_of_ids = ['751814647346102303', '246412496678682635']
        if (disnake.utils.find(lambda r: r.id == 897292885509148674, ctx.author.roles)):
            return True
        if ctx.author.id in list_of_ids:
            return True
        else:
            return None
    return commands.check(predicate)

Why does the if ctx.author.id in list_of_ids not work and raise checkfailure?

slate swan
#

user choice lower

slate swan
tender estuary
slate swan
#

.topic

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

Suggest more topics here!

tender estuary
slate swan
unique tendon
#

It’s just everyone is confusing me

slate swan
unique tendon
#

lmao

tender estuary
unique tendon
#

Like idk what to change

tender estuary
slate swan
tender estuary
#

Its just a metaphor

slate swan
slate swan
unique tendon
#

ok at this point ima just delete the cmd cuz idk what to do

slate swan
slate swan
unique tendon
#

can someone else help?

slate swan
vast gale
tender estuary
#
@client.command()
async def coinflip(ctx, guess : str):
  guesses=("Heads", "Tails")
  chance = random.choice(guesses)
  if guess != chance:
    cursor.execute(f"SELECT wallet_amt FROM account_table WHERE user_id = {ctx.author.id};")
    db.commit()
    result = cursor.fetchall()
    result = str(result).strip("[](),")
    result = int(result)
    result = result - 200
    await ctx.send(f"You lost, The bet and 200 coins. {ctx.author.mention}")
    cursor.execute(f"UPDATE account_table SET wallet_amt = {result} WHERE user_id = {ctx.author.id};")
    db.commit()
  elif guess == chance:
    cursor.execute(f"SELECT wallet_amt FROM account_table WHERE user_id = {ctx.author.id};")
    db.commit()
    result = cursor.fetchall()
    result = str(result).strip("[](),")
    result = int(result)
    result = result + 200
    await ctx.send(f"You won, The bet and 200 coins. {ctx.author.mention}")
    cursor.execute(f"UPDATE account_table SET wallet_amt = {result} WHERE user_id = {ctx.author.id};")
    db.commit()

Anything wrong with this? Don't golf.

slate swan
#

dont copy my emojilemon_pika

unique tendon
#

@slate swan can u help with my code?

#

Or someone else

tender estuary
unique tendon
#

Ok nvm

#

bye

keen talon
slate swan
vast gale
slate swan
#

pithink im not a pro

keen talon
slate swan
#
 chance = random.choice(["Heads", "Tails"])
#

these little things are the ones that make you betterpithink

tender estuary
slate swan
slate swan
slate swan
slate swan
tender estuary
slate swan
#

longer = better

slate swan
keen talon
slate swan
slate swan
tender estuary
slate swan
shadow wraith
#

i dont code discord bots that much

tender estuary
keen talon
slate swan
#

instead of importing dpy just paste the source code in

slate swan
#

use c instead of python

slate swan
#

c++ good

#

c# dead

slate swan
#

py super dead

#

Cause this lol

slate swan
slate swan
#

And python is written in c so yea

tender estuary
slate swan
#

yeah man

slate swan
keen talon
slate swan
#

You can just paste the complete discord.py code cause is overall like 30 different files

#

Atleast a person like me who stackoverflow's things can't

slate swan
slate swan
slate swan
#

Literally me^

#

i want to jump to rust but im not surelemon_pika

tender estuary
#

dead bot in a dead server

slate swan
slate swan
#

rust is worth learning

slate swan
slate swan
keen talon
tender estuary
slate swan
#

If you be consistent

slate swan
#

No idea about u

slate swan
slate swan
slate swan
#

!ot pithink

unkempt canyonBOT
slate swan
#

.topic

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

Suggest more topics here!

shadow wraith
slate swan
slate swan
keen talon
keen talon
tender estuary
#

I am so cruel I made a command for myself that gives me 999999999 coins.

shadow wraith
tender estuary
#

No one else cna use it.

shadow wraith
slate swan
#

.topic

keen talon
slate swan
shadow wraith
#

.topic

unkempt canyonBOT
#

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

random number is 4
keen talon
slate swan
#

some bots dont and they use reactions smh

keen talon
#

🙂

tender estuary
#

I use replit lmfao

#

ver 1.7.3

unique tendon
#

@client.command(aliases=["cf"])
async def coinflip(message: discord.Message):
    coin = ["heads", "tails"]
    flipchoice = random.choice(coin)
    while 'Wait 1 seconds':
        await message.channel.send(f"**`Heads`** or **`Tails`**?")
        msg = await client.wait_for('message', check=lambda message: not message.author.bot)
        if msg == "heads" or msg == "Heads":
            if flipchoice == "heads":
                await msg.send("You got it! The answer was heads!")
            if flipchoice == "tails":
                await msg.send("Oh no! Try again next time")
            if msg == "tails" or msg == "Tails":
                if flipchoice == "heads":
                    await msg.send("You got it! The answer was tails!")
                if flipchoice == "tails":
                    await msg.send("Oh no! Try again next time")
#

this isnt working for some reason

slate swan
shadow wraith
#

now my eyes is better

slate swan
#

not a message obj

#

and why the while loop?

unique tendon
slate swan
#

i get ignored againlemon_pika

slate swan
shadow wraith
#

what is while 'Wait 1 seconds':

unique tendon
shadow wraith
#

every value is true in python except for falsy ones so technically that'd loop it???/

unique tendon
#

I just got the code online im not good at coding im just trying to make a simple bot for my server thats it

vale wing
#

!e

print(bool('wait 1 seconds'))```
unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

True
vale wing
#

Always true condition done in a weird way

shadow wraith
slate swan
#

!e

print(bool(""))
shadow wraith
unkempt canyonBOT
#

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

False
unique tendon
#

Can someone help me fix it pls

slate swan
unique tendon
#

Idk what to do

slate swan
#

ik

vale wing
#

Empty string returns false, non empty true

shadow wraith
slate swan
#

yeah

#

pretty nice to know

shadow wraith
#

so technically your just infinitely looping it

vale wing
#

Yeah

#

That code is weird

slate swan
shadow wraith
#

i haven't use disnake is a whiel

slate swan
#

since a str is always true

shadow wraith
unique tendon
slate swan
shadow wraith
vale wing
#

I would done it in a different way lmao

shadow wraith
#

it's nice practice

slate swan
#

Pythòn

shadow wraith
# slate swan

did you do pip3 install discord (because you're not meant to)

iron quarry
#

.help

snow hare
#

@slate swan

slate swan
#

.Pythòn

#

@quanganh.command()
async def svinfo(ctx):
guild = ctx.guild
name = guild.name
rolenum = len(ctx.guild.roles) - 1
create_server = guild.created_at.strftime("%d-%m-%Y")
owner_server = guild.owner.mention
membercount = guild.member_count
boostnum = guild.premium_subscription_count
embed = discord.Embed(title=name, color=discord.Colour.random())
embed.add_field(name="Created at:", value=create_server, inline=True)
embed.add_field(name="Owner:", value=owner_server, inline=True)
embed.add_field(name="Member count:", value=membercount, inline=True)
embed.add_field(name="Number of Boost:", value=boostnum, inline=True)
embed.add_field(name="Roles Count:", value=rolenum, inline = True)
embed.set_image(url=ctx.guild.icon_url)
await ctx.channel.send(embed=embed)

#

what is happening

#

Pythòn

shadow wraith
#

whats happening

slate swan
#

ghê v

shadow wraith
#

@slate swan how did we have the same answers wtf???

vale wing
#

!e

import random
result = random.choice(['heads', 'tails'])
for i in range(5):
    print(result)```
slate swan
#

same error showing@shadow wraith

slate swan
#
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "e:\python\new\bot.py", line 494, in svinfo
    owner_server = guild.owner.mention
AttributeError: 'NoneType' object has no attribute 'mention'

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

Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'mention'```
shadow wraith
#

WTF IS HAPPENINGGG

unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

001 | tails
002 | tails
003 | tails
004 | tails
005 | tails
vale wing
#

Nice random

slate swan
#

thôi như cặc vậy

snow hare
#

i have run it on my computer, and it work, but when he run it, in return nonetype

slate swan
#

pp

vale wing
shadow wraith
unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

slate swan
snow hare
slate swan
#

Pythòn

#

same error

#

pp

#

again

#

wtf

#

is happening

tawdry perch
shadow wraith
snow hare
#

can someone help me pls ?

slate swan
shadow wraith
slate swan
#

we could if people stop spamming smh

slate swan
#

hello

slate swan
shadow wraith
#

i haven't used disnake in a while

slate swan
#

same error

slate swan
#

again

#

@slate swan so how can i solve it

#

im right here

#

why the ping

#

sr

tender estuary
vale wing
#

@slate swan update your python

slate swan
vale wing
#

I mean update the interpreter

slate swan
#
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "e:\python\new\bot.py", line 494, in svinfo
    owner_server = guild.owner.mention
AttributeError: 'NoneType' object has no attribute 'mention'

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

Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'mention'```
vale wing
#

It requires >= 3.8 and you have 3.7.2

shadow wraith
slate swan
#
@quanganh.command()
async def svinfo(ctx):
    guild = ctx.guild
    name = guild.name
    rolenum = len(ctx.guild.roles) - 1
    create_server = guild.created_at.strftime("%d-%m-%Y")
    owner_server = guild.owner.mention
    membercount = guild.member_count
    boostnum = guild.premium_subscription_count
    embed = discord.Embed(title=name, color=discord.Colour.random())
    embed.add_field(name="Created at:", value=create_server, inline=True)
    embed.add_field(name="Owner:", value=owner_server, inline=True)
    embed.add_field(name="Member count:", value=membercount, inline=True)
    embed.add_field(name="Number of Boost:", value=boostnum, inline=True)
    embed.add_field(name="Roles Count:", value=rolenum, inline = True)
    embed.set_image(url=ctx.guild.icon_url)    
    await ctx.channel.send(embed=embed)```
snow hare
#

stop spam @slate swan

slate swan
#

@snow hare

maiden fable
vale wing
slate swan
#

!rule 4

snow hare
unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

slate swan
#

oke

shadow wraith
maiden fable
#

!d discord.Guild.owner needs members intent haha

unkempt canyonBOT
#

property owner: Optional[discord.member.Member]```
The member that owns the guild.
slate swan
#

!intents

tender estuary
unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

maiden fable
slate swan
#

owner is a member obj

tender estuary
#

we can??????

maiden fable
#

Yea...

slate swan
#

and member obj has .mention attr

snow hare
#

he enable the Member intenes

maiden fable
#

Mhm

snow hare
#

but it still return nonetype

slate swan
snow hare
tender estuary
#

drop python learn erlang work for whatsapp 🙂

snow hare
#

both of them

slate swan
slate swan
#

for it to return none

shadow wraith
slate swan
#

ple

shadow wraith
#

python is literally my friend

#

its literally a calculator

snow hare
slate swan
#

seems like hes doing something wrong

snow hare
#

it return none

slate swan
#

!e print(0.2+0.7) # very reliable calculator

unkempt canyonBOT
#

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

0.8999999999999999
snow hare
#

ok

slate swan
shadow wraith
#

then float(0.8)

slate swan
vast gale
#

enter whatever that error was called

slate swan
vale wing
#

Python good at math

shadow wraith
#

ive seen around 3-5 people new to python and try coding a discord bot immediately

vale wing
#

And currently one guy is annoying me in DMs

shadow wraith
#

ive seen one that copied the github source code

tender estuary
shadow wraith
#

a discord bot

tender estuary
#

sue

shadow wraith
#

he got an indent and syntax error

slate swan
shadow wraith
#

and he didn't know wtf it meant

slate swan
#

!e print(@slate swan)

unkempt canyonBOT
#

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

<@​637458038915203127>
tender estuary
slate swan
#

fs

slate swan
slate swan
tender estuary
slate swan
#

wont call it lucky

tender estuary
slate swan
#

imopithink

shadow wraith
#

!e

for i in range(len(len(len([1, 2, 3])))):
  print("what")
unkempt canyonBOT
#

@shadow wraith :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: object of type 'int' has no len()
vast gale
slate swan
slate swan
vast gale
#

floating point error or rounding error

tender estuary
slate swan
vast gale
#

yes

slate swan
tender estuary
#

what really is esoteric python

shadow wraith
slate swan
#

lovely code

vast gale
slate swan
#

was very lovely

vast gale
#

🥲

#

I fix like one or two bugs a day

slate swan
tender estuary
vast gale
#

and with each bug fix, comes 200 more bugs

shadow wraith
#

!e

i = 49
if i == 49:
  if i < 50:
    if isinstance(i, int):
      if i != 50:
        if float(i) == 49.0:
          print("💀")
unkempt canyonBOT
#

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

💀
vast gale
#

so I fix 16 bugs that day

#

and add 3400 more

slate swan
shadow wraith
#

that's how to print hello world

vast gale
#

very!

shadow wraith
#

😎

slate swan
#

i never fix errors cuz my codes are well thought of

tender estuary
tender estuary
slate swan
#

runs on syntaxs errors: 🏃💨

vast gale
#

bold

tender estuary
#

I just type whatever comes in my mind... then fix it.

slate swan
#

what if i run a bot with !e

tender estuary
shadow wraith
#

people who have ZeroDivisionError: 🕴️

tender estuary
#

xD

shadow wraith
#

!e

import discord
unkempt canyonBOT
#

@shadow wraith :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'
vast gale
#

TBF had I written the entire bot from scratch I probably would have less problems

slate swan
shadow wraith
tender estuary
slate swan
tender estuary
#

Anyways I regenerate my token 4-5 times a day.

vast gale
#

as it stands, my bot started as a fork of @lament depot and @unkempt canyon melded into one bot with features of my own added

shadow wraith
#

how would you guys rate discord bot's code if they oftenly had zerodivisionerror

vast gale
#

overtime I'll fully rewrite my bot into my own source

slate swan
#

!e
m = True
while m:
print('infinite loop crash')

unkempt canyonBOT
#

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

001 |   File "<string>", line 3
002 |     print('infinite loop crash')
003 |     ^
004 | IndentationError: expected an indented block after 'while' statement on line 2
tender estuary
#

the bot gets glitchy when I test it for a long time and starts sending 2-3 duplicate messages at the same time.

slate swan
vast gale
#

monty python

slate swan
#

!e
m = True
while m:
print('infinite loop crash')

unkempt canyonBOT
#

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

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

Full output: too long to upload

slate swan
#

#bot-commands

#

fuck

shadow wraith
#

d-d-d-did you just try to flood chat?

slate swan
tender estuary
#

!e
while True:
print("huihui")

unkempt canyonBOT
#

@tender estuary :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print("huihui")
003 |     ^
004 | IndentationError: expected an indented block after 'while' statement on line 1
shadow wraith
slate swan
#

just do

while True:

😠

tender estuary
#

yea ofc.. no auto indent...

slate swan
tender estuary
#

any IDE or editor I used...

shadow wraith
#

there is a difference between while False: and while <avarwhichhasafalsyvalue>: i think

slate swan
tender estuary
unique tendon
#

I want to code/find a command where its like a giveaway drop, the first person to react to the message wins

#

Would this be hard?

slate swan
vast gale
tender estuary
#

Before that VSC. Before that studio, before that pycharm.

vast gale
#

or just general python programming

shadow wraith
#

!e

while False:
  print("???")
unkempt canyonBOT
#

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

[No output]
slate swan
tender estuary
#

!e
while True:
print("huihui")

unkempt canyonBOT
#

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

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

Full output: too long to upload

shadow wraith
#

!e

h = False
while h:
  print("huihui")
unkempt canyonBOT
#

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

[No output]
vast gale
#

but since I wanted features from both python and lance.... why would I want to host two & they're coupled to all of the features, so I just combined them into one and took out all of the fun features

tender estuary
unique tendon
slate swan
unique tendon
#

Wdym no wait

vast gale
slate swan
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
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 2, in <module>
003 | NameError: name 'okamii' is not defined. Did you mean: 'omamii'?
slate swan
#

FUCk

tender estuary
#

!e
while True:
chance = random.randint(1,34343434453)
print(chance)

unkempt canyonBOT
#

@tender estuary :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | NameError: name 'random' is not defined
vast gale
tender estuary
#

!e
import random
while True:
chance = random.randint(1,34343434453)
print(chance)

green bluff
unkempt canyonBOT
#

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

001 | 8473178990
002 | 32538215294
003 | 33566977677
004 | 7133613355
005 | 29514869072
006 | 16275754766
007 | 239594124
008 | 4338175846
009 | 22591317393
010 | 19790230607
011 | 27613002645
... (truncated - too many lines)

Full output: too long to upload

slate swan
green bluff
#

why doesnt this work

slate swan
#

!e
okamii = 'cuz why not'
okamii = okamii.split()
a = okamii[0]
b = okamii[1]
c = okamii[2]
prnt = f'{a} {b} {c}'
m = 'okamii'
while len(m) >= 6:
print(f'prnt')

unkempt canyonBOT
#

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

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

Full output: too long to upload

tender estuary
#

!e
import random
while True:
print(random.randint(1,34343434453))

unkempt canyonBOT
#

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

001 | 11919006997
002 | 21883672407
003 | 28203714443
004 | 9774762786
005 | 1152922010
006 | 17987628190
007 | 19453202220
008 | 12026612427
009 | 24947163732
010 | 10026345569
011 | 15397071891
... (truncated - too many lines)

Full output: too long to upload

slate swan
#

im

#

guys stop jeez

green bluff
vast gale
#

funny thing

green bluff
#

pls help

tender estuary
#

How is computer so random.

slate swan
unkempt canyonBOT
#

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

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

Full output: too long to upload

green bluff
#

BRUH

slate swan
#

wrote this shit on phone

tender estuary
#

Like humans can't be random there always is a pattern.. How are computers so randomly random.

slate swan
#

took a long ass time

green bluff
vast gale
#

my bot only has a snekbox and docs command after I made it public and then realised I should have it

slate swan
#

cant believe I misread ur name

slate swan
vast gale
#

I kept telling myself to add a snekbox and docs command like @unkempt canyon but muh DB and hosting! @slate swan

#

anyways it now has a docs and eval command.

slate swan
#

nice

tender estuary
#

what is the hardest topic about python here in the server

slate swan
#

cant say tbh

#

hardest topic

#

wydm

#

if you dont know them all you cant say

#

like hardest to learn or what

tender estuary
shadow wraith
#

definitely printing hello world is the hardest topic

slate swan
#

data science hardest brotha

visual island
vast gale
#

I mean... the topic that ppl probably struggle with the most is this channel

slate swan
#

120k salary for a reason

tender estuary
slate swan
slate swan
shadow wraith
vast gale
slate swan
#

networking + security aint really that complicated

#

data scientists dont get paid 100k/yr for nothing

shadow wraith
slate swan
#

!e

print("Hello World!")

pov: you started learning python

unkempt canyonBOT
#

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

Hello World!
tender estuary
shadow wraith
slate swan
#

wut

#

!e ctx.purge(limit=1000)

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 'ctx' is not defined
tender estuary
vast gale
#

:)

slate swan
shadow wraith
slate swan
#

gaved bro

shadow wraith
#

your previous opinion was my opinion on that too, not every opinion you have is also my opinion on that.

slate swan
vast gale
#

@slate swan for the 15 hundredth time, snekbox does not run on @unkempt canyon!!!

shadow wraith
#

guys wanna hear something tongue twisty

#

github copilot is:
a program programmed by a programmer to program programs

slate swan
tender estuary
vast gale
#

!e ```py
import sys
print(sys.orig_argv)

unkempt canyonBOT
#

@vast gale :white_check_mark: Your eval job has completed with return code 0.

['/usr/local/bin/python', '-Squ', '-c', 'import sys\nprint(sys.orig_argv)']
shadow wraith
#

!e

import sys; sys.exit()
unkempt canyonBOT
#

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

[No output]
slate swan
#

welp im going to go to sleep its 5am already so Gn guyspithink

shadow wraith
#

its literally morning in my country rn

slate swan
slate swan
#

almost

vast gale
#

nO

unique tendon
#

Can i ask ppl to help me code a command here? Because i dont know how to do it

vast gale
#

I stay up until 9am :)

slate swan
#

let me talk in 4 more minutes arl and youll be wrong

shadow wraith
unique tendon
vast gale
unkempt canyonBOT
#
Out of the question.

Sorry, you can't do that here!

slate swan
vast gale
#

darn

slate swan
#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

slate swan
#

3 more minutes

green bluff
unique tendon
# tender estuary yea ofc

Im trying to code a drop command, where the bot sends a message and the first person to react wins the drop

green bluff
#

plshelp

vast gale
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.