#discord-bots

1 messages Β· Page 566 of 1

slate swan
#

Not surprised it hasn't been fixed yet, it's discord after all

boreal ravine
#

good to know people have been asking for this for a long time now i didnt know what to answer

slate swan
#

πŸ˜‚

shrewd pasture
#
Josh. β€” Today at 7:45 PM
      finished = discord.Embed(title="Versai Applications", description=f'Your Answer for Question 12: `{a10.content}`\nAre you sure you want to submit? Please react below!', color = discord.Colour.blue())
      print("first mark")
      msg = await ctx.author.send(embed=finished)
      await msg.add_reaction(checkmark)
      await msg.add_reaction(xmark)
      print("second mark")
      def check(reaction, user):
        print("3rd mark")
        return all((user.id==ctx.author.id, reaction.message.id==msg.id, str(reaction.emoji) in (checkmark, xmark)))
        print("4th mark")

      reaction = (await self.bot.wait_for('reaction_add', check=check))[0]
      if str(reaction.emoji) == checkmark:
        print("5th mark")

I get 0 errors and when i run it it gets to the 3rd mark before not working. Anyone know why? It works perfectly fine in the main server when someone runs it

boreal ravine
#

why is there a [0]

shrewd pasture
#

i dont remember the reasoning i was given but it was for reactions i believe

boreal ravine
#

hm

shrewd pasture
#

the code works fine in the serevr

#

just not in dms, however this code previously worked?

hard trail
#

Someone please help me

shrewd pasture
#

@hard trail whats up

slate swan
hard trail
#
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import random
from random import choice
import embed
import time
import prsaw 
from prsaw import RandomStuff

PREFIX = ("$")
bot = commands.Bot(command_prefix=PREFIX, description='')

@bot.event
async def on_ready():
  activity = discord.Game(name="$help", type=3)
  await bot.change_presence(status=discord.Status.online, activity=activity)
  print("Bot is ready!")

rs = RandomStuff(async_mode = True)


@bot.event 
async def on_message(message):
  if bot.user == message.author:
    return
  if message.channel.id == 874847853888036949:
    response = await rs.get_ai_response(message.content)
    await message.reply(response) 


    await bot.process_commands(message)

bot.run('My Token')```
#

My code and I keep getting an error

shrewd pasture
#

where

boreal ravine
#

whats the error

hard trail
boreal ravine
#

you need an api key

shrewd pasture
#

^

hard trail
#

Sorry what does that mean?

shrewd pasture
#

hence the error literally saying you need the api key

#

the api key to the wwebsite

#

what are you even trying to do?

boreal ravine
hard trail
#

Create a chat bot

shrewd pasture
boreal ravine
echo wasp
#

it is discord bot related

shrewd pasture
#

@echo wasp send it here then

echo wasp
#

sure give me a second

lyric moat
#

no its in js its just an example

shrewd pasture
#

if you really wanted that you can just run the code on a js file on a vps and make it run so it shows that lol and then have your main bot code on another server or folder obv

pliant gulch
#

It is a bug you mess with the device information when connecting to the websocket

#

It isn't intended

#

This is possible with discord.py but requires that you monkeypatch it

#

Not worth in IMO, and discord, could at any time fix it

shrewd pasture
#

some people go through so much trouble for something so little and useless

boreal ravine
#

sad

shrewd pasture
#

agreed

slate swan
#

how long is a bot token

#

@boreal ravine

boreal ravine
boreal ravine
#

the command isn't in a class

slate swan
lyric moat
#

im making a kill command but it does not work when i try

https://nekos.life/api/v2/img/kill
boreal ravine
unkempt canyonBOT
#

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

18
lyric moat
hollow palm
#

When trying to run the terminal command python -m pip install -U git+https://github.com/Rapptz/discord-ext-menus I get this error. Ive tried installing git several times but its still not working

GitHub

Contribute to Rapptz/discord-ext-menus development by creating an account on GitHub.

lyric moat
#

but what else could i use

boreal ravine
lyric moat
#

hmm

boreal ravine
#

wdym

#

just find another api

lyric moat
#

like i tried kill

boreal ravine
#

its not that hard

lyric moat
#

war

#

ok

pliant gulch
# slate swan token, not id

There should be 59 characters in a token iirc, 24 before the first period, 6 in the second and 27 in the last

#

I could be wrong though

pliant gulch
#

59* actually

#

Including the periods

boreal ravine
#

i did mean token but i didnt know how long it was

slate swan
#

No you didn't, you showed the ID πŸ’€

boreal ravine
#

I did

#

I thought he meant "id not token"

boreal ravine
#

???? πŸ€·β€β™‚οΈ

slate swan
boreal ravine
#

he did

slate swan
boreal ravine
#

I said they were 10-20 chars long

slate swan
slate swan
#

It's 59 chars long

slate swan
#

also, can you enable 2fa on a bot using a discord bot client or something hmmfam

pliant gulch
#

The bot owner turns on 2fa

#

Which then makes the bot 2fa

echo wasp
#

@rancid grail i need help error in what you helped setup

#
# bot.py
import os
import discord
from discord.ext import commands
from Moveitfolders import main

from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')

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

def check_if_it_is_me(ctx):
    return ctx.message.author.id == 786788350160797706

client = commands.Bot(command_prefix='$', intents=intents, owner_id=786788350160797706)
print (GUILD)

bot = client

@client.event
async def on_ready():
    for guild in client.guilds:
        print(guild.name)
        if guild.name == GUILD:
            break

    print(
        f'{client.user} is connected to the following guild:\n'
        f'{guild.name}(id: {guild.id})\n'
    )

    members = '\n - '.join([member.name for member in guild.members])
    print(f'Guild Members:\n - {members}')


@bot.command(name='ping')
async def ping(ctx):
    await ctx.channel.send("pong")


@bot.command(name='Moveit')
@commands.is_owner()
async def only_for_me(self, ctx):
    ctx.channel.send(main())

client.run(TOKEN)``` code and i never touched The other file
boreal ravine
#

self is only for things in classes

echo wasp
boreal ravine
#

yes

remote condor
#

Pls

boreal ravine
#

Profile?

#

what do you mean

echo wasp
#

profile?

remote condor
#

Like the command

boreal ravine
#

oh

remote condor
#

