#discord-bots

1 messages · Page 1033 of 1

keen mural
#

.

boreal ravine
#

No

#

where do you define member_data

keen mural
#

if i plug in a different thing like wallet instead of shovel it works too

boreal ravine
#

show the json file

keen mural
#

the data.pickle file?

slate swan
#

got it

#

its because where you put the data you don't define the value of the shovel

keen mural
#

return Data(0, 0, 0)

slate swan
keen mural
#

if u mean that i have that rn doesnt work

slate swan
#

oh

nimble plume
#

Hi

boreal ravine
keen mural
nimble plume
#

Picole

#

pickle

keen mural
#

r u saying i have to delete it and make a new one

boreal ravine
slate swan
nimble plume
#

Hi im havingnindent errorv

boreal ravine
#

show ur current code

keen mural
#

i didnt change anything

boreal ravine
#

where do you use save_member_data?

keen mural
#
@client.command(aliases=['item', 'items'])
async def shop(ctx, item=None):
  member_data = load_member_data(ctx.author.id)
  if item == None:
    member_data.shovel += 1
    em=discord.Embed(title="Shop",description=(f"![shovel](https://cdn.discordapp.com/emojis/973047899363635291.webp?size=128 "shovel") **Shovel** ({member_data.shovel}) - 10,000\n╰ A shovel neccessary for the dig command, very useful!") , color = discord.Color.teal())
    await ctx.reply(embed=em)
    save_member_data(ctx.author.id, member_data)
    return
  elif item.endswith('shovel'):
    await ctx.reply("shovel is a shovel that digs the ground that the shovel is bought from the shop")
    save_member_data(ctx.author.id, member_data)
    return```
nimble plume
#
if 1:
print(1)
 Else:
print(none)
#

This is giving me error

keen mural
nimble plume
#

Why

keen mural
#

unindent else

nimble plume
#

What

slate swan
unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

boreal ravine
nimble plume
#

What

slate swan
#

the else is spaced out too much

nimble plume
#

No

slate swan
#
if 1:
  print(1)
else:
  print(none)
cloud dawn
nimble plume
#

U noob

slate swan
slate swan
cloud dawn
nimble plume
#

Yes he's noob

slate swan
#

Nvm too many typos

slate swan
nimble plume
#

Define none

#

Missing data

cloud dawn
nimble plume
#

It's None

#

Not none

boreal ravine
# keen mural

can you try deleting the pickle file and inserting Data(0, 0, 0)

cloud dawn
slate swan
#

i copied your code i didn't noticed that the "none" is not None

slate swan
# nimble plume Yes he's noob

It's hard to help those unfamiliar with Python, the best you can do is help or stay back and let others help. Calling someone a noob is kind of discouraging, you can definitely be nicer by just not saying anything.

nimble plume
#

!e
print(None)

unkempt canyonBOT
#

@nimble plume :white_check_mark: Your eval job has completed with return code 0.

None
nimble plume
#

See it works dont argue

keen mural
slate swan
boreal ravine
nimble plume
slate swan
keen mural
dusky pine
#

Lmao just because you knwo more than people doesn't mean you have to rub it in their face

cloud dawn
#

@slate swan @nimble plume, You guys are both being very defensive. I suggest just ignoring each other.

dusky pine
slate swan
nimble plume
#

:(

#

@slate swan friends 🤝 🤝 🫂 🫂

torn sail
#

hi

keen mural
cloud dawn
#

Some of us do yes, best is to just ask the question, rather than asking if there is someone who knows.

nimble plume
#

I also do

#

Slash commands

boreal ravine
keen mural
#

at the return Data(0, 0, 0)?

cloud dawn
#

Very good question, I solved this by making a Client and subclassing CommandTree of discord.app_commands

nimble plume
#

Hiiiiiiii

slate swan
#

Right

torn sail
#

you can use @my_app_command.error for an individual command or @tree.error for the command tree. you also can subclass CommandTree and make an async function on_error

cloud dawn
#

I have overridden the default on_error and made it a custom one.

torn sail
#

!d discord.app_commands.CommandTree.on_error

unkempt canyonBOT
#

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

A callback that is called when any command raises an [`AppCommandError`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.AppCommandError "discord.app_commands.AppCommandError").

The default implementation prints the traceback to stderr if the command does not have any error handlers attached to it.

To get the command that failed, [`discord.Interaction.command`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction.command "discord.Interaction.command") should be used.
slate swan
#

There we go

torn sail
#

!d discord.app_commands.CommandTree.error

unkempt canyonBOT
#

error(coro)```
A decorator that registers a coroutine as a local error handler.

This must match the signature of the [`on_error()`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.CommandTree.on_error "discord.app_commands.CommandTree.on_error") callback.

The error passed will be derived from [`AppCommandError`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.AppCommandError "discord.app_commands.AppCommandError").
nimble plume
#

how can I print(1)

slate swan
#

!d discord.app_commands.Command.error

unkempt canyonBOT
#

error(coro)```
A decorator that registers a coroutine as a local error handler.

The local error handler is called whenever an exception is raised in the body of the command or during handling of the command. The error handler must take 2 parameters, the interaction and the error.

The error passed will be derived from [`AppCommandError`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.AppCommandError "discord.app_commands.AppCommandError").
cloud dawn
#

Sure, this is my code of a custom handler. Not a lot now but easily expandable. ```py
from discord import Interaction
from discord.app_commands import CommandTree, AppCommandError, Command
from discord.errors import NotFound, HTTPException, Forbidden

from log import log

class CmdTree(CommandTree):
"""A subclass of CommandTree to override on_error"""

async def on_error(self, interaction: Interaction, command: Command, error: AppCommandError) -> None:
    # Per usual, getting the original error
    error = getattr(error, 'original', error)

    log.debug("Reached error_handler")

    if isinstance(error, (NotFound, HTTPException, Forbidden)):
        log.warn(f"'{interaction.command.name}' command raised {error.status} {error.__class__}")
        raise error
    else:
        raise error
