#discord-bots

1 messages · Page 541 of 1

slate swan
#

try doing this too

#

see what's not printing

river kindle
#
@client.command(description="Muta un utente")
@commands.has_guild_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):

  guild = ctx.guild
  mutedRole = discord.utils.get(guild.roles, name="Mutato")

  if not mutedRole:
    mutedRole = await guild.create_role(name="Mutato")


    for channel in guild.channels:
      await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_messages_history=True, read_messages=False)

  
  await member.add_roles(mutedRole, reason=reason)
  await ctx.send(f"Ho mutato {member.mention} | Motivo: {reason}    ")
  await member.send(f"Sei stato mutato in  {guild.name} | Motivo:  {reason}  ")```


this is the code
slate swan
#

nothing looks wrong

river kindle
#

ik

ripe jackal
#

exactly

slate swan
#

except that you named your bot var client instead of bot 🤨

#

naming conventions, won't actually affect your code but it'll look nicer

ripe jackal
#

it's depending on what a person finds nice

slate swan
#

anyways, after you added some print statements lmk where it's not printing but you know that it should

ripe jackal
#

for me client is better :p

river kindle
#

mh

slate swan
#

what version of dpy are you on

river kindle
river kindle
slate swan
#

could also be that the dpy version that you're using is extremely outdated

ripe jackal
#

2.0.0a3

slate swan
#

weird

river kindle
#

ah?

slate swan
#

hmm pithink

river kindle
#

sy baka

#

how i can fix it

slate swan
#

wait i just noticed, are you using this in another file

ripe jackal
#

no

slate swan
#

alr pithink

slate swan
#

and the code looks alright too

#

are you sure that you're passing the right token? and that you're running the bot?

#

or do you by any chance have anything that's blocking in your code

slate swan
#

then idk ¯_(ツ)_/¯

river kindle
#

no, problem thanks

ripe jackal
#

if someone have an answer, pls answer it lol

#

this is what i found, but it seems not working too :/

tawdry perch
#

Heroku seems to work with aiosqlite, interesting

slate swan
#

your embed needs to have either a description or a title
@ripe jackal

#

pretty sure

slate swan
#

pretty nice, innit

hasty iron
#

that’s not remotely close to naming a Bot instance client

#

since Bot subclasses Client we can say it’s okay to name it client

#

but str doesn’t subclass int so that doesn’t make sense

slate swan
#

👍

calm vortex
tawdry perch
#

Not sure, it just happens to work

#

may be a data loss on restart tho

calm vortex
#

Oh

tawdry perch
#

I have not tested it yet

calm vortex
#

It probably will be

tawdry perch
#

I will anyways be rewriting the whole database to mongodb

#

or postgres, not 100% sure yet

calm vortex
slate swan
#

Is there a way I can store all my commands in one file and then require them in the main file?

tawdry perch
#

cogs?

calm vortex
stiff ermine
#

can we set bot's status offline even if its actually online ?

#

like how i am now

hasty iron
#

yes

stiff ermine
#

oh found it

#

await client.change_presence(status=discord.Status.offline)

#

it seems not working

slate swan
tawdry perch
#

good to know

slate swan
#

i could be wrong tho

#

no it's not space limit, it's rows limit

#

you can have a max of 10k rows

#

Hello, i want some help, when i try to connect the mongo db i have a certificate error

#

Someone can help me please

#

If I was to store a users xp would i use mongodb?

slate swan
#

you're more likely to get help there

slate swan
#

K thx

#

Hello i have a cmd sp!setup that sends a message and waits for 30s but if the author again replies sp!setup, the message get taken but the same cmd runs again. How to prevent it?

slate swan
#

Don't change_presence (or make API calls) in on_ready within your Bot or Client.
Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 close code) and there is nothing you can do to prevent it.

Instead set the activity and status kwargs in the constructor of these Classes.

bot = commands.Bot(command_prefix="!", activity=..., status=...)

As noted in the docs, on_ready is also triggered multiple times, not just once.

Basically: don't 👏 do 👏 shit 👏 in 👏 on_ready.

tawdry perch
#

I create database at on_ready

boreal ravine
boreal ravine
hasty iron
#

use a startup task

boreal ravine
slate swan
#

How do I get a list of the names of the servers the bots are join?

slate swan
unkempt canyonBOT
#

property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
lament mesa
#

client.guilds

slate swan
tawdry perch
#

Never understood that method so I always create connection on every command

slate swan
#

Can anyone tell me, is there a way to pass parameters such that
....
if a user enters a sentence and then type -b and and then another sentence so I want my bot to put sentence 1 in variable 'a' and sentence 2 (after -b) in variable 'b'

vocal plover
#

At last I have my shard ratelimiter not spamming the gateway with identifies Kek

boreal ravine
#

hm

slate swan
#

!d str.split

unkempt canyonBOT
#

str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).

If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.

For example:
slate swan
#

Is it possible to generate an invitation link from a server id?

slate swan
slate swan
#

as well as having permissions to create an invite

slate swan
slate swan
# slate swan using `str.split('-b')`

imagine if there are different splits like that...

for example, first two sentences get spilit by -b and then to split in the third, we need -c

like xsplit I am blank -b I am a male -c I went to a party

slate swan
slate swan
errant shuttle
#

um........ ok....

slate swan
slate swan
#

e.x: ```py
string = "I am blank -b I am a male -c I went to a party"
split = string.split('-b')
split_c = split[-1].split('-c')

boreal ravine
slate swan
slate swan
#

!d discord.Guild.text_channels

unkempt canyonBOT
#

