#discord-bots

1 messages · Page 723 of 1

untold token
#

Hmm

#

Does it use pterodactyl?

silk mauve
#

idk

#

But you just need 5 minutes

#

and ur bot is on so

untold token
#

Does it say pterodactyl panel

#

Oh ofcourse it uses pterodactyl

graceful mulch
#

hello

untold token
#

Yeah nah, I absolutely despise that

glacial bridge
#

I wouldn’t jump at any free host so fast

#

Let me do some research rq

untold token
#

I tried some hosting services that were made for discord bots, like ploxhost or what not

#

They use the same system, pterodactyl panel

#

and its absolutely terrible, like they have a console but you can't run commands init, it is just for logs, then you have hardcoded startup command and you can't run any shell commands using a programming language as it results to a permissions error

#

Maybe it's the hosting service but pterodactyl in itself is awful to use

glacial bridge
untold token
#

I will use GCP/ aws, its good

glacial bridge
#

this might've been changed though, since that link no longer works (at least for me)

untold token
glacial bridge
#

yeah that link was taken down/moved, and the tos was probably revised

untold token
#

Eh, well you still can't trust em really

slate swan
#
@client.command(pass_context = True)
@commands.has_permissions(Administrator =True)
    async def mute(ctx, member: discord.Member):
        role = discord.utils.get(member.server.roles, name='Muted')
        await ctx.add_roles(member, role)
        embed=discord.Embed(title="User Muted!", description="**{0}** was muted by **{1}**!".format(member, ctx.message.author), color=0xff00f6)
        await ctx.send(embed=embed)
     else:
        embed=discord.Embed(title="Permission Denied.", description="You don't have permission to use this command.", color=0xff00f6)
        await ctx.send(embed=embed)

This is mute command what is wrong?

untold token
#

it's an indentation error, your editor / IDE will point you do that

#

Also the code is wrong

slate swan
glacial bridge
#

depends what version

#

if he's got a super outdated one KEKW

untold token
#

and Context class doesn't have a method as add_roles

slate swan
untold token
#

It's a method of the Member class

glacial bridge
#

you have to use utils i think

untold token
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
glacial bridge
untold token
glacial bridge
#

print(discord.__version.__)

#

^^that's how you check, and yeah it's prob not that old

untold token
#

mhm

slate swan
#
  File "bot.py", line 267, in <module>
    @bot.event()
TypeError: event() missing 1 required positional argument: 'coro'```
untold token
#

@bot.event

#

it doesn't have ()

slate swan
#

oh ok

untold token
#

@glacial bridge

#

They didn't improvise

glacial bridge
#

lool

#

it's like that with most free hosts

#

or they are bad, or they take your ip

#

there's no really 'free'

boreal ravine
#

i hate the pterodactyl dashboard

slate swan
#
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "bot.py", line 279, in give
    await add_points(users, member, amount)
TypeError: add_points() missing 1 required positional argument: 'pts'

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

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/container/.local/lib/python3.8/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: TypeError: add_points() missing 1 required positional argument: 'pts'```
boreal ravine
#

your missing an argument where u call the function

glacial bridge
#

and yeah, it says it in the error

slate swan
slate swan
glacial bridge
boreal ravine
glacial bridge
#

oh typo

slate swan
glacial bridge
untold token
#

Not might

#

You should

glacial bridge
#

trying to be nice but yeah

#

this is not a beginner project

#

learn at least the basics

untold token
#

You definitely need have strong python knowledge before using discord.py, it's not beginner friendly

velvet tinsel
untold token
#

Also the error raises an Argument Error, which basically means that you didn't pass something to argument in the function you made

velvet tinsel
#

He probably doesn’t even know what that is pithink

slate swan
#

-_-

untold token
#

!e

def func(a, b):
   return a + b

print(func(1, 2))  # passing values to the arguments of the function named "func"
unkempt canyonBOT
#

@untold token :white_check_mark: Your eval job has completed with return code 0.

3
untold token
#

Now

velvet tinsel
#

!resources || go through this

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.

glacial bridge
#

ah ok

untold token
#

!e

def func(a, b):
   return a + b

print(func(1))  # passing values to the arguments of the function named "func", but I only passed to only a single argument
unkempt canyonBOT
#

@untold token :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | TypeError: func() missing 1 required positional argument: 'b'
velvet tinsel
#

You’re quicker 😭

#

I’m on a phone, it’s not fair

untold token
#

Me on phone too

velvet tinsel
#

I would have destroyed you

velvet tinsel
#

what’s a tuple pithink

untold token
velvet tinsel
glacial bridge
#

you can always come back to this later after getting some knowledge, however long that takes

untold token
#

Yep

velvet tinsel
#

I learnt the basics first

#

at first I was a bit of an idiot but then something weird happened and I started learning hype pithink

cold sonnet
#

I didn't know any python, just java

#

but since I knew oop

slate swan
#

brush

cold sonnet
#

the basics were easy

#

took like a day

untold token
#

Well you need to have good knowledge of asynchronous programming

velvet tinsel
#

💀 you don’t want to know what I did

#

As a beginner

cold sonnet
velvet tinsel
#

I passed an argument, not a kwarg when I should have been using a kwarg 💀

velvet tinsel
slate swan
#

"we use async def for bot commands , because it should be done like that"

cold sonnet
velvet tinsel
#

bro

#

you don’t even know what async is

untold token
cold sonnet
#

I know what coroutines are

#

and that you use async for coroutines

velvet tinsel
#

amazing

slate swan
#

and you await them when calling.

velvet tinsel
#

well done yert

cold sonnet
#

yes

untold token
#

you need to know when to await and when not to await, awaitables

velvet tinsel
#

I love that name

#

“awaitables”

untold token
#

Lol

nova fjord
#

What iş the best library for mobile app

untold token
velvet tinsel
velvet tinsel
#

💀

cold sonnet
velvet tinsel
cold sonnet
#

yes

nova fjord
cold sonnet
#

I'm quite sure

velvet tinsel
#

Yes

#

we’re certain

#

I swear on my…bread

#

🍞

glacial bridge
glacial bridge
#

oh mb

velvet tinsel
#

He doesn’t know what he’s talking about

