#discord-bots

1 messages Β· Page 519 of 1

maiden fable
#

It can't happen, as I showed u in this picture lol. It raises an error

#

You are mistaken lul

visual island
dim cedar
#

thn why it works for me

maiden fable
visual island
visual island
dim cedar
#
@bot.command()  
async def clear(ctx, amount= 1):
  if ctx.author.id == 760010546728402975 or ctx.message.author.guild_permissions.administrator: 
    await ctx.channel.purge(limit=amount+1)```
#

this always works for me

maiden fable
visual island
#

u

slate swan
dapper cobalt
maiden fable
maiden fable
visual island
dim cedar
slate swan
dapper cobalt
visual island
maiden fable
visual island
maiden fable
dim cedar
dapper cobalt
odd pendant
#

πŸ˜‚ whos in trouble

ionic wadi
#
class WIP(commands.Cog, name='WIP (SOON)'):
    def __init__(self, bot):
        self.bot = bot
    
    @commands.command()
    async def getrole(self, ctx):
        message = await ctx.send("De bot is de reactions aan het laden, even geduld aub. Zodra de embed gestuurd wordt kan je je roles kiezen!")
        await message.add_reaction("🚧")
        await message.add_reaction("⭐")
        await message.add_reaction("πŸ“œ")
        await message.add_reaction('🎊')
        await message.add_reaction('πŸ“’')
        await message.add_reaction('πŸ€–')
        embed = discord.Embed(title='Rol Keuze Menu', description='Klik hieronder om een rol te kriigen, als je eentje weg wilt moet je opnieuw klikken!')
        embed.add_field(name=':construction:',value='Development')
        embed.add_field(name=':star:',value='Free Release Ping')
        embed.add_field(name=':scroll:',value='Payed Release Ping')
        embed.add_field(name=':confetti_ball:',value='Giveaway Ping')
        embed.add_field(name=':new:',value='Update Ping')
        embed.add_field(name=':loudspeaker',value='Mededelingen Ping')
        embed.add_field(name=':robot:',value='Bot Development Ping')
        await message.edit(embed=embed)

        def check(reaction, user):
            return user == ctx.message.author and str(reaction.emoji) in ['πŸ€–', 'πŸ“’']

        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=300.0, check=check)
    
            if reaction.emoji == 'πŸ€–':
                if ctx.author.has_role("Bot Development Ping"):
                    await ctx.send("U had de bot updates ping al, U wordt ervan verwijderd.")
                    await message.delete()
                else:
                    await ctx.send("U wordt geranked met de bot updates rank!")
                    await message.delete()```

I dont get an error or output
slate swan
#

the kids in my basement

dim cedar
odd pendant
#

only help if you can provide value then

#

giving bad code isn't much help

ionic wadi
odd pendant
#

you didnt show the setup func so just incase you don't have one, you need it

ionic wadi
#

Everything else In the cog works

odd pendant
#

ah right okay

slate swan
#

riad , if @unkempt canyon bot worked that way the server would already have been nuked

ionic wadi
#

but without the if ctx.author.has_role() it does work

dim cedar
#

!e
ctx.channel.purge(limit=4)

dapper cobalt
#

No such thing.

odd pendant
dapper cobalt
#

Though, you can do if role in ctx.author.roles.

ionic wadi
#

its in a wip cog xd

odd pendant
#

well you have an open try block with no except

slate swan
#

role being a discord.Role obj

ionic wadi
dapper cobalt
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 |   File "<string>", line 2, in calculate
004 | TypeError: unsupported operand type(s) for /: 'str' and 'str'
dapper cobalt
odd pendant
#

probably shouldn't do that though lol

dapper cobalt
#

Or, get the role:

role = ctx.guild.get_role(894910761669906432)
if role in ctx.author.roles
dapper cobalt
#

@dim cedar Do you have any idea what could happen if what you're trying to do is actually possible?

ionic wadi
#

Is there a thing like ctx.author.roles.remove also or?