slate swan
#

How do I do a masked link

sick birch
cloud dawn
sick birch
#

oops

#

looks like its

slate swan
cloud dawn
slate swan
#

got an unexpected keyword argument 'url'

boreal ravine
slate swan
cloud dawn
keen mural
#

:/

boreal ravine
#

Really it is

cloud dawn
keen mural
#

wherever i am putting it it doesnt work

boreal ravine
#

Put it where you save the user in the file

slate swan
keen mural
#

idk if thats a good example but yeah

slate swan
# keen mural bruh

maybe its when you try to load the data from the file you the else return a dictionary

cloud dawn
cloud dawn
slate swan
#
def load_data():
    if os.path.isfile(data_filename):
        with open(data_filename, "rb") as file:
            return pickle.load(file)
    else:
        return dict()
keen mural
#

i add to that?

slate swan
#

@cloud dawn

embed.add_field(name="> **Track**", value=f'{track}' + "\n", url=f'{songurl}', inline=False)
keen mural
#

!d dict

unkempt canyonBOT
#

class dict(**kwargs)``````py

class dict(mapping, **kwargs)``````py

class dict(iterable, **kwargs)```
Return a new dictionary initialized from an optional positional argument and a possibly empty set of keyword arguments.

Dictionaries can be created by several means:

• Use a comma-separated list of `key: value` pairs within braces: `{'jack': 4098, 'sjoerd': 4127}` or `{4098: 'jack', 4127: 'sjoerd'}`

• Use a dict comprehension: `{}`, `{x: x ** 2 for x in range(10)}`

• Use the type constructor: `dict()`, `dict([('foo', 100), ('bar', 200)])`, `dict(foo=100, bar=200)`
keen mural
#

save_member_data(id, Data(0, 0, 0, 0))
in the else statement?

cloud dawn
slate swan
#

so how would I do it instead?

#

hold on let me think for a bit

cloud dawn
slate swan
cloud dawn
#

@sick birch could you show an example im on phone rn

sick birch
#

hm?

#

Ah like a URL?

keen mural
sick birch
#

Sure I could. IIRC they work in descriptions, and what else?

#
url = 'https://www.google.com'
emb = discord.Embed(
    title='Cool embed with a link'
    description=f'[Click me!]({url})',
    ...
)
await ctx.send(..., embed=emb)
keen mural
#
# CURRENCY ATTEMPT!
import pickle

data_filename = "data.pickle"

class Data():
    def __init__(self, wallet, bank, shovel):
        self.wallet = wallet
        self.bank = bank
        self.shovel = shovel


#Commands
blah blah blah

#Functions
def load_data():
    if os.path.isfile(data_filename):
        with open(data_filename, "rb") as file:
            return pickle.load(file)
    else:
        return dict()

def load_member_data(member_ID):
    data = load_data()

    if member_ID not in data:
        return Data(0, 0, 0)

    return data[member_ID]

def save_member_data(member_ID, member_data):
    data = load_data()

    data[member_ID] = member_data

    with open(data_filename, "wb") as file:
        pickle.dump(data, file)

  
for filename in os.listdir('./cogs'):
  if filename.endswith('.py'):
    client.load_extension(f'cogs.{filename[:-3]}')```
if i want to add shovel, how would i go about doing that because it isnt working
its saying Data object has no attribute shovel
how would i add shovel without erasing all data
sick birch
#

I'm not 100% sure if Discord lets you have links in field values, give this a whirl anyway:

url = 'https://www.google.com'
emb = discord.Embed(...)
emb.add_field(..., value=f'[Click me!]({url})')
await ctx.send(..., embed=emb)
sick birch
keen mural
sick birch
#

Probably not the best idea

keen mural
#

what would be the better option for keeping data for currency bot

sick birch
#

Database

keen mural
#

that would be easy to add items like shovel

slate swan
sick birch
#

I wouldn't be surprised if you're losing the shovel attribute from pickling

keen mural
#

so pickle = bad

sick birch
sick birch
keen mural
#

so whats the easy alternative

#

that would make shovel easy to add without losing all data

sick birch
#

I'd suggest using a proper database

keen mural
#

like what (im a noob)

sick birch
#

Sqlite is by far the easiest (serverless, single-file). Disadvantages are that it doesn't scale that well, and is unsecure.

#

If you decide you want to improve your data storage architecture later on, you'll want to go for something more heavy duty and robust like postgresql

slate swan
#
embed.add_field(name="**Track**\n> ", value=f'[{songurl}]({track})', inline=False)

it's just sending the url not as a hyperlink

sick birch
#

What do you mean "it's sending the url not as a hyperlink"?

keen mural
sick birch
#

Your songurl should be inside the ()

#

Text goes in []
URL goes in ()

sick birch
#

If you like the JSON-like key/value format, MongoDB is used for that

#

You may wanna look into an ORM for mongoDB as I've heard it said that NoSQL queries are a pain in the arse to work with

keen mural
#

i dont really know what any of that means

slate swan
#
embed.add_field(name="**Track**\n> ", value=f'[{track}]({songurl})', inline=False)

How can I make it send without the > showing

keen mural
#

but you would say learning sql for right now would be good?

sick birch
keen mural
#

ok

sick birch
keen mural
#

and with sql i can add stuff like shovel with deleting all data?

sick birch
#

That's not to say it does have some security of course

cloud dawn
#

Very unlikely

sick birch
#

It's just not on par with databases like MySQL or postgres

sick birch
#

embed.add_field(name="**Track**\n ", value=f'[{track}]({songurl})', inline=False)

slate swan
#

I want it show like

example

cloud dawn
slate swan
#

honestly this one of the most confusing codes ever

keen mural
#

so sql is just making tables

sick birch
#

right

keen mural
#

so ig thats rlly good for a currency bot

sick birch
#

Most RDBMS (relational database management systems) use a table mechanism

keen mural
#

and thx RB

slate swan
#

it want to use a dict then covert somehow to a object and then save it like a dict

