#discord-bots

1 messages · Page 597 of 1

desert halo
dapper cobalt
#

!pypi disnake

unkempt canyonBOT
slate swan
#

And there's not only the author as member of the guild

queen gull
#

Hello, I am trying to make a discord bot to play music. This is the code I have for the play command

@client.command(name='play', help='This command plays music')
async def play(ctx,url):
    if not ctx.message.author.voice:
        await ctx.send('You must be in a voice channel to play music')
        return
    else:
        channel = ctx.message.author.voice.channel
        
    await channel.connect()
    
    server = ctx.message.guild
    voice_channel = server.voice_client
    query = await client.wait_for("message")
    query2 = query.replace(" ","+")
    url = "https://www.youtube.com/results?search_query={}".format(query2)
    html = urllib.request.urlopen(url)
    video_ids = re.findall(r"watch\?v=(\S{11})",html.read().decode())
    full_url = "https://www.youtube.com/watch?v=" + video_ids[0]
    
    async with ctx.typing():
        player = await YTDLSource.from_url(full_url, loop=client.loop)
        voice_channel.play(player, after=lambda e: print('Player error %s' %e) if e else None)
    
    await ctx.send(f'Now Playing: {player.title}')
#

When I use the play command in discord the bot doesn't do anything

desert halo
unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

Wdym dpy is still usable but not maintained and disnake is the best option,has the same syntax

quiet coral
#

Hello I am pretty new to discord.py have been working with for a about one month I have built a cryptocurrency bot but I still feel like I am lacking fluency with the library . I am looking for bot ideas do you have any to suggest ?

slate swan
regal shell
#

Hey so when I try to make my bot token a secret using

client.login(process.env.token)

It says
Traceback (most recent call last);

slate swan
regal shell
pliant gulch
#

process.env.token? This isn't javascript

quiet coral
slate swan
pliant gulch
#

They use process.env in javascript

slate swan
slate swan
regal shell
pliant gulch
#

Are you sure your friend is using discord.py???

#

Cause from what they told you seems to me like they are using javascript

slate swan
#

And not discord.js

regal shell
#

He said he’s using js but it’s the same command Idfk I’m new to this lol

pliant gulch
#

It isn't the same thing

slate swan
#

Doesnt seem like your friend understands python

#

Bro?

regal shell
#

Idk hes a computer nerd

#

What should I use to hide it instead of process.env.token

slate swan
#

<@&831776746206265384> someone sent a nazi logo picture in the chat but got deleted so pls stay in the look out

visual island
unkempt canyonBOT
#

os.getenv(key, default=None)```
Return the value of the environment variable *key* if it exists, or *default* if it doesn’t. *key*, *default* and the result are str.

On Unix, keys and values are decoded with [`sys.getfilesystemencoding()`](https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding "sys.getfilesystemencoding") and `'surrogateescape'` error handler. Use [`os.getenvb()`](https://docs.python.org/3/library/os.html#os.getenvb "os.getenvb") if you would like to use a different encoding.

[Availability](https://docs.python.org/3/library/intro.html#availability): most flavors of Unix, Windows.
slate swan
#

^

regal shell
#

So
os.env.get(token)

slate swan
#

Idk i dont use replit

regal shell
#

Ah ok I’ll try it thanks 😊

slate swan
#

Np

#

If im wrong andy can probably correct me

visual island
#

that's another way to do it yeah

slate swan
#

^

slate swan
regal shell
#

Now it’s saying “os” is not defined I hate this lol

visual island
#

import it

visual island
#

it's os.environ mb

#

os.environ.get

#

.environ itself returns a Mapping/dict

slate swan
#

^

regal shell
#

Bruh I hate this sm
It now says token is not defined but it’s written the same in the secret repl hates me

#

Pic is sending

pliant gulch
#

Your doing token

#

Not "token"

#

You need to pass the name of your environment variable

regal shell
#

Finally

regal shell
slate swan
quiet coral
#

If I wanted to get a list of all the commands that are available in my bot how can I do that?

bronze pilot
quiet coral
bronze pilot
#

idk

quiet coral
slate swan
quiet coral
bronze pilot
#

Working with polls and voting now.
I'm using embeds and would like to implement reaction voting.
Two questions: Is there already a method for polls with discord.py?
If not, how can I check when a user has "voted" (clicked on a reaction)?

#

I know there's an on_reaction_add() event handler but I'm not sure how to implement this in a way that it will only be invoked when a reaction is added to one of the poll embeds, not any other message

stoic bridge
wicked atlas
#

!d discord.ext.commands.Bot.commands

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.
wicked atlas
#

:(

#

!d discord.ext.commands.Bot.commands

quiet coral
#

ok thnx

cerulean osprey
#

How would I go about making a command that changes the activity of the bot? Naturally I’d want it locked to me but I could do that part

cerulean osprey
#

Nah I want to change the activity with a command at any moment

stoic bridge
cerulean osprey
#

Could I do
if author.id == “<my id>”:
<code>

stoic bridge
#

i think it could work

cerulean osprey
#

Alr thank you

stoic bridge
#

np

kindred epoch
patent lark
cerulean osprey
#
@client.command()
async def change_activity(ctx, activity):
    if ctx.author.id == '591047383044063244':
        await client.change_presence(activity=discord.Game(name=str(activity)))
    else:
        await ctx.send('This command is restricted for Wind!')

This is sending the else statement when I try

slate swan
pliant gulch
#

It will always be false

#

You need to remove the single quotes from the id you are comparing it to

cerulean osprey
#

Oh I did that and it gave an error but it just wasnt loading, thank you

slate swan
#

Dont know how much requests but its in the docs

cerulean osprey
#

Figured as much, I dont plan to spam it 80 thousand times tho

#

Prob just 1-2 times every now and then

pliant gulch
#

Its a gateway command so

#

You can do 120 change presence commands in 60 seconds at a time without getting ratelimited

#

After that you will be automatically disconnected

cerulean osprey
#

Oh good, so I dont have to worry

slate swan
slate swan
pliant gulch
#

Not an endpoint on the API

slate swan
#

I see

pliant gulch
#

I remember making the ratelimiter for the websocket

slate swan
slate swan
pliant gulch
slate swan
#

Just curious btw dont mean it in a bad way

pliant gulch
#

As well as utility focused

heavy folio
#

how do i use find_one_and_delete in mongodb?
so its an unblacklist command and i wanna erase the user's id along with the blacklist reason from the db (its in one document tho)

slate swan
pliant gulch
#

Thanks, we already have 100% coverage on rest Iirc

slate swan
pliant gulch
#

not going so well morale wise rn

#

I decided last night to switch docstring style to rST

slate swan
pliant gulch
#

So I literally have to redoc the whole library

#

That's what I'm doing right now actually, spent the whole day going through 5k lines of code redoccing

slate swan
slate swan
slate swan
kindred epoch
#

Huh

#

I said owner check decorator which totally means the is_owner check which is a decorator

slate swan
#

Alr🤷‍♂️

regal shell
#

@client.command(aliases=['8ball'])
async def _8ball(ctx,*, question):
responses = ['"it is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."
']
Pic loading of error

heavy folio
regal shell
#

Yes I don’t see how to fix lol

#

I’ve rewrote it 3 times

heavy folio
#

!e py print('"why is there a single apostrophe before this string")

unkempt canyonBOT
#

@heavy folio :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print('"why is there a single apostrophe before this string")
003 |           ^
004 | SyntaxError: unterminated string literal (detected at line 1)
slate swan
#

in discord.TextChannel.delete_messages is the messages arg just a list[int] or a list of message objects?

slate swan
slate swan
#

because it would be very ineficiant if i had to fetch all the messages

#

!e

print('"why is there a single apostrophe before this string"')
unkempt canyonBOT
#

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

"why is there a single apostrophe before this string"
unkempt canyonBOT
#

class discord.Object(id)```
Represents a generic Discord object.