property text_channels: List[discord.channel.TextChannel]```
A list of text channels that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
slate swan
#

this returns a list of the guild's channels

boreal ravine
#

a for loop maybe

slate swan
#

you don't even have to do a for loop actually

slate swan
#

you can just index the 1st

slate swan
#

indexing with -1 returns the last element

#

o yeah yeah

boreal ravine
slate swan
#

but if you wanna get that kind of info from a user i recommend using wait_for

boreal ravine
#

hm

slate swan
slate swan
#

yw

errant shuttle
boreal ravine
errant shuttle
boreal ravine
#

hm nice

cloud dawn
#

objects are not that hard right? right??

boreal ravine
#

Lmfao

errant shuttle
cloud dawn
#

Lol

#

OOP is easy to learn but hard to master.

boreal ravine
#

!e

dict = {"name":"panda", "age":18, "gender":"male"}
print(dict)
unkempt canyonBOT
#

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

{'name': 'panda', 'age': 16, 'gender': 'male'}
boreal ravine
#

idk whats hard pithink

cloud dawn
#

I'm 18 😥

boreal ravine
#

hm

errant shuttle
boreal ravine
#

cool

zenith zinc
#

Hii my friend

#

!e

slate swan
#

never used it

#

i can't really recommend something that i never used myself when there's something that i know how to use in that area

rotund creek
#

hi

slate swan
#

if you go with the mindset that you only need a discord bot and that you don't wanna learn the language, then you'll struggle with absolutely everything and never learn anything

#

which is literally what 80% of the discord bot devs do

dusk pumice
#

How can I get the owner of server?

#

or the owner id

#

anyone here?

#

😐

graceful gorge
#

helppppppp

slate swan
dusk pumice
#

tnx

dawn wasp
#

Hi everyone , Any idea on how to hide or disable a specific slash command and keep it enabled only for owner/admins

slate swan
#

depends on what your using fot slash commands

graceful gorge
#

lol

#

hooooooooooo

dawn wasp
dawn wasp
slate swan
#

As he said, it depends on what lib/fork you're using for slash commands

#

Every lib/fork does it differently

dawn wasp
slate swan
#

Ah, never used discord_slash, so idk how or if they even support perms for slashes

#

You could ask in their support server, you'd have more chances of getting help there

#

im gonna check discord_slash github and source code for abit

#

wait how do i make my bot delete his own message?

maiden fable
slate swan
#

bruh

maiden fable
slate swan
#

ty

slate swan
maiden fable
slate swan
#

wtf

#

why bot cant delete embed

#

ok nvm

dusk pumice
#

How can I make a role?

slate swan
maiden fable
unkempt canyonBOT
#

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

Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

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

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
dusk pumice
#

okay

#

thanks

maiden fable
#

(:

dusk pumice
maiden fable
#

Eh, I was here only, sooo 🤷‍♂️

dusk pumice
#

LOL

dawn wasp
dusk pumice
maiden fable
#

Nope, remove the *

dusk pumice
#

Than is it all?

maiden fable
#

Eh, u r doing the perms wrong. Also, remove the reason kwarg if u want it to be None

#

Permissions accept a dict of perms iirc

dusk pumice
#

huh?

#

I don't understand

maiden fable
#

Lemme give u an example. Gimme 1

dusk pumice
#

okay

#

thanks

dawn wasp
maiden fable
#

Try doing this

dusk pumice
#
await create_role(name="Muted", permissions={
"send messages": True, 
"embed links": True
}, color="e90000", reason="Hunter did it. not me!")
#

this???

#

😐 😦

bright palm
#

permissions=discord.Permissions(send_messages=True, embed_links=True)

#

Should be like that

dusk pumice
#

OMG

#

okay

#

\🏓

slate swan
#

how do i make that it shows specific item icon and not flood the chat

#

putting icon id into inventory 💀

slate swan
blissful bridge
#
    @commands.Cog.listener()
    async def on_message(self, message):

        print("executed?")
        await message.channel.send("am i looping?")

when i send i message like this it just repeatedly executes the on_message command so i get a infinite loop of the "executed?" text. However if i remove the "await message.channel.send" it only sends it one. does anyone know how to get it to stop looping?

boreal ravine
blissful bridge
#

what do you mean?

boreal ravine
blissful bridge
#

yeah

dawn wasp
slate swan
#

how do i fix this that it wont flood the embed and it show the specific item icon

@bot.command(aliases = ['inv'])
async def inventory(ctx, member : discord.Member=None):
  print(f"{ctx.author} issued inventory command")
  if not member:
    await open_account(ctx.author)
    user = ctx.author
    users = await get_bank_data()

    try:
        inventory = users[str(user.id)]["inventory"]
    except:
        inventory = []


    em = discord.Embed(title = "Inventory")
    for item in inventory:
      for icon in mainshop:
        name = item["item"]
        amount = item["amount"]
        icon = icon["icon"]

        em.add_field(name = f"{icon} {name}", value = amount, inline=False)    

    await ctx.reply(embed = em)```
slate swan
#

Never used discord_slash

boreal ravine
unkempt jacinth
#

Been using Heroku hosting service for a while - it's good but it cycles randomly causing the bot to restart and forget locally stored text files and so on. Is there a service which does not cycle and wont restart my bot for any reason?

blissful bridge
dawn wasp
slate swan
#

You can use forks

#

I recommend disnake, it has the exact same syntax as dpy 2.0

slate swan
#

And it's by far the best fork out of any other

boreal ravine
slate swan
#

but i need the specific item icon

blissful bridge
# boreal ravine hm

oh its looping because it detects it's own event so executes the on_message again to respond to the message it just sent. hence an infinite loop ...