sick birch
slate swan
#

its just confusing

#

I figured it out

keen mural
#

they wild sometimes

slate swan
#

i'm trying to wrap my head around this and my mind breaks every time i try to understand

sick birch
#

this sounds like an XY problem

#

You think what you're looking for is the solution (Y) to your real problem (X), but your attempted solution is a problem in and of itself

#

If we know what your real problem is, we can assist you better

slate swan
#

robin why do you explain what is an xy problem

#

!xy

unkempt canyonBOT
#

xy-problem

The XY problem can be summarised as asking about your attempted solution, rather than your actual problem.

Often programmers will get distracted with a potential solution they've come up with, and will try asking for help getting it to work. However, it's possible this solution either wouldn't work as they expect, or there's a much better solution instead.

For more information and examples, see http://xyproblem.info/

sick birch
#

oh

slate swan
#

🧠

sick birch
#

i forgor

#

well, TIL. will use that next time i sense an XY problem

cloud dawn
#

Unless...

sick birch
#

I refuse to believe this is not an XY problem

cloud dawn
sick birch
#

oh

#

spoke too soon

#

it is more than likely i will forgor again

#

in which case I hope okimii will be here to remind me to unforgor

cloud dawn
#

Okimii really just came in here to correct a helper

#

Which as is very satisfying can confirm.

sick birch
#

I don't mind being corrected when I say something stupid 😛

cloud dawn
#

Me neither.

#

Anyways, no more RB?

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 76, in on_raw_reaction_add
    await payload.member.add_roles(role)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 975, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
keen mural
#

send code ig

jade tartan
# keen mural send code ig
async def on_raw_reaction_add(payload):
    if payload.member.bot:
        pass
    else:
        with open('JSON/reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                        emoji = payload.emoji
                        role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=829665222380879912)
                        await payload.member.add_roles(role)
slate swan
#
embed.add_field(name="**Artist**\n ", value=f'> [{artist}]({artistfinalurl})' + "\n", inline=False)

It's sending wrong again @sick birch

sick birch
#

What's it sending?

slate swan
slate swan
slate swan
sick birch
slate swan
slate swan
#

hmm anyone know?

#
@client.event
async def on_raw_reaction_add(payload):
    ctx = await client.fetch_guild(payload.guild_id)

    if ctx.member.bot:
        pass
    else:
        with open('JSON/reactrole.json') as react_file:
            data = json.load(react_file)
            for key, value in data.items():
                        emoji = payload.emoji
                        role = discord.utils.get(ctx.roles, id=829665222380879912)
                        await ctx.member.add_roles(role)
slate swan
boreal ravine
#

Can I make 2 bots using 1 event loop?

slate swan
#

sifte you probably can help me your a genius

slate swan
slate swan
slate swan
#

nah it looks fine to me

#
artisturl = toptracks["artist"]["#text"]
artisturl = artisturl.replace(" ", "+")
artistfinalurl = f"https://www.last.fm/music/{artisturl}"
boreal ravine
slate swan
slate swan
#

oh yeah it does

#

strip it

#

or use .splitlines()[0]

#

i thought that was just his client lmao

#

I had a \n I added on accident 🤣

#

happens \🐢

jade tartan
#
async def reactrole(ctx, Member):
    button = discord.ui.Button(style=4, label="React!")
    embed=discord.Embed(title="React to this message", description="Want to see the rest of my server? Click the reaction button to give you the role")
    async def button_callback(interaction):
        await interaction.response.edit_message(view=None)
        
    button.callback = button_callback

    view = discord.ui.View()
    view.add_item(button)
    await ctx.send(embed=embed, view=view)
    return

    with open('JSON/reactrole.json') as json_file:
            data = json.load(json_file)

            new_react_role = {'role_name': role.name,
                              'role_id': role.id,
                              'emoji': emoji,
                              'message_id': msg.id}

            data['Member'] = new_react_role

    with open('reactrole.json', 'w') as f:
            json.dump(data, f, indent=4)
``` How do i make it give the role to the user? when he/she clicks the button
alpine cove
#

await interaction.response.user.add_roles()

vast gale
# slate swan

you have a nl or smth, probably. if not that then a non printing character between smth probably

vast gale
#

interaction.user.add_roles, probably

slate swan
vast gale
#

ah lol

lean mauve
#

Ok I’ve got a bit of an issue with a bot

#

I’m making something that will take a file of images on my computer and upload each one to a channel

#

Presumably this could be a LOT of images ~ 2k

#

The bot works with just a for loop iterating through each file and adding it as an attachment but it’s very slow

#

If I try to use webhooks, I get the same amount of speed

#

Any way to optimize this?

slate swan
#

You have to add tags to your bot

#

Congrats on 76+ servers bunParty

#

Hey i need a little help with my bot

#

.py''''
async def on_message(message):
if str(message.channel) == "general" and message.content != "":
await message.channel.purge(limit=1)
.py'''

#

i want it to delete a specific wors

#

word like duck

#

whnever it is said

#

!codeblock To format Python code, not .py''''

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.

slate swan
#

You can simply make a basic if check

#

!e
string = "I like ducks"

if "duck" in string:
print("Yes")

unkempt canyonBOT
#

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

Yes
slate swan
#

can someone explain the ascii coloring

#

ASCII coloring?

#

I meant ANSI

#

can I see some example code for say, red

#

Please. Read the guide

#

There is everything explained if you take the time to get to links we send to help you.

#

I've read it it's just sort of confusing in a way

#

There is even an example

#

And I don't believe you've read it within a few seconds after I've sent it

#
Gray
Gray bold
Gray underlined
Red
Red bold
Red underlined
Green
Green bold
Green underlines
-- I stopped adding the bold & underlined version --
Yellow
Blue
Pink
Cyyan
White
Firefly dark blue background
Orange background
Marble blue background
Greyish turquoise background
Gray background
Indigo background
Light gray background
White background
#
\u001b[1;32mTestomg
#

Look at these examples

\u001b[0;40m\u001b[1;32mThat's some cool formatted text right?
or
\u001b[1;40;32mThat's some cool formatted text right?
#

Then replace \u001b with the correct character if you don't use it with a bot.

slate swan
#

Nope

#

what does it look like on mobile?

#

Like plain text

#

A square, then the code and text [0;30mGray

paper sluice
vital whale
slate swan
#

Not related to discord bots. In addition to that, it's a personal choice only you can make.

slate swan
#

Not a reason ask in a topical channel unrelated to IDEs and games.

#

As I said, stop asking these questions here.

#

!rule 7

unkempt canyonBOT
#

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

slate swan
#

That doesn't matter

#

You need to follow the rules just like anyone.

#

How about being patient :)

loud junco
#

sure

slate swan
#

It's part of being a developer

loud junco
slate swan
#

And I don't see any messages sent by you related to whether or not it's good to use VSC and how to install it.
No wonder you didn't get any responses.

gaunt ice
#

hm

jade tartan
#

Please

slate swan
#

you provided a keyword "entity" which help commamd doesn't take

#

!d discord.ext.commands.HelpCommand

unkempt canyonBOT
jade tartan
slate swan
#

just do ctx.send_help("reactionroles")

jade tartan
lone hare
#

hi

#
error: failed to push some refs to 'https://git.heroku.comjsdjflkjflkgit'``` anyone ? trying to upload discord bot to heroku
jade tartan
#