The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.

There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.

x == y Checks if two objects are equal.

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

hash(x) Returns the object’s hash.
slate swan
slate swan
#

oh skelmis already answered it

slate swan
#

error.missing_perms must be the thing

#

you would have to add a py @commands.bot_has_permissions() check in the command tho

outer violet
regal shell
#

anyone know why its doing this it was just running before

#

nvm figured it out lol

sick birch
# regal shell
  1. it's client.command(), not client.command,
  2. client.command() needs to decorate an actual coroutine
  3. your client.run(...) is indented incorrectly, if done correctly, it should be at the top-level indent
regal shell
#

no i had it correct its because i had a random @ client.command in there

#

the command wasnt finished so it was trying to use the token as the command im guessing

slate swan
#

What are things needed to delete a message sent by webhook

hazy agate
#

hey

#

i have a doubt

#

while making discord bots

#

this is my commands

#

import discord
from discord.ext import commands
import music

cogs = [music]

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

@commands.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)
await ctx.send(f"{member} was kicked!")

@commands.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f"{member} was banned!")

@commands.command()
async def ping(ctx):
await ctx.send('Pong!')

@commands.command()
async def beg(ctx):
await ctx.send("Oh, Your are begger atleast get 10,000$ and support #TeamSeas , from MrBeast")

@commands.command()
async def spank(ctx):
await ctx.send("Spanking [TPG] Gurami#3388!")

@commands.command()
async def welcome(ctx):
await ctx.send("Welcome Mr.Nightmare#0361")

@commands.command()
async def minecraft(ctx):
await ctx.send("I like mincraft alot but don't have sadly!")

@commands.command()
async def wth(ctx):
await ctx.send("What da fak is wrong with you guys!!!!!!!!")

@commands.command()
async def amogus(ctx):
await ctx.send("u look like ssssussy cat")

@commands.command()
async def die(ctx):
await ctx.send("why do u want to die")

@commands.command()
async def annoy(ctx):
await ctx.send("why do you like pinging!")

@commands.command()
async def rules(ctx):
await ctx.send("1.Always have fun 2.ping everyone 3. NO spamming 😦 4.Be friendly :)")

@commands.command()
async def plsbeg(ctx):
await ctx.send("Oh you poor little beggar, take $1,602 and a Laptop")

@commands.command()
async def inv(ctx):
await ctx.send("U have 1602$ and a laptop")

@commands.command()
async def kill(ctx):
await ctx.send("Are you out of your dumb mind!")