waxen granite
#
        limitmsg = "The limited commands in this server are:\n"
        limitmsglist = []
        for command in guildLimit.keys():
            cmd = self.bot.get_command(command)
            cogname = cmd.cog.qualified_name
            channelList = guildLimit[command]
            if len(channelList) == 0:
                continue
            else:                
                limit_msg = f"**Command:** `{command}`, **CogName:** `{cogname}`\n"
                for channelid in channelList:
                    channel = self.bot.get_channel(channelid)
                    limit_msg += f"     **Channel:** {channel.mention} | **Channel ID:** `{channel.id}`\n"                    
                if len(limitmsg) + len(limit_msg) < 2000:
                    limitmsg += limit_msg
                else:
                    limitmsglist.append(limitmsg)
                    limitmsg = limit_msg                    
        for limitmsg in limitmsglist:
            await ctx.send(limitmsg)```
for some reason it is not sending the full list
hasty iron
fleet axle
#

hey I need help
whenever I delete a channel it says 'NoneType' object has no attribute 'delete'
any help please

hasty iron
#

we don’t have telepathic powers

fleet axle
#

wdym?

#

Do I have to send code here?

hasty iron
#

who knows

#

think about it with your brain

#

create_role is not defined and that’s not how you add permissions

#

!d discord.Guild.create_role

unkempt canyonBOT
#

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

Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

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

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
dusk pumice
#

than

hasty iron
#

read

dusk pumice
#

....

#

I read that docs already

hasty iron
#

doesn’t seem like it

slate swan
hasty iron
#

it clearly says permissions takes a Permissions object

#

and you’re passing in a dict

#

so i dont know

dusk pumice
#

...

#

😐

#

:

slate swan
#

replit

#

oh that's replit? :P

#

vscode when

fleet axle
#

alr found the solution

soft widget
#

can someone help me with this kind of error?

slate swan
#

show code

hasty iron
#

and you need to subclass commands.Cog not commands.cog

slate swan
hasty iron
#

and follow naming conventions

slate swan
#

^

#

How can I store all my commands in one file and then require them in the main file?

dusk pumice
#

Can you guys give me an ex code to made a role with bot?

slate swan
#

how to make a check that if its not admin then he cannot use the command?

#

not the server

#

How can I make it if a message is over the discord limit, make the bot say “…” or “message is too long”

slate swan
#

you get the message author

#

and you see if the user has the

#

role

#

nono

#

any way by which i can make MY CODE add NEW commands to itself?

#

like
admin = 'my friends id', 'my id', 'my another friends id'

#

and if its not admin then the command returns false

manic wing
#
@bot.check
async def admincheck(ctx):
      if ctx.author.id not in adminlist:
             return False
          return True```
#

ignore mobile indenting

manic wing
unkempt canyonBOT
#

add_command(command)```
Adds a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") into the internal list of commands.

This is usually not called, instead the [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.command "discord.ext.commands.GroupMixin.command") or [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.group "discord.ext.commands.GroupMixin.group") shortcut decorators are used instead.

Changed in version 1.4: Raise [`CommandRegistrationError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandRegistrationError "discord.ext.commands.CommandRegistrationError") instead of generic [`ClientException`](https://discordpy.readthedocs.io/en/master/api.html#discord.ClientException "discord.ClientException")
manic wing
#

I think theres a better way to do it but I can’t remember how

slate swan
#

but it's too much work

slate swan
manic wing
soft widget
manic wing
untold moon
#

can someone help me pls

manic wing
manic wing
untold moon
#

my friend was helping me but he had to go to sleep

slate swan
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
manic wing
slate swan
#

use this check , with administrator=True

manic wing
slate swan
untold moon
manic wing
untold moon
manic wing
#

just say the error

untold moon
#

File "main.py", line 37
async def ban(): …:
^
SyntaxError: invalid character in identifier

untold moon
slate swan
#

How would I code a bot where every time someone joins it dms them

covert igloo
#

on_member_join

slate swan
#

How would it dm em

covert igloo
#

await member.send

soft widget
#

@manic wing its fix now thanks

slate swan
#

O

#

Ty

covert igloo
#

There's also a lot of vids just look it up @slate swan

untold moon
#

😭

covert igloo
#

Send ur code

untold moon
#

?

#

me?

covert igloo
#

Yes

untold moon
#

dms?

covert igloo
#

Send it here

untold moon
#

what code

covert igloo
#

The code block that's raising the error

untold moon
#

File "main.py", line 37
async def ban(): …
^
SyntaxError: invalid character in identifier

covert igloo
#

Send the whole code

untold moon
#

i can send u collab link in dms

covert igloo
#

Just send a ss lol

untold moon
#

what is ss btw

slate swan
# manic wing ```py @bot.check async def admincheck(ctx): if ctx.author.id not in adminl...

idfk how to use @bot.check so i did this

  adminlist = ["460479556156129291", "629606911062573059"]

  if not user:
    if ctx.author.id not in adminlist:
      await ctx.reply("You are not admin.")
      return False
    else:
      #hypeblox : 460479556156129291
      #gnbimgoid : 629606911062573059
      await open_account(ctx.author)

      users = await get_bank_data()
      
      users[str(ctx.author.id)]["wallet"] = amount

      with open("mainbank.json","w") as f:
        json.dump(users,f)
      
      await ctx.reply("Command executed successfully")
      return True```
untold moon
#

wait

#

lemme guess ss is screenshot?

covert igloo
#

Yes bro

untold moon
#

what 😭

manic wing
#

just use my exact code

untold moon
manic wing
#

@bot.check just runs before every command is activated

untold moon
#

@covert igloo

slate swan
#

with my command

covert igloo
#

Bro u ain't even finish making the command

#

Of course it will raise an error

slate swan
covert igloo
#

Why did u put dots

#

It literally underlined it

untold moon
#

what do i dooo

manic wing
#

I gsve an example

slate swan
#

so i can add my code into check?

manic wing
dapper cobalt
slate swan
#

what i have to do with that check

#

add it and whats next

#

how do i get member count of my server with bot?

dapper cobalt
unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
lament mesa
#

Guild.members

manic wing
dapper cobalt
#

Just guild.member_count.

manic wing
#

where guild is an instance of discord.Guild

lament mesa
#

*count

manic wing
#

both work

slate swan
#

pls expain fully

#

i add that check whats next?

slate swan
#

i add piece of code into check?

manic wing
#

lets start from the beginning

slate swan
#
@bot.listen('on_message')
async def on_message(msg):
    elif msg.content.lower().startswith('op'):
        sending=await msg.channel.send(f'{msg.guild.name} server is OP!')
        await sending.add_reaction('☑️')
    elif msg.content.lower().startswith('prefix'):
        await msg.channel.send('The prefix of the bot is ***`.`***')
    elif msg.content.lower() == 'ping':
        before = time.monotonic()
        message = await msg.channel.send("Pong!")
        ping = (time.monotonic() - before) * 1000
        await message.edit(content=f"The ping is- `{int(ping)}ms`")
    elif msg.content.lower().startswith('date'):
        today=today = date.today()
        await msg.channel.send("Today's Date is-"+'***'+today.strftime("%B %d, %Y")+'***')
    elif msg.content.lower().startswith('member'):
        await message.channel.send(len(guild.members))```
graceful gorge
#

hello can i have help

dapper cobalt
final iron
dapper cobalt
#

You haven't defined it.

slate swan
manic wing
#

there are many things you can do if you want to limit commands to only a certain group of people:
a) you can just put if ctx.author.id not in adminlist: return at the start of the command you don't want normal people to run. This works, but may be annoying for you to change later.
b) put hidden=True when you do the @bot.command() and then add a check like this:

@bot.check
async def botcheck(ctx):
  if ctx.author.id not in adminlist and ctx.command.hidden: return False # the command.hidden can act as an 'admin-only' command
  return True #this means its a normal command```
dapper cobalt
slate swan
#

will it work?
guild = bot.get_guild(ID)

dapper cobalt
#

!resources Please, learn Python before jumping into discord.py.

unkempt canyonBOT
#
Resources

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

dapper cobalt
unkempt canyonBOT
slate swan
#

lol i already know python

#

i am not familiar with d.py stuff

dapper cobalt
#

Good.

final iron
dapper cobalt
#

That's understandable.

slate swan
#

my bot has list of custom replies inside the cogs file

dapper cobalt
#

That's making it harder, tbh.

manic wing
slate swan
#

and, i dont want to add stuff to cogs

manic wing
#

when you learn what you're doing wrong you will have to rewrite ALL your code

final iron
manic wing
#

maybe shortterm its easier, but you're going to have to rewrite everything when you learn why commands and cogs are better

#

everyone folds at some point

lament mesa
slate swan
#

i want my bot to be able to reply to message
any way - by not using 'on_message'

manic wing
#

Noone likes a 2k long main.py -_-

slate swan
#

it's half of my code

manic wing
final iron
#

Also you're triggering these without a prefix

vocal plover
#

Mayhaps it would be good to show them how cogs can be better :P
There's a bunch of stuff about cogs at https://vcokltfre.dev/tips/cogs so you can see why they make life easier

slate swan
#

full code is-

@bot.listen('on_message')
async def on_message(msg):
    if msg.author == bot.user:
        return
    elif msg.content.lower().startswith('mochi'):
        lst=[':m:',':regional_indicator_o:',':regional_indicator_n:',':regional_indicator_k:',':heart:']
        await msg.channel.send("Monk's Bae")
        for x in lst:
            await msg.add_reaction(x)
    elif msg.content.lower().startswith('monk'):
        lst=[':m:',':regional_indicator_o:',':regional_indicator_c:',':regional_indicator_h:',':information_source:',':heart:']
        await msg.channel.send("Mochi's bae")
        for x in lst:
            await msg.add_reaction(x)
    elif msg.content.lower().startswith('op'):
        sending=await msg.channel.send(f'{msg.guild.name} server is OP!')
        await sending.add_reaction(':ballot_box_with_check:')
    elif msg.content.lower().startswith('prefix'):
        await msg.channel.send('The prefix of the bot is ***`.`***')
    elif msg.content.lower() == 'ping':
        before = time.monotonic()
        message = await msg.channel.send("Pong!")
        ping = (time.monotonic() - before) * 1000
        await message.edit(content=f"The ping is- `{int(ping)}ms`")
    elif msg.content.lower().startswith('date'):
        today=today = date.today()
        await msg.channel.send("Today's Date is-"+'***'+today.strftime("%B %d, %Y")+'***')
    elif msg.content.lower().startswith('member'):
        await message.channel.send(len(guild.members))```
untold moon
#

i dont understand pyhton

slate swan
manic wing
dapper cobalt
unkempt canyonBOT
#
Resources

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

manic wing
#

because msg.author is different to msg.content

slate swan
#

the function will return if the message is by BOT itself right?

patent lark
#

yep

#

you are returning if the author is equal to the bot

slate swan
#

lmao forgot

#

i have opened the code after 1 month ;-;

patent lark
#

if you return to the function call after that if check returns True, then it should stop executing if the bot calls on_message

slate swan
#

yes, ik it works
the problem is
i want my bot to replymembercount whenever someone types member

patent lark
#

simple, however i dont recommend making commands using on_message

final iron
#

^

slate swan
#

ik, but there is no way my bot would be knowing if someone types only member
cause it would need prefix first

final iron
#

Why would you want the command to trigger without a prefix though

#

Let's say some people were complaining about their ping in a game

slate swan
final iron
#

Your bot would just constantly be sending the ping of itself

vocal plover
#

ideally you should just use slash commands instead which discord prompt new users on, as they're designed to be more intuitive

patent lark
#
if message.content.startswith("member").lower():
    await message.channel.send(len(int(message.guild.members)))```.  i’m on my phone so forgive me if i messed up any syntax
final iron
#

I think most people don't like making slash commands

vocal plover
#

i mean, "sucks" tbh, discord's making people use slash commands so slash commands people should use

slate swan
patent lark
final iron
#

I personally just don't like the concept of slash commands

vocal plover
#

disnake's impl. of slash commands is pretty nice

slate swan
#