I mean i want it to look like this

#

Do you know how?

#

i believe embed

slate swan
jade tartan
#

Yes

#

and it came out like this

slate swan
#

so you didn't subclass your HelpCommand class

#

thats what your issue is, and i believe menudocs( the tutorial) you are using did.

shrewd apex
slate swan
#

am talking about your help command, not your rr command.

jade tartan
#

i think thats the one but when he tried the cmd before he made his reaction class his looked embeded

shrewd apex
#

so embed urs

slate swan
#

he subclassed his help command, unlike you
the invoke/send_help doesn't work magically and creates an embed
it uses your help command class for doing that

shrewd apex
placid skiff
shrewd apex
#

yes

placid skiff
#

and other help commands that you create can have embeds, webhooks, buttons and wathever you want just like the help commands subclassed

slate swan
tired hinge
#

i'm a little confused looking at the docs.. how can i use bot.wait_for() to detect a certain reaction on a certain message?

boreal ravine
#
wait_for("reaction_add", check=...)```
slate swan
#

bot.wait_for("event name") waits for an event to dispatch, so for example if you want to detect a reaction you would use bot.wait_for("reaction_add")
to make sure its on a specific message you would have to use a check function ```py
def check(reaction, user):
if <condition to check message id>: return True

reaction, user = await bot.wait_for("reaction_add", check=check)

tired hinge
#

i know that much, the check is where i'm getting confused... how do i confirm that it's on a certain message and the reaction is a certain emote?

tired hinge
boreal ravine
#

yes

shrewd apex
#

yes

slate swan
#

ofcourse

tired hinge
#

okay, i'll be back if there's an error

#

ty

placid skiff
tired hinge
#

but it will keep listening for reactions until the timeout is over, right?

shrewd apex
#

yes

slate swan
#

no, it will only listen to the first reaction which matches the predicate

placid skiff
#

the check will take as arguments the same arguments given for that event
like a check for the message event wait_for will take the message as argument

shrewd apex
jade tartan
#

any ways i think i got it idk

slate swan
#

I was adding jishaku in my bot but its shows this error

tired hinge
#

;-;

loud junco
#

wow this is unexpected

slate swan
supple thorn
loud junco
#

idk how to verify it

#

alright i saw that lemme verify it

shrewd apex
loud junco
#

my bod is 9 december 2006

slate swan
#

You're 13 years old right?

loud junco
#

BRUH

slate swan
#

Yeah - verification is 16

#

Oh 2006

loud junco
#

im 16

slate swan
#

Not yet

loud junco
#

gg i need to wait for december

nimble plume
#

Very big

loud junco
quaint roost
#

is there an easy way to port a discord.py bot to pycord?

loud junco
#

but my skill compared to her 💀

nimble plume
slate swan
loud junco
quaint roost
loud junco
#

yesterday

slate swan
#

No?

loud junco
#

this one

slate swan
#

They "revived" it

vale wing
nimble plume
vale wing
#

Greatly outdated

#

Like 1-2 months

quaint roost
#

epic canary

nimble plume
#

69

loud junco
loud junco
nimble plume
#

96

#

🔀

slate swan
loud junco
#

true

slate swan
#

I personally don't really like that server

loud junco
#

just keep shouting at u

slate swan
#

Just there for updates

loud junco
#

and nvr tell u the solution

nimble plume
#

Aaaaaaaaaaaaaaaa

loud junco
#

...

nimble plume
#

I'm shouting

loud junco
#

bruh

nimble plume
#

How do get warn

loud junco
#

🤦

vale wing
#

There's one guy who doesn't know anything but pretends otherwise

nimble plume
#

Do we get nitro on 30 warns?

vale wing
#

😩

loud junco
slate swan
#

Lots of people there have an ego as big as the Mount Everest. There are some really helpful people, but that's not the majority.

tired hinge
#
def check(reaction, user):
   if reaction.message.id == em.id: return True

reaction, user = await bot.wait_for("reaction_add", check=check)

my two braincells got me this far, now, how do i call a function when the correct reaction is added?

nimble plume
#

.

nimble plume
slate swan
#

The example on the documentation is what you need, take a look at it.

#

Second example

supple thorn
#

You can just return reaction.message.id == em.id

nimble plume
#

It will auto return False

#

ez

supple thorn
unkempt canyonBOT
#

@supple thorn :white_check_mark: Your eval job has completed with return code 0.

True
nimble plume
#

If not *

#

No need for if

supple thorn
nimble plume
#

!e
def foo(bar):
return bar == 1

print(foo(2))

unkempt canyonBOT
#