@commands.command()
async def rickrole(ctx):
await ctx.send("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

client.run("TOKEN")

The official video for “Never Gonna Give You Up” by Rick Astley

“Never Gonna Give You Up” was a global smash on its release in July 1987, topping the charts in 25 countries including Rick’s native UK and the US Billboard Hot 100. It also won the Brit Award for Best single in 1988. Stock Aitken and Waterman wrote and produced the track which w...

▶ Play video
supple thorn
slate swan
brazen raft
#

And I'm assuming it's running? Otherwise you need to add bot.run("and put your bot's token here") to the bottom of your code

slate swan
#

He got that but client.run

sick birch
full valley
#

Hi guys, how would I make a command where its also listening for another members id or @mention,

#

e.g. !stats @ other user

slate swan
#

add a member argument to your command func

full valley
#

Yeah I have, but just a little confused

hazy agate
#

and i am using replit for some reason

#

i use to use visual

#

import discord
from discord.ext import commands
import youtube_dl

class music(command.Cog):
def init(self, client):
self.client = client

@commands.command()
async def join(self,ctx):
    if ctx.author.voice is None:
        await ctx.send("You are not in the voice channel!")
    else: 
        await ctx.voice_client.move_to(voice_channel)

@commands.command()
async def disconnect(self,ctx):
    await ctx.voice_client.dsconnect()

@commands.command()
async def play(self,ctx,url):
    ctx.voice_client.stop()    
    FFMPEG_OTIONS = {'before_options: '-reconnect i -reconnect_streamed 1 
    -reconnect_delay_max 5', 'options': ':vn'}
    YDL_OPTIONS = {'format':"bestaudio"}
    vc = ctx.voice_client

    with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
        info = ydl.extract_info(url, download=False)
        url2 = info['formats'][0]['url']
        source = await discord.FFmpegOpusAudio.from_probe(url, **FFMPEG_OPTIONS)
        vc.play[source]

@commands.command()
async def pause(self,ctx):
    await ctx.voice_client.pause()
    await ctx.send("Paused")

@commands.command()
async def resume(self,url):
    await ctx.voice_client.resume()
    await ctx.send("Resume")

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

#

see

#

like

#

i need to download moules

#

modules*

#

can someone suggest me>?

hazy agate
#

but i dont want to leak token

slate swan
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
hazy agate
#

ok

#

hey

#

this

#

but this is not working

slate swan
hazy agate
#

no

#

i use visual

#

and whas the

#

command

#

client.command()

#

or

#

bot.command()

#

or

#

commands.command()

slate swan
#

Depends on your commands.bot.Bot var tbh

hazy agate
#

ok

#

wanna be friendz

slate swan
#

yo

#

@hazy agate i think i have a fix for the ban

hazy agate
#

wdym

sick birch
#

@hazy agate

  • client.command() if you named your commands.Bot instance client (bad naming practice, should not be doing this)
  • bot.command() if you named your commands.Bot instance bot (good naming practice, should be doing this)
  • commands.command() if your command is within a commands.Cog subclassed class, or you are using bot.add_command() to manually register a command
hazy agate
#

bri

#

bro*

slate swan
#

what

hazy agate
#

like i dont know how many modules i need to download

sick birch
#

You were asking about the difference between client.command(), bot.command() and commands.command() right?

hazy agate
#

yes

#

andwhat r the modules to make a music bot

sick birch
hazy agate
#

idcabt yt cuz yt has taken down rythm and groovy

sullen shoal
#

we do

sick birch
#

Right, rhythm and groovy were taken down as they were found in violation of their terms of service. We can't really help you make a bot that violates their TOS

cerulean osprey
#

^

sick birch
cerulean osprey
#

You cant really expect them (not us bc idk a single thing abt music bots) to help with a bot that can potentially violate ToS KEKW

sick birch
#

We won't stop you from making a music bot (I personally discourage it), but you will have to find out how to do so by yourself

sullen shoal
#

small hint would be github

sick birch
cerulean osprey
#

Not if they dont find out ic

#

Kidding

sick birch
#

👀

cerulean osprey
#

Partially

full valley
#

Hey why isnt this working. trying to make it so people can only send the commands in certain channels.

talk_channels = [892691480228020235]

@bot.command(pass_context=True, name="leave", aliases=["l"], description="Remove yourself from the queue")
async def leave(ctx):
    if ctx.channel.id in talk_channels:
#

But the bot just doesnt hear the command at all even from that channel given

hazy agate
#

join my testserver

full valley
#

I dont understand, it should be working

hazy agate
#

oh

#

join my server

full valley
slate swan
hazy agate
#

i have not sent in the chat tho

#

and

#

i have another own server

slate swan
hazy agate
#

and 1 for testing

sick birch
# hazy agate wut abt lavalink?

If you asked something along the lines of "How can I use Lavalink to play an mp3 file present on my machine through my bot on Discord", we would have no problem explaining that. But if you ask us how to play a YouTube video through it, we can't really help with that

sick birch
full valley
#

I know for a fact that the code after it works

hazy agate
#

bro

sick birch
#

also this is more suited task for on_message or a global check, so that you can use all commands in certain channels without doing the if statement in every command

hazy agate
#

can i make a music bot in java?

#

node.js

slate swan
#

@hazy agate
1.please stop asking for help with projects that break tos of some platforms as YouTube or discord
2.please stop advertising
3.read the rules

sick birch
slate swan
#

when a user types the command, how do i make it delete after they sent it?

@client.command()
async def verify(ctx):
   if ctx.channel.id == 909671265864933406:
        fullaccessrole = get(ctx.guild.roles, id=909670961115201537)
        await ctx.author.add_roles(fullaccessrole)
sick birch
hazy agate
#

srysyr

sick birch
#

If you wish to make a music bot using Java, look into JDA
If you wish to make a music bot using Javascript, look into Discord.JS

hazy agate
#

hey i want to make in o

#

py

#

not working

sick birch
hazy agate
#

so irritated

sick birch
#

We won't help you make a music bot here. Period.

slate swan
slate swan
sick birch
slate swan
#

Havent used the commmand in a whole

sick birch
#

That's alright, I can see where you're coming from as the context object has some methods typically associated with a message object

slate swan
#

Yeah

slate swan
hazy agate
#

even if i write bot.command()

#

it is telling wrong

sick birch
#

You'll have to be more clear than that

#

Provide code and full tracebacks for us to debug your code.

hazy agate
#

thena async def blank(ctx):

slate swan
hazy agate
#

await ctx.send("blamd")

sick birch
#

Can you please send the full traceback?

hazy agate
#

but doesn't work for mee

sick birch
#

Saying "it is telling wrong" helps nobody understand what's wrong

#

We need to be able to understand whats wrong in order to fix it

hazy agate
#

i will share screen

slate swan
sick birch
#

I'd prefer not, can you copy & paste the full traceback here?

hazy agate
slate swan
sick birch
#

Either send a screenshot or copy and paste it

shy schooner
hazy agate
#

no

hazy agate
#

can u dm

#

or

sick birch
#

Copy the full error, and paste it here

hazy agate
#

ok

shy schooner
sick birch
#

Or take a picture of it, whichever you find easiest

slate swan
full valley
sick birch
sick birch
full valley
shy schooner
#

check ctx.channel

sick birch
slate swan
# sick birch no, it's `await ctx.message.delete()`

would this be right? im trying to make it delete every message a user sends in that channel

@client.command()
async def verify(ctx):
   if ctx.channel.id == 909671265864933406:
        fullaccessrole = get(ctx.guild.roles, id=909670961115201537)
        await ctx.author.add_roles(fullaccessrole)
        await ctx.message.delete()```
boreal ravine
#

bro try it and see

slate swan
#

A global check is a check in all commands correct?

sick birch
sick birch
full valley
slate swan
full valley
hazy agate
#

bro its confusing

#

wat is this

boreal ravine
hazy agate
#

code:

#

import discord
from discord.client import Client
from discord.ext import client

def new_func():
client = Client.Bot(command_prefix = "!")

boreal ravine
full valley
sick birch
#
@bot.check
def check_commands(ctx):
    return ctx.command.qualified_name in allowed_commands

From the raw docs

slate swan
sick birch
boreal ravine
#

🤔

sick birch
#

Though the documentation specifies it can be either

boreal ravine
#

Ah ok then

sick birch
#

This function can either be a regular function or a coroutine.

#

I assume calculating a boolean value would be sub-millisecond, so making it asynchronous is like bringing a gun to a knife fight.

slate swan
slate swan
sick birch
slate swan
#

yes

boreal ravine
#

so whats the issue then

#

you havent given any errors

sick birch
#

Oh I see, then you can just delete all the messages in that channel after the user invokes the commmand

full valley
sick birch
full valley
#

gotcha

cerulean osprey
#

Is it possible to count the amount of roles someone has and use it?

sick birch
#

Though I'd probably rename the function to something more fitting

slate swan
cerulean osprey
#

So if I were to do x = len(member.roles) I could use x as the count?

sick birch
#

That is correct.

cerulean osprey
#

Thank you

sick birch
#

My pleasure

slate swan
sick birch
#

😂

slate swan
full valley
#

I'm losing hope this still isnt working

sick birch
#

What do you mean by "it isn't working"

#

We'd need to see your code, what you expect, it's current behaviour, full traceback if applicable

boreal ravine
#

a chance that something is blocking it from running

cerulean osprey
#

Sorry for basic question again but would msg.channel.id work for getting ID of the channel the message was sent in? Assuming msg = message.content

sick birch
slate swan
cerulean osprey
#

NOTED thank you

sick birch
#

Purging some arbitrary small number such as 10 should suffice

full valley
sick birch
#

Is there a traceback with that?

full valley
#

there was no errors

sick birch
#

Just a side note, you don't have to pass in the pass_context and name kwargs, if the name and the name of the function are the same

sick birch
full valley
sick birch
#

Which command is it not picking up? All of them or just some?

#

Perhaps because it's ctx.command.channel.id rather than ctx.message.channel.id

full valley
#

all

#

side note, discord bot takes 5 years to go offline ffs

sick birch
#

You don't have to wait for it to go offline

maiden fable
#

It takes only 1 second. It's Discord API issue which shows the bot online

full valley
#

oh what

maiden fable
#

Try running commands after u stop the code

sick birch
#

Just turn it off and back on server-side, changes take effect

maiden fable
#

It won't work haha

sick birch
#

^

#

I've had it glitch out where my bot was online overnight, even though my server was completely unplugged haha

maiden fable
#

Haha

cerulean osprey
#

Its me again. So I wanted to create a command that bans someone if they type in a certain channel, then instantly unbans them, like Dyno's ?softban.. just automated.

if message.channel.id == 909685766244945921:
        zxc = message.author.id
        await message.author.ban(reason = 'You typed in the kick channel!')
        await message.guild.unban(zxc)

Would something like this work?

maiden fable
#

Sure

#

BTW

#

!d discord.on_typing is also there in case u wanna ban as soon as the person starts typing

unkempt canyonBOT
#

discord.on_typing(channel, user, when)```
Called when someone begins typing a message.

The `channel` parameter can be a [`abc.Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") instance. Which could either be [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel"), [`GroupChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.GroupChannel "discord.GroupChannel"), or [`DMChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.DMChannel "discord.DMChannel").

If the `channel` is a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") then the `user` parameter is a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"), otherwise it is a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

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

Damn nah I dont wanna be that strict, just as long as that works

maiden fable
#

It should work

sick birch
#

It would work

maiden fable
#

It will work

#

Wait no

slate swan
#

😭

full valley
#

great, now my mongodb "certificate verify failed"

maiden fable
#

U gotta do message.guild.unban(discord.Object(zxc))

#

Won't work with ID, u gotta convert to a discord Object

sick birch
#

Right, unban takes a snowflake

#

Always something 😂

slate swan
sick birch
#

It's how Twitter makes IDs, each ID is unique

#

hence the name snowflake

maiden fable
#

Yea

slate swan
#

I see thank you shipit

cerulean osprey
#

Alright so now, if I wanted it to only kick people with no roles..

if message.channel.id == 909685766244945921:
        plop = len(message.author.roles)
        if plop == 0:
            zxc = message.author.id
            await message.author.ban(reason = 'You typed in the kick channel!')
            await message.guild.unban(discord.Object(zxc))

would this do?

sick birch
#

Discord takes some things from twitter, for example the emojis are from twitter, so are the IDs

slate swan
sick birch
#

you could probably condense that and remove the plop variable

#

same with the zxc variable

cerulean osprey
#

So..

if message.channel.id == 909685766244945921:
        if len(message.author.roles) == 0:
            zxc = message.author.id
            await message.author.ban(reason = 'You typed in the kick channel!')
            await message.guild.unban(discord.Object(zxc))

Then how would I get rid of zxc

maiden fable
sick birch
#

just substitute message.author.id into where zxc is within the discord.Object()

#

For me, the rule of thumb is to never make variables that are only used once

maiden fable
#

True same

#

As long as the line doesn't become big asf

cerulean osprey
#

o yeah I was thinking of something but it actually made sense lol. I thought that as soon as you ban the bot would throw the ID out 😭 but yeah it makes sense now, thank you

sick birch
#

PEP 8 of course

sick birch
#

IIRC it was 80 columns per line? Give or take 10

maiden fable
#

I have manually set it to 120 cz I had 10 errors in my file all due to line lengths and, well, all those lines had list comps 😐

sick birch
cerulean osprey
#

Makes sense, so the code isnt working Pain

maiden fable
cerulean osprey
#

Nah

slate swan
#

plz help whats the problem here?

cerulean osprey
#

Just isnt working Pain

maiden fable
#

U tryna ban yourself? You can't ban the owner

cerulean osprey
#

Nah Im on an alt

#

Has no roles

sick birch
maiden fable
slate swan
cerulean osprey
slate swan
cerulean osprey
#

Token ic

hazy agate
#

no!

#

dont share token guys

cerulean osprey
slate swan
#

Question if a user gets ban in a guild by a bot if the user shares a guild which the bot is in will the bot ban him in all or just the guild the command got invoked?

sick birch
#

Just the guild

cerulean osprey
#

Id asume just the guild, but Im not sure

slate swan
sick birch
#

You have 2 methods of banning a member:

  • Using a member object (member.ban())
  • Using a guild object (guild.ban(member))
    Both methods tie to a singular guild, so no matter which method you use it will only ban within the guild
cerulean osprey
#

Now time to shamelessly change topics.. any idea why my bot is ignoring the on message now?

sick birch
cerulean osprey
#

Well its not ignoring the on_message so much as its ignoring the

if message.channel.id == 909685766244945921:
        if len(message.author.roles) == 0:
            await message.author.ban(reason = 'You typed in the kick channel!')
            await message.guild.unban(discord.Object(message.author.id))
sick birch
#

which part is it ignoring?

#

The first if or the 2nd one?

cerulean osprey
#

All of it, it wont do anything

#

No error messages, nothing

hazy agate
#

bro i really want to make music bot

sick birch
#

Try a print in both the top-level if and the nested if

cerulean osprey
#

Alright

sick birch
#

It'll help diagnose which if statement is not working

sick birch
slate swan
#

We can help for music bots

cerulean osprey
#

Ok its ignoring the second part

sick birch
#

Given it doesn't use YouTube videos

slate swan
#

Not all music bots are directly streaming from YouTube or other services

sick birch
#

Sorry, should've been more clear about that haha

slate swan
sick birch
#

the @.everyone role counts as a role

hazy agate
cerulean osprey
#

o

sick birch
#

Check if they have 1 role, rather than 0

cerulean osprey
#

So, thats why WHEEZE

sick birch
cerulean osprey
#

Error message 2DYayRainbow

#

Oh it doesnt have permission

sick birch
#

That's progress

heavy folio
#

how do i use find_one_and_delete in mongodb?
so its an unblacklist command and i wanna erase the user's id along with the blacklist reason from the db (its in one document tho)

cerulean osprey
#

Ig the bot needs permission to ban people 5Head

sick birch
#

Who would've guessed

slate swan
hazy agate
sick birch
slate swan
#

Can be used to hackban

hazy agate
#

Sheeeesh

slate swan
# hazy agate what is this!?

Look, if I don't answer it means I've never done a music bot, so please stop. I just say we can help for music bots not playing music from YouTube, that's it.

cerulean osprey
hazy agate
#

ok not from yt

slate swan
hazy agate
#

but can i make from lavalink?

cerulean osprey
#

Also 2fa is required for mod actions on this server so is there a way to get around that?

slate swan
#

Lavalink streams from YouTube

sick birch
#

Not sure if lavalink allows playing music from mp3

cerulean osprey
sick birch
#

We did already

slate swan
#

You already got told

sick birch
#

Remove your token, get rid of the space

slate swan
#

Remove the line

slate swan
sick birch
#

Clearly not

slate swan
#

everything

#

And regenerate your token now

heavy folio
#

read the error

slate swan
#

ok

cerulean osprey
# sick birch Bots should be exempt from that
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 50, in on_message
    await message.author.ban(reason = 'You typed in the kick channel!')
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 554, in ban
    await self.guild.ban(self, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/guild.py", line 2026, in ban
    await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 60003): Two factor is required for this operation

Its yelling at me

slate swan
#

trying agaon

cerulean osprey
hazy agate
#

!ban @hazy agate

heavy folio
sick birch
#

Perhaps you need 2FA enabled on your account?

heavy folio
#

no

slate swan
#

Remove this line, and hide your token next time. Now delete your screenshot and regenerate a new token

cerulean osprey
#

I have 2fa enabled on my account, do I need it for the account the bot was made on?

sick birch
#

Bots can't really use 2FA

heavy folio
sick birch
#

That would explain it

cerulean osprey
#

Understandable

sick birch
slate swan
#

Or take a look at the library documentation you're using

cerulean osprey
#

It worked 2DYayRainbow

#

Thank you all

sick birch
#

Awesome!

slate swan
#

@slate swan bro same error again I regenerated the token

hazy agate
slate swan
#

You didn't created the client variable

#

And you're using @commands.command which is for cogs

#

So only use @client.command and create the client variable

slate swan
slate swan
#

Well, indent the ping command correctly first

slate swan
slate swan
slate swan
#

@slate swan what to do?

#

Indent it correctly

#

ok

#

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

Suggest turning on auto-save

#

Or be like me and spam ctrl+s every second

slate swan
#

I get paranoidlemon_eyes

shadow wraith
slate swan
shadow wraith
slate swan
shadow wraith
#

if you'd rather have no syntax highliting over code completion, WHAT THE FU-

slate swan
#

My favorite shortcuts are Ctrl+S and Ctrl+Alt+L

slate swan
#

Indeed

#

Who doesnt 🤷‍♂️ yert

#

But unlike others, when I copy some code because mine triggers me, I fix it and make so that it works in my project

#

Others just copy paste and then they're like "Why doesn't it work?"

#

Yeah

slate swan
#

I understand all code i copy i just dont like doing long commands so i just copy them and fix them for my code 🤷‍♂️

slate swan
#

Back to topic pleasepithink

#

@slate swan sorry for the ping but what's the difference between a corountine and a function and are they the same thing?

#

They do the same, but are used in different context

#

Basically in short words, a coroutine runs in background

#

So doesn't stop your entire program from running

#

Ah i see

#

If you call 2 functions one after the other, the second function will only be executed when the first is finished

#

So its a async function?

#

If you turn the first function in a coroutine, it will run in background and the second can run simultaneously

#

Basically yeah, just add async

#

Then there are different usages

#

Thank you for the explanation i just gotta get my terminology yert

#

You can do

asyncio.run(main())

considering main is a coroutine

#

I see🤔

#

And like

slate swan
#
await echo("world")
echo("Hello")

gives some output like:

Hello
world
world
Hello
world
Hello
Hello
world
world
Hello
#

echo just prints 5 times the string from the argument

#

And as you can see both functions are running simultaneously

#

Without a coroutine it would just be 5 times world and 5 times Hello

#

Why 5 times?

#

That's what the function does

#

Prints 5 times the string

#

Hmmmm

#

Yeah lazy to copy the function code

#

Thank you bro 👍 yert

#

Wait

#

Yeah nevermind

#

Should be both 2 different functions

#

Lmao

#

Yeah I don't understand Python anymore

slate swan
#

You can only use await if it has async keyword

#

That's why I hate Python

#

Can't turn a function to a coroutine whenever you want

slate swan
#

Sucks ig

#

That's why I don't do projects that needs to be asynchronous with Python

slate swan
#

Like

#
async def echo():
    print("coro")

asyncio.run(echo())
echo()
#

This is not possible

#

Second call will return error

#

It won't return error

#

it will

#

A RuntimeWarning

slate swan
#

Which won't execute the code in the function

#

Ah right, mb

slate swan
#

It'll just say it wasn't awaited

#

Oh that was- ah never mind

#

Ah

#

It's just pain

#

That's why I hate Python's asynchronous coding

slate swan
slate swan
#

so im trying to use a command in dms but i keep getting this error discord.ext.commands.errors.NoPrivateMessage: This command cannot be used in private messages.

#

You have a check on the command that prevents you from executing the command in private messages

#

You probably have something like @commands.guild_only()

#
@bot.command()
@commands.is_owner()
 #permissions
async def role(ctx, user : discord.Member, *, role : discord.Role):

  if role in user.roles:
      await user.remove_roles(role) already has
      await ctx.send(f"Removed {role} from {user.mention}")
  else:
      await user.add_roles(role) 
      await ctx.send(f"Added {role} to {user.mention}") 
boreal ravine
#

DMs don't have "roles"

slate swan
#

You can't add roles from a private message

#

oh

slate swan
# slate swan oh

You need to get a member object from the guild, not a user object, and add roles to that

#

how would i do that

full valley
#

What’s the simplest way to give your bot a custom prefix function

slate swan
#

Get guild
Guild.get_member
Member.add_role
Iirc. I might be wrong

slate swan
full valley
#

yeah

grand shell
#
    async def on_reaction_add(self, user, reaction):
        print("Normal Reaction")

hey guys. for some reason, this event is never called. 'on_raw_reaction_add' does though. Does anyone know why? thanks :))

slate swan
grand shell
#

ahhh ok

slate swan
#

Just read the docs on those, pretty good stuff

grand shell
#

lemme test somethin

grand shell
slate swan
#

I haven't really worked with multiple server bots before, so I just:
On_command: change prefix
Write new prefix to db
Bot.prefix=new prefix

And while initiating I select it from the db

#

That is one way, I'm pretty sure there are better.

slate swan
#

is it possible to use an image from my local pc instead of a URL in an embed?

slate swan
#

ah thanks , i figured out

#

:D

#

now new problem
How to attach an image from a url without an embed?

boreal ravine
#

u mean like sending a normal image?

slate swan
#

yessir

#

i have a url of that image

boreal ravine
#

ah

#

!d discord.File you gotta save the image in this

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
boreal ravine
#

!d discord.TextChannel.send then send it using the file kwarg

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

no

#

without saving or embed

boreal ravine
#

It isnt an embed

boreal ravine
slate swan
#

Works

#

🥲

boreal ravine
#

Bruh ok

hazy agate
#

hey

boreal ravine
#

What

hazy agate
#

how can i make a tic tac toe bot

boreal ravine
#

Make it ez

hazy agate
#

can somebody guide me

#

then i will go to yt

#

if no body helps me

rich escarp
#

@hazy agate you'd be better off finding a prerecorded help video vs a chat app

#

If you need help you can ask here

hazy agate
#

ok

slate swan
#

How to get the permission integer of bot in a guild?

slate swan
#

if bot has admin perms, it would return 8

full valley
#

Hey can someone help me out with a custom prefix command.

#

Im using mongo db

#

I originally tried:



def get_prefix(bot, message):
    options = settings.find_one({"guild_id": message.guild.id})
    prefixes = options["prefix"]
    return prefixes

bot = commands.Bot(command_prefix=get_prefix)

@bot.event
async def on_guild_join(guild):
    guild = settings.find_one({"guild_id": guild.id})
    if guild is None:
        newguild = {"guild_id": guild.id, "prefix": "!", "game_id": 1, "qsize": 6}
        settings.insert_one(newguild)

@bot.command(pass_context=True, name="prefix", description="Change the bot prefix")
async def prefix(ctx, prefix):
    if ctx.channel.id in allowed_channels:
        options = settings.find_one({"guild_id": ctx.guild.id})
        settings.update_one({"guild_id": ctx.guild.id}, { "$set": { 'prefix': prefix } })
        embed = discord.Embed(description=f"The prefix has been update to {prefix}", color=0xE74C3C)
        embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
        await ctx.channel.send(embed=embed)
slate swan
unkempt canyonBOT
#

The raw value. This value is a bit array field of a 53-bit integer representing the currently available permissions. You should query permissions via the properties rather than using this raw value.

slate swan
#

and you would use something like , guild.me.guild_permissions to get the discord.Permissiom object

full valley
#

I just tried something

slate swan
#

Is settings variable your mongo client?

full valley
#

settings is my collection

#
cluster = MongoClient(
    "mongodb+srv://~")
database = cluster["6mans"]
pstats = database["stats"]
settings = database["settings"]
#
  File "D:\6Mans\Main\mainwithdict.py", line 15, in get_prefix
    prefixes = options["prefix"]
TypeError: 'NoneType' object is not subscriptable
boreal ravine
#

options

#

is none

full valley
#

so how would I fix that

boreal ravine
#

insert something

full valley
#

o wait

boreal ravine
#

👀

full valley
#

fixed

sullen shoal
sullen shoal
#

nothing very much

#

aight i gotta go debug my code

tired agate
#

my console bully me pls help 02heart

slate swan
#

how do i make a 'only visible to you' message from interaction in a server

#

like drop down

#

my mistake?

slate swan
#

@unkempt canyon

#

@trail flower

#

help me plz

#

1st, don't @ people wtf is wrong with u
2nd, you didn't save and restart

boreal ravine
#

Nice

slate swan
#

Yeah already told that around 3 weeks earlier

slate swan
#

5 hours ago

slate swan
slate swan
#

I am using dpy 2

#

If you're using discord.py 2.0 it's ephemeral=True apparently

#

Thanks!

strong kettle
#

How can I wait for the member response and take an example, write your name, then write the member and say to him, write your age

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
ornate lichen
#
@client.command(pass_context = True)
async def mute(ctx, member: discord.Member):
     if ctx.message.author.server_permissions.administrator:
        role = discord.utils.get(member.server.roles, name='Muted')
        await ctx.add_roles(member, role)
        embed=discord.Embed(title="User Muted!", description="**{0}** was muted by **{1}**!".format(member, ctx.message.author), color=0xff00f6)
        await ctx.send(embed=embed)
     else:
        embed=discord.Embed(title="Permission Denied.", description="You don't have permission to use this command.", color=0xff00f6)
        await ctx.send(embed=embed)
#

nothing shows up

#

when i run it

boreal ravine
#

anyways server doesnt exist

#

use guild instead

slate swan
#

And change

await ctx.add_roles(member, role)
to
await member.add_roles(role)

ornate lichen
#

oh

slate swan
#

And yeah, don't copy paste code

ornate lichen
#

it worked

#

thanks

ornate lichen
#

i just wanted to try it

cinder horizon
#
  meh = time.datetime.now() + time.timedelta(seconds=timed)
  meheh = meh.strf('%A %d %B %Y at %H:%M:%S %p')
  await ctx.send(meheh)
Command raised an exception: AttributeError: 'datetime.datetime' object has no attribute 'strf'
```...wut do i do?
slate swan
#

Pretty sure it's strftime

ornate lichen
#

it only works in one server

slate swan
#

Because the role doesn't exist on the other

cinder horizon
slate swan
cinder horizon
#

..aighty

ornate lichen
#

it doesnt work in my own server

#

only in my friends one

slate swan
#

Don't copy paste code anyways

#

Bot might not have permissions or role not existing

patent surge
#

How to change bot's pfp ?

slate swan
#

Developer portal

ornate lichen
#

the Muted?

slate swan
#

Yes

patent surge
ornate lichen
#

alr

slate swan
#

bot role above the muted role?

ornate lichen
#

yeah

#

wait

#

yup still doesnt

ornate lichen
#

same prob'

boreal ravine
slate swan
#

image needs to be a bytes-like object

gaunt ice
#

Code: ```@tasks.loop(minutes=60)
async def send():

channelAutomeme = bot.get_channel(903173605364469770)
content = requests.get("https://meme-api.herokuapp.com/gimme").text
data = json.loads(content,)
response = data['url']
await channelAutomeme.send(response)

@send.before_loop
async def before():
await bot.wait_until_ready()```

Error:Unhandled exception in internal background task 'send'. Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop await self.coro(*args, **kwargs) File "main.py", line 471, in send await channelAutomeme.send(response) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1065, in send data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request raise Forbidden(r, data) discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

#

halp

slate swan
#

your bot does not have enough permissions

gaunt ice
#

oh

#

okk tysm

#

what perms does it need to do this

slate swan
#

your bot can't send a message in the channelAutomeme channel

gaunt ice
#

ohh

#

okk tysmm

slate swan
#

so you should make sure it has the send messages permission in the channel

pallid harbor
#

how can I get user display name from specified guild?

slate swan
#

nickname?

#

member.nickname

gaunt ice
#

YO TYSM IT WORKS

slate swan
#

you're welcome

patent surge
#

why my tasks.loop() does not works ?

slate swan
#

what's the error?

gaunt ice
#

it works

slate swan
#

"does not work" isn't helpful for anyone, send the error

patent surge
slate swan
#

send code

gaunt ice
#

did u import discord.ext tasks

slate swan
#

he said no error

gaunt ice
#

hmm

patent surge
slate swan
#

have you started the loop?

patent surge
gaunt ice
#

ok

slate swan
patent surge
#

yes got it

pallid harbor
dapper cobalt
#

!d discord.Member.nick

unkempt canyonBOT
slate swan
#

“The 10 minute cooldown for changing avatars was brought in to stop people from abusing the avatar function using scripts to create a free 'animated' avatar.
Just as side note @patent surge

dapper cobalt
#

It's nick and not nickname.

slate swan
pallid harbor
#

Can I get user's nickname with that if I have their id?

slate swan
#

yes

#

just put id in place of name

#

discord.utils.get(guild.members, id=member_id)

patent surge
slate swan
#

10*

slate swan
#

!d discord.Guild.get_member

unkempt canyonBOT
patent surge
pallid harbor
slate swan
sage otter
#

Not in the guild then.

pallid harbor
slate swan
#

id is already a member object

patent surge
#

await client.user.edit(avatar=next(pfp))

#

gives error

slate swan
#

what error

patent surge
#

Unhandled exception in internal background task...

slate swan
#

full backtrace

pallid harbor
slate swan
pallid harbor
slate swan
#

whereas you need a nickname

patent surge
#

How to change the bots pfp using discord py

gaunt ice
#

homo i need to get list of members of the server , how to

slate swan
#

guild.members

pallid harbor
gaunt ice
#

thats it?

slate swan
#

returns a list of the members inside the guild

gaunt ice
#

okk ty

slate swan
sage otter
pallid harbor
dapper cobalt
#

Why do you have client and bot?

slate swan
pallid harbor
sage otter
slate swan
#

Is there any difference between Client and Bot? @dapper cobalt

sage otter
#

If you want the message authors nickname. Literally just do
message.author.nick

slate swan
pallid harbor
slate swan
#

Here they are

slate swan
#

thanks!

dapper cobalt
# pallid harbor

You have many useless variables. Could you please send your code?

slate swan
dapper cobalt
#

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

slate swan
#

one-liner

dapper cobalt
slate swan
#

depends on if he wants to get the nick of the message author or another member

dapper cobalt
#

!d discord.Message.author

pallid harbor
# dapper cobalt You have many useless variables. Could you please send your code?
import discord
from discord.ext import commands

client = discord.Client()

@client.event
async def on_message(message):
    if not message.guild:
        if message.author.id != 811223402308042792:
            avatar = client.user.avatar_url

            id = message.author.id
            username = await client.fetch_user(id)
            image = message.attachments[0].url
            message1 = message.content
            await message.add_reaction('👍')

            channel = client.get_channel(907619999114489886)
            guild = client.get_guild(886255929044111420)
            display_name = discord.utils.get(guild.members, id=message.author.id)
            print(display_name)
            try:
                embed = discord.Embed(title="Новая фотокарточка", description=message1, color=0x2F3136)
                embed.set_author(name=f"{username}", icon_url=avatar)
                embed.set_image(url=image)
                await channel.send(embed=embed)
            except:
                embed = discord.Embed(title="Новая фотокарточка", color=0x2F3136)
                embed.set_author(name=f"{username}", icon_url=avatar)
                embed.set_image(url=image)
                await channel.send(embed=embed)

    else:
        if message.author.id == 811223402308042792:
            await message.add_reaction("👍")
            await message.add_reaction("🍞")
            await message.add_reaction("👎")


@client.event
async def on_ready():
    print('Запущено')

client.run('')
unkempt canyonBOT
patent surge
dapper cobalt
slate swan
pallid harbor
slate swan
patent surge
slate swan
pallid harbor
#

that's how it looks now

slate swan
#

asking for a friend, how many messages can a discordbot send before not being able to? (per min)

dapper cobalt
patent surge
#

Can bots send friend request?

slate swan
#

no

#

I don't think so

sage otter
dapper cobalt
# pallid harbor ```py import discord from discord.ext import commands client = discord.Client()...
import discord
from discord.ext import commands

client = discord.Client()

@client.event
async def on_message(message):
    if not message.guild:
        if message.author.id != 811223402308042792:
            guild = client.get_guild(886255929044111420)
            display_name = guild.get_member(message.author.id).nick or message.author.name
            await message.add_reaction('👍')

            channel = client.get_channel(907619999114489886)

            embed = discord.Embed(title="Новая фотокарточка", color=0x2F3136)
            if message.content:
              embed.description = message.content
            embed.set_author(name=message.author.name, icon_url=client.user.avatar_url)
            embed.set_image(url=message.attachments[0].url)
            await channel.send(embed=embed)

    else:
        if message.author.id == 811223402308042792:
            await message.add_reaction("👍")
            await message.add_reaction("🍞")
            await message.add_reaction("👎")


@client.event
async def on_ready():
    print('Запущено')

client.run('')
#

Edited.

slate swan
#

why does my bot print this everytime it starts up lol

main.py:80: RuntimeWarning: coroutine 'Command.__call__' was never awaited
#

funny enough, line 80 has nothing in it

#

Guyz

patent surge
slate swan
#

How To False Add Reaction ?

pallid harbor
slate swan
slate swan
# slate swan you tried to use a variable before defining it
@bot.listen()
async def on_message(message): 
  if "dropping" in message.content:
    if message.author.id == 603446902393929728 or 646937666251915264 or 815289915557675118 or 707787324469280799:
      if "3 cards" in message.content:
        n = 4 
      elif "4 cards" in message.content:
        n = 5
      elif "2 cards" in message.content:
        n = 3
       
      attachment = message.attachments[0]
      a = attachment.url
        
      r = api.ocr_url(a)
      buf = io.StringIO(r)
      char = []
      for i in range(1,n):
        try:
          x = buf.readline()
          dict = ani.search.character(x, page = 1 , perpage = 1)
          a = dict['data']['Page']['characters'][0]['favourites']
          b = dict['data']['Page']['characters'][0]['name']['full']
          if a < 301:
            rarity = "Common"
          elif 300<a<1001:
            rarity = "Uncommon"
          elif 1000<a<2401:
            rarity = "Rare"
          elif 2400<a<6001:
            rarity = "Exotic"
          elif 6000<a<10001:
            rarity = "Legendary"
          elif 10000<a:
            rarity = "Godly"
          try:
            ping =get(message.guild.roles, name=str(rarity))
            pm = ping.mention
          except :
            pm == "NO-PING"
            pass
          print (pm)
        except:
            
          pass
        try:
          c = str(i) + ". "+"**Character:** "+str(b)+" **Rarity:** " + str(rarity) + " :CH_wink:" + "**Ping:** "+ pm
          
          char.append(c)
          ch = '\n'.join(char)
        
        except:
          pass
      await message.reply(ch)
      print ("dropped")
      
keep_alive()      
bot.run(token)


where is the mistake here?, it was working before i added the keep alive

dapper cobalt
slate swan
slate swan
dapper cobalt
#

Do you mean remove a reaction?

slate swan
#

there is literally nothing in line 80

#

if i want to send to a specific channel shouldn't

channel = bot.get_channel(810282417850941440)
await channel.send(text)

work?

patent surge
gaunt ice
patent surge
#

How to I change bot's pfp ?
Someone explain me how do I get this

rare saddle
#

How to make a time check function? I am making a mute command and I need to make a function that, after a person is muddied, will check whether the mutation period has ended or not

dapper cobalt
pallid harbor
slate swan
gaunt ice
#

asyncio.sleep(we can only keep seconds?)

slate swan
#

yes

gaunt ice
#

ah

slate swan
#

use 60*60 for minutes

#

e.g

asyncio.sleep(60*60) # sleeps for 60 mins
#

Guyzzzz How to False add reaction ?

gaunt ice
#

okk

dapper cobalt
slate swan
slate swan
#

members cant add reaction ticket tool

dapper cobalt
#

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

if i want to send to a specific channel shouldn't

channel = bot.get_channel(810282417850941440)
await channel.send(text)

work?

sage otter
#

Honestly I’m not too fond of sleeping commands for reasons like that. Completely halts the full execution of the functions which isn’t that nice. Consider loop.call_later() or something

slate swan
rare saddle
slate swan
#

asyncio.sleep doesn't block

sage otter
#

I’m not saying it blocks but it doesn’t allow the full execution of the command

boreal ravine
slate swan
gaunt ice
slate swan
#

i added a check

boreal ravine
#

whatt does it print

gaunt ice
#

hmm what shud it do , tell that and i will telll u

rare saddle
slate swan
#

it print's the correct number

boreal ravine
slate swan
sage otter
rare saddle
#

@slate swan

gaunt ice
boreal ravine
gaunt ice
#

ye

slate swan
pallid harbor
gaunt ice
#

ohhh u mean it shud send text in random channels?

slate swan
#

my 3channels on MY discord server (i'm giving a notification to multiple channels with different people on them)

sage otter
# slate swan

Bruh. What’s the point of casting. Just remove the quotes off the ids in that list.

gaunt ice
#

u can do
await channel1.send()
await channel2.send()
await channel3.send()

slate swan
#

the channels will change over time

slate swan
gaunt ice
#

hmm

sage otter
slate swan
# slate swan

the id that you pass on to bot.get_channel must be an integer

slate swan
#

thanks iguess?

boreal ravine
#

Well

#

you did cast i in some random place