tries this

   elif msg.content.lower().startswith('member'):
        await msg.channel.send(len(msg.guild.members))```
gives `1`
patent lark
#

intents

final iron
#

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

patent lark
#

!intents

#

!d discord.Intents.members

unkempt canyonBOT
#

Whether guild member related events are enabled.

This corresponds to the following events...

patent lark
#

you need this specifically

slate swan
#

gtg i'll try later ty guys

patent lark
#

you’re welcome

waxen granite
crystal cliff
fringe zephyr
#

i was considering making some bash aliases to request and quickly respond to any notifications i may have in discord, do you guys know if something like that is against ToS? It's automation of a normal user i guess? but im not going to distribute it in any way.

#

i should say python scripts not aliases

waxen granite
#
        limitmsg = "The limited commands in this server are:\n"
        limitmsglist = []
        for command in guildLimit.keys():
            cmd = self.bot.get_command(command)
            cogname = cmd.cog.qualified_name
            channelList = guildLimit[command]
            if len(channelList) == 0:
                continue
            else:                
                limit_msg = f"**Command:** `{command}`, **CogName:** `{cogname}`\n"
                for channelid in channelList:
                    channel = self.bot.get_channel(channelid)
                    limit_msg += f"     **Channel:** {channel.mention} | **Channel ID:** `{channel.id}`\n"                    
                if len(limitmsg) + len(limit_msg) < 2000:
                    limitmsg += limit_msg
                else:
                    limitmsglist.append(limitmsg)
                    limitmsg = limit_msg                    
        for limitmsg in limitmsglist:
            await ctx.send(limitmsg)```
for some reason it is not sending the full list
reef shell
#

is it related to discord bots tho pithink

fringe zephyr
#

yes

waxen granite
#

@crystal cliff

fringe zephyr
#

the alternative would be for me to create a bot account and get it invited to servers im in, and then automate that

#

and in both cases id be using the discord API

reef shell
#

automating user accounts is against ToS

fringe zephyr
#

ah

desert musk
#

does anyone know zeobot?

fringe zephyr
#

is there such thing as a graphical bot client? like using a bot as if it were a normal user but you have your own client

final iron
pliant gulch
#

At least if you were to login the bots account via its token

#

To the discord client, otherwise I'm sure some programs out there exist for this purpose, but logging in as a bot is a grey area in the ToS I'd say

neon spear
#

When i try to use the command !dm i get this error: AttributeError: 'DMChannel' object has no attribute 'name'
Here is my code:

filenameArray = []

@client.event
async def on_message(message):
    if(message.channel.name == 'visitcard_database'):
        filename = message.attachments[0].filename
        filename.replace(".png","")
        filenameArray.append(filename)
    await client.process_commands(message)
    
@client.command()
async def dm(ctx):
    await ctx.author.send(filenameArray)
lusty swallow
#

you should add a check to filter out dm messages

neon spear
lusty swallow
#
if type(message.channel) != discord.DMChannel:
    # do code
```This is just a sample. You can expand this depending on your requirements
neon spear
lusty swallow
#

it's because of the dm thing. Dm channels doesn't have a name

neon spear
#

@lusty swallow got it working

lusty swallow
#
filenameArray = []

@client.event
async def on_message(message):
    if type(message.channel) != discord.DMChannel:
        if(message.channel.name == 'visitcard_database'):
            filename = message.attachments[0].filename
            filename.replace(".png","")
            filenameArray.append(filename)
    await client.process_commands(message)
    
@client.command()
async def dm(ctx):
    await ctx.author.send(filenameArray)
```This should work tho
neon spear
dapper cobalt
lusty swallow
neon spear
#

Thanks for the support guys appreciate it 😊

slate swan
#

true.lower()

#

or false.lower()

lunar helm
boreal ravine
#

@lunar helm max characters maybe

lunar helm
boreal ravine
#

max is 1024 iirc

lunar helm
#

ok let me try

slate swan
tawdry perch
#

.bm a embed thing

tender charm
#

Hello, I am making discord bot over python, and i am trying to make autorole, but it's not working. This is my code:```Intents = discord.Intents(messages=True, guilds=True, reactions=True, members=True)

bot = commands.Bot(command_prefix = '-')

@bot.event
async def on_member_join(ctx):
autorole = discord.utils.get(ctx.guild.roles, name = 'Member')
await ctx.add_roles(autorole)``` Can somebody help me please? I've tried everything and it still doesn't work

slate swan
#

well that's cool af

#

you have to paste intents=intents into your bot constructor

tender charm
#

So | bot = commands.Bot(command_prefix = '-', intents=intents)?

slate swan
#
bot = commands.Bot(command_prefix = '-', intents=intents)```
#

I'm not sure about this way of defining the intents

tender charm
#

Ok, I will try it.

slate swan
#

you wrote it with a capital letter

tender charm
#

It propably has to be Intents = Intents.. :D

slate swan
#

intents=Intents

tender charm
#

Its working ?!!?!?!?!?!!?!

slate swan
#

omg

#

👏

tender charm
#

I am finding why is it not working for 2 hours, and you wrote ONE thing, and its works

#

Actually god

#

Thank you so much bro!!!!!

slate swan
#

just come here when you have problems

#

using time so inefficiently

tender charm
#

Yes, i will. Again, thank you so much!!

slate swan
#

feels really bad

slate swan
#

what's the error

#

wait why are you deleting every role from a guild

#

what's that for

tawny shell
#

sad

slate swan
#

well we can't really help with such troll bots I think

maiden fable
#

Sad, nuke bots

kindred epoch
#

idk why ppl think nuking a guild is fun

maiden fable
#

🤷‍♂️

slate swan
#

how to make bot restart

    await ctx.reply("Restarting... :arrows_counterclockwise:")
    await ctx.bot.logout()
    print("Logged out")
    await ctx.bot.login("joe mama", bot=True)
    await ctx.reply("Done! :white_check_mark:")
    print("Logged in")```
kindred epoch
#

!d discord.ext.commands.Bot.login

unkempt canyonBOT
#

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

Logs in the client with the specified credentials.
kindred epoch
#

idk about that joe mama there

slate swan
#

do i need "token"

#

or just token

kindred epoch
#

token as str

lament mesa
#

the bots token from the dev portal

slate swan
#

nono

#

"bottoken" or bottoken

kindred epoch
#

the first one

slate swan
#

and the bot died

kindred epoch
#

show code

slate swan
#
  admins = 772460927685230592, 460479556156129291, 629606911062573059
  if ctx.message.author.id in admins:
    await ctx.reply("Restarting... :arrows_counterclockwise:")
    await bot.close()
    print("Logged out") 
    await bot.login("joe biden")
    await ctx.reply("Done! :white_check_mark:")
    print("Logged in")```