@nimble plume :white_check_mark: Your eval job has completed with return code 0.

False
nimble plume
#

See

supple thorn
#

Yeah you just copied what i said

nimble plume
#

I'm showing you bro

supple thorn
#

What

nimble plume
slate swan
supple thorn
#

Why would you need to show me

nimble plume
#

I want to show you

supple thorn
slate swan
jade tartan
#
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\reactions.py", line 4, in <module>
    import emojis
ModuleNotFoundError: No module named 'emojis'```
slate swan
#

What are you trying to import?

jade tartan
#

Here is the code

slate swan
#

!pypi emojis

unkempt canyonBOT
slate swan
#

If you're trying to use that, you've got to install it

jade tartan
slate swan
#

Apparently not

#

At least not correctly

jade tartan
#

emoji==1.7.0
ffmpeg-python==0.2.0
frozenlist==1.3.0
future==0.18.2
handler==1.3.0
idna==3.3
imageio-ffmpeg==0.4.7
import-expression==1.1.4
jishaku==2.5.0
multidict==6.0.2
numpy==1.22.3
six==1.16.0
typing_extensions==4.2.0
yarl==1.7.2

slate swan
#

Well, the library is called "emojis"

#

And the latest version is 0.6.0

#

Otherwise you'd need to import emoji

loud junco
slate swan
#

And not emojis

loud junco
slate swan
#

You can't use .item on an Item object.

loud junco
#

?

#

i only use item. not .item

slate swan
#

Apparently not

loud junco
#
class Item():  
  def __init__(self, ctx):  
    self.userid = str(ctx.author.id)

    #item
    self.pogchop = db[self.userid + 'pogchop']
    self.cooked_pogchop =  db[self.userid + 'cooked_pogchop']
    self.beef =  db[self.userid + 'beef']
    self.steak =  db[self.userid + 'steak']
slate swan
#

You're trying to get the attribute item

#

You'd need to give more of your code

loud junco
#

oo i see it

#

item.item.coal :/

slate swan
#

Yep there

quaint epoch
#

hmm, do i smell dank memer clones

loud junco
#

?

tiny ibex
#

hey what are the headers for a webhook?

loud junco
#

show picture

tiny ibex
tiny ibex
slate swan
exotic maple
#

How would i assign a id to a an embed sent by my bot?

#

And store the id

fluid zodiac
#

hey guys,
im trying to figure how to send the next command only visible for the one who typed the command in the same channel

@Mybot.command()
@commands.has_any_role(x)
async def clear(ctx, number=0):
  await ctx.send(f"Are you sure you want to clear {number} messages?", view=View)

its making a two buttons but the buttons are visibly to everyone

exotic maple
#

Use the hidden=true

slate swan
#

ephemeral=True, after your view=...

exotic maple
#

might work

#

of ephermeral

#

or

fluid zodiac
#

where should i put the hidden=true ?

slate swan
exotic maple
#

after the view

fluid zodiac
#

ok

exotic maple
#

, hidden=true

fluid zodiac
#

i'll check that

slate swan
#

And not hidden

exotic maple
#

oh

slate swan
#

But ephemeral

exotic maple
#

hidden works for me

loud junco
#

i doesnt even hear ephemeral before
new vocabulary but what does that mean

slate swan
#

Most likely because of a bad practice/outdated library

loud junco
#

the word itself

exotic maple
pliant gulch
#

Ephemeral sort of means temporary

minor totem
fluid zodiac
#

i got python nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Messageable.send() got an unexpected keyword argument 'ephemeral'

exotic maple
loud junco
loud junco
exotic maple
#

why

#

expensive

minor totem
loud junco
#

if u are using replit then its ok

jade tartan
exotic maple
#

i use pycharm

jade tartan
#

Someone

exotic maple
loud junco
fluid zodiac
slate swan
loud junco
#

ask other krypton
he can help u
idk about database

exotic maple
#

@slate swan do u know any free database's?

minor totem
slate swan
#

If you have a server, most of the databases are free

slate swan
loud junco
quaint epoch
slate swan
#

!d discord.ext.commands.Context.bot

unkempt canyonBOT
fluid zodiac
# minor totem DM them

im not trying to make it like in dm, i want to make it when person type the command it will appear on the same channel but the person that typed the command will only will see this

exotic maple
slate swan
fluid zodiac
#

cuz if i type my command everyone can see my buttons and also can click on them

minor totem
slate swan
#

Such as slash commands for example

exotic maple
#

i mean ive never had a problem with json files but yeah

quaint epoch
minor totem
fluid zodiac
slate swan
pliant gulch
#

Your view should be implementing a interaction_check method to stop others from pressing your button

exotic maple
#

I want them short

minor totem
# fluid zodiac how to do that?

Inside of the view you need a check that verifies the author. You can pass ctx into the view (it you modify __init__() and store it on the view, which is later used for the check.

slate swan
quaint epoch
#
class view(disnake.View):

  @disnake.ui.button(style=disnake.Style.green, label="hello")
  async def callback(self, button: disnake.ui.Button, interaction: disnake.Interaction):
    if interaction.author == ctx.author:
      pass
    else:
      return```
minor totem
slate swan
#

I'd rather check != and then return

minor totem
#

Ah hold on 😅

slate swan
#

base64 will make it longer

minor totem
slate swan
#

I want them short

exotic maple
#

what are the negatives with using json files

dense swallow
#

as db?

slate swan
#

it's OTczMTU2MTYwODk3MTgzNzc0

exotic maple
#

yeah

slate swan
#

So not short as they asked

I want them short

dense swallow
#

it's just not good, and is not meant as a db

slate swan
#

Encoding in base64 is not really useful in any way

dense swallow
#

use SQLite or any others as alternatives

quaint epoch
quaint epoch
jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\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\thoma\OneDrive\Desktop\discord server bot\cogs\reactions.py", line 84, in rr_channel
    reaction_roles = await self.client.reaction_roles.get_all()