glacial bridge
#

no yeah, it's dpy

untold token
untold token
#

No

cold sonnet
velvet tinsel
#

he doesn’t know what he’s talking about

glacial bridge
#

👌

velvet tinsel
untold token
#

Don't provide wrong help to people who are beginners, even it's for trolling purposes

velvet tinsel
#

it’s for mobile apps yert

untold token
#

¯\_(ツ)_/¯

slate swan
slate swan
#

you can correct me if i am wrong.... thats what i knew about it.

velvet tinsel
#

after 10 years of experience with coding, do you become Caeden

cold sonnet
#

probably

echo lagoon
#

heyo, looking for a way to get error line in dpy (in code), outside of dpy this works:

try:
    raise NotImplementedError("Not implemented")
except Exception as e:
    exception_type, exception_object, exception_traceback = sys.exc_info()
    filename = exception_traceback.tb_frame.f_code.co_filename
    line_number = exception_traceback.tb_lineno

    print("Exception type: ", exception_type)
    print("File name: ", filename)
    print("Line number: ", line_number)

but when using dpy, says tb_frame is none, is there a way to get error line number in dpy?

cold sonnet
#

uh

#

raise e

echo lagoon
#

Ofcourse example is using try except - while in dpy I’m using error handler function

cold sonnet
#

raise error

#

man Imma shut up

echo lagoon
#

;-; yes but I can’t get the line the error occured on from trace back - only the description of error

velvet tinsel
#

let’s see?

#

I don’t think this applies with discord bots

#

@echo lagoon

slate swan
#

How do I delete the command the person did

#

Let’s just say I did !help that it just deletes the !help

cloud dawn
velvet tinsel
cloud dawn
velvet tinsel
#

I’m bad at helping

cloud dawn
#

Use on_command if you want it for all commands

velvet tinsel
#

but I still admire you ♥️

slate swan
cloud dawn
velvet tinsel
#

but mainly it’s Caeden, Okimii and kayle and myxi

#

💀 but I still admire you

tough lance
#

wat

echo lagoon
# velvet tinsel I don’t think this applies with discord bots

ye, i guess your right. . .

this was the best traceback i can get, which again doesnt show the actual cog file nor the origin of the error. . .

                trace = []
                tb = error.__traceback__
                while tb is not None:
                    trace.append({
                        "filename": tb.tb_frame.f_code.co_filename,
                        "name": tb.tb_frame.f_code.co_name,
                        "lineno": tb.tb_lineno
                    })
                    tb = tb.tb_next
                print(str({
                    'type': type(error).__name__,
                    'message': str(error),
                    'trace': trace
                }))
slate swan
#

@cloud dawn if "@brisk portal" in message.content: ctx.message.delete() await message.channel.send(" please do not menion me thanks")

echo lagoon
#

thx!

tough lance
#

dms are closed?

fervent shard
tough lance
slate swan
#
    ctx.message.delete()
      await message.channel.send(" please do not menion me thanks")```
#

I’m getting error lol

#

I think Ik why tho I want someone to do it

fervent shard
sullen shoal
#

you cant DM someone if you dont have any mutual servers with them

cloud dawn
sullen shoal
#

you will have to DM before banning

fervent shard
#

look

@bot.command(aliass=['k'])
@commands.has_permissions(kick_members=True)
async def kick(ctx,member : discord.Member,*,reason=None):
  if member == ctx.author:
    em2 = discord.Embed(description=f"**you** cannot `kick` yourself", colour=discord.Colour.red())
    await ctx.send(embed=em2)
  else:
    em = discord.Embed(description=f"**{member}** has been `kicked` for **{reason}**", colour=discord.Colour.green())
    await ctx.send(embed=em)
    await ctx.guild.kick(discord.Object(id = member.id))```
sullen shoal
#

cant find member.send

#

anywhere

slate swan
#

its member.send

sullen shoal
#

oh yeah

acoustic marsh
#

anyone can build bot?

slate swan
#

ye everyone can

tough lance
#

We all can

#

Not for anyone tho

sullen shoal
#

discord api is free to use so yeah

slate swan
#

can someone help me with flask socketio?

acoustic marsh
#

ok , what about interest to develop or build bot have free well reactions

tough lance
#

You can find help there I think

slate swan
#

its ded

acoustic marsh
#

after can, interest, time
anyone have time?

sullen shoal
#

i have no idea what you're talking about tbh

slate swan
#

they are asking for help ig

sullen shoal
#

with what

slate swan
#

with building a bot?

#

build a bot for them

sullen shoal
#

use an api wrapper for it or the api itself

#

thats it

slate swan
#
      await message.channel.send(f"{message.author.mention} please do not menion me thanks")``` I wanna delete command on use someone help
unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
sullen shoal
#

discord.abc.Messageable.send
returns the Message object you send @slate swan

slate swan
#

Ok

#
bot.remove_command('help')
#

oh nvm

sullen shoal
slate swan
sullen shoal
fervent shard
#

how do i fix it

sullen shoal
#

don't call an int object

#

1()

tough lance
#

Code?

sullen shoal
#

!e 1()

unkempt canyonBOT
#

@sullen shoal :x: Your eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: 'int' object is not callable
sullen shoal
fervent shard
# tough lance Code?
@bot.command(aliass=['k'])
@commands.has_permissions(kick_members=True)
async def kick(ctx,member : discord.Member,*,reason=None):
  if member == ctx.author:
    em2 = discord.Embed(description=f"**you** cannot `kick` yourself", colour=discord.Colour.red())
    await ctx.send(embed=em2)
  else:
    em = discord.Embed(description=f"**{member}** has been `kicked` for **{reason}**", colour=discord.Colour.green())
    em3 = discord.Embed(description=f"**you** have been `kicked` for **{reason}**", colour=0())
    await ctx.send(embed=em)
    await member.send(embed=em3)
    await ctx.guild.kick(discord.Object(id = member.id))```
acoustic marsh
#

any bot programmer want give me his time? and his knowledge ?

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.

sullen shoal
acoustic marsh
#

no

sullen shoal
#

do have a loom at rule 9

#

look

acoustic marsh
#

im not look for freelancing sites