kindred epoch
#

bruh

slate swan
#

ikr

kindred epoch
#

did you replace the bot token with joe biden?

slate swan
#

ye

kindred epoch
#

ohk

lament mesa
#

Does login connect to the websocket though?

slate swan
#

why it logs out but doesnt log in

#

tell how now

maiden fable
lament mesa
#

!d discord.Client.start

unkempt canyonBOT
#

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

A shorthand coroutine for [`login()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.login "discord.Client.login") + [`connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.connect "discord.Client.connect").
maiden fable
#

wait seems like no

slate swan
#

bruh

lament mesa
#

connect does

maiden fable
#

u also gotta call connect

lament mesa
#

try bot.start()

slate swan
lament mesa
slate swan
#

use disnake

#

still nothing

#

!pypi disnake

unkempt canyonBOT
graceful gorge
#

helppppppppp

slate swan
#

yw

slate swan
graceful gorge
slate swan
#

elaborate

graceful gorge
#

ik how to make it in js but i just copy paste code i want to learn it in python

slate swan
#

guild.id

#

so what's the issue

unkempt canyonBOT
graceful gorge
slate swan
#

hi

#

whats the problem?

    users = await get_bank_data()
    try:
      inventory  = users[str(user.id)].get("inventory")
    except:
      inventory = []
          
    obj = {"item": item , "amount" : amount}
    users[str(user.id)]["inventory"].remove(obj)```
graceful gorge
slate swan
#

then learn py and then start making the bot

#

there are bunch of tutorials

stiff nexus
#

help??```py
Exception in voice thread Thread-8
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 673, in run
self._do_run()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 666, in _do_run
play_audio(data, encode=not self.source.is_opus())
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/voice_client.py", line 672, in send_audio_packet
self.socket.sendto(packet, (self.endpoint_ip, self.voice_port))
TypeError: str, bytes or bytearray expected, not _MissingSentinel
172.18.0.1 - - [17/Oct/2021 16:53:14] "HEAD / HTTP/1.1" 200 -
Exception in voice thread Thread-12
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 673, in run
self._do_run()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 666, in _do_run
play_audio(data, encode=not self.source.is_opus())
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/voice_client.py", line 672, in send_audio_packet
self.socket.sendto(packet, (self.endpoint_ip, self.voice_port))
TypeError: str, bytes or bytearray expected, not _MissingSentinel

slate swan
cunning violet
#

holy

slate swan
# slate swan your code doesn't match your error

heres full code

@bot.command(aliases=['dii','delinvitem','delitem'])
async def removeinvitem(ctx, user : discord.Member, amount:int, *, item,):
  admins = 772460927685230592, 460479556156129291, 629606911062573059
  if ctx.message.author.id in admins:
    users = await get_bank_data()
    try:
      inventory  = users[str(user.id)].get("inventory")
    except:
      inventory = []
          
    obj = {"item": item , "amount" : amount}
    users[str(user.id)]["inventory"].remove(obj)
  else:
    await ctx.reply("You are not allowed to execute this command. :thumbsdown:")```
graceful gorge
slate swan
#

pov : u dont know what google means

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)
graceful gorge
slate swan
#

WDYM

#

there's no x var in your code

#

so?

graceful gorge
slate swan
#

...

#

you're just telling us "help me man"

#

we need code and error

#

atleast

slate swan
# slate swan so?

alr nvm i just tested it out, you're getting an error because there's no obj in your inventory

#

do you have the guild object?

kindred epoch
#

just get it

slate swan
#

click on the guild icon in discord with right click

#

click copy ID

#

on discord

#

just the picture of the server

#

copy ID in English

boreal ravine
#

doesnt change

#

just right click a guild

slate swan
#

also, you have to enable developer mode

amber imp
#

It works everywhere

#

!tag developer

boreal ravine
#

no tag for it sadly @amber imp

amber imp
#

Ok

slate swan
#

settings -> advanced -> developer mode

#

then it works

graceful gorge
#

help me for making bot my bot come online now msg sent

amber imp
#

But what to help?

graceful gorge
slate swan
amber imp
slate swan
#

...
you're just telling us "help me man"
we need code and error
atleast

graceful gorge
amber imp
slate swan
#

meh dpy coder — today at 19:03

graceful gorge
amber imp
graceful gorge
slate swan
#

can someone dm me

#

i need help

amber imp
#

Ohh but i m on mobile now

valid perch
boreal ravine
#

dont @amber imp u will be trapped in a helping hell loop

slate swan
#

just ask here everybody

valid perch
graceful gorge
slate swan
#

oh gosh

boreal ravine
#

!indents @graceful gorge

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
#

i need to work out how to use a paid proxy with requests module

#
import requests
from bs4 import BeautifulSoup as bs

string=input("Enter anime name: ")
url=f"https://myanimelist.net/anime.php?q={string.replace(' ', '%20')}&cat=anime"
r=requests.get(url)
soup=bs(r.content, 'html5lib')
temp=soup.find_all('div', attrs={'class':'box-unit1'})
print(temp)```

It returns empty list, I want to get the url of the first anime in search list (Also I dont want to use the API of myanimelist)

please help
valid perch
amber imp
slate swan
#

that doesn't have to do anything with dpy @slate swan

boreal ravine
#

!resources pls @graceful gorge

unkempt canyonBOT
#
Resources

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

graceful gorge
valid perch
amber imp
graceful gorge
slate swan
#

!resources

unkempt canyonBOT
#
Resources

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

amber imp
slate swan
#

I suggest reading this

amber imp
#

U need to learn python first bro

graceful gorge
graceful gorge
graceful gorge
amber imp
slate swan
#

yes

amber imp
boreal ravine
graceful gorge
amber imp
graceful gorge
slate swan
boreal ravine
#

@graceful gorge
Before learning discord.py, you should know all of these in Python first!

variables
scoping
functions
asynchronous programming
classes/oop in general
decorators
subclassing/inheritance
type-hinting
imports

valid perch
graceful gorge
valid perch
#

!resources