AttributeError: 'Bot' object has no attribute 'reaction_roles'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 27, in on_command_error
    raise error
  File "C:\Users\thoma\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\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1348, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "C:\Users\thoma\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\thoma\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: 'Bot' object has no attribute 'reaction_roles'
``` its showing that neither bot or client work for that
pliant gulch
#

Your bot could stop sending heartbeats as a result form blocking

#

Which will cause a disconnect

pliant gulch
#

You can just to_thread opening the file tbh

exotic maple
#

Ok ill have to pay for a actual db then

quaint epoch
dense swallow
quaint epoch
#

it returns an error

slate swan
dense swallow
exotic maple
#

so SQlite is free?

quaint epoch
jade tartan
dense swallow
loud junco
jade tartan
#

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

exotic maple
#

cool ill switch to that today

slate swan
#

!pip aiosqlite use this

unkempt canyonBOT
supple thorn
dense swallow
minor totem
jade tartan
dense swallow
#

ur using client, so I mentioned that

quaint epoch
#

!pypi aiofiles

unkempt canyonBOT
quaint epoch
#

there

jade tartan
#

Should i change everything to bot attribute?

dense swallow
#

u don't need to

exotic maple
#

eg setup a channel

dense swallow
#

client is usually referred to discord.Client

#

but I think most tutorials on yt tells u to use client

jade tartan
#

Well it doesnt seem to work

dense swallow
#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord.
This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
dense swallow
supple thorn
jade tartan
exotic maple
pliant gulch
#

You'd want to make sure to sanitise any data inbound from the user before adding it to the database if you're taking in user input

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\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\thoma\OneDrive\Desktop\discord server bot\cogs\reactions.py", line 84, in rr_channel
    reaction_roles = await self.client.reaction_roles.get_all()
AttributeError: 'Bot' object has no attribute 'reaction_roles'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 27, in on_command_error
    raise error
  File "C:\Users\thoma\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\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1348, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "C:\Users\thoma\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\thoma\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: 'Bot' object has no attribute 'reaction_roles'
#

@dense swallow

pliant gulch
dense swallow
#

not code..

jade tartan
#

you want the code i

dense swallow
#

yes

jade tartan
#

ok

dense swallow
#

also put it in this format, it's easy to read this way

#

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

loud junco
#

sry wrong server

jade tartan
slate swan
jade tartan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

dense swallow
#

it's that long?

jade tartan
#

Yeah

dense swallow
#

k then

jade tartan
dense swallow
#

is ur bot obj in a class or just one line

pliant gulch
dense swallow
#

and line 5, I don't think it's built in, u have make it or it won't work

jade tartan
jade tartan
#

thats what menudocs used

dense swallow
slate swan
jade tartan
dense swallow
#

ctx.bot.config is custom made

#

and ur also calling bot.reaction_roles which is also not in the library

minor totem
unkempt canyonBOT
#

@minor totem :white_check_mark: Your eval job has completed with return code 0.

973156160897183774
dense swallow
#

43

minor totem
#

👌

slate swan
#

Yeah what I thought, just not what can help help either way

dense swallow
jade tartan
#

Dude this is really fkd up nothing is that easy

dense swallow
dense swallow
jade tartan
#

?

#

Idk dude

dense swallow
#

if u use:
client = commands.Bot()
it's self.client

if u use:
bot = commands.Bot()
it's self.bot

slate swan
#

Not really no

#

You can still set to client in the cog 🤷

dense swallow
#

it's been a while since I have used normal ones.. I usually sub class my bot

slate swan
#

You can define self.client = bot in the init function of your cog

#

No idea who would do that, but yeah

jade tartan
dense swallow
#

ok then bot would work.
but as u said, who would do it lol

slate swan
#

Yeah KEKW

#

depends on what you named inside the init dunder

oblique adder
#

how do I put animated emoji in the dropdown emoji parameter ?

jade tartan
slate swan
# jade tartan

Keep it to self.client = client , we were talking, not saying what you need to copy

jade tartan
#

So? i mean i do get the same error either way

heavy folio
#

look clients dont even have cogs, only bots do. Stick to a good naming convention, commands.commands.Bot -> bot, discord.discord.Client -> client

slate swan
#

The person most likely once did client.reaction_roles = ... or self.client.reaction_roles = ...

jade tartan
oblique adder
slate swan
#

I believe so

#

Just use the appropriate format

sacred gull
#

Is it possible to run multiple db executes on 1 on_guild_join event?

loud junco
sacred gull
#

fair enough

loud junco
#
  elif isinstance(error, commands.CommandNotFound):
    await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
  elif isinstance(error, commands.MissingRequiredArgument):
    if commands.name == 'open':
      await ctx.send(f'**{ctx.author.name}**, what are you trying to open?')
    else:
      raise error
#

commands doesnt have name as attribute so i think commands is the wrong one

slate swan
#

I believe in that case it's ctx.command.name

loud junco
#

ok thanks

slate swan
#

!d discord.ext.commands.Context.command

unkempt canyonBOT
slate swan
#

Yeah

boreal ravine
loud junco
#
  elif isinstance(error, commands.CommandNotFound):
    await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
  elif isinstance(error, commands.MissingRequiredArgument):
    if ctx.command.name == 'open':
      await ctx.send(f'**{ctx.author.name}**, what are you trying to open?')
    elif ctx.command.name == 'craft':
      await ctx.send(f'**{ctx.author.name}**, try rpm craft 1` instead')
    else:
      raise error
  else:
    raise error
    ctx.send('tell HydroRICO1209#5556 there is a bug')
