#discord-bots

1 messages · Page 591 of 1

mortal turret
#

lmao

tiny ibex
#

I agree

hollow sedge
#

speaking of heroku, anyone know about this? ._.

mortal turret
#

its “free” but you have to do hours of free advertising for this kid to use his sub par servers Ke

tiny ibex
tiny ibex
#

Literally I went on his server and I was like fuckkkkkkk

#

Expensive asf

#

Heroku is 1000000000000000000000000000x times better

#

Even repl is better than that hosting service😂🤣

slate swan
#

Do you know why the message doesn't delete itself? ```py
msg = await ctx.author.send("** **", view=view)
await view.wait()
await msg.delete()

hollow sedge
#

code can go from github to heroku but i want to make github sync with heroku cuz my bot changes some files durings its deploy and the changes are not visible on github

hollow sedge
#

changing files?

tiny ibex
slate swan
#

You can push code to GitHub from Heroku

tiny ibex
#

I don't think you can push from Heroku to Github

slate swan
#

You can

tiny ibex
hollow sedge
#

the only method i know is to pull the code from heroku but thats a hassle everytime i wanna redeploy

#

tho i wonder if theres another hosting website that has github integration and the code is always updating to its github repo

#

that would be simpler

hollow sedge
tiny ibex
heavy folio
#

^

boreal ravine
#

Is it bad that I have like 3 on_message events

boreal ravine
heavy folio
#

hold up

heavy folio
boreal ravine
heavy folio
#

the thing is insert_one begins with 0 points because i want it to begin from 0

heavy folio
boreal ravine
#

I'm saying that if the thing ur looking for exists

#

@heavy folio

#

That might be it

#

you inserted 0 but your looking for 1

fading harness
#

can we restart a bot using jishaku?

#

if yes, how?

boreal ravine
#

Yep, jsk restart doesnt exist

#

Don't think you can do that with 3rd party libraries but you can try editing the view once it got clicked to another view/button

valid niche
#

you will need to edit the message with a new button

#

so edit the message, and pass a new components

#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
valid niche
#

just in view= just like you are creating a new message

odd walrus
#

anyone got a list of the id for colours for embed

boreal ravine
unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

boreal ravine
#

wtf

#

!d discord.Colour

unkempt canyonBOT
#

class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)").

There is an alias for this called Color...
odd walrus
#

got it tq

valid niche
#

grab your code where you send the message with the buttons, now replace the .send with .edit, and instead of a channel it's on a message

valid niche
boreal ravine
#

I mean having 2 class for colors is just weird agreed

valid niche
#

don't edit whatever comes out of the wait for, store your message send return value then edit that message

unkempt canyonBOT
#

discord/colour.py line 329

Color = Colour```
valid niche
#

literally all there is to it haha

waxen granite
#
                if commandInvoker.guild_permissions.administrator is False:
                    await ctx.channel.send(f"{commandInvoker.mention}, this command isn't allowed here.")```
is this correct? commandInvoker = ctx.author
boreal ravine
#

is commandInvoke defined as ctx.author? my bad

boreal ravine
#

wait its wrong

waxen granite
#

doesnt seem to work tho, sends the msg for people with admin perm too

boreal ravine
#

you cant check if its False just use a not statement

waxen granite
#

hm

valid niche
#

so lets say you have the code

await ctx.send("Some text", view=MyButtons())

You can then edit it with

msg = await ctx.send("Some text", view=MyButtons())
await msg.edit(content="Some other text", view=MyOtherButtons())
#

yes, or if you make that View class take input you can use the same class and just use input to change the colour

#

well okay discord_components is a third party extension for discord.py

#

but they do their stuff differently

#

no extra libraries

#

just plain vanilla discord.py with no third party extensions

#

don't forget you need discord.py 2.0 for this, which isn't on pypi

boreal ravine
#

!pypi disnake personally

unkempt canyonBOT
valid niche
#

:p

#

!pypi disthon

unkempt canyonBOT
tawdry mist
#

Guys someone just told me that discord.py going to be shut down soon
this is correct?

boreal ravine
#

it already did

valid niche
boreal ravine
#

i cant find the github for it

#

is it still private

valid niche
#

2021-08-28 is when danny announced that he quit

valid niche
#

like just as an advisor so to say

valid niche
waxen granite
waxen granite
#

the error is, if the commandInvoker doesnt have guild perms administrator, it should send the ctx.channel.send msg but it sends the msg even for member with admin perm

slate swan
#

is commandInvoker context.author?

waxen granite
#

ye

slate swan
#

the command might have been used in dms

waxen granite
slate swan
fading harness
#

hi

slate swan
valid niche
#

it's still all WIP

slate swan
valid niche
#

just need to get it known to the public slowly and in an acceptable manner :p

slate swan
#

¯\_(ツ)_/¯

valid niche
# slate swan Not even an example nor docs, wouldn't recommend it to anyone when most people m...

also want an exmple:

import discord

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

@client.event("on_message")
async def bounce_message(msg):
    if msg['d']['content'] == "Hello":
        await client.handler.send_message(int(msg['d']['channel_id']), "Hello World!")

@client.event
async def on_message(msg):
    if int(msg['d']['channel_id']) == 890495312811151370:
        await client.handler.edit_guild_text_channel(890495312811151370, topic=msg['d']['content'])


client.run("TOKEN")
#

shows how rough it is atm

slate swan
#

Damn, that's a lotta json

valid niche
#

ye it's currently passing the raw json stuff from the API to the code, but no fear those models are next

frail rapids
#