slate swan
#

Then what are you looking for

acoustic marsh
#

i just want another thing you dont want it

#

you can skip or i can out its ok

fervent shard
maiden fable
#

@acoustic marsh what happened

slate swan
maiden fable
#

Damn they left

sullen shoal
#

dont call int objects

#

!e 0()

unkempt canyonBOT
#

@sullen shoal :x: Your eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: 'int' object is not callable
kind wind
#
@bot.command() #BALANCE COMMAND
async def bal(ctx):
  await open_account(ctx.author)
  user = ctx.author
  users = await get_bank_data()
  
  souls_amt = users[str(user.id)]["souls"]

  em = discord.Embed(title = f"{ctx.author.name}'s balance",color = discord.Color.green())
  em.add_field(name = "Souls", value = souls_amt)
  await ctx.reply(embed = em)

async def open_account(user):
  
  users = await get_bank_data()

  if str(user.id) in users:
    return False
  else:
    users[str(user.id)] = {}
    users[str(user.id)]["souls"] = 0

  with open("mainbank.json", "w") as f:
    users = json.dump(users, f)
  return True

async def get_bank_data():

  with open("mainbank.json", "r") as f:
    users = json.load(f)
  return users

@bot.command() #WORK COMMAND
@commands.cooldown(1, 30, commands.BucketType.user)
async def hunt(ctx):
  await open_account(ctx.author)
  user = ctx.author
  users = await get_bank_data()

  souls = random.randrange(11)

  await ctx.reply(f"You went for a hunt and hunted {souls} souls!")

  em = discord.Embed(title = f"Hunting!", color = discord.Color.red())

  users[str(user.id)]["souls"] += souls

  with open("mainbank.json", "w") as f:
    json.dump(users, f)

What's wrong with my code? It gives me errors when I try to use it

#

Anyone?

sullen shoal
#

show the traceback

kind wind
#

wait

#