```its like this
boreal ravine
loud junco
nimble plume
#

Hi

#

I'm newbie007

quaint epoch
paper sluice
#

👋

stiff gorge
#

how to import a file from a folder

loud junco
#

how can i see which server my bot joined and the server owner?

#

cuz i think somebody is spamming new server and putting my bot inside it

slate swan
#

hey! 👋

loud junco
#

HIHI sparky

slate swan
#

Hii

slate swan
loud junco
#

ok thanks
and i cant get the server owner?

gaunt ice
#

it's server_owner or smth

#

but there is a way to get the owner

#

!d discord.Guild.owner

unkempt canyonBOT
slate swan
gaunt ice
#

yes

slate swan
#

why this is not working anyone?

#

Broooo

#

Wtd

#
from jishaku.cog import Jishaku

def setup(bot: commands.Bot):
    bot.add_cog(Jishaku(bot=bot))
#

correct?

granite parcel
#

how to give space

#

without\n

loud junco
slate swan
#

Spacebar

granite parcel
#

in embed

loud junco
#

!eval

print('''
something
like
this
''')
unkempt canyonBOT
#

@loud junco :white_check_mark: Your eval job has completed with return code 0.

001 | 
002 | something
003 | like
004 | this
granite parcel
#

owo

slate swan
#

Or \n

loud junco
loud junco
granite parcel
loud junco
slate swan
unkempt canyonBOT
#

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

001 | something 
002 |  like 
003 |  that
rapid knoll
#

whats the code to add reactions?

loud junco
slate swan
#

msg.add_reaction()

#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Adds a reaction to the message.

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

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

Adds a reaction to the message.

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

Late

rapid knoll
#

thanks

loud junco
slate swan
#

sparky got sum speed

#

I'm on mobile...

#
 python3 main.py
Traceback (most recent call last):
  File "main.py", line 40, in <module>
    from jishaku.cog import Jishaku
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jishaku/__init__.py", line 15, in <module>
    from jishaku.cog import *  # noqa: F401
#

me too, just purged my laptop's disk, feeling proud.

#

anyone?

slate swan
#

I usually type on my tab I'm from mobile rn so I can't type that fast

jade tartan
#

Can someone test this cog and help me fix the code

#

Its giving me too much

slate swan
#

Yes?

jade tartan
#

errors

jade tartan
slate swan
#

Why not here?

jade tartan
#

Fine

#

Here

slate swan
jade tartan
#

Keep in mind that my bot is client not bot

slate swan
#

What's error?? @jade tartan

jade tartan
#

as well as bot

loud junco
slate swan
#

Back

loud junco
#

ursina's documentation
looks like its made by a 3yo

jade tartan
# slate swan What's error?? <@506940530333057025>
Traceback (most recent call last):
  File "C:\Users\thoma\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\thoma\OneDrive\Desktop\discord server bot\cogs\reactions.py", line 84, in rr_channel
    reaction_roles = await self.client.reaction_roles.get_all()
AttributeError: 'Bot' object has no attribute 'reaction_roles'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 27, in on_command_error
    raise error
  File "C:\Users\thoma\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\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1348, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "C:\Users\thoma\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\thoma\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: 'Bot' object has no attribute 'reaction_roles'       
slate swan
jade tartan
slate swan
#

The person most likely once did client.reaction_roles = ... or self.client.reaction_roles = ...

loud junco
quaint epoch
loud junco
#

i want this

quaint epoch
#

lemme send deez nuts code

loud junco
loud junco
slate swan
loud junco
#

thanks

quaint epoch
#

!d disnake.ActivityType

unkempt canyonBOT
#

class disnake.ActivityType```
Specifies the type of [`Activity`](https://docs.disnake.dev/en/latest/api.html#disnake.Activity "disnake.Activity"). This is used to check how to interpret the activity itself.
slate swan
#

Sry @jade tartan I can't figure out

#

You skipped something

loud junco
#

shesssh
i have it now

slate swan
#

You've never defined the bot variable, unlike in the tutorial

loud junco
#

looks pro but still noob

quaint epoch
#

for example ~ py game = discord.Game("your mom") bot = commands.Bot(activity=game) # will show "Playing your mom" as a status message

loud junco
#

BRUH u really like trolling 🤣

quaint epoch
slate swan
#

Not what they want at all, but yeah

loud junco
#

imagine saying u are below 13

quaint epoch
loud junco
#

ik

quaint epoch
#

i can send both sides of my passport if you need further id

loud junco
#

hehe go ahead

#

imma use ur id to signup a credit card and spam the card with nitro

quaint epoch
#

😓

#

cya gotta do smth

slate swan
#

ID doesn't give the address, so you can't really signup a credit card with just the ID

loud junco
jade tartan
#

What are you talking about?

slate swan
#

They once defined client.reaction_roles

#

Which you have never done

#

So yes, you have skipped something

jade tartan
#

Like that?

slate swan
#

No.

#

Stop guessing, you're doing random things as you don't know Python properly.

#

I would learn Python more and actually follow the tutorial correctly.

#

You definitely skipped something.

loud junco
jade tartan
#

well await self.client.reaction_roles looks the same as await self.bot.reaction_roles

#

looks the same except using diff attr

loud junco
#

im doing step by step with the tutorial but i end up forgetting how to write it without guidance
but i know what it does if i look at it

alpine cove
jade tartan
#

not i use my bot as a client

alpine cove
#

what are you trying to do anyways?

jade tartan
#

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

slate swan
#

They haven't defined the bot variable, unlike the tutorial

#

There's nothing we can do for you besides tell you to look at the tutorial properly from the beginning. As yourself most likely don't know what a bot variable is, or what the self.client.reaction_roles is supposed to return, therefore you can't explain that and we can't provide proper help in the end.

loud junco
#

LOL

alpine cove
jade tartan
#

Reaction roles

alpine cove
#

Like on emoji press

jade tartan
#

To when a user can get a role to get verified and see the rest of the channels

#

Yes

jade tartan
#

since you dont wanna help

slate swan
#

They will tell the fame

alpine cove
jade tartan
slate swan
#

I'd love to help like I do, but due to your lack of knowledge and understanding I can't help you.

slate swan
#

You don't know what the client.reaction_roles variable is supposed to return, we can't help you further.

jade tartan
#

but thanks

slate swan
#

The only thing I can tell you is to watch the tutorial more closely.

alpine cove
jade tartan
alpine cove
jade tartan
loud junco
#

how do i get this image

#

urcraft/dirt.png?

#

but its not working

boreal ravine
loud junco
#

ok

dull terrace
#

get the image? you'll need the full path if your bot isn't in the pictures directory

alpine cove
alpine cove
#

yea

#

as said im like couple of hours in

#

but I added examples to the github

sage otter
#

isn’t docs like a come as you go kinda thing tho

alpine cove
#

yea lmao

#

im adding that to the to do

#

gotcha

loud junco
alpine cove
#

cya guys later heading off

slate swan
rotund creek
#

what do you guys use to host?

#

I use this thing called salafihosting.com, its pretty cheap, 2 dollars for 1 gb, 5 dollars for 2gb, 8 dollars for 4 gb, and 10 dollars for 8 gb

#

I think its pretty cheap

#

how much do you guys pay?

slate swan
rotund creek
#

wait what

#

do you use heroku

#

😹

flint isle
#

Code

@bot.command(name="lnk")
async def lnk(ctx, link):
    print(Fore.YELLOW + ctx.message.content + Fore.WHITE)
    wget.download(link, "temp/")

Error

Ignoring exception in command lnk:
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 169, in wrapped
    ret = await coro(*args, **kwargs)
  File "<string>", line 108, in lnk
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/wget.py", line 506, in download
    (fd, tmpfile) = tempfile.mkstemp(".tmp", prefix=prefix, dir=".")
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/tempfile.py", line 332, in mkstemp
    return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/tempfile.py", line 251, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: './temp/jtnpfhd7.tmp'

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

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/bot_base.py", line 570, in invoke
    await ctx.command.invoke(ctx)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 920, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 178, in wrapped
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: './temp/jtnpfhd7.tmp'
slate swan
#

12 months of AWS is a good option though

rotund creek
#

u could use replit

slate swan
rotund creek
#

btter than nothing

#

if a bot reaches 75 servers within 2 weeks

slate swan
#

the servers your bot is in has more bots than actual members or doesnt have enough members to get marked as an actual server

slate swan
flint isle
rotund creek
flint isle
slate swan
rotund creek
#

it prolly is

slate swan
#

well, if you know the reason, why'd you ask us?

rotund creek
#

i got my answer from discord dev server

#

idk if its true

#

the admin said if it reaches 75 servers in a short period of time

#

idk

flint isle
ebon island
#

Hey can you apply a cooldown to an events listener successfully?\

#

For example debouncing flood protection for joining/leaving voice channel as an example

#

or how would you go about doing that?

terse coyote
#

what to do if, when using the command, data in json-file is overwritten, and not written to a new line. I want the data to be written and not updated

slate swan
# flint isle Can you give an example that should work for me?
import aiohttp
import aiofiles
#assuming this is inside a command
# I recommend creating a single ClientSession and storing it in a botvar

async with aiohttp.ClientSession() as session:
     image = await session.get(link)
     async with aiofiles.open(...) as f:
      await f.write(image.content)
jade tartan
#

I think am doing it wrong

#

i mean i passed every parameter

slate swan
flint isle
slate swan
placid skiff
terse coyote
slate swan
terse coyote
# slate swan sure, that is what i was asking
@client.command()
async def bans(ctx, member: discord.Member, *, reason = 'причина не вказана'):
    author = ctx.message.author
    command = 'BAN'
    toprole = author.top_role
    data = {
        "Role": f'{toprole}',
        "ID": f'{author.id}',
        "Name": f'{author}',
        "Command": command,
        "Reason": f'{reason}',
        "Member": f'{member}'
        }
    with open('jsons\\bans.json', 'w', encoding = 'utf-8') as write_file:
        json.dump(data, write_file, indent = 4, ensure_ascii=False)```
boreal ravine
#

using an API VS using asyncpraw pithink

placid skiff
slate swan
sage otter
#

Reddits api is so easy to use. Idek why people use praw

slate swan
#
with open(...) as f:
  data = json.load(f)

data[str(user_id)] = {}
data[str(user_id)['key1'] = ...
...
placid skiff
#

json is not a storage method

#

a guild can have only one owner

sage otter
#

You can do that with list comp

#

Wait.

#

I think I mis read the question.

#

I thought he meant every server the bot was in

#

And see all of the owners of those.

placid skiff
#

well dunno that, i'm readin' the server so i assume it is for a specific server

sage otter
#

Yea just use list comp or something and do your own display.

#

[g.owner for g in bot.guilds]

jade tartan
#

I mean I got this off of the internet obviously we can’t obviously waste our time writing all this

placid skiff
jade tartan
#

Can you help me with it?

sage otter
#

I just gave you it

placid skiff
#

As i said the code is a mess, you are tryin' to use the command reaction add but reaction doesn't have any subcommand named add or everything else, instead you have a command called reaction_add which is a command on his own

sage otter
#

It’s up to you to figure out how you wanna display each and every in that list

stable leaf
#

does someone know how to put a icon of a guild in embed.set_thumbnail() ?

placid skiff
stable leaf
#

thx

slate swan
placid skiff
#

NAIN!

#

lol

stable leaf
#

it doesnt work

#

and no error

placid skiff
#

if you copied it is because i miss typed thumbnail

stable leaf
#

oh

placid skiff
slate swan
stable leaf
#

still

#

doesnt work

placid skiff
#

can you show?

stable leaf
#

k

placid skiff
#

bruh

#

you have two guild object in that command, one named server and one is the attribute guild of ctx

#

and you just typed guild

stable leaf
#

i also tried server.___

placid skiff
#

bruh

vague arrow
#

How do i add a role to a member using their discord ID? I can get a user object but user objects dont have an "add_roles" function?

placid skiff
#

of course it has

#

Well not user object, but Member does

#

!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.
vague arrow
#

How do i get the a member object from a user ID?

placid skiff
stable leaf
#

ok

#

doesn't work

slate swan
#

can bots bypass bans or something? 😔

placid skiff