So I am working with nextcord to migrate my old discord.py over to it and I realised that my unload and load command for cogs stopped working (or never worked at all it's been a while since I worked in this bot) what is the best way/proper way to unload and load cogs?

pliant gulch
#

This seems more like a rest client

#

Unless this is just a WIP

valid niche
#

just yeah the models aren't implemented yet, which is next on the list

#

so it's all just raw json parsing

pliant gulch
#

The name handler doesn't make sense to me

valid niche
#

handler is just the internal thing that does all the API calls

#

it handles the API calls

#

hence handler

bitter perch
#

Someone is gonna have fun when they figure out how shit the documentation is

valid niche
pliant gulch
#

Name mangling isn't for private variables

valid niche
pliant gulch
#

Yeah and your using double underscores

#

Which mangles it

valid niche
#

ah did we?

pliant gulch
#

That is used for classes meant to be subclassed

#

It's not supposed to be used for private variables as said in pep8 somewhere iirc

valid niche
#

yeah i am aware, the double underscore means you can access the attribute using instance._Classname__attributename for when you're subclassing a lot

warm mirage
#

guys i need help

slate swan
#

Guyz How To Change Button Color ?

valid niche
warm mirage
#

im making a discord bot that dms someone when a command is activated this is the command but i want it to later delete the message from the dms i tried it with the code below can somoen pls help? :

await user.send(f'a member has an issue they said that there was an issue with one of the following: the server one of the member idk just check out the ask owner someone mustve said it')
dmchannel = bot.get_channel(450568681898901515)
for message in dmchannel(limit=100):
    if message.author == bot.user: 
        await dmchannel.delete(450568681898901515)
valid niche
# slate swan how ?

when you make a button you just pass a style like this @discord.ui.button(label='<<', style=discord.ButtonStyle.blurple, custom_id='pg_bck')

#

and that button is blurple

warm mirage
#

seb can you help me?

valid niche
warm mirage
#

im new to making the code i just found it online modified it and it works but i want it to delete messages from my dms with the bot

#

idk how to do it

#

and i gave up trying

valid niche
#

when you send a message, it returns the message object, just call .delete() on it and it's gone

#

alternatively pass delete_after= to the send

warm mirage
#

i tried that but it doesn't work

#

it keeps on giving me

#

wait lemme get the issue

valid niche
#
msg = await user.send("Hello")
# some code
await msg.delete()

or

await user.send("Hello", delete_after=20) # will delete the message after 20 seconds
calm viper
#

hello there; i get this error: AttributeError: module 'discord' has no attribute 'ButtonStyle' what should i do?

slate swan
#

what version you are at?

calm viper
#

3.9

slate swan
valid niche
valid niche
calm viper
#

1.7.3

valid niche
#

good spot

calm viper
#

oh so i should update it?

valid niche
# calm viper 1.7.3

yeah buttons and interactions and such are added in 2.0, which is not on pypi btw, so a pip install -U discord.py will not work

calm viper
#

ah i see

valid niche
#

read this

warm mirage
#

seb thank you i found out how to delete it

#

but i have another problem

#

i have tried this so many times

#

idk how to delete this

valid niche
#

ah wait that doesn't exist for DMs

warm mirage
#

crap

valid niche
#

so you'll have to async for loop over the history and delete all messages one by one

#

!d discord.abc.Messageable.history

unkempt canyonBOT
#

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

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

Examples

Usage...
valid niche
#

then for every message delete it

warm mirage
#

how to delete it

#

sorry for asking im new to discord bot making

valid niche
#

told you already

warm mirage
#

is it still delete after?

warm mirage
#

oh

valid niche
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

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

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

im dum

#

thanks

#

THANS SEB IT WORKED

#

after dying for 2 days it finally works

pliant gulch
#

Perhaps HTTPHandler or just HTTPClient

valid niche
#

hmm, maybe httphandler

#

tbh most are never going to know about the class because it's hidden/backend

#

but for the few maybe make it slightly more clear yeah

pliant gulch
#

If you want to facilitate development in your wrapper

#

So everything you do should be explicit

#

In my wrapper I have almost all internals documented

#

This is done so that it allows for contributors to understand the codebase without reverse engineering

valid niche
#

that's a very good point yeah, i was expecting people to be possibly interested in the behinds the scene. I'll probs put on my todo to document the internals very well and rename a few things to make it more explicit

pliant gulch
valid niche
#

pythonpixels was my first one, but that was such a small and tiny project for me to work alone on

#

!pypi pythonpixels

unkempt canyonBOT
pliant gulch
#

Alright well a good thing to keep in mind is

#

It's a lot easier to make the wrapper than it is to make it easy for people to use

valid niche
#

haha

slate swan
#

Why when o join repl.it download all imports ?

valid niche
#

and most here will tell you to not use replit

#

or at least not for discord bots

slate swan
#

@valid niche can you suggest me a host?

valid niche
#

a VPS

#

here

#

and why not to use heroku/replit @slate swan

slate swan
#

Don't use replit/heroku as you got told above

cinder horizon
#
for entry in entries:
          embeds.append(discord.Embed().from_dict(entry))
        await ctx.send(embed=embeds)
```wut do i do?
leaden jasper
boreal ravine
#

which part

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

boreal ravine
leaden jasper
#

what is the difference between task.stop() and task.cancel()?

valid niche
valid niche
leaden jasper
#

it says cancel() stops it immediately but what is is_being_cancelled() for

valid niche
#

!d discord.ext.tasks.Loop.stop

unkempt canyonBOT
#

stop()```
Gracefully stops the task from running.

Unlike [`cancel()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.cancel "discord.ext.tasks.Loop.cancel"), this allows the task to finish its current iteration before gracefully exiting.

Note

If the internal function raises an error that can be handled before finishing then it will retry until it succeeds.

If this is undesirable, either remove the error handling before stopping via [`clear_exception_types()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.clear_exception_types "discord.ext.tasks.Loop.clear_exception_types") or use [`cancel()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.cancel "discord.ext.tasks.Loop.cancel") instead.

New in version 1.2.
leaden jasper
#

or did they just use the wrong word here?

valid niche
#

!d discord.ext.tasks.Loop.cancel

unkempt canyonBOT
leaden jasper
#

so does is_being_cancelled() come to use after stop()?

cinder horizon
#

@valid niche @boreal ravine it worked...i tried smtn else

#

thenks for showing up tho

boreal ravine
#

no problem

valid niche
#

looking at it, it seems rather odd

leaden jasper
#

well im running a task and after some event it starts another task where in that task it stop()s the first task, letting it run its last loop, and in the meantime waits until its done with is_being_cancelled()

#

with the point being to avoid overwriting the same data

twilit scarab
#

Hello guys, can you help me out how to get the reason (begruendung) connected with the name (user.id) so i can display a members warnings?

This is my code so far

@client.command(pass_context = True)
async def warnings(ctx,user:discord.User):
  if user.id in [x["name"] for x in report["Mitglieder"]]:
      gruende = [x["Begruendung"] for x in report["Mitglieder"]]
      IDENT = [x["name"] for x in report["Mitglieder"]]
      await ctx.channel.send(f"{user.name} wurde bereits {IDENT.count(user.id)} mal verwarnt! wegen {gruende}")
  else:
    await ctx.channel.send(f"{user.name} wurde noch nicht verwarnt")  

And this is the .json data where the information is from

{"Mitglieder": [{"name": 502804107040653312, "Begruendung": ["taktisches Warten"]}, {"name": 290991651755786240, "Begruendung": ["baseraid"]}, {"name": 766247684859363359, "Begruendung": ["darum"]}, {"name": 502804107040653312, "Begruendung": ["TEST"]}, {"name": 569670203345207306, "Begruendung": ["TEST"]}, {"name": 766247684859363359, "Begruendung": ["Schuldspruch"]}, {"name": 766247684859363359, "Begruendung": ["Tralala"]}, {"name": 290991651755786240, "Begruendung": ["Dumbo"]}, {"name": 385001631265062913, "Begruendung": ["Datzbert"]}, {"name": 290991651755786240, "Begruendung": ["Dullibert"]}], "name": [], "Begruendung": []}

Im thankful for any help!

slim whale
#

how i can make my bot delete his message after 3 seconds?

#

await asyncio.sleep(3)
await channel.delete_messages(1)

#

i have this but doesnt work xd

twilit scarab
#

ctx.send(delete_after=5)

slate swan
#

Code?

slim whale
twilit scarab
#

or in your case 3 instead of 5

slim whale
#

so i need to change the channel delete thing for that

twilit scarab
#

because that means the ctx which was send will be deleted after 5 seconds

slim whale
#

ohhh okkk

#

It works! thanks

twilit scarab
#

You're welcome

slate swan
#

No erros?

#

Does it send the embed?

sweet geyser
#

For some reason

#
async def on_member_join():
    print("member joined")
#

this works

#

but this doesnt

async def on_member_remove():
    print("member left")
#

I tried on_member_leave too

#

it didn't work

#

only on_member_join worked

#

i have enabled intents to

slate swan
#
async def membercount():
    guild = bot.get_guild(serverid)
    totalchannel = bot.get_channel(totalmembercountchannel)
    humanchannel = bot.get_channel(humancountchannel)
    botchannel = bot.get_channel(botcountchannel)
    true_member_count = len([m for m in guild.members if not m.bot])
    total_member_count = guild.member_count
    bot_count = len([m for m in guild.members if m.bot])
    await humanchannel.edit(name=str(true_member_count)+" Members |:star:") # HUMANS
    await totalchannel.edit(name=str(total_member_count)+" Total Members |:sparkles: ") # TOTAL
    await botchannel.edit(name=str(bot_count)+" Bots |:robot:")  #BOT COUNT```

Any1 know how to add boost count
sweet geyser
#

```python

#

add python in the line before to get highlighted text

#

silent chat

slim whale
#

xd

slate swan
sweet geyser
#

wait no

#

thats very weird thats not how t works

#

let me check the docs

#

so ez

slate swan
#

wait so instead of bot.get_serverboosts its guild_object.premium_subscription_count

sweet geyser
#
guild = bot.get_guild(<guild id>)
boost = guild.premium_subscribers
sweet geyser
#

get_server boosts is kinda different

#

premium_subscribers

#

i don't think get server boosts exists

#

even if it did you didn't specify the guild

slate swan
#

await boostchannel.edit(name=str(guild_object.premium_subscription_count)+" Boosts")

#

then that yeah

sweet geyser
#

Okay

sweet geyser
slate swan
sweet geyser
#

yes

slate swan
#
async def on_member_remove(member):
    channel = client.get_channel(ID)
    await channel.edit(name = 'Member count: {}'.format(channel.guild.member_count))```
sweet geyser
#

ye i did tat

slate swan
#

u tried that

#

hmmm

sweet geyser
#

also a recommendation

sweet geyser
#
await channel.edit(name = f'Member count: {channel.guild.member_count}')
slate swan
#

u looked at that

sweet geyser
#

oh wait i found what i was looking for

#

this is what i was looking for

slate swan
#

    await self.coro(*args, **kwargs)
  File "C:\Users\liamd\Desktop\Sen\MainGen\main.py", line 90, in membercount
    boost = guild.premium_subscription_count(boostchannel)
TypeError: 'int' object is not callable```
sage otter
#

I mean the error is self explanatory. You tried to pass arguments into an attribute.

#

premium_subscription_count isn’t a method. It’s an attr

slate swan
#

sorry am new to python aha trying something different from js

spark mortar
#

How to use await edit ?

slate swan
sage otter
slate swan
sage otter
slate swan
#

@sage otter

async def membercount():
    guild = bot.get_guild(serverid)
    totalchannel = bot.get_channel(totalmembercountchannel)
    humanchannel = bot.get_channel(humancountchannel)
    botchannel = bot.get_channel(botcountchannel)
    guild = bot.get_guild(serverid)
    boost = guild.premium_subscription_count(boostchannel) --  -- this line
    true_member_count = len([m for m in guild.members if not m.bot])
    total_member_count = guild.member_count
    bot_count = len([m for m in guild.members if m.bot])
    await humanchannel.edit(name=str(true_member_count)+" Members |⭐") # HUMANS
    await totalchannel.edit(name=str(total_member_count)+" Total Members |✨ ") # TOTAL
    await botchannel.edit(name=str(bot_count)+" Bots |🤖")  #BOT COUNT
    await boostchannel.edit(name=str(guild_object.premium_subscription_count)+" -- this line
Boosts")```
sage otter
#

Consider using f strings

#

name=f"Boost Count: {guild.premium_subscription_count}"

slate swan
tawdry mist
valid niche
#

read this

manic wing
#

can someone sum up what get_prefix is pls

#

or link to a docs

valid niche
#

that last point is extremely important to keep in mind, because it means if you use replit to host your bot, you have a chance of literally just being banned from discord

slate swan
valid niche
#

!d discord.ext.commands.Bot.command_prefix

unkempt canyonBOT
#

The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.

An empty string as the prefix always matches, enabling prefix-less command invocation. While this may be useful in DMs it should be avoided in servers, as it’s likely to cause performance issues and unintended command invocations.

manic wing
#

eh

sage otter
valid niche
#

a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.

slate swan
sage otter
#

bruh

#

put it where you change the name of the boost channel.

#

inside the edit method

slate swan
#

sp

#

so
await boostchannel.edit(name=f"Boost Count: {guild.premium_subscription_count}")

#

@sage otter

sage otter
#

👌

bright latch
#

I have a question how i can make the size from a discord cdn url better

#

because on streams/guild thats not work

#

.png?size=80

slate swan
#

File "C:\Users\liamd\Desktop\Sen\MainGen\main.py", line 91, in membercount
boost = guild.premium_subscription_count(boostchannel)
TypeError: 'int' object is not callable

#

do i just remove that line

severe quarry
sage otter
#

Wait what the hell. Why are you passing for. That’s probably why it’s not sending anything.

sage otter
sage otter
#

You don’t need to pass after redefining

slate swan
#

intents = discord.Intents.default()
AttributeError: module 'discord' has no attribute 'Intents'

#

works on my pc not a friends tho

#

@sage otter

#

u know?

tulip frigate
#
   guild = bot.get_guild(897948463243874344)
   role =  guild.get_role(898339367242829825)
   print("people:" + str(role.members))

why does this get me an empty list? over 500 ppl have the role

sage otter
#

No not really. That definitely exist. You’re friend just isn’t doing something t right.

tulip frigate
#

they are in a task, and the task waits for the bot to be ready

sage otter
#

Yeah but do you have them in your code at all

tulip frigate
#

intents = discord.Intents(messages=True, guilds=True, reactions=True)

#

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

sage otter
#

do intents = discord.Intents.all()

#

And restart and try again

tulip frigate
sage otter
#

What library is it

tulip frigate
#

edpy

sage otter
#

what?

tulip frigate
#

enhanced discord py

sage otter
#

That’s literally the same thing

#

It’s just a fork

#

With mods.

#

I doubt they changed the intent system. Do what I said and try again.

tulip frigate
#

they did, i got told so. other bots i did like this work

#

but ok, let me try

#

actually, i do get some discord api related stuff

#

well well a new app worked

sage otter
#

wow literally nothing changed

tulip frigate
#

Got told so and it worked on other bots i worked with shrug

sage otter
#

Not sure who told you that garbage but it’s false.

tulip frigate
#

anyways, thanks for helping out here I guess hmm

sage otter
#

It ended up working in the end?

tulip frigate
#

yeah, so do other of my bots thinkRoll

rotund nova
#

low prays vps?

long cove
#

Anybody else having their utils.get or utils.find returning non-objects and non-Nonetype values

rotund nova
#

Good vps bot low prays and option paysafecard

slate swan
#

.

oak falcon
#

can I hold reference to one msg in another channel msg?

#

I want channel with history of specific content but copied from original message, and if someone edits the message I need original message reference to be in body of history channel message

#

I know 😄

#

right now I am comparing msg.content

#

which is shitty solution

#

I would like to have id of one message in another message as a reference

spark kite
#

Can someone help me? My on_reaction_add event is only being called when the bot reacts to a message and not when someone else reacts to a message

#

I don't know why this is happening it used to work, then I tried to change the event and it stopped working so I reset my version to the original code but that doesn't work anymore

wicked atlas
#

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

spark kite
#
@client.event
async def on_reaction_add(reaction,user):
  print(reaction.message.author)
  
  print(user.name)
  print(reaction.emoji)
  if str(reaction.message.author) == "mybot#3923" and reaction.emoji == "🖕" :
    await reaction.message.channel.send("Hey don't react with that emoji to me!")
    print("hi")
    print("hsjhsdjsds")
spark kite
#

it only prints when its the bot itself that reacts

#

i have no idea why since the event should be called when anyone reacts

wicked atlas
#

Which prints?

#

There are quite a few

spark kite
#

print(reaction.message.author)
print(user.name)
print(reaction.emoji)

#

This code used to work perfectly fine until today

wicked atlas
#

Before I try and think of why this isn't working, you know you can also do

reaction.message.author == client.user
```to test if it's the bot user right?
#

Better in the long run

spark kite
#

oh yeah I just forgot to update it

wicked atlas
#

Perhaps you need to enable some intents

#

Do you change your bot's intents anywhere?

spark kite
#

I never had any enabled before when it was working however today I tried enabling to see if they would work

#

I have them all enabled now

wicked atlas
#

Have you tried using on_raw_reaction_add?

spark kite
#

yes and it worked I was just unsure of how to get the message author and reaction with that and wanted to find out why

on_reaction_add

would not work

#

How would I access the author and emoji if I use that because it only takes in payload?

wicked atlas
#

The payload has that information

#

!d discord.RawReactionActionEvent

unkempt canyonBOT
#

class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
spark kite
#

When I run it I get told that reaction and user does not exist

#

in

  print(reaction.message.author)
  print(user.name)
wicked atlas
#

If you're using on_raw_reaction_add, it's because it has different argument passed in than on_reaction_add

spark kite
#

so how would I get the author and emoji with on_raw_reaction_add through the payload?

wicked atlas
#

payload.emoji and payload.user_id

#

Or if you have member intents, you might be able to do payload.member

#

But to get the message, you can only get the id

spark kite
#

Is there a way to get the user who added the reaction in a dm, since payload.member is only for guilds?

#

I dont see a parameter to do this so I assume you can't

spark kite
#

apparently now the on_reaction_add will only work in a guild

#

so that is why it is not called

#

I was testing it in a dm

#

I just have one question

#

I am new to programming

spark kite
#

since they do the same thing

vocal hollow
#

is there any way to get all attributes of a channel in one variable for discord.py?
like all the permissions, position, name, etc

#

and then use it later to make the channel again

pliant gulch
#

!d discord.TextChannel.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.
vocal hollow
#

no not clone like basically when a channel is deleted it just makes it again from data it already has stored

#

but idk how to get the permissions and stuff in a variable

visual island
vocal hollow
#

it says invalid syntax

visual island
#

name: channel.name what's this

vocal hollow
#

the name of the channel

visual island
#

it will already included in your dict

#

you dont need to put the name there again

vocal hollow
#

ok

#

it works thanks, but how would i create the channel again exactly with this info?

visual island
#

oh, you want to create a channel with it

vocal hollow
#

ye

visual island
#

remove the if not name.startswith("_") part

vocal hollow
#

ok

visual island
#

you probably should've use .clone() its 1000% easier

vocal hollow
#

noo im trying to make it so that when my bot joins a server, it stores all the channels & their attributes and then after that in the future if the channel is ever deleted then it can easily recreate it with the data it already has

pliant gulch
#

Store the channel in a variable, when the channel is deleted call .clone() on the variable

visual island
#

but, you can use this:

channel = guild.create_text_channel(type("channel", (object,), attr_dict))
```not sure if this will work but just try
pliant gulch
#

what

visual island
#

hmm?

vocal hollow
visual island
#

yes

vocal hollow
#

kk

#

how ab the posititon

#

like where it is in the category

pliant gulch
#

It creates a channel with all of the same properties

#

So yes, it does create it in the same position

vocal hollow
#

ok

vocal hollow
visual island
visual island
#

wait, the channel which just cloned?

pliant gulch
vocal hollow
#

no in the first step io have to get the channel and store it in a diff file or something and then when it is deleted i retrieve that info and clone it

#

but how doo i store it in a variable

visual island
#

so I made it with the raw way, type()

pliant gulch
#

That just makes no sense here

vocal hollow
#

yh it works i did it like this

#

tysm

#

wait i dont think it works when i do it like this the result was this

visual island
visual island
vocal hollow
#

wdym

vocal hollow
pliant gulch
#

And with what you did I'm pretty sure something would've broken

#

Probably with the bases

vocal hollow
#

??

slate swan
#

how can i use discord.Game to retrieve the name of the game a user is playing

distant tree
#
bot.guild_ids = []

async def get_guild_ids(bot):
    for guild in bot.guilds:
        await bot.guild_ids.append(guild.id)

get_guild_ids(bot)

print(bot.guild_ids)
Warning (from warnings module):
  File "C:\Users\cwals\Documents\GitHub\proxy-testing\main.py", line 70
    get_guild_ids(bot)
RuntimeWarning: coroutine 'get_guild_ids' was never awaited
[]

If I await it it doesn't run. Gives me the error await outside function

slate swan
#

How can I print the actual error in this code instead of a discord object:

@decode.error
async def decode_error(error, ctx):```
slate swan
distant tree
slate swan
#

Thats not normal

#

does it give an error?

distant tree
#

something along those lines

slate swan
#

Oh right

#

you can only use await in async functions

#

so you'd have to have something like this

async def caller()
await get_guild_ids()

#

and to run caller in the first place you need an async loop

distant tree
distant tree
slate swan
#

you basically need to make a loop that can run async functions

#

which has to be an async loop

distant tree
#

i forgot loops existed

slate swan
#

yah its pretty unnecessarily complex

simple kettle
#

Does anyone know how to keep the name and value in embed message on the same line?

#

so for example it would show "ping: shows latency in ms" all in one line

slate swan
#

Cant you just write name="Ping: {latency}"

simple kettle
#

i think when i do that it gives me a error saying there is not a value set but let me try it real quick

visual island
#

embed field needs name and value as the required argument

slate swan
#

like an empty string might work

visual island
#

no

simple kettle
#

does not work

#

there has to be something in there

visual island
#

just use the embed's description

simple kettle
#

oh

#

i did not think about that

distant tree
slate swan
#

async is a function asyncio calls the function

distant tree
#

could you possibly tag somewher i could learn about async loops?

#

not an async loop?

#

it's supposed to call the guild function but it didn't work so i changed it

slate swan
#

Yah sure one moment I have a great tutorial

#

In today's video, I'll be talking to you about asynchronous programming in python. This Python Async tutorial will cover the 'async' and 'await' keyword, coroutines, futures and tasks, and some basic features from the asyncio module in Python. This video is for intermediate programmers, and it's recommended you have Python 3.7 or above.

💻 Algo...

▶ Play video
visual island
# pliant gulch Probably with the bases

yeah, but I eventually made the worst way to clone a channel using the attributes

import inspect
attr_dict = {name: value for name, value in inspect.getmembers(ctx.channel) if name != "__slots__"}
channel = await type("channel", (discord.abc.Messageable, discord.abc.GuildChannel, discord.mixins.Hashable,), attr_dict).clone()
#

I can't find a way to create a channel using the object

pliant gulch
#

What do you mean create a channel using the object?

visual island
pliant gulch
#

You would need to read the data via the HTTPClient and send a POST request to the guilds channel

#

then update the guilds internal channel cache

visual island
#

can't you do it without messing with HTTPClient?

loud junco
#

from discord import command

loud junco
#

i forgot ;-;

pliant gulch
#

Discord.py creates objects which keyword, represents the discord object

#

It requires the HTTPClient and the gateway in order to make the objects act upon the objects they represent

distant tree
#

just to be clear it is required to await an append correct?

forest vortex
loud junco
distant tree
forest vortex
visual island
pliant gulch
#

Haven't you constructed a channel object already?

distant tree
#
bot.guild_ids = []

async def get_guild_ids(bot):
    for guild in bot.guilds:
        await bot.guild_ids.append(guild.id)

asyncio.get_event_loop().run_until_complete(get_guild_ids(bot))

print(bot.guild_ids)
======== RESTART: C:\Users\cwals\Documents\GitHub\proxy-testing\main.py ========
[]

All I'm trying to do is append all of the guilds (their ids) that the bot is in into the list.

simple kettle
#

Is there anyway to get the number of messages a member has sent in a guild

pliant gulch
#

Or do you mean a built in way to send the http request

#

without making your own

pliant gulch
#

Holdon

visual island
unkempt canyonBOT
#

discord/http.py line 845

def create_channel(```
pliant gulch
#

If it didn't then there wouldn't be Guild.create_text_channel

distant tree
#
    @commands.Cog.listener()
    async def on_ready(self):
        async def get_guild_ids(self):
            for guild in self.bot.guilds:
                await self.bot.guild_ids.append(guild.id)
        asyncio.get_event_loop().run_until_complete(get_guild_ids(self))
        print(bot.guild_ids)
RuntimeWarning: coroutine 'Events.on_ready.<locals>.get_guild_ids' was never awaited
#

It just crashed.

pliant gulch
#

append is not a coroutine, you do not await it

visual island
pliant gulch
#

And your in a coroutine

#

You don't need to do run_until_complete

#

Just await get_guild_ids

#

Why do you even have this in a nested function?

#

Just do it inside of on_ready without the nested function, you don't need it

distant tree
simple kettle
#

instead of this being a certain channel can i somehow make it get the history in all channels in the guild

counter = 0
async for message in channel.history(limit=200):
    if message.author == client.user:
        counter += 1
distant tree
#

i've used the append function so many times before. i have no clue why it stays in my mind as if it needs to be awaited.

pliant gulch
visual island
pliant gulch
#

Iterate through the attrs of the channel

#

Example: If it wasn't slotted you could do for name, value in obj.__dict__.items():

visual island
loud junco
#

what does this means

pliant gulch
#

That means you can use getattr

visual island
loud junco
visual island
#
import inspect
attr_dict = {name: value for name, value in inspect.getmembers(ctx.channel) if name != "__slots__"}
channel = await bot.http.create_channel(ctx.guild.id, 0, **attr_dict)
print(channel)
```this works but doesn't create the channel in the right position
pliant gulch
#

Does attr_dict contain a position?

visual island
#

oh wait, the method doesn't have category kwarg?

pliant gulch
#

You would have to reverse engineer create_text_channel in discord.py ¯_(ツ)_/¯

#

I'm busy right now as I'm implementing application commands

#

Otherwise I'd give more in-depth help

visual island
#

why is it so hard to just create a channel with the object 😔

pliant gulch
#

Because that just sounds dumb in itself

loud junco
#

is this how u get user id?

#

🤣 🤣 🤣

visual island
#

worked!!

#

code:

import inspect
attr_dict = {name: value for name, value in inspect.getmembers(ctx.channel) if name != "__slots__"}
channel = await bot.http.create_channel(ctx.guild.id, 0, parent_id=attr_dict["category"].id, **attr_dict)
polar ice
#
@client.listen("on_message")
async def automated_replies(message):
    if message.author == client.user:
        return


    if any(word in case_insensitive for word in forbiden_words):
        msg = f"{message.author}, Please don't use language like that."
        await message.channel.send(msg)
        await message.delete()``` Any ideas why message.delete isnt working?
steel trench
#

Which is done by

#

Uh

#

Idk I forget the exact wording

polar ice
#
client.remove_command("help")```
steel trench
#

Yeah

#

That

slate swan
#

shipit subclass the help cmd instead of removing it and creating a new one , its a lot more efficient

#

!d discord.ext.commands.HelpCommand

unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
loud junco
#

@maiden grove

#

sry wrong cookie

slate swan
#

how do i check if someone is the owner of the guild?

slate swan
slate swan
#

you can compare author's id with guild owner's id

#
if ctx.author.id == ctx.guild.owner_id```
slate swan
#

i wanna check if the person is the guild owner without a id or name

loud junco
#

i dont think u can

slate swan
#

you mean like a decorator check?

loud junco
#

its like recognising a person wihout identification card

#

unless u know that guy if not u are not gonna know who is him

slate swan
#

dang

slate swan
#

btw why dont you want to do that by if statement?

slate swan
slate swan
#

since ids are the recognisation of all discord objects

#

dang

#

ill check the api reference deeply

#

to see what i can do

#

sure thing

#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a “server” in the official Discord UI.

x == y Checks if two guilds are equal.

x != y Checks if two guilds are not equal.

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
slate swan
#

it would have everything you can do with guild's owner

#

alr

slate swan
slate swan
#

if you mind telling

slate swan
#

oh nice

#

so @commands.has_permission() check?

slate swan
#

yea thats it

#

yeah i just checked

loud junco
#

someone help

#

is this how u find user id?

slate swan
#

yea if message is a discord.Message object

#

or Context

patent lark
#

message object, likely you're using this when on_message is called i assume

slate swan
#

hi i want client.events docs discord.py can anyone help

patent lark
unkempt canyonBOT
#

class discord.Client(*, loop=None, **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").
patent lark
#

the embed title link will bring you to the documentations

slate swan
slate swan
patent lark
#

if you're making a discord bot, dont use discord.Client, use commands.Bot

slate swan
patent lark
#

!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
slate swan
#

i use discord.ext.commands.Bot

#

...

#

okay

#

leme switch to bot then

loud junco
#

i know its dumb but

#
@bot.command(name='start')
async def start(ctx: commands.Context):
  userid = ctx.author.id

  if has_registered == True:
    await ctx.channel.send('Do you wanna start all over again?')
  else:
    db[userid + 'pogchop'] = 0
    db[userid + 'cooked_pogchop'] = 0
    db[userid + 'beef'] = 0
    db[userid + 'steak'] = 0
    db[userid + 'wool'] = 0
    db[userid + 'treasure_map'] = 0
    db[userid + 'wither_skull'] = 0
    db[userid + 'blaze_rod'] = 0
    db[userid + 'blaze_power'] = 0
    db[userid + 'ender_pearl'] = 0
    db[userid + 'eye_of_ender'] = 0
#

:)

#

is there a better way to do this

#
item = {
  'mobdrop': {
    'pogchop' : 0,
    'cooked_pogchop' : 0,
    'beef' : 0,
    'steak' : 0,
    'wool' : 0,
    'treasure_map' : 0,
    'wither_skull' : 0,
    'blaze_rod' : 0,
    'blaze_power' : 0,
    'ender_pearl' : 0,
    'eye_of_ender' : 0
  },
    
  'misc':{
    'cobble' : 0,
    'coal' : 0,
    'iron' : 0,
    'diamond' : 0,
    'gold' : 0,
    'netherite_scraps': 0,
    'netherite_ingot' : 0,
    'redstone' : 0,
    'soul_sand' : 0,
    'wood' : 0,
    'bed' : 0
  },
    
  'illegal': {
    'bedrock' : 0,
    'bedrock_trophy' : 0,
    'pogchamp' : 0
  }
}
#

can i use for loop for that?

slate swan
#

idk

#

experts there

loud junco
#

ok

high pollen
#

Y does this unban command not work?

@has_permissions(ban_members = True)
async def unban(self, ctx, member:discord.Member):
    banned_users = await ctx.guild.bans()
    member_name, member_discriminator = member.split("#")

    for ban_entry in banned_users:
        user = ban_entry.user

        if (user.name, user.discriminator) == (member_name, member_discriminator):
            await ctx.guild.unban(user)
            await ctx.send(f'**UNBANNED {user.mention}**')
            return```
#

This is in a cog

#

Error:-

discord.ext.commands.errors.MemberNotFound: Member "295499172994351105" not found.```
#

The user is banned

#

Anyone?

final iron
final iron
#

!unban 669343267589980160

#

Would not work

#

But

#

!unban Water_Gazes#9999

#

Would

high pollen
final iron
high pollen
#

ok

final iron
high pollen
#

member not found

final iron
#

^

#

The way he does some things are just terrible

boreal ravine
#

@high pollen

#

😂

opaque plinth
high pollen
high pollen
boreal ravine
# high pollen did not get u

Your unban command only takes the full username and not an ID. If you want an ID to be unbanned use discord.User

opaque plinth
#

use typing union ig

boreal ravine
#

what anu said

high pollen
#

ok ty

#

i am remaking it

#

this does not work

boreal ravine
#

what

slate swan
#

can you asign custom variables to commands.Bot client?

boreal ravine
#

!botvar

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

slate swan
# boreal ravine yes

can you do this and still be able to change the values when you have intents arg passed into it?

boreal ravine
#

theres nothing blocking you

slate swan
#

because i have tryed that with log_channel = 0 and in a on_ready i get_channel the channel and set the log_channel to it

#

i try to send a message to it and it says its a int and not a discord.TextChannel

boreal ravine
#

I mean to get channels your supposed to do

slate swan
#

bot.get_channel?

boreal ravine
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
slate swan
#

ik

boreal ravine
slate swan
#

thats what i did

boreal ravine
#

Hm

slate swan
#

also

#

my bot is verified and only have members intents

slate swan
#

does intents auto default to everything enabled except members and presence intents or does it now have message default to False

cerulean osprey
#

Yo so a few questions. How would I go abt getting a User's ID? and if I were to want to restrict a command to only be accessed by a certain user could I just do

    <code>
else:
    return```
boreal ravine
slate swan
#

commands.Bot(intents = intents_var)

boreal ravine
#

Hm

#

whats in the intents var

slate swan
slate swan
cerulean osprey
#

So ctx.author will give ID? and not name?

boreal ravine
loud junco
#
bot.command(name='inv')
async def inv(ctx: commands.Context):
  userid = ctx.author.id
  names1 = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender']
  res = '__items__\n'
  for name, val in {userid}names1:
    res += f"{name}: {val}\n"
  await ctx.channel.send(res)
```can someone help?
sullen shoal
cerulean osprey
#

Alright

slate swan
cerulean osprey
#

Ok, thank you :D

boreal ravine
slate swan
sullen shoal
slate swan
boreal ravine
loud junco
#

the logic looks sucks

#

lemme reorganise it

slate swan
#

i only have members intents so :/ and i do not need anything else

boreal ravine
#

Hm

#

!d discord.ext.commands.Bot.command_prefix

unkempt canyonBOT
#

The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.

An empty string as the prefix always matches, enabling prefix-less command invocation. While this may be useful in DMs it should be avoided in servers, as it’s likely to cause performance issues and unintended command invocations.

boreal ravine
#

I mean u could try that

boreal ravine
sullen shoal
#

looks like prefix variable's value is "prefix"

slate swan
sullen shoal
# slate swan

so you're still confused why you got the error or what

slate swan
#

im 100% sure something is going on because in the on_ready where it sets the bot_log_channel to a channel it also sends this to the log channel too say when it started

sullen shoal
#

what do you exactly need help with

boreal ravine
# slate swan

Wheres this in your code it might be overwriting the variable

boreal ravine
sullen shoal
#

because you already fixed your error with those 3 screenshots

#

you assigned 0 to the attribute

#

hence its an int

#

int has no attribute as send

slate swan
#

hang on

#

the on_ready listener is not being called???

#

why would this be

#

if i dont use intents it is called but if i parse intents into commands.Bot its not called

high pollen
# final iron Completely rewrite it

I rewrote it. this returns a error

@has_permissions(ban_members = True)
async def unban(self, ctx, *, member):
    print(member)
    user = await self.bot.get_user(member)
    if user is not None:
        try:
            await ctx.guild.unban(user)
            await ctx.send(f'UNBANNED {user.mention}')
        except:
            await ctx.send(f'{user.mention} IS NOT BANNED')```
Error:-
```user = await self.bot.get_user(member)
TypeError: object NoneType can't be used in 'await' expression
The above exception was the direct cause of the following exception:
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object NoneType can't be used in 'await' expression```
sullen shoal
#

who are we supposed to know that without code

loud junco
#
@bot.command(name='inv')
async def inv(ctx: commands.Context):
  userid = ctx.author.id
  names1 = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender']
  names2 = ['cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed']
  names3 =['bedrock', 'bedrock_trophy', 'pog_champ']
  res = '__items__\n'
  for name in names1:
    res += f"{name}: {userid}{name}.values()\n"

  res += '__misc__\n'
  for name in names2:
    res += f"{name}: {userid}{name}.values()\n"

  res += '__illegal__\n'
  for name in names3:
    res += f"{name}: {userid}{name}.values()\n"
  await ctx.channel.send(res)
```output 

items
pogchop: 757508305256972338pogchop.values()

items
pogchop: 0

slate swan
#

ok the on_ready is finaly called????? wtf is this

sullen shoal
#

{name.values()}

loud junco
sullen shoal
#

dont think thats going to help though

loud junco
#

=.=

sullen shoal
#

where even is the dict

#

its just a list of strings

loud junco
#

wait

#

i deleted it accidentally

#

how do i call a dictionary again? ;-; google

sullen shoal
#

i never saw someone calling a dict

#

not sure what you are talking about

sullen shoal
opaque plinth
#

u should use discord.User

#

member: discord.User

sullen shoal
sullen shoal
#

also member is string there

boreal ravine
#

also why have *

opaque plinth
#

the code is fully wrong rewrite again

boreal ravine
#

you cant

sullen shoal
#

actually there are better ways to unban users

boreal ravine
#

discord limitation

boreal ravine
loud junco
#
item = {
  'mobdrop': {
    'pogchop': 0,
    'cooked_pogchop': 0,
    'beef': 0,
    'steak': 0,  
    'wool': 0,
    'treasure_map': 0,
    'wither_skull': 0,
    'blaze_rod': 0,
    'blaze_power': 0,
    'ender_pearl': 0,
    'eye_of_ender': 0
  },
    
  'misc':{
    'cobble': 0,
    'coal': 0,
    'iron': 0,
    'diamond': 0,
    'gold': 0,
    'netherite_scraps': 0,
    'netherite_ingot': 0,
    'redstone': 0,
    'soul_sand': 0,
    'wood': 0,
    'bed': 0
  },
    
  'illegal': {
    'bedrock': 0,
    'bedrock_trophy': 0,
    'pogchamp': 0
  }
}
###################################
@bot.command(name='inv')
async def inv(ctx: commands.Context):
  userid = ctx.author.id
  res = '__items__\n'
  for name in item['mobdrop']:
    res += f"{name}: {userid}{name.values()}\n"

  res += '__misc__\n'
  for name in item['misc']:
    res += f"{name}: {userid}{name.values()}\n"

  res += '__illegal__\n'
  for name in item['illegal']:
    res += f"{name}: {userid}{name.values()}\n"
  await ctx.channel.send(res)
```idk why its not working
sullen shoal
#
member = discord.Object(id=0) # user ID
try:
    await guild.unban(member)
except discord.NotFound:
    # member not banned / doesnt exist 
boreal ravine
#

😂

boreal ravine
#

maybe soon 👀

loud junco
boreal ravine
#

So?

boreal ravine
sullen shoal
#

i would suggest to store it this way,

names = [("key1",0),("key2",0),("key3",0)]
for key, value in names:
    ...```
#

if the value is not going to be changed

#

from 0

#

otherwise use dict

loud junco
sullen shoal
#
_dict = dict(name1="test")
for item in _dict:
    print(_dict.get(item))```
#

or,

_dict = {"name1":"test"}
for item in _dict:
    print(_dict.get(item)) 
loud junco
#

er

#

the output will be different

#

i wan
pog_chop: 0

#

instead of
0

sullen shoal
#

item holds the name of the key

#

as string

loud junco
#

so can i print item.values()?

#

or it will give the error just now

sullen shoal
#

didn't i show you an example like 5 messages above

#

to get the value of item

#
_dict = {"name1":"test")}
for item in _dict:
    print("name", item)
    print("value",_dict.get(item)) 
high pollen
#

I used this

high pollen
boreal ravine
loud junco
#

output
items
pogchop: userid
cooked_pogchop: userid

@bot.command(name='inv')
async def inv(ctx: commands.Context):
  userid = str(ctx.author.id)

  res = '__items__\n'
  for name in item['mobdrop']:
    userid += name
    res += f"{name}: userid\n"

  res += '__misc__\n'
  for name in item['misc']:
    userid += name
    res += f"{name}: userid\n"

  res += '__illegal__\n'
  for name in item['illegal']:
    userid += name
    res += f"{name}: userid\n"
  await ctx.channel.send(res)
#

whats wrong lmao

#

lemme try
res += f"{name}: {userid}\n"

sullen shoal
#

looks like you have no idea how f strings work

loud junco
#
@bot.command(name='inv')
async def inv(ctx: commands.Context):
  res = '__items__\n'
  for name in item['mobdrop']:
    userid = str(ctx.author.id)
    userid += name
    res += f"{name}: {userid}\n"

  res += '__misc__\n'
  for name in item['misc']:
    userid = str(ctx.author.id)
    userid += name
    res += f"{name}: {userid}\n"

  res += '__illegal__\n'
  for name in item['illegal']:
    userid = str(ctx.author.id)
    userid += name
    res += f"{name}: {userid}\n"
  await ctx.channel.send(res)
#

how do i print the value of {userid}

#

{userid.values()}?

#

the value is in database

sullen shoal
#

well i give up i have wasted alot of time

cerulean osprey
#
@client.command()
async def activity(ctx, arg1, arg2):
    if ctx.author.id == 591047383044063244:
        if arg1.lower == 'listening':
            await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=arg2))
        
        elif arg1.lower == 'playing':
            await client.change_presence(activity=discord.Game(name=arg2))

        elif arg1.lower == 'watching':
            await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=arg2))
        
        elif arg1.lower == 'streaming':
            await client.change_presence(activity=discord.Streaming(name=arg2, url='url'))
    else:
        await ctx.send('This command is for Wind only!')```
I am trying to create a command that will let me change the presence within discord. This is what I came up with but it is not responding. I had an else statement there and it would only reply with the else statement.
#

o shit advertising, mb hold on

sullen shoal
#

this is why you complete your basic course of python before using libs like discord.py.
you seem to have no idea what methods are, the only thing you care about is getting your values() somehow work no matter what object it is

#

this is my message to a person yesterday. hope this helps

loud junco
#

i just realised what is wrong

#

...

#

the key in dictionary and in my database is different

#

one missing _

#

🤦

heavy folio
warped spear
#

how do you fix corutine 'x' was never awaited

#

i tried adding the loop but diidn work

maiden fable
#

@warped spear await x()

ornate lichen
#
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/Users/aarav/Documents/GitHub/awaffle_bot/main.py", line 314, in help
    await message.clear_reactions()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/message.py", line 1309, in clear_reactions
    await self._state.http.clear_reactions(self.channel.id, self.id)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

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

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions```
#