In which lobby

boreal ravine
remote condor
#

Ya

eternal ore
#

How can I edit/change a file from a message? For example

message = await ctx.send(file=discord.File(...))
await message.edit(?=discord.File(...))
echo wasp
boreal ravine
#
message = await ctx.send(file=discord.File(...))
await message.edit(file=discord.File(...))
eternal ore
echo wasp
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.
boreal ravine
#

hm your right

echo wasp
boreal ravine
echo wasp
eternal ore
slate swan
#

How do you make those page type help commands

boreal ravine
#

Page?

slate swan
#

Mhm

#

It'll be like

1/9

#

Then they're would be reactions to move pages

#

That should help

boreal ravine
#

I mean check for the reactions and if a user reacted edit the message

#

idk how

slate swan
#

How can you add several checks

slate swan
#

Noone

lyric moat
#

how can i make this command that tracks how many times you have said its prefix?

unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

spiral frigate
#

How can I check several conditions at once in the if statement?

#

code

    @commands.command(name= "ΠΎΡ‡ΠΈΡΡ‚ΠΈΡ‚ΡŒ")
    async def clear(self, ctx, amount=None):
        if amount==None or amount==0:
            await ctx.send("Π£Ρ€Π°")
tawdry perch
spiral frigate
tawdry perch
#

How's that?

spiral frigate
#

That's what I'm asking you

tawdry perch
#

So it always sent the Ypa?

spiral frigate
#

no, he is sending the current amount=None

tawdry perch
#

So what doesn't work?

spiral frigate
#

when I drive 0 it doesn't work in amount==0 either

tawdry perch
#

Oh, because it's string I guess

#

You should make it integer

#

Or, condition=="0"

spiral frigate
#

everything works

tawdry perch
#

Good

boreal ravine
zenith hare
#

Why when I try to get the uses of the event invitations on_member_join it doesn't work, but in "on_invite_create" it works, even when I convert the invite.uses to int?

#

console:

visual island
zenith hare
visual island
#

oh wait my bad, you sent the error

#

!d discord.ext.commands.Bot.fetch_invite fetch the invite

unkempt canyonBOT
#