unkempt canyonBOT
#
Resources

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

boreal ravine
#

@graceful gorge thats a function

amber imp
graceful gorge
slate swan
#

are you trolling rn?

slate swan
amber imp
slate swan
graceful gorge
#

@amber imp

#

lol

#

ik import

boreal ravine
amber imp
slate swan
#

sak.py please stop trolling, this chat is already too hyped of this

slate swan
amber imp
#

A kid can make bot if he wants

slate swan
graceful gorge
#

simp

graceful gorge
amber imp
graceful gorge
boreal ravine
graceful gorge
#

yaar

graceful gorge
slate swan
boreal ravine
graceful gorge
# boreal ravine why not?

Import Discord Package

import discord

Client (our bot)

client = discord.Client()

async def on_ready():

Do Stuff

general_channel = client.get_channel(877778689650200579)
general_channel.sent('hello dostoooo')

#run the client on discord server
client.run('sorry i can tell token')

#

see command

#

error

boreal ravine
#

bruh

graceful gorge
# boreal ravine bruh

File "c:\Users\Admin\Desktop\python\real wale\my bot.py", line 9
general_channel = client.get_channel(877778689650200579)
^
IndentationError: expected an indented block

graceful gorge
#

see errror

graceful gorge
valid perch
boreal ravine
slate swan
#

i used this

boreal ravine
#

no spoonfeed

graceful gorge
graceful gorge
amber imp
graceful gorge
amber imp
graceful gorge
slate swan
#

I kinda wanna ping moderators

boreal ravine
slate swan
graceful gorge
graceful gorge
amber imp
boreal ravine
#

@graceful gorge how old are you?

graceful gorge
slate swan
#

he would die in the dpy server

valid perch
#

This is a help channel, if your not looking for actual help rather then just trolling us please goto general or off topic

graceful gorge
amber imp
valid perch
#

!ot

unkempt canyonBOT
slate swan
amber imp
slate swan
#

does anyone know how to start a vm from a phone remotely?

graceful gorge
#

wth

graceful gorge
graceful gorge
amber imp
slate swan
#

not for dpy

tawdry perch
#

@graceful gorge , it would be nice if you were serious. And keep it related to topic.

boreal ravine
graceful gorge
slate swan
amber imp
amber imp
unkempt canyonBOT
#

Hey @graceful gorge!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

slate swan
graceful gorge
#

why

tawdry perch
amber imp
tawdry perch
#

Starting a vm from phone sounds off topic for me

tawdry perch
#

.topic

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

tawdry perch
unkempt canyonBOT
#

Hey @graceful gorge!

It looks like you tried to attach file type(s) that we do not allow (). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.

Feel free to ask in #community-meta if you think this is a mistake.

slate swan
#

bro just stop

amber imp
crimson pulsar
#

!warn @graceful gorge we'd appreciate if you stayed on-topic and contributed to the discussions in the channel instead of having off-topic conversations

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @graceful gorge.

crimson pulsar
amber imp
boreal ravine
#

u cant

final iron
#

^

slate swan
#

anyone would be able to nuke the server

boreal ravine
#

yes

crimson pulsar
#

but you can always add new features to @lament depot if its good enoguh @amber imp

slate swan
#

ban the trolls pls

#

here we go again

#

tf is this

tawdry perch
#

@novel apex is for discussing about infractions iirc @graceful gorge

slate swan
tawdry perch
#

nice

amber imp
tawdry perch
#

you can

crimson pulsar
tawdry perch
#

.src

crimson pulsar
valid perch
crimson pulsar
#

the first link is the contributing guide

crimson pulsar
willow vine
#

why does my timestamp give wrong values

crimson pulsar
tawdry perch
#

how do you set it?

valid perch
#

Whats the time your giving it?

willow vine
#

i use timestamp=datetime.now()
which works fine in other bots i've made, but doesnt in this bot

#

why is that

tawdry perch
#

try: .utcnow() ?

willow vine
#

works fine now

#

but why was that happening

tawdry perch
#

¯_(ツ)_/¯

tender charm
#

Hello, i have problem with making discord bot in python, I am trying to split Auto role and Welcome message, my code: ```Intents = discord.Intents(messages=True, guilds=True, reactions=True, members=True)

bot = commands.Bot(command_prefix = '-', intents=Intents)

@bot.event
async def on_member_join(ctx, member):
guild = bot.get_guild(----------------------)
channel = guild.get_channel(----------------------)
embed = discord.Embed(title="Nový člen!", description=(f'Vítej {member.mention} na arPlay discordu!'), color=0x66d9ff)
embed.set_thumbnail(url='https://i.imgur.com/laIDPip.png')
autorole = discord.utils.get(ctx.guild.roles, name = 'Member')
await ctx.add_roles(autorole)
await channel.send(embed=embed)I tried this:bot = commands.Bot(command_prefix = '-', intents=Intents)

@bot.event
async def on_member_join(ctx):
autorole = discord.utils.get(ctx.guild.roles, name = 'Member')
await ctx.add_roles(autorole)

@bot.event
async def on_member_join(member):
guild = bot.get_guild(----------------------)
channel = guild.get_channel(----------------------)
embed = discord.Embed(title="Nový člen!", description=(f'Vítej {member.mention} na arPlay discordu!'), color=0x66d9ff)
embed.set_thumbnail(url='https://i.imgur.com/laIDPip.png')
await channel.send(embed=embed)``` But when I used this, Autorole isn't work, please help me.

final iron
#

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

remove ctx from on_member_join

valid perch
#

event only lets you do it once, you need to use listen

slate swan
#

it only has member

tawdry perch
#

oh nvm it was alrd explained

slate swan
#
bot = commands.Bot(command_prefix = '-', intents=Intents)

@bot.event
async def on_member_join(ctx):
    autorole = discord.utils.get(ctx.guild.roles, name = 'Member')
    await ctx.add_roles(autorole)