im getting this whenever i put a reaction

#

on the bot

#

's embed

ornate lichen
#

sry did it alr

ornate lichen
#

are there any api which can allow my bot to have a kill function

maiden fable
#

Your bot didn't have the perms

ornate lichen
#

like dank memer

ornate lichen
maiden fable
#

Ah

#

That

#

Well, dank memer just uses a list of strings

ornate lichen
#

so theres no api?

maiden fable
#

Nah

ornate lichen
#

oh

heavy folio
#

could someone help

boreal ravine
heavy folio
boreal ravine
heavy folio
#

the first time i run the command, it'd return this ```py
Ignoring exception in command auc:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\user\Desktop\theBot\cogs\dankdaily.py", line 166, in auc
for x in points_count:
TypeError: 'NoneType' object is not iterable

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

Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 894, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 176, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not iterable```

boreal ravine
#

well poins_count is none

hushed siren
#

im making a help command for my bot but it gives an error saying

File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1280, in decorator
    self.add_command(result)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1149, in add_command
    raise CommandRegistrationError(command.name)
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
#

and the code is this:

@client.group(invoke_without_command=True)
async def help(ctx):

  em = discord.Embed(tittle = "Help", description = "Use ?help <command> for extented info on a command.", color = ctx.author.color)

  em.add_field(name = "Modration", value = "Kick, Ban, Unban, Mute And Unmute")

  em.add_field(name ="Fun", value = "No fun commands yet")

  await ctx.send(embed = em)



@help.command()
async def kick(ctx):

  em = discord.Embed(tittle = "Kick", description = "Kicks a member from the server", color = ctx.author.color)

  em.add_field(name = "Example", value = "?kick {User} {Reason} eg ?Kick Mixu#0720 Get out!")

  await ctx.send(embed = em)

@help.command()
async def ban(ctx):

  em = discord.Embed(tittle = "Ban", description = "Bans a member from the server", color = ctx.author.color)

  em.add_field(name = "Example", value = "?ban {User} {Reason} eg ?ban Mixu#0720 Get out!")

  await ctx.send(embed = em)

@help.command()
async def unban(ctx):

  em = discord.Embed(tittle = "Unban", description = "Unbans a member from the server", color = ctx.author.color)

  em.add_field(name = "Example", value = "?unban {User} {Reason} eg ?unban Mixu#0720 Appealed")

  await ctx.send(embed = em)

@help.command()
async def mute(ctx):

  em = discord.Embed(tittle = "Mute", description = "Mutes a member", color = ctx.author.color)

  em.add_field(name = "Example", value = "?mute {User} {Reason} eg ?mute Mixu#0720 spamming!")

  await ctx.send(embed = em)

@help.command()
async def unmute(ctx):

  em = discord.Embed(tittle = "Unmute", description = "Unmutes a muted member", color = ctx.author.color)

  em.add_field(name = "Example", value = "?unmute {User} {Reason} eg ?unmute Mixu#0720 mute appealed.")

  await ctx.send(embed = em)
tawdry perch
#

you might want to disable the default help command if you want to make your own

boreal ravine
unkempt canyonBOT
#

remove_command(name)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.

This could also be used as a way to remove aliases.
boreal ravine
#

do that first before making a help command

maiden fable
#

No

#

help_command = None in the bot constructor

slate swan
#

How do i send a message to a specific channel in every guild?im close but it only sends it to one

tawdry perch
#

you have to get the guild the channel is in + the channel for that guild

maiden fable
#

BTW that will rate limit u hard

slate swan
#

Rn my code looks like this im on mobile so indents are bad:

for guild in bot.guilds:
for channel in guild.channels:
if channel.name == "name":
h = channel.id
await bot.get_channel(h).send("msg")
#

Looks like that but idk if the for loop are right

slate swan
maiden fable
#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
maiden fable
#

Bruh

slate swan
slate swan
boreal ravine
slate swan
heavy folio
boreal ravine
#

¯_(ツ)_/¯

heavy folio
#

huh

slate swan
slate swan
#

Thx but i still have the same problemlemon_warpaint

outer violet
boreal ravine
outer violet
#

what do i do then

tawdry perch
#

install it

outer violet
#

install what

boreal ravine
tawdry perch
#

oh... right

tawdry perch
outer violet
#

yeah

tawdry perch
#

then thats the problem I'd say. I don't think replit has that module there

outer violet
#

oh

slate swan
#

How do bots even get bigger ratelimits?

boreal ravine
#

they dont

slate swan
#

Didnt big bots like the verified ones get bigger rate limits?

sullen shoal
#

rate limit is depends on invites

slate swan
#

On invites?

sullen shoal
#

discord will increase the limit to get ratelimited if your bot gets big (gets invited by many people)

heavy folio
maiden fable
rotund nova
#

Good vps bot low prays and option paysafecard

warm mirage
#

guys i need help im not sure how to fix this it isn't working for some reason and i tried fiddling with it for about 20 min now

frigid python
#

did you import discord?

frigid python
#

and enable it your code as well

warm mirage
#

yes i have everything

#

it still isn't workn

frigid python
#

intents enabled?

#

if yes, send the new code

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
#

how would i go about making my help command do something like -help ban

#

and list a new embed

#

about the ban command

warm mirage
#

just if it

slate swan
#

how did i not think about that

warm mirage
#

is that sarcastic or did you forget to use it?

slate swan
#

somehow

warm mirage
#

ok

slate swan
#

if message.content.lower() in any(['welc','welcome','welc']):

#

TypeError: argument of type 'bool' is not iterable

maiden fable
warm mirage
#

well i added intent yet it didn't do anything

maiden fable
#

@slate swan do u have intents?

boreal ravine
#

presence intents

maiden fable
#

U need presences intent

#

kayle.... just whyyyy

boreal ravine
#

dev portal

maiden fable
#

!d discord.Intents.presences

unkempt canyonBOT
#

Whether guild presence related events are enabled.

This corresponds to the following events:

on_presence_update()

This also corresponds to the following attributes and classes in terms of cache...

opaque plinth
#

also better do discord.Intents.all() and remove intents.members = True

maiden fable
#

Yea

opaque plinth
#

yes