dapper cobalt
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

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

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

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 removed [`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.
ionic wadi
#

remove_roles is not defined

dapper cobalt
#

You're trying to create a command in @unkempt canyon.

ionic wadi
#

What do i have to use

#

to define It

odd pendant
ionic wadi
#

ah ok

odd pendant
#

it's a method of discord.Member

dapper cobalt
dim cedar
#

Copied too many lines

vocal cargo
#
@client.command()
async def unmute(ctx, user):
        await user.edit(mute=False)``` trying to make a server mute/unserver mute command get error message 'str' object has no attribute 'edit'
waxen granite
#
    def bid(self, userid, bid):
        self.bids[str(userid)] = bid
        if datetime.datetime.now() > (self.endtime - datetime.timedelta(seconds=3600)):
            self.endtime += datetime.timedelta(seconds=3600)```
i have this code, when anyone does `?bid` it adds 3600seconds to the end time. what should i do so that it maintains the `?bid` current time and the endtime as 3600?
tropic briar
#

Hmm

boreal ravine
#

typehint user to discord.Member

vocal cargo
#

huuuuh

tropic briar
#

ctx, user, member

#

Am I doing right?

vocal cargo
tropic briar
boreal ravine
tropic briar
#

So basically you need to add member there

vocal cargo
boreal ravine
tropic briar
#

Ohh

steep estuary
#

how to check for multiple messages in bot.wait_for ?

boreal ravine
vocal cargo
#

what is typehint

hasty iron
boreal ravine
#

hmm

hasty iron
#

!d asyncio.wait

unkempt canyonBOT
#

coroutine asyncio.wait(aws, *, timeout=None, return_when=ALL_COMPLETED)```
Run [awaitable objects](https://docs.python.org/3.10/library/asyncio-task.html#asyncio-awaitables) in the *aws* iterable concurrently and block until the condition specified by *return\_when*.

The *aws* iterable must not be empty.

Returns two sets of Tasks/Futures: `(done, pending)`.

Usage:

```py
done, pending = await asyncio.wait(aws)
```  *timeout* (a float or int), if specified, can be used to control the maximum number of seconds to wait before returning...
vocal cargo
#

!type hint user to discord.Member

steep estuary
hasty iron
#

i know

vocal cargo
#

!hint user to discord.Member

hasty iron
vocal cargo
#

im a little slow

#

!hint user to discord.Member

steep estuary
boreal ravine
unkempt canyonBOT
#

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

5
hasty iron
#

yes i know

boreal ravine
#

like that i cant explain

steep estuary
# hasty iron yes i know
pages = ["1","2","3","4","5","6","7","8"]
                            def check(message):
                                return message.author.id == user.id and message.channel == reaction.message.channel  and message.content == any(pages)
hasty iron
#
done, pending = await asyncio.wait([bot.wait_for('message', check=check), bot.wait_for('message')], return_when=asyncio.ALL_COMPLETED)
vocal cargo
#

just lmk how i can correct the code

boreal ravine
boreal ravine
vocal cargo
#

kk

dim cedar
steep estuary
#
pages = ["1","2","3","4","5","6","7","8"]
def check(message):
   return message.author.id == user.id and message.channel == reaction.message.channel  and message.content == any(pages)
#

this?

hasty iron
#

what

steep estuary
#

how i can check for multiple words?

hasty iron
#

im confused on what you want now

boreal ravine
steep estuary
#

i mean i want all the numbers in pages list

vocal cargo
steep estuary
#

:/

hasty iron
hasty iron
#

man

#

that code tells me nothing

vocal cargo
#

im like very new

boreal ravine
vocal cargo
#

and i need to make an unmute

steep estuary
hasty iron
boreal ravine
#

typehint user to discord.Member obj

hasty iron
#

ok then just do message.content in pages

steep estuary
#

ok

vocal cargo
#

anywhere

steep estuary
#

lol it was silly

boreal ravine
vocal cargo
#

i understand that, But where in my file do i place that snippet of code

boreal ravine
#
user: discord.Member
#

!d discord.Member

unkempt canyonBOT
#

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

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

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

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

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
boreal ravine
#

^

vocal cargo
#

@boreal ravine im so lost

odd pendant
#

a typehint is where you specify the type of something, so in your case you'd need async def unmute(ctx, user: discord.Member):

vocal cargo
#

oooh

hasty iron
#

it seems like you're a beginner

vocal cargo
#

very new to it

hasty iron
#

then you should learn more python

vocal cargo
#

only know very basics

#

thats the objective

hasty iron
odd pendant
#

although it's a good idea to give variables meaningful names, a user and member are different things and in this case it'd be safe to assume you will only be using members, so name the param member not user

hasty iron
#

!resources

unkempt canyonBOT
#
Resources

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

vocal cargo
#

worked thank you

ionic wadi
#

How do I remove all reactions from the bots own message , if thats possible

#

In one code, if possible

odd pendant
#

!d discord.Message.clear_reactions

unkempt canyonBOT
#

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

Removes all the reactions from the message.

You need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to use this.
waxen granite
#
[**{auction.itemname}**]({msgurl.jump_url})```
this gives me this, why? `[qwe]([#893075969261305897 message](/guild/722342386164039793/channel/893075969261305897/))`
boreal ravine
waxen granite
#

you can@boreal ravine

slate swan
#

Yes you can

boreal ravine
#

i mean in the brackets

slate swan
#

You can

rare shoal
#

im new to progamming
jut a question....
how do i code a ludo bot?

boreal ravine
slate swan
boreal ravine
#

^

waxen granite
slate swan
#

If you want to make it as a normal message, webhook is your only solution

boreal ravine
rare shoal
slate swan
#

;-;

#

If you're new you shouldn't start with this type of idea

#

And learn Python before that

boreal ravine
rare shoal
boreal ravine
#

also where did you get the profile picture sparky

#

I keep seeing it

rare shoal
waxen granite
#

<@{auction.get_highest_bid()[0]}> how do i just send the name?

#

its a str obj

steep estuary
#

how bot can send its prefix when mentioned?

waxen granite
#

if bot.user.mentioned_in

#

in an on_message event

steep estuary
#

i know that but how to get prefix?

#

bot prefix :/

waxen granite
#

send the msg

steep estuary
#

?

waxen granite
#

fetch the prefix from where you are storing it

steep estuary
#

i have setprefix command so different servers and different prefixes

steep estuary
#

i can fetch but it sends something else also with prefix

waxen granite
#

what else?

#

show

steep estuary
#

something like Request prefix = "!"

boreal ravine
#
webhook = await ctx.channel.create_webhook(name=ctx.author.name, avatar=ctx.author.avatar.url) #doesnt work as of now
``` how would I set the avatar if I have no pfp?
waxen granite
left dove
#

Python 3.10 Build Wheels Sucks with Windows XD

boreal ravine
waxen granite
#

if else statements maybe

#

if the user has avatar or not

boreal ravine
#

hm

steep estuary
#

this it sends

#

i use postgres

waxen granite
#

your code?

steep estuary
#
current_prefix = await bot.pg_con.fetchrow("SELECT prefix FROM prefixes WHERE guild_id  = $1", message.guild.id)
#

?

#

is there any way to take the letters after ' and before '

#

in python

left dove
steep estuary
#

ok

slate swan
#

Don't slice it

steep estuary
#

but what if there prefix length is 2 or 5

#

how i can specify it ?

slate swan
steep estuary
#

is there any way to get words after ' and before '

left dove
#

Change those numbers depends on the string char

prefix = f"{current_prefix}"[15:-2]
steep estuary
steep estuary
#

i think it is saying the recorded prefix

slate swan
#

That's completely wrong

steep estuary
#

than tell pls what is the way?

left dove
left dove
slate swan
#

It's a custom type of the library

#

Which means it's not a string

left dove
slate swan
#

And you can't slice it

slate swan
left dove
#

its a class object

slate swan
#

And you want to slice a class

steep estuary
#
for words in that:
  if words == "'":
    length = len(words)
    idk wht to do now :| 
```something like this will work 😐
#

after ' and before '

#

is there any way to get letters between that?

slate swan
#

It's a class

steep estuary
#

hm

slate swan
#

Stop trying to extract things inbetween the ''

steep estuary
#

ok

#

than?

slate swan
#

Basic python class knowledge Β―_(ツ)_/Β―

left dove
#

then get data from that class

left dove
slate swan
#

Just like you get the name or anything else from a discord.Member object

left dove
steep estuary
steep estuary
#

is there any way to get that?

#

okk

left dove
#

i use redis as my db

slate swan
left dove
#

cuz its fast as fuk

steep estuary
#

why they never show examples 😐

slate swan
#

Never said the opposite

#

Learn to read the documentation by using your Python knowledge

steep estuary
#

:/

slate swan
#

Don't expect to always be given the code to copy paste

steep estuary
#

i learn from docs only

#

but here idk what that is called :/

slate swan
#

And you will understand what to do

#

To get the value in the prefix field of the class

left dove
left dove
#

but that link has no downloadable software

#

when i click on it nothing download

#

and it shows ur download started if not click retry but still not downloading

hasty iron
#

or install the build tools

left dove
left dove
hasty iron
#

install the build tools

left dove
#

but only happens with windows

slate swan
#

There's literally a download button

left dove
#

shit windows

hasty iron
#

then dont use windows

left dove
slate swan
left dove
slate swan
slate swan
left dove
reef shell
#

Imagine paying for shits

left dove
slate swan
hasty iron
slate swan
#

Then click on download agian

left dove
hasty iron
#

you'll have to install VS either way

solar pike
#

anyone knows how to make embed color random :))

left dove
slate swan
unkempt canyonBOT
#

classmethod random(*, seed=None)```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") with a random hue.

Note

The random algorithm works by choosing a colour with a random hue but with maxed out saturation and value.

New in version 1.6.
slate swan
#

or make a custom hex color generator if you don't want to use the default available colors

solar pike
#

ok ok i shall loose more brain cells making one ty

left dove
slate swan
#

it's not python

#

It's your computer

hasty iron
#

its not

#

its the library not being compatible

slate swan
#

That doesn't have the compatible tools installed

#

So don't put the blame on Python

hasty iron
#

if you wait some time, and try again it should work

#

and by some time, i mean a couple of weeks

left dove
#

not on python

left dove
slate swan
#

Then you're blaming on yourself

hasty iron
#

downgrading is the easier option

slate swan
#

Deal with it or downgrade

solar pike
#

how to make uptimer for a bot

slate swan
left dove
solar pike
slate swan
#

You don't?

#

Just run the script and it keeps running

#

And if you're using replit, stop it and change to a vps

hasty iron
solar pike
solar pike
slate swan
#

As I said, don't use replit

solar pike
slate swan
#

You should not use Repl.it to host your bot.

While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:

  • The machines are super underpowered.

    • This means your bot will lag a lot as it gets bigger.
  • You need to run a webserver alongside your bot to prevent it from being shut off.

    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.

    • This means any file you saved via your bot will be overwritten when you next launch.
  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please avoid using repl.it to host your bot. It's not worth the trouble.

slate swan
#

If you already got told to stop using it then maybe you should really think about changing

left dove
slate swan
hasty iron
#

why do you even need 3.10

slate swan
#

People who want the lastest version on everything for no reason shrug

left dove
hasty iron
#

discord bot speed

left dove
slate swan
#

Just a very few things that are a little bit faster

slate swan
#

Which won't affect a lot

left dove
reef shell
#

!d discord.ext.commands.Exceptions

boreal ravine
#

Whats the file for the documentation command on the github for @unkempt canyon?

slate swan
#

It's really spread everywhere

#

In 1 folder tho, but all those files contribute for the docs command

#

!source d

unkempt canyonBOT
#
Command: docs

Look up documentation for Python symbols.

Source Code
slate swan
#

The folder is "doc"

#

Gl trying to copy all that πŸ˜‚

dusty rover
#

guys, im getting error code 400 while trying to send a message to a discord webhook, any solutions? (doesn't matter the code, i get a code 400 error code)

#

or can someone tell me what causes the error?

reef shell
#

You can't send message to a discord webhook , there is no option

dusty rover
#

well sending things to it, like uh

reef shell
#

you can send message to a channel using webhook

dusty rover
#

well, that

#

but can you tell me what causes error code 400?

broken dirge
#

@ client.command(pass_context=True) async def calculator(ctx): global times_used await ctx.send(f"xxxxxxxx") try: msg = await client.wait_for("message", check=check, timeout=30) except asyncio.TimeoutError: await ctx.send("Sorry, you didn't reply in time!") I'm getting error with check
what would be the problem?

dusty rover
covert igloo
#

Before check=check

broken dirge
#

not sure

slate swan
unkempt canyonBOT
slate swan
#

!pypi master branch

unkempt canyonBOT
slate swan
#

Eh

waxen granite
#

whats the difference between if member is None and if not(member)

lament mesa
round dune
waxen granite
#
                    member = ctx.guild.get_member(int(auction.get_highest_bid()[0]))
                    if member is None:
                        auction_list += f"**{counter}.**  `Auction ID:` **{auction.auctionid}** | `Item Name:` **{auction.itemname}** | `Sold By:` {self.bot.get_user(auction.seller).name} | `Ends in:` **{retryMessage}**\n     **Highest Bid:** `None`.\n\n"
                    else:
                        auction_list += f"**{counter}.**  `Auction ID:` **{auction.auctionid}** | `Item Name:` **{auction.itemname}** | `Sold By:` {self.bot.get_user(auction.seller).name} | `Ends in:` **{retryMessage}**\n     **Highest Bid:** `{auction.get_highest_bid()[1]}` **by** `{member.name}`.\n\n"
            ``` 
well this gives`TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'`
odd pendant
#

auction.get_highest_bid()[0] is None so it can't be converted to an int

odd pendant
severe oar
#

How can i make generic conventer?

lament mesa
waxen granite
odd pendant
#

check for what? In order to get the guild member, you need to pass a valid argument, such as an int, what you're passing is NoneType so it can't be casted to an int

#

if auction.get_highest_bid()[0] is "305573693134733313" for example then what you have is fine, however it's not "305573693134733313", it's None

severe oar
#

How can i make generic conventer?

hasty iron
#

a generic converter? why?

waxen granite
#

.bid 16334615530 your dad woody Converting to "float" failed for parameter "amount".
how should i raise the error if this is the case

#

and send in the ctx chan

#

value error?

slate swan
#

Hello all, is there any bot source code for discord.py because i need for my server

lament mesa
#

!src

unkempt canyonBOT
slate swan
#

alright thanks i guess?

#

? from discord_components import *

boreal ravine
slate swan
stiff nexus
#
    @commands.command()
    async def nuke(self, ctx, channel: discord.TextChannel = None):
            channel = channel or ctx.channel
            if channel is None: 
                await ctx.send("You did not mention a channel!")
                return
            nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
            if nuke_channel is not None:
                new_channel = await nuke_channel.clone(reason="Has been Nuked!")
                await nuke_channel.delete()
                await new_channel.send(f"{utily.done} Successfully Nuked this channel by {ctx.author}")
            else:
                await ctx.send(f"No channel named {channel.name} was found!")
```this works good but i just want to know that is this method safe?????
hasty iron
#

doesnt seem like since anybody can do it

#

also what even is this nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)

#

are you thinking with your brain

slate phoenix
hasty iron
#

thats not the nuke you have in mind

grand anvil
#

other than that it seems to be fine

grand anvil
#

wait nvm its fine its utils.get not find

slate phoenix
slate phoenix
#

oh I see it just clones the channel and deletes it ty

stiff nexus
#

why when i say nuke u guys think like banning all users in a guild and deleting everything

#

FIRST READ THE CODE AND THEN REPLY

grand anvil
stiff nexus
stone palm
#

Why this error?```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1460, in _load_from_module_spec
setup(self)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jishaku/cog.py", line 55, in setup
bot.add_cog(Jishaku(bot=bot))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1328, in add_cog
raise TypeError('cogs must derive from Cog')
TypeError: cogs must derive from Cog

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

Traceback (most recent call last):
File "main.py", line 94, in <module>
client.load_extension("jishaku")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1520, in load_extension
self._load_from_module_spec(spec, name)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1465, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'jishaku' raised an error: TypeError: cogs must derive from Cog

lyric moat
#

why this gives an error?

Ignoring exception in command help:
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in 
wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\ATKDJ\Desktop\programs\cogs\General.py", line 30, in help
    @help.error
AttributeError: '_Helper' object has no attribute 'error'

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

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in 
invoke
    await ctx.command.invoke(ctx)
  File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\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: AttributeError: '_Helper' object has no attribute 'error'
solar pike
#

import discord
import random
import json
from discord.ext import commands

class Money(commands.Cog):

def init(self, client):
self.client = client

@commands.command()
async def balance(self, ctx):
  await open_account(ctx.author)
  user = ctx.author
  users = await get_bank_data()

  wallet_amt = users[str(user.id)]["wallet"]
  bank_amt = users[str(user.id)]["bank"]
  embedVar = discord.Embed(title=f"{ctx.author.name}'s balance", color = discord.Color.red())
  embedVar.add_field(name = "Wallet Balance",value = wallet_amt)
  embedVar.add_field(name = "Bank balance",value = bank_amt)
  await ctx.send(embed=embedVar)

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

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

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

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




async def beg(self, ctx):
  users = await get_bank_data()
  user = ctx.author
  earnings = random.randint(1,500)

  await ctx.send(f"WOAW someone just gave u {earnings} coins!!" )



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

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

def setup(client):
client.add_cog(Money(client))

valid niche
valid niche
valid niche
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.

solar pike
#
import random
import json
from discord.ext import commands

class Money(commands.Cog):

  def init(self, client):
    self.client = client 

    @commands.command()
    async def balance(self, ctx):
      await open_account(ctx.author)
      user = ctx.author
      users = await get_bank_data()

      wallet_amt = users[str(user.id)]["wallet"]
      bank_amt = users[str(user.id)]["bank"]
      embedVar = discord.Embed(title=f"{ctx.author.name}'s balance", color = discord.Color.red())
      embedVar.add_field(name = "Wallet Balance",value = wallet_amt)
      embedVar.add_field(name = "Bank balance",value = bank_amt)
      await ctx.send(embed=embedVar)

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

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

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

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




    async def beg(self, ctx):
      users = await get_bank_data()
      user = ctx.author
      earnings = random.randint(1,500)

      await ctx.send(f"WOAW someone just gave u {earnings} coins!!" )



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

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


def setup(client):
  client.add_cog(Money(client))```
valid niche
#

that's still not what i asked for

#

at least i can see now that the issue is indentation

slate swan
#

anyone have any working eval commands?

solar pike
valid niche
#

but it's very much wrong indentation

solar pike
#

oooooo ok

valid niche
unkempt canyonBOT
#
Command Help

!site
Can also use: s

Commands for getting info about our website.

Subcommands:

!site faq
Info about the site's FAQ page.
!site help
Info about the site's Getting Help page.
!site home
Info about the website itself.
!site resources
Info about the site's Resources page.
!site rules [rules]...
Provides a link to all rules or, if specified, displays specific rule(s).
!site tools
Info about the site's Tools page.

valid niche
#

!source e

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
valid niche
solar pike
#

@valid niche can u rectify how to do it?

valid niche
solar pike
valid niche
#

if you are doing discord bots you are expected to have a good basic understanding of python

#

if you have this knowledge you can easily solve this on your own

lyric moat
valid niche
#

if you don't well good lukc

valid niche
#

you have a command named help, which is a function, but it's denied from overwriting the built in help

lyric moat
#

so i can not add help error?

valid niche
#

so help.error isn't your help function/command

#

it's the built in help function

valid niche
#

help is a reserved name in python

leaden anvil
#

Ok why am I getting this error Positional argument cannot appear after keyword arguments for FS. I am trying to send select menu with an embed and buttons but it gives me the following error. Here is the script py #feedback @client.group(invoke_without_command=True) async def feedback(ctx, *, text = None,): try: text = text.split("|") report=discord.Embed(color=0xfff868) report.add_field(name='Pending Confirmation', value=f"{text[1]} #Tittle \r {text[2]} #Description") FB=[[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]] FS=Select(placeholder = 'Where to post',options = [SelectOption(label="Bugs", value="value1"),SelectOption(label="Commands", value="value2"),SelectOption(label="Suggestions", value="value3"),SelectOption(label = "Other", value = "value4")]) await ctx.channel.send(embed=report, components=FB, FS) except: await ctx.reply("Please enter `/feedback format` to check how to format.") To check if the button variable works I did components=FB and it works perfectly fine but when I checked the select menu it gave me this object of type 'Select' has no len() . To solve the first error I did view=FS but that only gives me the error send() got an unexpected keyword argument 'view' why just why

valid niche
#

you already have the embed= and components = kwargs

#

so you cannot have a positional argument FS

#

that must also be a kwarg then

#

also that code is EXTREMELY difficult to read

leaden anvil
leaden anvil
valid niche
#

if you clean up your code debugging is 300 times easier

lyric moat
fathom hound
#

hi, could someone please help? why does it return this error;

client.default_color = discord.Color(int(get_dominant_color(client.user.avatar.url), 16))
AttributeError: '_MissingSentinel' object has no attribute 'avatar'
#

...on trying to access the client instance that way?

fallow mauve
#

how do i test whether or not the ctx of a command is a specific phrase?

dim cedar
#

hello

#

i have aproblem

fallow mauve
#

me too

dim cedar
#
@bot.event
async def on_message(message):
    if message.content == "!mute @dim cedar":
        user = message.guild.fetch_member(760010546728402975)
        guild = message.guild
        mutedrole = discord.utils.get(guild.roles, name = "Muted")
              await sleep(5)
        await user.remove_roles(mutedrole)
        await message.channel.send("Did you just escaped a Mute @dim cedar")```
#

after including this to the code none of the cmds of my bot are working

fallow mauve
#

you have to put "return" at the end

valid niche
valid niche
valid niche
#

if you are ignoring it, i'm not going to tell you again

dim cedar
valid niche
#

i mean it's jank

#

using sleep

fallow mauve
valid niche
#

especially since you're doing it using bot.event aka you're overwriting the internal on_message, and thus you are sleeping for exceptionally large amount of times

valid niche
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

fallow mauve
#

lol

valid niche
#

hmm one second

fallow mauve
#

lmao

dim cedar
valid niche
#

it's a HUGE class, it's a GIANT pile of information

dim cedar
#

it shows invalid syntex

valid niche
#

so what part of ctx should be whatever you want?

fallow mauve
fallow mauve
valid niche
valid niche
unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
valid niche
#

so what part should be that text?

dim cedar
fallow mauve
fallow mauve
valid niche
#

ctx is a HUGE ball of information generated by the library

fallow mauve
valid niche
#

you can pass your own arguments after that

fallow mauve
#

ok

fathom hound
# valid niche i think your client is defined as something else due to the _MissingSentinel par...

i thought so too so i put in a print(client) right above that line, and it returns the bot object <disnake.ext.commands.bot.Bot object at 0x000001DCA301FFD0>, rightly so
it seems like the problem only arises when i try to access an attribute from the client without an async function, that's when it throws the _MissingSentinel error which is strange. it works as intended when done inside an async function.

valid niche
#

but ctx is a huge pile of information

valid niche
dim cedar
dim cedar
valid niche
#

by writing correct python code?

fathom hound
leaden anvil
# valid niche the thing is, making clean code is purely so it's easier to debug and maintain

well 'tuple' object does not support item assignment I know I probably did this wrong but is this how your supposed to do it ? py @client.group(invoke_without_command=True) async def feedback(ctx, *, text = None,): try: text = text.split("|") report=discord.Embed(color=0xfff868) report.add_field(name='Pending Confirmation', value=f"{text[1]} #Tittle \r {text[2]} #Description") FB=[[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]], Select(placeholder = 'Where to post',options = [SelectOption(label="Bugs", value="value1"),SelectOption(label="Commands", value="value2"),SelectOption(label="Suggestions", value="value3"),SelectOption(label = "Other", value = "value4")]) FS=FB await ctx.channel.send(embed=report, components=FS) except: await ctx.reply("Please enter `/feedback format` to check how to format.") also please forgive me for the sin I have just committed NOT Formatting the code

valid niche
#

tho idk where because the code is quite a mess

dim cedar
#

nvm

leaden anvil
leaden anvil
valid niche
#

and then there's a good chance the issue will just present itself for you

steep estuary
hasty iron
#

no

steep estuary
#

:/

#

but i saw in yt :/

hasty iron
#

it’s not dead

#

it’s still very much alive

steep estuary
#

-_-

fallow mauve
#

undefined name "check"

#

why is this happening?

hasty iron
#

because its not defined

fallow mauve
#

how do i define it?

#

what does 'define' mean?

steep estuary
hasty iron
#

im making my own wrapper with a friend

steep estuary
#

hmm

fallow mauve
hasty iron
hasty iron
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.

fallow mauve
#

?

steep estuary
#

like pycord

#

i am thinking to switch in pycord :/

hasty iron
#

thats not a library, that’s just trash

steep estuary
#

why?\

#

pycord?

hasty iron
#

yes

steep estuary
#

:/

slate swan
#

blanket any good forks or libraries then?

steep estuary
#

then switch()

hasty iron
#

idk about libs, but no good forks rn

steep estuary
#

anyother option?

hasty iron
#

keep using dpy

#

it’s still very usable

slate swan
steep estuary
#

but what if they will announce it outdated?

hasty iron
#

then switch

#

pycord and stuff like that are just forks

slate swan
hasty iron
#

you wont need to change syntax

slate swan
steep estuary
#

?

slate swan
#

you can't, you'll have to switch to another fork or library

hasty iron
#

you can

steep estuary
#

using slash commands and app commands are too easy in pycord

slate swan
#

wat

hasty iron
#

you can make it on your own

steep estuary
#

how?

hasty iron
#

all the http endpoints are already there

#

and you can use on_interaction

#

!d discord.on_interaction

unkempt canyonBOT
#

discord.on_interaction(interaction)```
Called when an interaction happened.

This currently happens due to slash command invocations or components being used.

Warning

This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the [`View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View") instead as it provides a nicer user experience.

New in version 2.0.
steep estuary
#

idk how i got d.py -_- i think its a trash :/

hasty iron
#

dpy is trash?

#

then what about forks

steep estuary
#

idk yt says that

hasty iron
#

which are shittier

slate swan
steep estuary
hasty iron
#

so what

steep estuary
#

now they will not add in it

hasty iron
#

dead = not usable?

steep estuary
#

idk

slate swan
steep estuary
#

d.py will end ? if not i will keep using it

slate swan
hasty iron
#

it will stop getting updates

slate swan
#

it just won't be maintained

steep estuary
#

ok

slate swan
#

yeah

steep estuary
hasty iron
#

why though

steep estuary
placid skiff
steep estuary
#

:(

#

:/

#

pycord is better or nextcord?

placid skiff
#

I never used pycord so i don t have an answer to that

slate swan
steep estuary
#

what?

slate swan
#

!pypi disnake

unkempt canyonBOT
steep estuary
#

what is this :/

slate swan
#

something better than those 2 forks you mentioned

steep estuary
#

hmm

#

d.py don't have this many features?

slate swan
#

no

#

dpy stopped being maintained 1-2 months ago

steep estuary
#

i asked here they told i can use d.py :/

slate swan
#

u can't use dpy for slash commands

#

and if new features come you won't be able to use them either

steep estuary
#

and message commands?

slate swan
#

iirc dpy only had buttons and select menu

placid skiff
slate swan
#

yes

steep estuary
#

app commands?

placid skiff
#

Well, it s time to convert my code

slate swan
leaden anvil
#

Just wanted to ask if this code is goodly formatted ```py

feedback

@client.group(invoke_without_command=True)
async def feedback(
ctx,
*,
text=None,
):
try:
text = text.split("|")
report = discord.Embed(color=0xFFF868)
report.add_field(
name="Pending Confirmation",
value=f"{text[1]} #Tittle \r {text[2]} #Description",
)
FB = [
[
Button(style=ButtonStyle.red, label="Discard", custom_id="n"),
Button(style=ButtonStyle.green, label="Send", custom_id="y"),
]
], Select(
placeholder="Where to post",
options=[
SelectOption(label="Bugs", value="value1"),
SelectOption(label="Commands", value="value2"),
SelectOption(label="Suggestions", value="value3"),
SelectOption(label="Other", value="value4"),
],
)
FS = FB
await ctx.channel.send(embed=report, components=FS)```

steep estuary
#

ohh

#

but pycord also have this :/

placid skiff
steep estuary
#

and i heard it is in top in github

steep estuary
#

it will show Apps

slate swan
#

the only reason pycord is on top is because the owner of it is a yt

leaden anvil
placid skiff
slate swan
#

exactly

steep estuary
#

then what i should use now ?

slate swan
#

disnake

hasty iron
steep estuary
#

is the syntax different?

hasty iron
#

its a fork so no

slate swan
#

the syntax is dpy 2.0's syntax

steep estuary
#

:/

placid skiff
#

I discovered nextcord searching by buttons
Now i will try disnake and if i can get used to it probably i will use it

hasty iron
#

i dont know what they even added in nextcord

#

i literally found nothing source code diving

steep estuary
#

which is mostly used?

placid skiff
placid skiff
#

When i converted to nextcord i didn t changed nothing to my code, only the package

steep estuary
#

😫

#

it mean i have to change my code?

pliant gulch
#

Because its a fork lol

steep estuary
#

if i switch?

pliant gulch
steep estuary
#

but i have 54 commands so i have to change all?

hasty iron
#

dude

#

we literally told you like 4 times you wont have to change anything

steep estuary
#

:/

#

ok

placid skiff
#

It s a fork bro

steep estuary
#

i will try disnake

placid skiff
#

It s pretty the same as the original package

#

But with other features

steep estuary
#

i will try to convert my code to disnake tomorrow :/

ripe wolf
#

hey uh how can I get a command to loop given a certain number and how can I also limit the amount of times it preforms it
i.e like a roll command where id do like !roll 10

steep estuary
#

Rip yt is not showing a single word named disnake :/

sick birch
#

You can pass in the count parameter

slate swan
#

If I want to make slash commands and put each of the guild IDs the bot is in in the guild_ids parameter, is it a good thing, and how exactly is the best way to do so?

hasty iron
#

just use global slash commands?

slate swan
#

the command doesn't show up after /command name

hasty iron
#

it takes an hour for global commands to sync iirc

slate swan
#

I see

#

I tried iterating through each of the guilds the bot is in and got the ID but well that didn't work

#

probably not a good thing to do though

hasty iron
#

doesnt seem too efficient to me

steep estuary
#

what is slash = (SlashCommands) in d.py?

#

@slash.slash?

#

oops

fallow mauve
#

this is annoying me, "[pyflakes] local variable 'choice' defined in enclosing scope on line 40 referenced before assignment"

slate swan
#

By the way blanket is there any guide or doc to what you said before about putting slash cmds into d.py yourself?

hasty iron
#

no

fallow mauve
#

ew slash commands

slate swan
fallow mauve
#

i dont like them

slate swan
#

you'll have to switch to them at a point

fallow mauve
#

i dont want to

steep estuary
#

@slash.slash?

#

what is this :/

fallow mauve
#

harumph

fallow mauve
hasty iron
#

you just need to implement the classes

slate swan
#

or use class variables

slate swan
#

I just did

fallow mauve
#

oh, you turned off ping so i didnt see it

#

what do you mean global choice?

#

ive never used that

slate swan
#

scoping in python

steep estuary
steep estuary
fallow mauve
#

ive never used it, you realize ive only been using python for like 2 weeks right?

steep estuary
#

i use it everyday i thought it is basic if u use functions :/

fallow mauve
#

:/

#

ok, im sure it is but idk what it is

steep estuary
#

u can change or make a global variable by that

fallow mauve
#

how?

slate swan
#

functions do not recognise global variables defined in the root code

#

that's how you can take variables into functions

steep estuary
slate swan
#

!d global

unkempt canyonBOT
#

7.12. The global statement


global_stmt ::=  "global" identifier ("," identifier)*
``` The [`global`](https://docs.python.org/3.10/reference/simple_stmts.html#global) statement is a declaration which holds for the entire current code block. It means that the listed identifiers are to be interpreted as globals. It would be impossible to assign to a global variable without `global`, although free variables may refer to globals without being declared global.

Names listed in a [`global`](https://docs.python.org/3.10/reference/simple_stmts.html#global) statement must not be used in the same code block textually preceding that `global` statement.

Names listed in a [`global`](https://docs.python.org/3.10/reference/simple_stmts.html#global) statement must not be defined as formal parameters, or as targets in [`with`](https://docs.python.org/3.10/reference/compound_stmts.html#with) statements or [`except`](https://docs.python.org/3.10/reference/compound_stmts.html#except) clauses, or in a [`for`](https://docs.python.org/3.10/reference/compound_stmts.html#for) target list, [`class`](https://docs.python.org/3.10/reference/compound_stmts.html#class) definition, function definition, [`import`](https://docs.python.org/3.10/reference/simple_stmts.html#import) statement, or variable annotation.
hasty iron
#

dont use globals

#

they’re bad practice and bad in general

fallow mauve
#

ok then how fix?

slate swan
#

use class variables is the second option

fallow mauve
#

?

#

pretend i dont know what these terms are

slate swan
#
#global variable
number = 1

class myClass():
    #class variable
    classNumber = 2
#
print(myClass.classNumber)
#

useful in cogs... I think

fallow mauve
#

i seriously have no idea how id put that into the code

slate swan
#

pretty sure you'll want to learn cogs once

fallow mauve
#

cogs...

#

isnt that a thing thats used a lot but nobody has ever told me to use before

slate swan
#

it doesn't change much

#

in efficiency view

fallow mauve
#

ok...

frank sable
#

just change the first choice to choices or something and then do random.choice(choices) or you could just remove the list entirely and just do random.choice(['rock', 'paper', 'scissors'])

slate swan
#
@bot.command()
async def guessgame(ctx):
    embed=discord.Embed(title=':thinking: The Emoji Guess Game', description='Guess an emoji out of the 5 that the bot added as reaction and tap it.', color=0xfbe79f)
    choices=[':tennis:', ':baseball:', ':softball:', ':volleyball:', ':rugby_football:']

    bot_choice = random.choice(choices)

    message = await ctx.send(embed=embed)

    for __choice in choices:
        await message.add_reaction(__choice)

    def check(reaction, user):
        return user == ctx.author

    reaction = None


    while True:
        if str(reaction) == bot_choice:
            embed=discord.Embed(color=0xfbe79f)
            embed.add_field(name=':win: You won!',value=f'you guessed my choice!')
            await message.edit(embed=embed)
        else:
            embed=discord.Embed(color=0xfbe79f)
            embed.add_field(name=':lose: You lost!',value=f'you didnot guessed my choice!')
            await message.edit(embed=embed)
        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=30.0, check=check)
            await message.remove_reaction(reaction, user)
        except:
            break

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji

what is the invalid emoji? i copied every name of the emojis from discord

#

oh

#

maybe you cannot add :emoji:

fallow mauve
slate swan
#

i think this is the problem

#

brb

manic wing
slate swan
#

i mean

#

you need to copy the emoji itself, not the name

#

yes, this is the problem

manic wing
#

no, you don’t.

frank sable
#

if you're using it in a message you dont but when you're adding a reaction yeah you do

#

embed fields need values

#

all of them

#

np

elfin flicker
#

thank you

#

ha, okey

#

thank you xd

slate swan
#

how do i import 'bot'?

jade jolt
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
slate swan
#

why command doesnt work : ```py
@bot.command
async def game(self, ctx):
number = random.randint(0, 100)
for guess in range(0, 5):
await ctx.send('guess')
Message = await self.bot.wait_for('message')
Message = int(Message)
if Message.cleant_content > number:
await ctx.send('bigger')
elif Message.cleant_content < number:
await ctx.send('smaller')
else:
await ctx.send('true')

mental bloom
jade jolt
#

its exact isnt it

mental bloom
#

Different first line

slate swan
#

i asked a friend for the code

#

bc im trying to learn py

jade jolt
#

its broken code lol

mental bloom
lapis lintel
#

Is there a way to use a local image on an embed's thumbnail?

strong kettle
#

The number of bot members is 500 thousand, and when I restart it, it is delayed because of its assembly of members. What is the solution?

#

Anyone?

leaden anvil
ripe jackal
#

what?

bitter depot
#

@ripe jackal we aren't going to help with a nitro-gen brute forcer here

ripe jackal
#

what is brute forcer?

#

this is something stupid and fun, there is no way to get that lucky to get a real nitro lol

#

i though it can be fun :/

#

to have a command like it

leaden anvil
strong kettle
visual yarrow
#

Yeaahh, but I'm still not sure Discord would be happy about it @ripe jackal πŸ˜„

ripe jackal
ripe jackal
#

both

visual yarrow
#

I'm sure generating nitro gift links is against Discord's ToS.

#

Within this server, we usually give people a chance to learn the rules. It would only be an issue if you continued to ask for help with something after being told not to by a moderator.

ripe jackal
visual yarrow
#

As we are a partnered server.

ripe jackal
#

yeah, I got it

winged ruin
#

hello

ripe jackal
#

hi

leaden anvil
strong kettle
leaden anvil
strong kettle
#

Server

leaden anvil
strong kettle
slate swan
cloud dawn
#

isn't a vps local pithink

slate swan
#

no...

#

I think so atleast

#

but it could be anything lmao

#

from heroku and replit to some official google stuff

leaden anvil
#

@strong kettle

#

hello

#

Ok I want to send a message with a embed, select menu and buttons but I got the error 'tuple' object does not support item assignment to solve this I did this ```py

feedback

@client.group(invoke_without_command=True)
async def feedback(
ctx,
*,
text=None,
):
try:
text = text.split("|")
report = discord.Embed(color=0xFFF868)
report.add_field(
name="Pending Confirmation",
value=f"{text[1]} #Tittle \r {text[2]} #Description",
)
FB =[ [
[
Button(style=ButtonStyle.red, label="Discard", custom_id="n"),
Button(style=ButtonStyle.green, label="Send", custom_id="y"),
]
], Select(
placeholder="Where to post",
options=[
SelectOption(label="Bugs", value="value1"),
SelectOption(label="Commands", value="value2"),
SelectOption(label="Suggestions", value="value3"),
SelectOption(label="Other", value="value4"),
],
)]
FS =FB
await ctx.channel.send(embed=report, components=FS)``` but now I am getting a error 'list' object has no attribute 'to_dict' How do I solve this ?

#

Any help

cloud dawn
#

traceback?

leaden anvil
cloud dawn
#

just ctrl+f to find to_dict attribute

leaden anvil
cloud dawn
#

Well that is true isn't it?

#

!e list().to_dict

unkempt canyonBOT
#

@cloud dawn :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | AttributeError: 'list' object has no attribute 'to_dict'
leaden anvil
cloud dawn
#

Because you are using to_dict on a list

leaden anvil
cloud dawn
#

i have no idea what datatype FS is but if you tried FB.to_dict then it won't work

cloud dawn
#

idk what you are trying to do.

#

You haven't told us.

leaden anvil
cloud dawn
#

Yeah you told you wanted to create a message with embed and buttons but that's not what you currently want.

#

Why do you want to convert it to a dict?

hasty iron
#

FS is actually a list inside a list

cloud dawn
#

Also saw that don't know why though.

hasty iron
#

thats the cause

#

components expects a list

#

iterates through it and calls to_dict

#

but here it found another list

#

thus raising AttributeError

leaden anvil
#

ok thanks

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1633466265:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

leaden anvil
# hasty iron thus raising AttributeError

Fine I solved that but now it gives me the error 'Select' object is not iterable here is the new line of code ```py
FB = [
[
Button(style=ButtonStyle.red, label="Discard", custom_id="n"),
Button(style=ButtonStyle.green, label="Send", custom_id="y"),
]
]

    FA=Select(
        placeholder="Where to post",
        options=[
            SelectOption(label="Bugs", value="value1"),
            SelectOption(label="Commands", value="value2"),
            SelectOption(label="Suggestions", value="value3"),
            SelectOption(label="Other", value="value4"),
        ],
    )
    FS=zip(FB,FA)```
hasty iron
#

why are you ziping it

#

do you know what zip does

cloud folio
#

Hi, could you please help me with getting list of channels in specified category?

leaden anvil
slate phoenix
unkempt canyonBOT
#

property channels: List[GuildChannelType]```
Returns the channels that are under this category.

These are sorted by the official Discord UI, which places voice channels below the text channels.
flint forum
#

Where do you learn slash.py in (I'm not talking about youtube wise) I'm talking about reading it not listening

flint forum
#

mhm

slate phoenix
#

There are examples on their GitHub

flint forum
#

if thats what slash cmds is

#

like /

#

Oh okay

floral jacinth
#

a little question
new_channel = await after.channel.clone(name=f'Squadra di {member.name}') can i set the category where it will be created?

boreal osprey
#

What is yalls opinions on bdfd(bot designer for discord)

hasty iron
#

!d discord.abc.GuildChannel.clone

unkempt canyonBOT
#

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

Clones this channel. This creates a channel with the same properties as this channel.

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

New in version 1.1.
hasty iron
#

huh

floral jacinth
#

not understand

#

so can't set the category?

hasty iron
#

guess not

#

you have to edit the category once cloned

#

clone -> edit position

#

?

#

ok

floral jacinth
hasty iron
#

discord.TextChannel.edit takes a category kwarg

#

and also position

boreal osprey
#

just a question but is d.py gonna stop support for bots in 2022?

hasty iron
#

probably not

#

the change for intents only affects verified bots and bots planning to get verified

boreal osprey
#

oh ok

#

cus people in the bdfd server were saying that "d.py would be useless after 2022"

hasty iron
#

no

#

that’s not true

#

discord.py will keep working until it stops working

#

we don’t know when it will break but the intent change won’t break it

boreal osprey
#

true

#

just importing all intents should work for someone

pliant gulch
#

In the future it might break but the beauty of the MIT license and an open source repo. Allows users to edit the library in the future to fix their own problems and distribute to other users as well

slate swan
#
total_users = len(guild.members)
        total_bots = len([member for member in guild.members if member.bot == True])
        total_humans = total_users - total_bots
``` what is the issue with this command, its such a pain
marsh depot
#

Hi, im trying to check how can i make users can't mention guild.roles or guild.members, how can i make it?

runic lagoon
#

unrelated topic, but python is not installing a discord module why

#

I basically ran this on heroku

#

it says installed, then when I run pip freeze it doesn't display the new module why

#

and it doesn't have the new module downloaded, because it states "invalid module" when I try to run import on it

marsh depot
dapper cobalt
#

Yeah, it won't work.

#

discord.utils.find doesn't have a bot attr.

slate swan
#
bot = commands.Bot(command_prefix=[':banana:', ':banana: '], help_command=None)```
so, i have my bot prefix as the banana emoji, but for discord convenience, i want it to accept the emoji with a space after it (bc discord automatically adds the space after when you type an emoji), but it doesn't actually take ```:banana:(imagine there's a space here)```
 as an input. only ```:banana:```
#

how would i make it accept the space after? or is there not a way to

hasty iron
dapper cobalt
#

Can it take a check?

hasty iron
#

!d discord.utils.find

unkempt canyonBOT
#

discord.utils.find(predicate, seq)```
A helper to return the first element found in the sequence that meets the predicate. For example:

```py
member = discord.utils.find(lambda m: m.name == 'Mighty', channel.guild.members)
```  would find the first [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") whose name is β€˜Mighty’ and return it. If an entry is not found, then `None` is returned.

This is different from [`filter()`](https://docs.python.org/3/library/functions.html#filter "(in Python v3.9)") due to the fact it stops the moment it finds a valid entry.
dapper cobalt
#

But that returns only the first result found.

waxen granite
#

Is there a way get the channels a member is able to see?

hasty iron
#

!d filter

unkempt canyonBOT
#

filter(function, iterable)```
Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which supports iteration, or an iterator. If *function* is `None`, the identity function is assumed, that is, all elements of *iterable* that are false are removed.

Note that `filter(function, iterable)` is equivalent to the generator expression `(item for item in iterable if function(item))` if function is not `None` and `(item for item in iterable if item)` if function is `None`.

See [`itertools.filterfalse()`](https://docs.python.org/3.10/library/itertools.html#itertools.filterfalse "itertools.filterfalse") for the complementary function that returns elements of *iterable* for which *function* returns false.
dapper cobalt
#

Yeah, I've already checked that out.

pliant gulch
#

Just use sum

#

sum(member.bot for member in guild.members)

slate swan
#

the subtraction is the issue i bell

#

believe

#

actually ik it's the issue

bright palm
marsh depot
bright palm
#

What do you mean by check if the message has guild.roles?

marsh depot
#

Or when anyone ping a guild.roles in the message, the bot dont ping and say (only if has a guild.roles mention) This Message Won't ping

marsh depot
bright palm
#

You need to check the message.role_mentions

fair panther
marsh depot
bright palm
#

Don't check the message.content.role_mentions

marsh depot
#

How can I do it then?

bright palm
#

Check if the role was mentioned in message.role_mentions

marsh depot
#

Still the same

Rather, how can I do so that if someone mentions a server role in the command, that above the message they put a message saying "This messages won't ping". Only when someone does the command mentioning a role

karmic totem
#

Hey, how can I get the ID of a user when they add a reaction to a message

reef shell
unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
reef shell
#

the 2nd param. is the user reacting to a message

karmic totem
# reef shell the 2nd param. is the `user` reacting to a message

Code:```py
async def on_raw_reaction_add(reaction, user):
try:
db[f"{reaction.message.id}"]
thing = True
except KeyError:
thing = False
if thing == True:
current = db[f"{reaction.message.id}"]
db[f"{reaction.message.id}"] = f"{current}, {user.id}"

Error:
```diff
-Ignoring exception in on_raw_reaction_add
-Traceback (most recent call last):
- File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
-    await coro(*args, **kwargs)
- TypeError: on_raw_reaction_add() missing 1 required positional argument: 'user'```
reef shell
#

Are you using that event inside a cog?

#

If so, you forgot to pass self as a param.

karmic totem
#

no I am not

reef shell
karmic totem
pliant gulch
#

On on_raw_reaction_add only takes payload

#

on_reaction_add is reaction and user

#

These are two different events

karmic totem
#

ok

reef shell
#

Oh yeah

#

Didn't notice

reef shell
boreal ravine
#

!d discord.ext.commands.Bot.allowed_mentions

unkempt canyonBOT
brittle ingot
#

that or you can use clean_content iirc to remove any mentions for a specific situation.

boreal ravine
#

hm

brittle ingot
#

!d discord.Message.clean_content

unkempt canyonBOT
#

A property that returns the content in a β€œcleaned up” manner. This basically means that mentions are transformed into the way the client shows it. e.g. <#id> will transform into #name.

This will also transform @everyone and @here mentions into non-mentions.

Note

This does not affect markdown. If you want to escape or remove markdown then use utils.escape_markdown() or utils.remove_markdown() respectively, along with this function.

slate swan
#

AttributeError: 'int' object has no attribute 'get_role'

grabrole = payload.guild_id.get_role(rolefromdb)

pliant gulch
#

get_role is a method of discord.Guild

#

guild_id attr of payload is an int, not a discord.Guild instance

#

You can pass payload.guild_id to Bot.get_guild to get the instance

#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
slate swan
#

i see

#

thank you

eternal delta
#

anyone know how to keep my bot file alive using digitalocean host? whenever i close my ssh client the terminal, along with the script, kills itself

slate swan
#

Missing Permissions

nickname = thing pulled from db
await payload.member.edit(nick=nickname)

bot has administrator and manage nick perms, and is above @ everyone

eternal delta
#

is the bot's highest role above the user's highest role?

slate swan
#

yes

eternal delta
#

also, the bot cannot change the server owner's nickname

slate swan
#

perhaps is the reason, ill get a friend online. thank you

outer violet
#

Is it a good option to make a remind command with asyncio?

visual island
#

no, do it with tasks.loop

#

asyncio.sleep will take too much RAM

outer violet
#

What do I do with this then .-.


@commands.command(aliases=['rem'])
    async def remind(self, ctx, time, task):
        def convert(time):
            pos = ['s', 'm', 'h', 'd']

            time_dict = {"s": 1, "m": 60, "h": 3600, "d": 3600*24}

            unit = time[-1]

            if unit not in pos:
                return -1
            try:
                val = int(time[:-1])
            except:
                return -2
 
            return val * time_dict[unit]

        converted_time = convert(time)

        if converted_time == -1:
            await ctx.send("You didn't answer the time correctly.")
            return

        if converted_time == -2:
            await ctx.send("The time must be an integer.")
            return

        embed = discord.Embed(title=f"Your reminder has been set!", color=0x000100)
        await ctx.send(embed=embed)

        await asyncio.sleep(converted_time)
        embed = discord.Embed(title="Reminder πŸ””", 
            description=f"{task}", 
            color=0x000100
        )
        await ctx.author.send(embed=embed)
visual island
outer violet
#

Oh okay thank you

lofty heron
#

hi, how can i make a command not case sensitive so the help command can also he HeLp

grim oar
#

pass case_insensetive=True in commands.Bot()

jade jolt
#

case_insensitive ^

boreal ravine
hard trail
#

Does anybody know how to code an application bot?

#

The bot recieves applications from members for staff to read

final pumice
#

do i need to use the os module to make discord bots?

boreal ravine
final pumice
#

sick

final iron
#

How long does the discord api take to update a bots name?

buoyant sage
#

can anyone help with this error?

buoyant sage
#

have been stuck on this for 12hrs!

slate phoenix
gaunt herald
slate phoenix