await fetch_invite(url, *, with_counts=True, with_expiration=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gets an [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") from a discord.gg URL or ID.

Note

If the invite is for a guild you have not joined, the guild and channel attributes of the returned [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") will be [`PartialInviteGuild`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialInviteGuild "discord.PartialInviteGuild") and [`PartialInviteChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialInviteChannel "discord.PartialInviteChannel") respectively.
zenith hare
#

Do you think it could be because when I took the information out of the database I converted it to str?

visual island
#

your current invite is currently a str

rotund nova
#

.

slate swan
unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

rotund nova
#

And?

slate swan
#

Basic Python...

rotund nova
#

I already do it

#

but when i do it i got more errors

slate swan
#

Then maybe send these and not the previous one facepalm

jade tartan
#

hello any one here to help?

slate swan
#

Just send what you need help for

#

If someone can help they will

jade tartan
#

well i want to have the member get a specific role but the bot isnt really doing what am telling it do

slate swan
#

What's your code, what errors do you get, etc. etc.

jade tartan
#

here is my code

eager pawn
#

my goodness

#

please learn basic python

slate swan
#

UnboundLocalError: local variable 'member' referenced before assignment

#

You should indent this there:

jade tartan
distant tinsel
#

for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
client.load_extension(f"cogs.{filename[:-3]}")

#

help

slate swan
#

"help", doesn't give any information on what's not working

unreal mortar
distant tinsel
#

sorry to bother i figured it out

slate swan
#

!indents

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

slate swan
#

Fix your indentation

#

Wait

#

What is the entire code

icy mango
#

how do i fetch member name from on_member_edit

slate swan
icy mango
#

tell me what is the code to fetch it

slate swan
#

please

icy mango
slate swan
#

Have you imported intents??

#

ok then

icy mango
slate swan
#

on_member_edit is not even a valid event, it's on_member_update

#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

β€’ nickname

β€’ roles

β€’ pending...
slate swan
#

before.name -> after.name

#

yup

urban star
#

What is shard?

icy mango
slate swan
icy mango
#

how do i fetch member from on_message_edit

icy mango
#
@client.event
async def on_message_edit(before, after) :
slate swan
#

Yeah

icy mango
#

so will it work

slate swan
#

So?

icy mango
#

because i am not taking message as argument

#

argu are before and after only

slate swan
icy mango
#

oh yeah ok ok

#

thank you!

#

um

#
@client.event
async def on_message_edit(before, after) :
    mod_log = client.get_channel(mod_log_channel)
    embed = discord.Embed(title = "A message is edited!", color = discord.Color.red())
    embed.add_field(name = "Before Message", value = f"{before}", inline = False)
    embed.add_field(name = "After Message", value = f"{after}", inline = False)
    embed.add_field(name = "Message sent by", value = f"{before.author.name}", inline = False)
    embed.set_author(name = f"{before.author.name}", icon_url = f"{before.author.avatar_url}")
    embed.set_footer(text = "Developed by The Epix Ray", icon_url = "https://cdn.discordapp.com/attachments/881224361015672863/903317898016198787/channel-profile.png")
    await mod_log.send(embed = embed)
#

i would help but i dont know how to use cogs

icy mango
#
@client.event
async def on_guild_role_create(role) :

how do i fetch role author who created it?

oak falcon
#

hi guys, do you know how can I use users avatar as an emoji?

#

in discord of course πŸ™‚

cloud dawn
dapper cobalt
oak falcon
#

I think I am going to resize the picture

#

with PIL

slate swan
#

how would i check if the bot can join a voice channel? i use @commands.bot_has_permissions(connect = True) and it just says it does not have connect permissions

vocal magnet
# icy mango anyone

you'll need to use the audit log, since it's not included as part of the event

icy mango
#

i will understand it

vocal magnet
#

No, as I don't have code written.

glossy edge
#

How can i wait momentarily until an interaction is dispatched rather than a wait for stop in a view in dpy 2.0?

amber imp
#

help please?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'session'

glossy edge
#

I'm assuming that the Context object is the object passed into your command callback, and it doesn't have an attribute session

#

Or is this your subclass or something

reef shell
amber imp
reef shell
#

Hence the error is raised

glossy edge
#

What is your intention?

icy mango
#

can anyone send me a youtube tutorial you think is best to learn audit logs from dpy

reef shell
reef shell
#

And learn by reading the docs

amber imp
icy mango
reef shell
icy mango
#

i cant understand docs (i am finding how to fetch creator of a role in the docs) and it has been half hour

amber imp
#

!stb

unkempt canyonBOT
reef shell
#

As i said Context object doesn’t have any attribute session..
You have to use aiohttp.ClientSession() to do http requests

#

!d aiohttp.ClientSession

unkempt canyonBOT
#
class aiohttp.ClientSession(*, connector=None, loop=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, json_serialize=json.dumps, version=aiohttp.HttpVersion11, ...)```
The class for creating client sessions and making requests.
finite plinth
#

yo guys how to make a user like unreact from a reaction

old shoal
#

getting this issue

#

any fix?

slate swan
#

tab

old shoal
#

tab?

short jacinth
#

how do discord bots work?

brazen raft
short jacinth
#

what languages are used to develop discord bots?

dapper cobalt
old shoal
#

hmm

dapper cobalt
dusk pumice
#

What does this error mean?

Traceback (most recent call last):
  File "main.py", line 24, in <module>
    from ButtonPaginator import Paginator
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/ButtonPaginator/__init__.py", line 1, in <module>
    from .paginator import Paginator
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/ButtonPaginator/paginator.py", line 8, in <module>
    from discord_components import (
ImportError: cannot import name 'InteractionType' from 'discord_components' (/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/__init__.py)
old shoal
#

what should I change

dapper cobalt
#

Your indentation.

old shoal
#

or the gaps

dusk pumice
#

I think it's client = discord.Client()

dapper cobalt
#

!indent

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

dapper cobalt
dusk pumice
#

Okay

#

Hmm...............................

old shoal
#

now i shows this

#

I am good at Html5 and css

oak falcon
old shoal
#

but i was trying

#

python

dapper cobalt
#

Do you think that in any way this is correct indentation?

slate swan
#

can someone tell me how to make a self bot ?

slate swan
slate swan
#

its not i think

dapper cobalt
unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
# old shoal python

before you start developing discord bots first learn python, indentation errors are really basic

slate swan
#

also i want it only for memes

#

@slate swan

#

doesn't matter your reasons, it's against discord's ToS

supple thorn
#

Still breaks discord's TOS

slate swan
#

bro idgaf about discord TOS

dusk pumice
#

Self Bot against discord's ToS

slate swan
supple thorn
slate swan
#

we don't care if you don't care about it but no one is gonna help you do something malicious

#

its not malicious

dusk pumice
slate swan
dusk pumice
#

We can't help you with breaking ToS

slate swan
supple thorn
dusk pumice
#

Yea

slate swan
#

if you really wanna make a selfbot learn the language and do it yourself πŸ˜‚

#

or if you want "just to post memes" , discord allows you to do that

dapper cobalt
#

@arctic python I think we need a little help here.

slate swan
dusk pumice
#

You made self bot?

slate swan
slate swan
#

there's google lmao

slate swan
#

google it

#

Β―_(ツ)_/Β―

dapper cobalt
#

So you can get banned, of course!

slate swan
#

moderators ping moment

#

πŸ˜‚

dapper cobalt
#

Someone needs to DM modmail at this point.

slate swan
#

'gay things' explen

slate swan
dusk pumice
#

-help

#

Good

#

there is no self bot now

slate swan
#

they just deleted the message lol

dapper cobalt
#

Only the author of the self bot can use it.

slate swan
dusk pumice
#

LOL

slate swan
#

same

dapper cobalt
#

Sebastian is here.

slate swan
#

why my message getting deleted πŸ€”

kind hill
#

We've handled the situation, we can move on :)

slate swan
#

alr

#

alrighty , lessgo

dapper cobalt
#

No need to continue that, let's move on as it's already handled.

dusk pumice
#

Thanks

boreal ravine
#

@zenith pewter literally an alt

#

how are yall not noticing this

slate swan
boreal ravine
#

My account is literally 3 years old

slate swan
#

default pfp = alt 😌

finite plinth
#

yo guys how to remove a reaction from a message?

slate swan
#

!d discord.Message.remove_reaction

unkempt canyonBOT
#

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

Remove a reaction by the member from the message.

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

If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.

The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
finite plinth
#

ah ok

#

thx

slate swan
#

yw

boreal ravine
brave flint
#

hello, i got a issue on FFmpeg that i host at heroku
i arl specify ffmpeg at requirements and i arl try add ffmpeg to buildpack and got error
ClientException: ffmpeg was not found.

slate swan
#

@languid charms πŸ˜‚

#

NO

#

oh it's an account, thought i actually pinged mods by accident lemon_sweat

boreal ravine
#

@slate swanz

brave flint
slate swan
#

add those 2 instead

#

and remove the one you added

brave flint
#

ok ill try brb

brave flint
# slate swan add those 2 instead

its output is same
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.

slate swan
#

also add ffmpeg in your requirements.txt

finite plinth
#

i want it to get rid of the reacts

slate swan
#

all of the emojis?

brave flint
slate swan
#

then that's a weird error

#

did you save and restart? try re-deploying

finite plinth
#

yes

#

needs a redeploy

#

i got the same error

#

like couple days ago

slate swan
finite plinth
#

ye

slate swan
#

!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.
finite plinth
#

what i mean was like

slate swan
#

there

finite plinth
#

when i add a reaction

#

someone react to it

#

i want the bot to remove

brave flint
finite plinth
#

uhm

brave flint
#

i think i didnt do that

placid skiff
slate swan
finite plinth
#

make the member unreact

#

or something like that

#

how to do that?

slate swan
#

yes, it's remove_reaction

placid skiff
slate swan
finite plinth
#

i did

slate swan
#

then??

finite plinth
#

it just removes like all this

slate swan
#

a

#

@slate swan

finite plinth
#

i want it from this

slate swan
finite plinth
#

to this

slate swan
finite plinth
#

ooooooooh wait

#

i used it wrongly

oak falcon
#

hi guys

finite plinth
#

looool thx for the help @slate swan

oak falcon
#

how can I set my textchannel to be news channel?

slate swan
slate swan
unkempt canyonBOT
#

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

Edits the 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 use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
patent surge
#

How do I catch Dm Messages ?

slate swan
#

or if the guild is None, since dms aren't inside a guild

quasi wharf
#

hi, after a long time i am getting back to building a discord bot for a college project and i find out that the discord.py library is set to read-only and would no longer be maintained. I wanted to ask if it still works or do we have to change any code or any alternatives? Can anyone point me to the right docs given the change?

visual island
#

it still works

#

until api v8 is deprecated

oak falcon
slate swan
visual island
#

oh,

slate swan
oak falcon
#

ok I see, so I have another question, can I set news channel via discord app?

#

not via code

slate swan
#

the best alternative is disnake, has the same dpy 2.0 syntax and by far the most promising fork out of all the others

patent surge
oak falcon
#

I do but I have no opton

slate swan
quasi wharf
oak falcon
#

do I need some Nitro?

slate swan
patent surge
slate swan
oak falcon
#

I do not see anything like it

#

I will check via browser

#

maybe it is the client

slate swan
#

it won't make a difference but alr Β―_(ツ)_/Β―

oak falcon
#

I do not see anything like you said

#

I do right click on channel. I select Edit Channel I scroll down

#

and I see this:

#

@slate swan where is it?

slate swan
#

NSFW channel is what marks it as a nsfw type channel

oak falcon
#

and then it is a news channel?

slate swan
#

if you want the Announcement channel you need to make your server become a community

oak falcon
#

I see

slate swan
#

Server settings > Enable community

#

how do i send message to discord id discordpy

oak falcon
#

and what it gives me ? is it making it public server?

patent surge
#

discord.DMChannel is not an instance of Dm Messages .

#

How do i catch dm messages ?

slate swan
slate swan
slate swan
#

it says all that it does when you enable it

slate swan
#

use isinstance for it

#

it returns True if the channel's type is a discord.DMChannel else False if it isn't

oak falcon
#

@slate swan thank you

slate swan
#

yw

patent surge
#

gotta dm messages working

#

thanks

slate swan
#

yw

quasi wharf
#

the new message content intent is only for verfied bots, so if i make a bot for personal use in 1 server only, it wont be affected with this change right?

visual island
#

yes

quasi wharf
#

okk thanks

#

and these intent granting process which needs special approval and all is also only for verified bots, right?

valid perch
#

Yes

#

If your under 75 servers your fine

oak falcon
#

another question:
I do not get archived threads when do this:
py g = bot.get_guild(810847352650465330) for t in g.threads: if t.archived: print(t.name, "is archived, id:", t.id) try: await t.delete() except discord.DiscordException as e: print(e) else: print(t.name, "is active, id:", t.id)

#

sometime I get them but most of the time I do not

slate swan
#

how can i do this

#

unix timestamps

supple thorn
slow fog
#

i cant find any warn command

#

all of them doesnt work

#

with some errors

#

!d def warn

#

bruh

boreal ravine
#

make it urself tf?

slow fog
#

i did

boreal ravine
#

yes and?

oak falcon
slow fog
#

but doesnt work then i tried to search but even the search doesnt work

boreal ravine
oak falcon
#

yes

boreal ravine
slow fog
#

search on google to see what is the wrong with mine

oak falcon
#

I would like to find archived threads and their origin messag and remove them

boreal ravine
#

did you fix it?

slow fog
#

nothing

#

no

boreal ravine
#

show me it

slate swan
#

πŸ˜‚

boreal ravine
#

I know

#

πŸ™ƒ

#

he isnt sending it

#

nice

oak falcon
#

so what about this threads, I am looking for archived but they are never on guild.threads

steady flume
#

guys, how to make a bot divide a number into tens, hundreds, thousands, etc. with commas. for example, let's take the number 10000, and the bot recorded it as 10,000

boreal ravine
unkempt canyonBOT
#

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

5,000
boreal ravine
#

I dont exactly know what its called lol

boreal ravine
#

on_message only takes one parameter

steady flume
#

done)

boreal ravine
#

πŸ‘

rotund nova
boreal ravine
#

i dont know what you want

#

i cant read your mind

rotund nova
#

i want no errors

#

and command working

boreal ravine
#

what command

boreal ravine
#

parameter*

rotund nova
#

so

rain olive
#

its not even a command

boreal ravine
#

^

dusk pumice
#

How can I get when account is created

boreal ravine
unkempt canyonBOT
#

property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
dusk pumice
#

tnx

boreal ravine
#

Or user

#

πŸ‘

dusk pumice
#

πŸ™‚

slate swan
#

i need a "warnings" command

#

i tried

rotund nova
# rain olive its not even a command

full code

@client.event
async def on_message(message, ctx, suggestion):
    if message.channel.name != "suggestions":
        return
    await message.add_reaction('βœ…')
    await message.add_reaction('❌')
        
    embed = discord.Embed(title="no c", description=f"cc", colour=discord.Colour.light_gray())
    embed.add_field(name="Sugestie daΕ‚ {ctx.author.name}", icon_url = {ctx.author.avatar_url}, inline=False)
    embed.add_field(name="Mowa sugestia!", value=f"{suggestion}", inline=False)

    await ctx.send(embed=embed)
    
@client.event
async def on_reaction_add(reaction, user):
    if reaction.message.channel.name != "suggestions":
        return
    if (reaction.emoji == upvote) and (reaction.count == up_needed):
        print("upvotes reached")
        await client.send_message(reaction.message.server.get_member_named(admin), "A suggestion has reached " + str(up_needed) + " :arrow_up:!")
        await client.send_message(reaction.message.server.get_member_named(admin), reaction.message.content)
    if (reaction.emoji == downvote) and (reaction.count == down_needed):
        await client.send_message(reaction.message.server.get_member_named(admin), "A suggestion has got " + str(down_needed) + " :arrow_down:!")
        await client.send_message(reaction.message.server.get_member_named(admin), reaction.message.content)```
rain olive
#

the reason why ur on_message event doesnt work is because that event only takes in ONE argument

rotund nova
#

u help me fix it?

rain olive
#

im already helping you, start off by deleting everything and using proper commands

rain olive
#

just the on_message

slate swan
#

!d

unkempt canyonBOT
#
All inventories (`36` total)

β€’ urllib3
β€’ urwid

rotund nova
#

already

rain olive
#

now transfer all of that junk into actual commands

#

@client.command() that is

rotund nova
#

i dont want command

slate swan
#

i need a thing that every time someone get warned record the warn so i can use it with the warnings command

rotund nova
#

when someone write on channel "suggestions" bot give message in embed and give reaction

#

@rain olive

slate swan
#

Hello, i could need some help and i dont know how to solve it 😦

i get this Error:

Trying to Reconnect now
<class 'RuntimeError'> Concurrent call to receive() is not allowed
Backend TkAgg is interactive backend. Turning interactive mode on.
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages\discord\gateway.py", line 150, in run
f = asyncio.run_coroutine_threadsafe(coro, loop=self.ws.loop)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\asyncio\tasks.py", line 912, in run_coroutine_threadsafe
loop.call_soon_threadsafe(callback)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 756, in call_soon_threadsafe
self._check_closed()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 504, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception in thread Thread-10:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
sys:1: RuntimeWarning: coroutine 'HTTPClient.close' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

#

I suspect it from those lines:



@client.event
async def on_disconnect():
    print("Lost connection", datetime.datetime.now())
    print("Trying to Reconnect now")
    try:
        await client.connect()
        await asyncio.sleep(60 * 5)
    except discord.ConnectionClosed:
        print("There has been an Error during the reconnection")
    except discord.GatewayNotFound:
        print("There is an Error with the Token or at least the API --> GateWayNotFound")
    except RuntimeError:
        # os.startfile(str(__file__))
        exit()```
boreal ravine
#

didnt i tell u to send ur code

#

an hour ago

slate swan
#

is that all the code?

coarse compass
#

I can't seem to find an error in their code tho

slate swan
boreal ravine
#

wym

slate swan
#

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
sys:1: RuntimeWarning: coroutine 'HTTPClient.close' was never awaited

#

the bot runs around 30 min without problems...and then poof...Disconnected and he tries to reconnect with those lines

#

try:
    client.run(Token) 
except SystemExit:
    os.startfile(str(__file__))
    exit()

except BaseException as e:
    print(type(e), e)
    skip = False
    if not isinstance(e, SystemExit):
        if not os.path.isfile("Error.txt"):
            with open("Error.txt", "w") as Err:
                pass
        with open("Error.txt", "a") as Err:
            try:
                Err.write(str(datetime.datetime.now()) + "," + str(discord.__version__) + "," + str(
                    traceback.print_tb(e.traceback)) + "\n")
            except AttributeError:
                skip = True
                pass
            except:
                if not skip:
                    Err.write(str(datetime.datetime.now()) + "," + str(discord.__version__) + "," + str(
                        traceback.print_tb(e)) + "\n")
        # os.startfile(str(__file__))
        exit()

except Exception as e:
    print(type(e), e)
    skip = False
    if not isinstance(e, (SystemExit, RuntimeWarning)):
        if not os.path.isfile("Error.txt"):
            with open("Error.txt", "w") as Err:
                pass
        with open("Error.txt", "a") as Err:
            try:
                Err.write(str(datetime.datetime.now()) + "," + str(discord.__version__) + "," + str(
                    traceback.print_tb(e.traceback)) + "\n")
            except AttributeError:
                skip = True
            except:
                if not skip:
                    try:
                        Err.write(str(datetime.datetime.now()) + "," + str(discord.__version__) + "," + str(
                            traceback.print_tb(e)) + "\n")
                    except:
                        Err.write(str(datetime.datetime.now()) + "," + str(discord.__version__) + "," + str(
                            type(e)) + " " + str(e) + "\n")
        # os.startfile(str(__file__))
        exit()```

Thats how i tried to catch the Errors
rotund nova
#

someone know how can i fix that?

slate swan
#

send_message is no longer a thing

boreal ravine
#

on_message only takes 1 parameter

#

not 3

slate swan
#

yeah that too^

rotund nova
#

idk how i can edit this

#

i dont want break it more

slate swan
#

!d discord.on_message as you can see it takes only message as an argument

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of β€˜recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
#

use message to define the channel using , message.channel , and send the embed

#

await message.channel.send is the new thing

#

yes in 1.x +

#

Author can also be used as a Channel

boreal ravine
# rotund nova so what do

learn more about python functions? also if u read the docs you'll see that on_message only takes 1 parameter

rotund nova
#

thx

#

for help

boreal ravine
#

πŸ‘

rare saddle
#

Please tell me if it is possible to send news from the site to the discord channel? For example, news was published on the site in a specific section, and the bot took and sent this news to the channel. Maybe someone has examples of such work. I will be grateful

rotund nova
#

i read this and how move it

boreal ravine
#

wot

rotund nova
#

for its working and have one parameter

slate swan
#

!d discord.Message , this is what the message arg returns , using its attributes you can do all the stuff you would do with ctx

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
rotund nova
left wind
#

How do I make a bot send an image that I've made with PIL?

slate swan
slate swan
slate swan
left wind
#

ah ok

rotund nova
left wind
#

thanks πŸ˜„

slate swan
rotund nova
#

Yes

slate swan
#

message is a discord.Message there

#

and it has attributes like channel , author and stuff

#

use them in your code

rotund nova
#

u, i try

oblique slate
#

Hey can someone help me with this
I have a dir called routes and it wrks locally, but doesnt when i run using gunircorn it says import error

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 384, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/root/aerzik/__init__.py", line 5, in <module>
    from routes.web import app
ModuleNotFoundError: No module named 'routes'
[2021-10-28 17:21:34 +0000] [21595] [INFO] Worker exiting (pid: 21595)
[2021-10-28 17:21:34 +0000] [21596] [ERROR] Exception in worker process
boreal ravine
#

weird

oblique slate
boreal ravine
#

wait this is the wrong channel to ask that

oblique slate
boreal ravine
#

idk

patent surge
#

I am unable to add reaction via add_reaction()

#

Getting HTTPException error

boreal ravine
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Add a reaction to the message.

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

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
boreal ravine
patent surge
#

That only

boreal ravine
#

yes

#

but what does the error say

patent surge
#

Unknown emoji

#

oh

boreal ravine
#

hm

boreal ravine
patent surge
#

what argument does add_reaction() takes

steady flume
#

guys, how to calculate the percentage of a number?

boreal ravine
#

.add_reaction(":grinning:")

patent surge
#

ok lemme see

tawdry perch
steady flume
#

amount *% and then divide on 100

dim cedar
#

Hello

#

How can i make buttons in dpy?

manic wing
#

what version are you on

ocean leaf
#

this is my ban code

#

idk why it is not working

#

not even erorr

#

*error

dim cedar
#

Dpy version idont know

boreal ravine
#

wtf

ocean leaf
#

anyone?

boreal ravine
#

which part isnt working

ocean leaf
boreal ravine
dim cedar
#

What

boreal ravine
#

try adding print statements to the command

ocean leaf
boreal ravine
#

!d discord.ui.View

unkempt canyonBOT
#

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

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

New in version 2.0.
boreal ravine
#

weird

boreal ravine
dim cedar
#

Hmm

#

Thanks

boreal ravine
#

πŸ‘

#

its a decorator fyi xD

ocean leaf
#

not even error

boreal ravine
#

Does your bot have permissions
Did u try to ban yourself
Does the bot have member intents

boreal ravine
#

maybe cuz of this

boreal ravine
#

!intents

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.

ocean leaf
#

ok wait a sec

lyric moat
#
    @commands.command()
    async def status(self,ctx, member : discord.Member=None):
      if member is None:
       member = ctx.author
      embed=discord.Embed(title=f"{member.name} your current status is", description= f'{member.activities[0].name}', color=0x2f3136)
      await ctx.send(embed=embed)```
why does this command does not responds?
ocean leaf
#

already have it

#

still

lyric moat
#

just does not respond

slate swan
#

is the cog loaded?

lyric moat
#

yeah

ocean leaf
#

wierd

slate swan
#

and , do you have an error handler?

lyric moat
#

yeah

slate swan
#

could you please show that?

ocean leaf
slate swan
#

its probably eating your error

lyric moat
#

the error handler?

slate swan
boreal ravine
#

is activities a thing?

#

!d discord.Activity

slate swan
#

yes

#

and it returns a list

boreal ravine
#

dont exist?

#

!d discord.Member.activities

unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.

slate swan
#

!d discord.Member.activities

boreal ravine
#

hm

#

does the user have a activity

slate swan
#

returns a BaseActivity

boreal ravine
#

ok

slate swan
#

ok so it does not have a name attr

boreal ravine
#

hm

lyric moat
#

ima try do it without cog

boreal ravine
#

I dont think lists even have

#

a name attr

#

doesnt make sense

slate swan
#

that's the reason they indexed it

boreal ravine
#

hm

vast jolt
#

yo i need help with a simple anti spam event when someone spams just to delete their messages

slate swan
#

use on_message events , and count how many messages the member sent ( probably in a dictionary which you can reset after every n seconds/minutes) , if the number of message exceeds spam limit , message.delete() it

lyric moat
#
    @commands.guild_only()
    @commands.command(description = "Show the status of a member or of yourself.", usage = "status [member]", aliases = ["us", "user-status", "member-status"])
    async def status(self, ctx, *, member: discord.Member = None):
        member = member or ctx.author
        if member.activity is None:
            member_status = "No status"
        else:
            member_status = member.activity.name

        embed = discord.Embed(title = f"{member.name}#{member.discriminator}", description = f"Status: **{member.status}**\n*{member_status}*", colour = member.colour)
        embed.set_author(name = f"{member.id}", icon_url = member.avatar_url)
        embed.set_thumbnail(url = member.avatar_url)
        await ctx.reply(embed = embed)```
this one works but does not show there status
slate swan
unkempt canyonBOT
#

Cooldowns in discord.py

Cooldowns can be used in discord.py to rate-limit. In this example, we're using it in an on_message.

from discord.ext import commands

message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)

@bot.event
async def on_message(message):
    bucket = message_cooldown.get_bucket(message)
    retry_after = bucket.update_rate_limit()
    if retry_after:
        await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
    else:
        await message.channel.send("Not ratelimited!")

from_cooldown takes the amount of update_rate_limit()s needed to trigger the cooldown, the time in which the cooldown is triggered, and a BucketType.

slate swan
#

take it as an example , you would be deleting the message instead of sending the error

lyric moat
#

like dnd and this

marble atlas
#
    author = ctx.message.author

    await ctx.send( arg )```
 how to make it so that he would answer not only the first word after the command?
slate swan
#

You want him to send the command word and arg ?

vast jolt
#
@bot.event 
async def on_message(message):
  counter = 0
  with open("spam_detect.txt", "r+") as file:
      for lines in file:
          if lines.strip("\n") == str(message.author.id):
              counter+=1

      file.writelines(f"{str(message.author.id)}\n")
      if counter > 5:
        await message.guild.ban(message.author, reason="anti-raid by cryptic🌌"
        await asyncio.sleep(1)
        await asyncio.sleep(1)
        await message.guild.unban(message.author)

i have this rn but i want one that just deletes the message when someone keep spamming

static hamlet
slate swan
lyric moat
#
    @commands.guild_only()
    @commands.command(description = "Show the status of a member or of yourself.", usage = "status [member]", aliases = ["us", "user-status", "member-status"])
    async def status(self, ctx, *, member: discord.Member = None):
        member = member or ctx.author
        if member.activity is None:
            member_status = "No status"
        else:
            member_status = member.activity.name

        embed = discord.Embed(title = f"{member.name}#{member.discriminator}", description = f"Status: **{member.status}**\n*{member_status}*", colour = member.colour)
        embed.set_author(name = f"{member.id}", icon_url = member.avatar_url)
        embed.set_thumbnail(url = member.avatar_url)
        await ctx.reply(embed = embed)```
this one works but does not show there status
static hamlet
lyric moat
slate swan
#

in the code as well?

slate swan
unkempt magnet
#

Hey could i get some help making a embed message update? I have variables inside that are constantly changing and i need them to update. Heres my code, it isnt working:

@client.event
async def on_message(message, self):
  guild = self.bot.get_guild(894937415607779349)
  channel = guild.get_channel(903612015354982430)
  msg = await message.channel.get_message(903659880995508274)
  while True:
    asyncio.sleep(2)
    await msg.edit(embed = embed)
ionic wadi
#

Is there something like a

random.choice(1,3) or?

#

I currently have number = random.choice(1,3) for rock paper scissors command but get the following error:

#

File "/home/container/bot.py", line 263, in sps
nummer = random.choice(1,3)
TypeError: choice() takes 2 positional arguments but 3 were given

#

Fixed It

slate swan
#

:> it takes a list as argument

slate swan
#

are you in cogs?

unkempt magnet
#

could you tell me what code it needs then?

#

i’ve have been at this since first thing this morning

#

and nothing has worked

slate swan
unkempt magnet
#

i don’t know what that means

exotic cosmos
#

Theyre asking if what youve shown is in a cog i believe

unkempt magnet
slate swan
unkempt magnet
#

because i don’t know what i’m doing

slate swan
#

!d discord.on_message , reading this would help

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of β€˜recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
#

if you face any problem even after that , you can ask here...

unkempt magnet
#

i know that, im trying to make embed message update the variables inside

icy mango
#
await ctx.message.delete()
        help_log = client.get_channel(help_log_channel)
        confirmation = await ctx.send(
            "Are you sure you want to continue",
            components = [
                Button(style = ButtonStyle.green, label = "Continue"),
                Button(style = ButtonStyle.red, label = "I wanna go back")
            ]
        )
        confirmation.delete()

throws an error

slate swan
#

since you aint inside a class , are you?

unkempt magnet
#

so i can send a message and start the infinite loop

#

i have variables that need to be updated

slate swan
#

you wont be using self there in that case

unkempt magnet
#

with the current script it does this:

#

it spams this ^

slate swan
#

!simple

unkempt canyonBOT
#

Star / Wildcard imports

Wildcard imports are import statements in the form from <module_name> import *. What imports like these do is that they import everything [1] from the module into the current module's namespace [2]. This allows you to use names defined in the imported module without prefixing the module's name.

Example:

>>> from math import *
>>> sin(pi / 2)
1.0

This is discouraged, for various reasons:

Example:

>>> from custom_sin import sin
>>> from math import *
>>> sin(pi / 2)  # uses sin from math rather than your custom sin

β€’ Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import.
β€’ Causes ambiguity. From the example, it is unclear which sin function is actually being used. From the Zen of Python [3]: Explicit is better than implicit.
β€’ Makes import order significant, which they shouldn't. Certain IDE's sort import functionality may end up breaking code due to namespace collision.

How should you import?

β€’ Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name)

>>> import math
>>> math.sin(math.pi / 2)

β€’ Explicitly import certain names from the module

>>> from math import sin, pi
>>> sin(pi / 2)

Conclusion: Namespaces are one honking great idea -- let's do more of those! [3]

[1] If the module defines the variable __all__, the names defined in __all__ will get imported by the wildcard import, otherwise all the names in the module get imported (except for names with a leading underscore)
[2] Namespaces and scopes
[3] Zen of Python

slate swan
#

hm

#

!d simple

unkempt canyonBOT
#

7. Simple statements

A simple statement is comprised within a single logical line. Several simple statements may occur on a single line separated by semicolons. The syntax for simple statements is...

slate swan
#

boi

#

!d simple discord bot

unkempt canyonBOT
#

7. Simple statements

A simple statement is comprised within a single logical line. Several simple statements may occur on a single line separated by semicolons. The syntax for simple statements is...

slate swan
#

ok

#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
#

bro

patent surge
boreal ravine
#

hm

slate swan
#

\πŸ˜€

#

.add_reaction("πŸ˜€")

patent surge
slate swan
#

error?

slate swan
#

works perfectly for me

slate swan
#

if you will just do .send(embed) it will just send the object name

unkempt magnet
#

now all i need is the variables to update

patent surge
unkempt magnet
#

thats the code for defining the embed

icy mango
#

i have a issue

unkempt magnet
#

i need that to update with the variables

icy mango
#

i am getting a error 400 bad request (some error code) : Unknown emoji

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

embed kwarg

boreal ravine
icy mango
# boreal ravine use its unicode emoji
        suggestion_message = await help_log.send(embed = embed)
        await suggestion_message.add_reaction(":thumbsup:")
        await suggestion_message.add_reaction(":thumbsdown:")
#

what is unicode?

boreal ravine
#

add a slash before an emoji

slate swan
#

\emoji

icy mango
#

no ::??

boreal ravine
#

to get the markdown of that emoji AKA a unicode emoji

#

yes i mean no

slate swan
#

in discord

#

\πŸ‘

icy mango
#

what?

boreal ravine
#

like \:thumbsup:

icy mango
#

oh ok

#

thank ya

slate swan
#

write that in discord

#

try it

icy mango
#

wait

slate swan
#

not in the code

icy mango
#

when i copy that too my code

slate swan
#

hide your token , sir

icy mango
#

it looks like a emoji in my code

slate swan
#

I said don't do that bro

#

then okay

#

then my bad

slate swan
#

oh lol it's actually there

stiff nexus
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 151, in on_ready
    self.add_view(buttons.trash(self))
  File "/home/runner/core/buttons.py", line 50, in __init__
    self.bot = ctx.bot
AttributeError: 'Pogbot' object has no attribute 'bot'
slate swan
#

self.bot = bot

stiff nexus
# slate swan self.bot = bot
class trash(discord.ui.View):
    def __init__(self, ctx):
        super().__init__(timeout=None)
        self.ctx = ctx
        self.bot = ctx.bot

    async def interaction_check(self, interaction: discord.Interaction) -> bool:
        if interaction.user.id != self.ctx.author.id:
            await interaction.response.send_message(
                embed=discord.Embed(description=f"{utily.error} Sorry, you can't use this!",color=self.bot.colour), ephemeral=True)
            return False
        return True

    @discord.ui.button(style=discord.ButtonStyle.green, custom_id="quit", emoji="πŸ—‘οΈ")
    async def stop_pages(self, button: discord.ui.Button, interaction: discord.Interaction):
        await interaction.response.defer()
        await interaction.delete_original_message()
        self.stop()
slate swan
#

why ctx.bot

stiff nexus
#

then how do i get bot?

slate swan
#

pass a bot parameter in init

#

well that's how cogs work, should be how buttons work aswell

slate swan
#

I mean the cogs' constructor

#

takes a bot parameter

#

but I can't find any example for this

stiff nexus
#

ok

slate swan
stiff nexus
#

i got it

slate swan
#

Alr

icy mango
#

if i have a custom emoji and i want my bot to react with that emoji how can i do it?

slate swan
#

type what we said in discord

icy mango
slate swan
#

\emoji

icy mango
#

ok thank you again

#

you pro lol

slate swan
#

it will give you what you have to copy-paste

boreal ravine
#

did he get it?

slate swan
#

Probably not, looked in the dpy server and him getting help kinda just died πŸ˜‚

#

Although he was being explained why what he's trying to do isn't working

boreal ravine
#
    self.ctx = ctx
#

hm

slate swan
#

He's just another code copy paste person that knows shit and nothing of what they're doing πŸ˜‚

boreal ravine
#

no offence but he asks for help in 3 servers that I know of

slate swan
#

Pfft-

boreal ravine
#

crossposts*

slate swan
#

That just makes him a complete python beginner πŸ˜‚

boreal ravine
#

Β―_(ツ)_/Β―

slate swan
#

hmm

#

can I use menus with normal buttons that aren't reactions?

#

I want my menu to seem cool

boreal ravine
slate swan
#

yes

#

No not really

#

Just make your own

#

do I look like I know something about that? lemon_angrysad

#

It's just a paginator

#

lemme try something

#

How do I delete a reaction when it is added to a message?

unkempt magnet
#

just channel ids

slate swan
#

the icon_url in set_author

candid ore
steady flume
#

guys, how to count how many commands my bot used by a certain member??

boreal ravine
unkempt canyonBOT
#

property commands: Set[discord.ext.commands.core.Command[discord.ext.commands.core.CogT, Any, Any]]```
A unique set of commands without aliases that are registered.
boreal ravine
#

you can use len on that

unkempt magnet
#

my token is now regenerated

kindred epoch
boreal ravine
#

ohhh

kindred epoch
#

He said by member not how many commands his bot has

#

Lol

boreal ravine
#

idk then

#

the only thing I can think of

#

is if you save it in a db

kindred epoch
#

@steady flume you have to do that by ur self

slate swan
#

Hello, someone know a way to mention a channel in the footer of an embed ?
I tried this: py embed.set_footer(text="Lis les " + member.guild.get_channel(903237826487935026).mention)
but it return this:

lyric moat
#

how can i do on guild join command like when my bot joins a server it sends in a server

slate swan
#

it's bot.get_channel

#

not guild

#

well maybe guild works too hm

lyric moat
#

like this

slate swan
#

How would I invoke a command inside another command?
For example, say I have

@bot.command()
async def test(ctx, strarg):
  await ctx.send(strarg)

Now what if I want to run this test command in another command? Something like this:

@bot.command()
async def use():
  await test('asd')
lyric moat
#

how could i make it send in a channel instead of a user?

@client.listen("on_guild_join")
async def foo(guild):
    channel = guild.text_channels[0]
    rope = await channel.create_invite(unique=True)
    me = client.get_user(737448363418452019)
    await me.send("dj they added me")
    await me.send(rope)```
slate swan
unkempt canyonBOT
#

get_command(name)```
Get 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 get aliases.

The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.
slate swan
#

and invoke it using .invoke() all the args required for the command should be provided inside invoke

slate swan
lyric moat
slate swan
upbeat otter
slate swan
#

what

upbeat otter
#

How do I add multiple arguments in discord-py-slash-commands?

slate swan
lyric moat
#

is it possible for on_guild_remove

#

or leave

sick birch
#

?

lyric moat
#

like it shows who when the server kick the bot

sick birch
#

i don't think you can tell who kicked the bot

#

unless you get the audit log of the guild, and search to see who kicked you

lyric moat
#

like u see on_guild_join

#

lemme screen shot

#

how can i make it says it leave a server?

slate swan
lyric moat
#

:/

#

on_guild_leave?

slate swan
#

its on_guild_remove but you cannot see who kicked the bot

sick birch
#

oh you mean you want the bot to send a message when a member joins the server?

boreal ravine
unkempt canyonBOT
#

discord.on_guild_remove(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is removed from the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

This happens through, but not limited to, these circumstances...
slate swan
sick birch
#

is it not a cached property?

boreal ravine
#

property?

slate swan
sick birch
#

oh okay, i thought it would be

#

then there's no way to know who removed the bot

boreal ravine
#

or just assume that the owner removed the bot

#

ez pz

slate swan
#

Are there any site I can host my bot for FREE?

#

yea many , but at your own risk ℒ️

#

wdym

#

the site owners can acess part of your codes / tokens and stuff

#

Bro then nobody should host nothing on any site with that logic

crystal rapids
slate swan
#

If I remember right, u could host on GitHub?

crystal rapids
#

Not sure. I've only heard of GitHub pages

#

Which isn't what ur looking for anyway

slate swan
#

Okay what is the best host site for a new bot?

#

with a good deal

#

not too much money

exotic cosmos
#

ovh

#

cheapest plan has good specs for the price

slate swan
#

Can I trust that one

exotic cosmos
#

Yes

slate swan
#

what is the site called?

exotic cosmos
#

Otherwise look for dedicated discord bot hosts

slate swan
#

47 DOLLARS????

boreal ravine
#

robo danny uses that

crystal rapids
#

I use galaxygate
No serious issues so far

slate swan
#

I dont understand about these stuff, I just need a cheap host for my discord bot

boreal ravine
#

iirc dank memer uses it

crystal rapids
#

Yeah

slate swan
#

Which one do I go to?

crystal rapids
slate swan
#

which one do I choose

#

domains, web hosting, virtual servers, dedicated servers, DDOS protection or block storage

slate swan
#

Hello?

boreal ravine
#

why do u need

#

ddos protection

#

on a bot

slate swan
#

im asking which one i choose?

#

i've never hosted a bot before

boreal ravine
#

oh

boreal ravine
slate swan
#

are u sure?

boreal ravine
#

since a bot isn't: making a domain, web hosting, needs ddos protection, needs dedicated servers (if ur bot isnt big), idk what block storage is but it isnt needed

boreal ravine
#

i mean im sure*

slate swan
#

okay thanks

#

Hello how can I make a command run if the author has a specific permission?

sick birch
#

yep

#

next best thing to AWS