@bot.event
async def on_member_join(member):
    guild = bot.get_guild(835809421766164482)
    channel = guild.get_channel(850829119713181748)
    embed = discord.Embed(title="Nový člen!", description=(f'Vítej {member.mention} na arPlay discordu!'), color=0x66d9ff)
    embed.set_thumbnail(url='https://i.imgur.com/laIDPip.png')
    await channel.send(embed=embed)
#

wouldn't work because there are 2 of the same events

tawdry perch
#

and wrong arg on first one*

slate swan
#

you could use @bot.listen() instead of @bot.event

tender charm
slate swan
#

just naming

slate swan
#

are you using the first code?

tender charm
#

Yes

slate swan
#

oh

tawdry perch
#

you are officially a god now

slate swan
#

in that case, it should work with the correct naming

tender charm
#

This, and its working :-) @bot.event async def on_member_join(member): guild = bot.get_guild(----------------------) channel = guild.get_channel(----------------------) embed = discord.Embed(title="Nový člen!", description=(f'Vítej {member.mention} na arPlay discordu!'), color=0x66d9ff) embed.set_thumbnail(url='https://i.imgur.com/laIDPip.png') autorole = discord.utils.get(member.guild.roles, name = 'Member') await member.add_roles(autorole) await channel.send(embed=embed)

slate swan
#

I'm just the better player

tawdry perch
#

I see

hasty iron
tender charm
#

meh dpy coder is legend. Actually I dont know how is he doing it, but every time its working 😄

hasty iron
#

lmao

slate swan
#

you can remove the brackets from
description=(f'Vítej {member.mention} na arPlay discordu!')
just so it looks nice

maiden fable
#

Surely he is a pro lol

slate swan
#

this is kinda disturbing when they tell better programmers that someone is a god

glad sleet
#

hey i use heroku but when i run consol it say discord_components are not module

slate swan
#

you have it in the requirements file?

hasty iron
#

add it to requirements.txt

tawdry perch
#

does heroku allow a file to be shared between 2 accounts?

hasty iron
#

this isn’t heroku help

#

well atleast its not related to discord bots

glad sleet
stable edge
tawdry perch
#

I should use off topic, my bad

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
#

what are you using

#

My own music

#

wat

inland wedge
#

whats the command for printing out stuff from the txt file since when i do return line my bot doesnt display the output instead it says cannot send an empty msg

slate swan
#

ik you can't help me, so be quit

tawdry perch
#

ehh, no need to be rude or smth

#

everyone is volunteer for helping anyways

crimson pulsar
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

Can someone help me with it?```py
if ctx.author.voice:

    music = discord.utils.get(client.voice_clients, guild=ctx.guild)

    channel = ctx.author.voice.channel

    if not music.is_connected():
        await channel.connect()

    if ctx.author.voice.channel == ctx.guild.me.voice.channel:

        if music.is_playing():
            music.stop()

```Console: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'is_connected'

slate swan
#

I'm not sure if this isn't against rules

#

but your get() failed

#

what kind of object is music supposed to be

#

but my leave cmd is working with it

#

!d discord.ext.commands.Context.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
A shortcut to [`Guild.voice_client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.voice_client "discord.Guild.voice_client"), if applicable.
slate swan
#

why don't u use this

glad sleet
#

hey how i add modules in requirements in github

slate swan
#

this is off-topic

#

but you just

#

add discord_components to the file

#

wtf

#

you start a new line and type discord_components

glad sleet
#

and ?

slate swan
#

no and

#

that's it

glad sleet
#

ok ty

willow vine
#

How do I get ctx.author's timezone

glad sleet
#

datetime.datetime.utcnow()

slate swan
slate swan
#

or you import it

#

but this isn't gonna fix anything

willow vine
slate swan
#
music = discord.utils.get(client.voice_clients, guild=ctx.guild)

if ctx.guild.me.voice.channel == ctx.author.voice.channel:
    # leaving

elif not music.is_connected():
    # says error
#

its a elif

#

so how is music NoneType in the first one

#

and not here

#

yeah

#

that's the fkn question

glad sleet
#

this come in heroku

slate swan
#

show your requirements file

#

pip install discord-components

stable edge
reef shell
#

you need to install that package

glad sleet
neon spear
#

File name is same as user id but isn't working.

if(ctx.author.id == (file.replace(".png",""))):
willow vine
slate swan
glad sleet
#

i am new in github things...

#

file*

slate swan
glad sleet
#

aniblobsweat yes

willow vine
slate swan
#

hmmm

#

Anyone knows how to get the object of ur own bot, for example if i want to make the bot mention itself, similar to a discord.Member class

willow vine
#

Which all files do you have

glad sleet
#

procfile

slate swan
willow vine
#

Where yu defined it

slate swan
glad sleet
#

requirement.txt

willow vine
#

With their versions

glad sleet
lusty swallow
#

How do you change the discriminator to something like this? I just saw this bot with 0000 . Iirc, it's not possible to change it

willow vine
slate swan
#

or is it discord.Bot??

willow vine
slate swan
#

oh u mean client.Bot?

willow vine
#

You do @bot.commands yeah?

slate swan
#

or whatever ur decorator is

willow vine
#

Just do bot

lusty swallow
#

Try bot.user

slate swan
#

ok

willow vine
#

Yeah, it should work

willow vine
lusty swallow
#

!d discord.ext.commands.Bot.user

unkempt canyonBOT
slate swan
#

client.Bot.user?

lusty swallow
#

What are you using? Client or bot?

slate swan
#

client as my decorator

lusty swallow
#

The object type?

willow vine
#

Just do client.user then

slate swan
#

ye

#

oh ok

lusty swallow
#

Yeah probably just that

#

Client.user.mention if you want mention

slate swan
#

yeah im trying to make those "send prefix if bot mentioned" functions

#

thx

slate swan
#

to change the bots discimi

lusty swallow
neon spear
#

When I print ctx.author.id and (file.replace(".png","")) the outcome is the same but not working in this if statement, any idea?

        if(ctx.author.id == (file.replace(".png",""))):

lusty swallow
slate swan
#

yeah

#

idk

slate swan
#

webhooks don't have a profile

lusty swallow
boreal ravine