Ignoring exception in command bal:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\user\Documents\GitHub\ghostbot\main.py", line 18, in bal
await open_account(ctx.author)
File "c:\Users\user\Documents\GitHub\ghostbot\main.py", line 30, in open_account
users = await get_bank_data()
File "c:\Users\user\Documents\GitHub\ghostbot\main.py", line 45, in get_bank_data
users = json.load(f)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 293, in load
return loads(fp.read(),
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

#

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

Traceback (most recent call last):
File "C:\Users\user\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\user\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\user\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: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

sullen shoal
#

would've helped if you were using an actual database for a job that is an actual database supposed to store

#

guess you could hope for someone else to waste their time

kind wind
#

what?

#

what did I do?

sullen shoal
#

you used json as a database

slate swan
#

thats what smart ppl do

sullen shoal
#

and you are stuck with an error you will not have to care about if you use an actual database

kind wind
#

i imported json to store the balances in a .json file

untold token
sullen shoal
#

json is not a db

slate swan
#

ye ik

untold token
#

Json isn't a database and if you use it as one, you will deal with more problems than good

slate swan
#

oh

#

better than a nosql db

#

which is remote

#

if u know how to handle issues

untold token
#

Uh? what? Json isn't a database, remote or not

#

If you want a database that us similar to structure of json, use mongoDB

kind wind
untold token
#

Or if you want relational database, use postgresql or even sqlite

slate swan
#

i mean

kind wind
#

i dont remember

slate swan
#

json is better than a nosql db which is remote

kind wind
#

its been a while since I saw it

slate swan
#

u can use json if u know how to handle concurrency issues

kind wind
sage otter
#

Or literally just save yourself the trouble and don’t do that.

untold token
kind wind
#

i thought that the bot writes on the .json file when the command is triggered

untold token
#

Why would you even want to use something as something when it is not meant to be that thing

sullen shoal
#

parsing and loading json takes time. as your bot will be used by more users the time will increase and one day you will reach the point where it will take ages to get the data

untold token
#

Json isn't better than any NoSQL db

kind wind
#

I understood something from that
"w" = writes on the file
"r" = reads the file

#

and it was that in the code

untold token
#

Its not better that MongoDB

#

MongoDB is a remote NoSQL based database

untold token
#

But if you are reading from an empty json file, you will receive that error

kind wind
#

so the bot is supposed to write on the file by using this:

if str(user.id) in users:
    return False
  else:
    users[str(user.id)] = {}
    users[str(user.id)]["souls"] = 0
#

its on the open_account function

untold token
#

You have an empty json file? Right?

kind wind
#

yea

untold token
#

Did you add {} in that?

kind wind
#

No

untold token
#

Write {} in your json file, that way when you are writing into the json file, you won't get the error.

kind wind
#

i will but last time I left it blank and the bot wrote it by itself

untold token
#

Ah hm

kind wind
#

i might did it but not remember but i am sure that i didnt

sullen shoal
#

so you are sure you didn't add it

kind wind
#

yeah

#

at least it works

#

thanks

untold token
#

Lol

sullen shoal
#

another guy wasting their time for shitty code

kind wind
slate swan
#

help
i am trying to make timeout commands and this shows p

untold token
#

and use them make your stuff

#

rather than json

kind wind
#

I am still learning discordpy

untold token
#

Type git in console

slate swan
#

ok

untold token
#

You need to install git
....?

slate swan
slate swan
untold token
#

Well git isn't recognized

#

Install git

#

git is a command line tool, which is basically a version control system

slate swan
#

@slate swan

slate swan
#

bot isnt disconnecting from vc for some reason-
code

  @commands.command()
     async def disconnect(self,ctx):   
         await ctx.voice_client.disconnect()    
sage otter
#

Get any errors

slate swan
#

nope

maiden fable
#

!d discord.ext.commands.Context.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
A shortcut to [`Guild.voice_client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.voice_client "discord.Guild.voice_client"), if applicable.
maiden fable
#

!d discord.VoiceProtocol.disconnect

unkempt canyonBOT
#

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

An abstract method called when the client terminates the connection.

See [`cleanup()`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol.cleanup "discord.VoiceProtocol.cleanup").
maiden fable
#

@slate swan it's an abstract method (nvm)

full lily
#

There's no reason that would happen. The more likely scenario is that the users leaked the token themselves

slate swan
#

what to do?

#

discord.Member not _

vague grove
#

is there a way to fetch all the dms that someone sent to the bot

#

for dm in user.dms

#

something like that?

slate swan
#

replace _ with .

slate swan
quaint epoch
quaint epoch
glacial bridge
#

^^change it to this

vague grove
quaint epoch
#

and idk if this is just me, but you should prob read the id as an int and fetch the member

vague grove
#

hm.. alr

slate swan
quaint epoch
#
async def mute(ctx, member: discord.Member):
maiden fable
maiden fable
full lily
#

It's not valid to say that a hosting company is bad because someone leaked their token with them

gaunt fox
#

use env variables if you know its open source

#

like replit

maiden fable
#

Well yea, but I just told him what the other person whose token got leaked said. Nevertheless, I better not continue/comment

maiden fable
gaunt fox
#

not with repli

maiden fable
#

Anyways I gtg sleep, have a good day/night everyone!

gaunt fox
#

gn

slate swan
kindred drum
#

yo how do you edit fields in a embed message after its been sent

quick gust
cold sonnet
#

he's definitely trolling lmao

cold sonnet
quick gust
velvet tinsel
velvet tinsel
slate swan
#

is there a way to add an emoji randomly?

#

add a reaction or just a text or something

slate swan
fading knot
#

Is there any replit alternative

slate swan
#

I use that after replit

fading knot
#

Android?

#

@slate swan

slate swan
#

pydroid

slate swan
wicked atlas
#

Also, not really the channel for that

fading knot
#

But i cannot keep it always on

slate swan
#

vscode

#

you can use vscode text editor online :0

wicked atlas
slate swan
#

yeah but you can still make your projects atleast

#

idk about better alternatives

late karma
fading knot
#

Yes keeping project online

#

@late karma

wicked atlas
#

Well, the only two I can think of is pythonanywhere, and one I have only a little experience with, codingrooms

velvet tinsel
late karma
late karma
# fading knot Yes keeping project online

Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it.
🚨Note: At 16:43, Replit now has a new method for environment variables. Check the docs: https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables

Along the way, you will learn to use Repl.it's built-in database and cr...

▶ Play video
slate swan
#

Bro that's replit

slate swan
late karma
#

oh, my bad

#

I thought he didn't know about this method of to keep the project online through the replit

slate swan
#

replit is still bad for hosting

late karma
#

I use it on small projects and I never had a big problems.

slate swan
#

is what makes replit bad

#

and how slow it is

late karma
#

i get it

slate swan
#

¯_(ツ)_/¯

patent lark
#

i dont consider replit to be a terrible host, its just bad at hosting discord bots, as thats not what its intended to do.

sage otter
#

I think you might be referring to heroku??? Maybe.

#

That’s more built for web stuff

patent lark
#

either way. replit isnt for hosting discord bots, or as you said, hosting in general

pliant gulch
#

Even though the owner of repl.it endorses discord bots on their platform lmao

cloud beacon
#

using dpy 2.0, view.wait() doesn't work for dropdown menus - any alternative? im trying to reference the response from the dropdown in my main command

velvet tinsel
hollow mortar
#

hey i have question

#

do i can run 20 discord bots using 1 code and 20 config files

#

and each config file have token

cloud beacon
#

i don't see why not

#

never tried it though so im not sure if that would work

hollow mortar
#

i dont think that works

cloud beacon
#

like if you are using cogs or something

#

im not sure if there is a limit on how many configs can use a cog

hollow mortar
#

i dont think that works

#

idk there is a guy telling me it works but im saying no it doesnt work

cloud beacon
#

then try it, it wouldnt take long

slate swan
#

Yes you can.

#

pls help me i have wrote like almost 500 lines of discord.py bot's code and now i want to use cogs. how can i use cogs? I literally don't know anything about cogs. Pls help

slate swan
#

what is @commands.guild_only()?

sage otter
#

What do you think it does?

#

It’s just a decorator that makes the command it’s associated with a command that can only be used in a guild.

slate swan
#

k

sage otter
#

Hence guild_only

slate swan
#

will it be client.guild_only()

#

?

sage otter
#

No

slate swan
#

i am not using cogs

sage otter
#

So? you don’t need to be.

slate swan
#

ok

hushed field
#

send code and error

#

so

#

to simplify it

upbeat otter
#

You can just add an argument and set the default value as none, then you can use conditionals to set the value of the added argument

hushed field
#

do async def (self, ctx, member: discord.Member)
pull_from_db = member or ctx.author

pull_from_db is either member if passed or author

upbeat otter
#

;-;

hushed field
#

not exactly

#

it will error since member is none and say id has no attr

upbeat otter
#

Oh yeah, pull_from_db.id

cedar stream
#

To get id

#

user=None

final iron
#

Just like assigning a variable

quaint epoch
#

so, you want to just fetch a users profile?

cedar stream
#

Rename arg to member if It’ s discord.Member and then do member = member or ctx.author

quaint epoch
#

i don't understand

cedar stream
knotty gazelle
#

You should do

user = arg or ctx.author
user_id = user.id
cedar stream
#

Dont define user_id

#

Also if It’ s discord.Member it should probably be named member and not user so It’ s not confused with discord.User

slate swan
cedar stream
#

Me

#

!d disnake.ui.View

unkempt canyonBOT
#

class disnake.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
cedar stream
#

Read this, It’ s rly handy

#

Click the link

#

You create a subclass of discord.View

#

And then you can do inter.send(view=YourSubclassOfView)

slate swan
cedar stream
slate swan
#

Tf how

cedar stream
slate swan
cedar stream
#

No, name of view

#

Read what I sent u

slate swan
#

There’s why I never Use repl only for uptime

cedar stream
#

Wdym

pliant gulch
#

When will people realize repl.it isn't for hosting

#

It's just a work around lmao

slate swan
pliant gulch
#

🤔

cedar stream
#

Hows ur api wrapper @pliant gulch

jaunty wraith
#

Is it possible to be able to send a function like printing a function

pliant gulch
#

Not much development rn I might end up refactoring the codebase

cedar stream
#

I might use it for a bot

jaunty wraith
cedar stream
#

If I get any will to make another bot

cedar stream
jaunty wraith
#

So if i do ctx.send(ball) (ball is my function it should send whatever is in the function right?

cedar stream
jaunty wraith
#

Lol i should explain it better

cedar stream
#

With ()

cedar stream
jaunty wraith
#

so ctx.send((ball))

cedar stream
#

No

#

ball()

jaunty wraith
#

ctx.send(ball())

cedar stream
#

But what I see from ur code, ball is a list

slate swan
#

for checking if someone had permissions to kick, would it be this?

@commands.has_permissions(kick_members=True)
jaunty wraith
slate swan
#

Turns out the bot didn't have a high enough role

jaunty wraith
#

oh lol

cedar stream
jaunty wraith
#

I put my bots role at the top of my server above mine

cedar stream
jaunty wraith
#

8 ball command

cedar stream
#

Use random.choice(list)

jaunty wraith
#

Ok.

cedar stream
#

Also ball list should probably be named choices or answers or something

#

And put the list inside the function

brazen raft
jaunty wraith
jaunty wraith
pliant gulch
#

You can't name it 8ball because it has a number at the start

jaunty wraith
pliant gulch
#

If you really wanted to name it 8ball you could just put an underscore before the 8 and that would be close enough

#

But choices is also a good name choice

slate swan
#

is this how you would mention a interaction author

interaction.author.mention
magic ore
#

!d discord.Interaction.user

unkempt canyonBOT
jaunty wraith
slate swan
#

how does user not have an attribute discrimator

#

Because it's discriminator, not discrimator.

#

!d discord.User.discriminator

unkempt canyonBOT
slate swan
#

fun spelling mistakes

grand shell
#

hey! im looking for an affordable solution to hosting a bot! there are loads of options but its quite hard to tell which is better. does anyone have any thoughts / advice?

wild oak
#

don't mind me just lurking for ideas 😭

#

@grand shell what's your budget?

grand shell
#

under $5 / month

wild oak
#

Hmmm

#

I'm guessing you want it online 24/7

grand shell
#

iv heard of galaxygate and vultr but idk how they compare..

wild oak
slate swan
#

its lowest plan is 5$ a month

pliant gulch
#

Vultr is good, so is digital ocean

#

Linode is amazing

slate swan
#

it kinda depends where you live aswell

pliant gulch
#

Most of these services are global, they should have servers in your region

blazing lynx
#

is a radio command ageinst tos too?

silk mauve
#

Does {ctx.guild.boost_level} exist? Because I've a serverinfo command and I want to see the Server boosts

#

Like the count of

#

Or level

pliant gulch
#

!d discord.Guild.premium_tier

unkempt canyonBOT
#

The premium tier for this guild. Corresponds to “Nitro Server” in the official UI. The number goes from 0 to 3 inclusive.

silk mauve
#

ty

lime totem
#

hi

silk mauve
#

Is there anyway that there is a command which shows what u are listening to right now

#

any way*

silk mauve
#

Ye

cloud dawn
# silk mauve Ye
if isinstance(member.activity, discord.Spotify):
    print(member.activity.title)
#

*user can have multiple activities.

silk mauve
#

How does this wanna worj?

#

work

slate swan
#

Guys I am trying to write an if statement to check if the embed has no fields in it, how would I go about this? I have this so far

if msg.embeds[0].fields is discord.Embed.Empty:
slate swan
#

I am pretty sure it is

if msg.embeds in msg.content:
#

does anyone know how to save user input to a .txt file using discord.py?

muted vessel
#

how i make bot for discord

slate swan
#

use this stuff

haughty quartz
#

any idea of how to make a bot work in threads?

torn sail
#

They’re pretty bad

echo lagoon
#

working on a music bot,

any pointers to what i should use for queuing songs?

i would like the ability to go back to previous songs, so i wasnt so sure about using queues,
but at the same time, wasnt sure how id check if something was added to an array when empty. . . (or max index reached)

jaunty wraith
#

Is bot.process_commands(message) the same as client.process_commands(message)
If i use client not bot

#

I tried it before and it didnt work I probably did something wrong

torn sail
#

Well discord.Client doesn’t have commands

slate swan
#

ok

#

then use the docs

slate swan
#

depends what you call bot = to

#

either client or bot or anything works

jaunty wraith
#

Ok

slate swan
#

could call it James if you wanted

jaunty wraith
#

Lmao

#

(Im a pokemon fan i just instantly thorght of that)

sick birch
#

That's like the worst

slate swan
#

Code:

@bot.command()
async def purge(message, amount):
    if not message.author.guild_permissions.administrator:
        await message.channel.send('You do not have the `ADMINISTRATOR` permission in order to continue this operation!')
        return
    
    for i in message.channel.history(limit=amount):
        try:
            await i.delete()
        except Exception as e:
            print(f'[ERR] -> {e}')

Full Traceback:

Traceback (most recent call last):
  File "C:\Users\mal\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\mal\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\mal\AppData\Local\Programs\Python\Python39\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: TypeError: 'HistoryIterator' object is not iterable
loud junco
heavy folio
#

is it possible to get a part of the code using eval

loud junco
#

not sure

heavy folio
#

also is there a method which i can get command info, e.g. command name, help, aliases and other stuff

heavy folio
unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
cloud dawn
#

!customhelp

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

heavy folio
cloud dawn
#

!d disnake.ext.commands.Command.aliases

unkempt canyonBOT
jaunty wraith
#

@client.event
async def on_message(message,ctx):
if message.content.startswith("joe?"):
await ctx.send("hehehee")
await client.process_commands(message)
Does anyone know why my bot isn’t responding to “joe”

#

Or any other commands event tho i did the await client.process

slate swan
heavy folio
#

like everything in a dict

outer violet
#

How do I get the total number of commands in a bot?

cloud dawn
#

..??

#

!d disnake.ext.commands.Command

unkempt canyonBOT
#

class disnake.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
heavy folio
sinful marsh
loud junco
#

:/

jaunty wraith
#

Wouldn’t recommend learning like that but i did

sinful marsh
#

This is a much better one

#

What error is it throwing

cloud dawn
#

{Guest, Member, HonoraryMember, VIP, Moderator, Administrator, Organizer} ;-;

#

But why a dict

surreal sierra
#

hi, very confused here. can someone explain why my bot use both . and ? as prefix for the commands when it is set to .. What I mean is that the bot answers when I do the commands with both dot/. and question mark/?.
here is how I set up the prefix, no idea why the bot answers to both when it is not supposed to do it

Bot = commands.Bot(command_prefix='.', case_insensitive=True, intents=intents)
jaunty wraith
#

Anyone know what the problem is with this code?

#

@client.event
async def on_message(ctx,message):
if 'fuck' in message.content:
await ctx.send("no")
await ctx.message.delete()

#

Its not giving any error

cloud dawn
loud junco
#

u should make the delete thing first

loud junco
#

u are deleting the msg u are sending :/

jaunty wraith
cloud dawn
surreal sierra
jaunty wraith
cloud dawn
cloud dawn
jaunty wraith
cloud dawn
surreal sierra
loud junco
jaunty wraith
#

Thats what i did

cloud dawn
jaunty wraith
#

Ok thank you

#

Ill try it

surreal sierra
jaunty wraith
#

Ive added “await client.process_commands(message)” to the end of my on_message code but it still isnt letting my other commands work

#

@cloud dawn when they see im typing VulpixDissapoint

cloud dawn
#
elif messages[0] >= 100:
    if any([bool(role) for role in member.roles if role in (Guest, Member, HonoraryMember, VIP, Moderator, Administrator, Organizer)]):
        Reward = f"{1000 - messages[0]} messages away from becoming a Member." if role == Guest else "No further rewards to unlock"
        await member.remove_roles(Visitor)
        await member.add_roles(Guest)
jaunty wraith
#

Oop didnt mean to ping sorry

cloud dawn
blazing lynx
#

ImportError: cannot import name 'Random' from partially initialized module 'random' (most likely due to a circular import) (/home/fazeexotic224/ZeroOne/cogs/random.py)

blazing lynx
#

its a import error

cloud dawn
#

I know

jaunty wraith
#

@client.event
async def on_message(message):
if 'fuck' in message.content:
await message.channel.send("no")
await message.delete()
await client.process_commands(message)

blazing lynx
#
import json
import os
import random
import sys

import aiohttp
import disnake
from disnake.ext import commands
from disnake.ext.commands import Context
import platform

from helpers import checks

if not os.path.isfile("config.json"):
    sys.exit("'config.json' not found! Please add it and try again.")
else:
    with open("config.json") as file:
        config = json.load(file)

        
    @commands.command(
        name="randomfact",
        description="Get a random fact."
    )
    @checks.not_blacklisted()
    async def randomfact(self, context: Context):
        """
        Get a random fact.
        """
        # This will prevent your bot from stopping everything when doing a web request - see: https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-make-a-web-request
        async with aiohttp.ClientSession() as session:
            async with session.get("https://uselessfacts.jsph.pl/random.json?language=en") as request:
                if request.status == 200:
                    data = await request.json()
                    embed = disnake.Embed(
                        description=data["text"],
                        color=0xD75BF4
                    )
                else:
                    embed = disnake.Embed(
                        title="Error!",
                        description="There is something wrong with the API, please try again later",
                        color=0xE02B2B
                    )
                await context.send(embed=embed)

    @commands.command()
    @checks.not_blacklisted()
    async def info(self, ctx):
        embed = disnake.Embed(title="", description="**[TwoZero](no self promo)**\n\nTwoZero-Statistics")
        embed.add_field(name="OS", value=platform.system())
        await ctx.send(embed = embed)


def setup(bot):
    bot.add_cog(Fun(bot))
cloud dawn
cloud dawn
unkempt canyonBOT
#

When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.

Instead of writing

def update_score():
    global score, roll
    score = score + roll
update_score()

do this instead

def update_score(score, roll):
    return score + roll
score = update_score(score, roll)

For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.

jaunty wraith
#

Ok.

#

Uh

loud junco
#

cuz there are used quite often but idw to call them everytime cuz there is tons of them

#

should i use dictionary?

cloud dawn
blazing lynx
#

wym

cloud dawn
#

Wait let me ask the cavalry

blazing lynx
#

yea py import random

cloud dawn
#

You can just use the emoji's from the server and fetch them with the api instead of doing so much manual labor.

blazing lynx
cloud dawn
pliant gulch
# jaunty wraith

Your process_commands call is inside of the if statement, thus would only process commands when the if statement is True. Unindent the process_commands call by one level

#

Or 2 levels since you seem to be indenting everything by 2?

cloud dawn
#

Told him that too 😅

jaunty wraith
#

Uh

cloud dawn
#

But Andy any idea about the circular import?

pliant gulch
#

I mean, seems like its a 2 space indent, so this is just the standard 4 message indent

jaunty wraith
tame nymph
pliant gulch
#

Either or

cloud dawn
#

As long as it is consistent.

pliant gulch
#

And the circular import is probably because they have a file named random.py

jaunty wraith
cloud dawn
#

Yeah i was thinking that too

pliant gulch
#

I mean, it shows in the error as well

#

they do have it

pliant gulch
tame nymph
#

yup problem solved

#

never name your files the same as builtin modules

simple gulch
#

What do you recommend as the best slash addon to discord.py?

digital ingot
#
@client.command(pass_context=True)
async def unbanall(ctx):
    guild = ctx.message.guild
    for member in list(client.get_all_members()):
        try:
            await guild.unban(member)
            print ("User " + member.name + " has been unbanned")
        except:
            pass
    print ("Action completed: UnBan all")``` no error code what so ever
#

it just doesnt unban anyone

#

i would use a autoclicker but i have 441 ppl banned in my server

#

so this is the faster way

heavy folio
#

!d discord.Guild.bans

unkempt canyonBOT
#

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

Retrieves all the users that are banned from the guild as a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry").

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.
digital ingot
dusk pumice
#

Help me...
What does this means???
And the token... I don't care. It's a test bot

digital ingot
#

i literally cant read anything

#

its just a big error code

dusk pumice
#

Yep...

digital ingot
#

could you send me the end of the error code?

dusk pumice
#

Okay

#

Oh

#

Wait a min..

#

Maybe I can fix it

digital ingot
#

then uh

#

do it ig

jade tartan
#

Would it be easy to create a discord bot dashboard for your desired bot?

heavy folio
#

you on replit?

heavy folio
late mauve
#

someone please help, am trying to make my bot welcome people but no matter how much i corrrect its not working.

import discord
from json import load
from pathlib import Path
from datetime import datetime


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

channel_id = config["channel_id"]
token = config["token"]

intents = discord.Intents.all()
intents.members = True
client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print("Everything is set to go!!!")

@client.event
async def on_message_join(member):
    channel = client.get_channel(channel_id)
    embed = discord.Embed(title=f"weclcome {member.name}", description=f"thanks for joining {member.guild.name}!", colour=0xf1c40f, timestamp=datetime.utcnow())
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_image(str ="https://cdn140.picsart.com/286390297028201.png")
    embed.set_footer(text="we would be glad if you show more love to us~", icon_url= str("https://cdn.discordapp.com/emojis/754736642761424986.png"))
    await channel.send(embed=embed)

client.run(token)
tame nymph
#

you mean on_member_join

somber crown
#

using this time converter

time_regex = re.compile(r"(\d{1,5}(?:[.,]?\d{1,5})?)([smhd])")
time_dict = {"h":3600, "s":1, "m":60, "d":86400}

class TimeConverter(commands.Converter):
    async def convert(self, ctx, argument):
        matches = time_regex.findall(argument.lower())
        time = 0
        for v, k in matches:
            try:
                time += time_dict[k]*float(v)
            except KeyError:
                raise commands.BadArgument("{} is an invalid time-key! h/m/s/d are valid!".format(k))
            except ValueError:
                raise commands.BadArgument("{} is not a number!".format(v))
        return time```
how would i convert an arg where the argument is `s` `m` `h` `d` (second minute hour day) to retrieve a timestamp so i can have something like this
cloud dawn
#

<t:1641091657>

#

I have no idea

pliant gulch
#

Would make a datetime.datetime object, then make a datetime.timedelta object with seconds minutes, etc then add the two objects together resulting in a new datetime.datetime, you'd then convert that into epoch time and use that for the timestamp

cloud dawn
#

Well not the entire thing is a string

#

("UPDATE parties SET activity_points = ? WHERE user_id = ?", (hmm?, 491289245974003722))

loud junco
#

why are ecoal and ecobble undefined

slate swan
#

globals are bad at time , try using bot vars instead

loud junco
#

how

#

any api for that?

slate swan
# loud junco any api for that?

you can have something like ```py
bot = commands.Bot(....
bot.my_emote = {'emote1':'theemote'}

#when u need it :
bot.my_emote['emote1']```

bitter perch
blazing lynx
#

ImportError: cannot import name 'Random' from partially initialized module 'random' (most likely due to a circular import) (/home/fazeexotic224/ZeroOne/cogs/random.py)

slate swan
#

what are you even importing Random ?

#

also , its an inbuilt python library, really bad to name another file as random

blazing lynx
#

@slate swan

dusk pumice
shrewd inlet
#

is there any way to remove your bot from servers you don’t have bot permissions in?

#

pls help cus my bot keeps getting random welcome messages

jaunty wraith
#

Can someone tell me what’s wrong with my code i cant work out how many indents i need in my else: its saying its a syntax error

#

@rickroll.event
@commands.is_owner()
else:
async def on_message(message):
if 'prick' in message.content:
await message.channel.send("no")
await message.delete()
await rickroll.process_commands(message)

crude crater
#

Unless ofc you reassigned it

jaunty wraith
#

I changed it so in my repl the equivalent of bot is rickroll dont know why

#

Yea

crude crater
#

Oh okay

jaunty wraith
#

Its something to do with my else:

crude crater
#

What line in specific has the syntax error?

#

Ah

foggy current
#

that else is completely out of place

crude crater
#

I think the indent is wrong

jaunty wraith
#

If i put it with no indents it says syntax error if i add any indents then it says unexpected indent

foggy current
#

Why is there an else there in the first place?

#

There’s also no reason for @commands.is_owner() to be there either since its not a command, its an event

jaunty wraith
#

Because its a no swearing code i want it so because im owner (@commands.is_owner) it will ignore me because i am the string above else:
else: (if your not the owner) it will delete the word

#

True

crude crater
#

Yeah you wrote it completely wrong then

jaunty wraith
#

Im new to this part of python sorry 😅

crude crater
#

It's okay lol

foggy current
#

We all start somewhere

crude crater
#

Ofc ofc

jaunty wraith
#

Lol

foggy current
#

I started with discord.py myself so ive been almost exactly where you are lul

jaunty wraith
#

I started from stealing my friends embed code going to where it said title and changing it thats how i learnt to make a embed

#

Self-taught

crude crater
jaunty wraith
#

How can i get it to ignore me

#

I guess if id = my id then ignore else: delete

slate swan
foggy current
dusk pumice
slate swan
dusk pumice
#

I use vsc to

slate swan
#

use a vps

dusk pumice
#

But can't host my bot

slate swan
#

.

dusk pumice
#

so I bought a hacker plan

slate swan
#

flask doesnt exist?

dusk pumice
#

It's against ToS

slate swan
#

bruh

jaunty wraith
#

Flask is against tos?

shrewd inlet
#

yo i need help

slate swan
#

no

shrewd inlet
#

how do i get the guild id from a server that my bot is in

dusk pumice
shrewd inlet
#

i am not in the server and idk why it’s there

slate swan
#

..

jaunty wraith
torn sail
foggy current
#

The check needs to be in the function

shrewd inlet
quick gust
slate swan
dusk pumice
jaunty wraith
slate swan
slate swan
#

no problem

slate swan
#

yep

quick gust
slate swan
#

i dont use f""

#

thats absolutely gay

quick gust
#

it's way better

dusk pumice
#

f-str is better

slate swan
#

go cry

quick gust
slate swan
#

you make codes look weird

dusk pumice
#

...

quick gust
slate swan
#

You could do

"{0.name}".format(ctx.author)
#

i think

#

im high

shrewd inlet
#

it didn’t print 😭

slate swan
#

lol

#

something wrong with your ide

#

oh

#

wait nvm

shrewd inlet
slate swan
#

Maybe try

@bot.event
async def on_ready():
      ...
maiden grove
#

guys is it possible to make a video streaming discord bot in python

maiden grove
#

im planning to make one but idk if its possible

maiden grove
#

oh

#

okay then thanks

slate swan
#

no prob

maiden grove
#

ig that’s a short concise answer, though slightly disappointing

quick gust
slate swan
#

I already did everything for him

slate swan
outer violet
#

i have a koala command and it sends pictures of random koalas but when i added the embed, it gave me this error can someone help?

    @commands.command(help='This command shows you a picture of a koala')
    async def koala(self, ctx):
        async with aiohttp.ClientSession() as session:
            requests = await session.get('https://some-random-api.ml/img/koala')
            dogjson = await request.json()
            request2 = await session.get('https://some-random-api.ml/facts/koala')
            factjson = await request2.json()

        embed = discord.Embed(title="Koala", color=discord.Color.purple())
        embed.set_image(url=dogjson['link'])
        await ctx.send(embed=embed)
slate swan
#

you still need help with on_ready events

slate swan
heavy folio
#

im trying to make a "Any" button which randomizes choices (role objects), if the role is in author.roles: it'll choose again, else: it'll pass (so it doesnt random.choice() again
here's the thing, im not sure what to use, a while loop or?

quick gust
quick gust
#

I answered u

slate swan
outer violet
slate swan
heavy folio
#

here's the thing, im not sure what to use, a while loop or?

slate swan
#

send the already used code

heavy folio
#

bruh?

#

i already said i dont know what to use and your asking me to send the code, genius

quick gust
#

but did u even read what I said now?

outer violet
#

yeah

slate swan
#

its just

output = random.choice([".", ".."])
if output == ".":
   ...
else:
   ...
heavy folio
#

but

slate swan
#

but?

heavy folio
#

in my scenario, it's different

#

sec

heavy folio
slate swan
#

what?

#

explain, your making no sense

heavy folio
#

e.g. py output = random.choice([".", ".."]) if output == ".": output2 = random.choice([".", ".."]) # choosing again because i got "." and that's not what i want else: pass if output2 becomes "." again, what do i do

slate swan
#

thats not my fault, its randomized

pliant gulch
#

So you want a random choice but not really a random choice??

#

At that point you might as well hardcode it to be . with that logic lol

slate swan
#

Yeah

heavy folio
#

i'll just explain what i want my brain's not working rn

#

so cant explain much

slate swan
#

Just dont make "output" . again. make it ".."

#

directly

heavy folio
#

choices to choose from: [roleobj1, roleobj2, roleobj3, roleobj4]
choice_role = random.choice(choices) - if the choice_role (a role obj) is in user's roles: do random.choice() again, keep choosing again till the role is not in user's roles

#

not sure if you understand, if not i'll try

slate swan
#

then remove that from the list

heavy folio
#

if the user has all 4 of them? or 3 of them?

pliant gulch
slate swan
#

yeah

pliant gulch
#

Way better then going over again until its empty

heavy folio
#

right that makes sense, thanks

slate swan
pliant gulch
slate swan
#

LOL, mb

blazing lynx
#

ExtensionFailed: Extension 'cogs.statcord' raised an error: TypeError: Expected class deriving from discord.Client for arg bot not Bot

#
import disnake
from disnake.ext import commands

import statcord


class StatcordPost(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.key = "statcord.com-key"
        self.api = statcord.Client(self.bot,self.key)
        self.api.start_loop()


    @commands.Cog.listener()
    async def on_command(self,ctx):
        self.api.command_run(ctx)


def setup(bot):
    bot.add_cog(StatcordPost(bot))
outer violet
#

i also have a red panda command and it uses the same website, whenever i try it, it gives me this error

    @commands.command(name='redpanda', aliases=['rpan'], help='This command shows you a pictue of a red panda')
    async def Red_panda(self, ctx):
        async with  aiohttp.ClientSession() as session:
            request = await session.get('https://some-random-api.ml/img/red_panda')
            dogjson = await request.json()
            request2 = await session.get('https://some-random-api.ml/facts/red_panda')
            factjson = await request2.json()

        embed = discord.Embed(title="Red Panda", color=discord.Color.purple())
        embed.set_image(url=dogjson['link'])
        await ctx.send(embed=embed)
slate swan
outer violet
slate swan
#

let me test

outer violet
#

alr

slate swan
slate swan
#

LOL

#

ok im sorry, ill stop

grim oar
#

that wasnt funny imo

slate swan
#

wasnt supposed to be, gtho

final iron
#

If you don't think it's funny what's the point

slate swan
#

because I can.. are you in control?

grim oar
#

so you purposefully recommended bad thing? thats so evil dude

slate swan
slate swan
grim oar
#

i mean, i can report to mods

quick gust
#

stop trolling

slate swan
#

^

slate swan
grim oar
#

<@&831776746206265384> ^

slate swan
#

trolling and giving bad advice

final iron
#

Also being moderately toxic

slate swan
#

it was a mistake, I am currently tired

grim oar
#

they will decide that

slate swan
#

ok

final iron
slate swan
#

I fixed it, and it works.

#

It was something wrong with aiohttp

final iron
#

No it doesnt

slate swan
#

and the, ahem, async

grim oar
#

digging your own grave

blissful lagoon
#

!mute 924590198313086976

slate swan
#

using aiothttp wont be hard ... ```py
import aiohttp
@command()
async def cmd(...
async with aiohttp.ClientSession() as session:
res = await session.get('url')
json_data = await res.json()

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1641107596:f> (59 minutes and 59 seconds).

quick gust
#

get some time off discord, you need it

slate swan
slate swan
#

mods have it all under control leave it to them

grim oar
#

theres a bracket and : missing too

slate swan
#

i think we all need sleep lol

#

i mentioned ... instead

grim oar
#

he just woke up

final iron
#

They'll figure it out

slate swan
#

that was just an example..

#

oh nvm

crimson dew
#

damn, what happened here?