#discord-bots

1 messages · Page 605 of 1

slate swan
#

on github

sullen shoal
#

let me check

slate swan
#

ok thankes

#

maybe can you chek with just python

keen talon
#

I mean he has to do it with a audio file ig

slate swan
#

not bot

#

yeah

#

thats what i was searching @keen talon

#

with my own wav file

#

@sullen shoal can u tell me that plz

sullen shoal
slate swan
#

ok

#

and is there a way with norma python

sullen shoal
slate swan
#

like with recorded wav file

slate swan
#

coz i am making a jarvis project

#

i mean without bot

sullen shoal
tropic briar
#
@bot.listen()
async def on_message(message):
  await bot.handler.propagate(message)
  await bot.process_commands(message)
  print(message.content)
  for i in Filter:
    if i in message.content:
      await message.channel.send("I don't like that word")
``` This is not working
slate swan
#

@sullen shoal ?

slate swan
#

like idk nvm

#

u all arent helping

sullen shoal
slate swan
#

can you maybe send coz i was trying to find one

tropic briar
slate swan
#

but didnt find

sullen shoal
slate swan
#

i am a literal rookie

sullen shoal
slate swan
#

i know it

#

this is robotic sound

#

i need custom voice

sullen shoal
sullen shoal
slate swan
#

sadly

#

and connecting my wav audio file

slate swan
sullen shoal
#

it accepts either the name as string or its id as int

slate swan
#

and make it tts

slate swan
#

@sullen shoal

sullen shoal
slate swan
#

bye the way i have a platform azure

#

but i dont know how to connect the api can you maybe take a look the link i will send

sullen shoal
# slate swan bouncer

on_message event's first argumrnt will be discord.Message which has an attribute author which returns discord.Member

slate swan
#

can you send full source code in one file

#

pls

sullen shoal
#

idk

slate swan
#

it was to me

sullen shoal
#

pip install azure-cognitiveservices-speech

slate swan
#

ok

#

than

slate swan
#

yeah but before i did

#

didnt worked

#

maybe can you write it all in one file pls

sullen shoal
#

i have not tried any of these things nor i want to

#

i gotta do my project

tropic briar
#
@bot.group(invoke_without_command=True)
async def help(ctx):
  em = discord.Embed(title = 'Help', desciption = 'Hi')
  em.add_field(name = 'Monke Jr.', value = 'I am a Anti-Spam and AutoModeration bot created by Giant#5070')
  ctx.send(embed = em)
``` This doesn't send any embed or anything
#

oh I forgot to await

#

I did it but it sends 2 same embeds

slate swan
tropic briar
#

still i think

slate swan
#

Are u running two instances of the bot?

tropic briar
#

no

slate swan
#

Do .help and tell me if it sends 2 same embeds

sullen shoal
#

usually happens when you use crap extensions to run your script

slate swan
tropic briar
tropic briar
sullen shoal
#

two instances of your bot are running

devout iris
#

hi

slate swan
#

His way of doing the command is weird im not used to bot.group

boreal ravine
slate swan
#

And invoke without command

tropic briar
boreal ravine
slate swan
sullen shoal
slate swan
tropic briar
#

Now if I change something in 1 script it changes in both embeds

sullen shoal
#

answer my question

boreal ravine
tropic briar
devout iris
#

when i mentioned bot, only event is working so i cant use mention as prefix. how can i fix it?

slate swan
sullen shoal
#

open your task manager and kill the process of python

slate swan
#

Well technically he only has commands.Bot coz wouldnt that override his first one

slate swan
boreal ravine
slate swan
#

Ah i am making a discord bot
usin python
I need to do something like if a user says the line- "I am trying to do somethin" he should be given the potter role
and if he says "I am Busy" it should be taken back from him
can soemone help

unkempt canyonBOT
slate swan
boreal ravine
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
boreal ravine
#

!d discord.Member.remove_roles

slate swan
#

everyone saying something else

unkempt canyonBOT
#

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

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

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
slate swan
#

idk how to do it

#

I need a script or a code

boreal ravine
#

we don't spoonfeed

#

we help

slate swan
slate swan
#

i am a rookie ffs

sullen shoal
#

check the examples, docs and learn

slate swan
#
if 'idk how to do it' in message.contents.lower():
 await message.author.add_roles(Spoonfed)```
high pollen
#

How do i get the link of a message????

boreal ravine
slate swan
#

Like that but u gotta also get the role

boreal ravine
unkempt canyonBOT
slate swan
#

Can u do the bot for discord.utils i duno how to use it

slate swan
sullen shoal
#

he is just going to copy paste this nothing else

slate swan
#

I cant remember the exact command

slate swan
#

U can

#

i am a modder actually lol

boreal ravine
#

Modding is different than coding something, both requires different skills

slate swan
#

yo iy worked the voice is so natural

slate swan
#

and human

#

!d discord.utils.get

unkempt canyonBOT
#

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

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

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

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

Examples

Basic usage...
#

Hey @tropic briar! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

boreal ravine
#

L

tropic briar
#

It is not a valid token

slate swan
#

idk why this event wont work

#
@client.event
async def on_guild_channel_delete(channel):
   guild = channel.guild
   id_ = guild.id
   channel_ = cl.find_one({"_id" : id_})["channel"]
   if channel.id == channel_:
      cl.update_one({"_id" : id_},{"$set": {"channel" : "None"}})```
#

Put py on the same line as the 3 backticks

#

Actually just lowercase py

boreal ravine
slate swan
#

What is cl?

slate swan
slate swan
#

Oh

#

Nosql db

#

Nvm it works now

devout iris
#

when i mentioned bot, only event is working so i cant use mention as prefix. how can i fix it?

sullen shoal
#

!d discord.ext.commands.when_mentioned_or

unkempt canyonBOT
#

discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
devout iris
#

not working

sullen shoal
#

whats not workig

devout iris
#

i said

devout iris
#

the code is okay

sullen shoal
#

if your code is okay your bot is perfect

devout iris
#

no

#

bot just implements on_message

#

so prefix is not working

slim dragon
#

can anyone tell me how to get the name of the member of the message in discord bot program... pLease

devout iris
#

when i mention and writing command, bot is sending on_message event

unkempt canyonBOT
#

property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
slim dragon
#

thanks but can you give me the example code in my dm with example output

slate swan
devout iris
#

not everymessage

slate swan
#

Well every mention message

devout iris
#

bot gonna run commands with mention prefix and if only mentioned, bot will send a message

slate swan
#

Your code is not okay

devout iris
#

hmmm

#

what is the problelm then

#

i cloudnt fix it for 2 days

sullen shoal
#

actually the entire code is kinda trash

slate swan
#

The mention message happens if the bot is mentioned at all, the commands count as that

sullen shoal
#

i would have described the problem if they sent the code here as a snippet

#

but okay

slate swan
#

Its confusing me

devout iris
# sullen shoal i would have described the problem if they sent the code here as a snippet
@bot.event
async def on_message(message):
    if bot.user.mentioned_in(message):
        msg = await message.channel.send("Hey, ummm... Bana Mı Seslendin? Eğer Cevabın Evet ise; işte Tam Buradayım Acaba Sana Nasıl Yardımcı Olabilirim? **Detaylar:** `i!help` \n \n **Bu Mesajı Silmek İçin Alttaki Emojiye Tıkla!** ")
        await msg.add_reaction("\N{WASTEBASKET}")
        def check(reaction, user):
          return user == message.author and str(reaction.emoji) == "\N{WASTEBASKET}"
        reaction, user = await bot.wait_for('reaction_add', timeout=None, check=check)
        await msg.delete()
    elif message.content == "sa":
        await message.reply("As")
    await bot.process_commands(message)


sullen shoal
#

nope, they have commands.ext.when_mentioned_or as the prefix

#

and they also have that if statement

devout iris
slate swan
#

AttributeError: module 'discord' has no attribute 'embed'
Any way to fix this?

devout iris
#

emoji 😄

slate swan
#

Like its really confusing me unless you can send emojis to discord like that and i dont know about it

#

do I change the last line?

#

Me being like Info Go Brrr

sullen shoal
# devout iris ```py @bot.event async def on_message(message): if bot.user.mentioned_in(mes...

if bot.user.mentioned_in(message)
this gets triggered when ever your bot is mentioned. it doesnt care about commands.ext.when_mentioned_or.
so this code will always get triggered no matter what you put after the mention it will just get triggered,

        msg = await message.channel.send("Hey, ummm... Bana Mı Seslendin? Eğer Cevabın Evet ise; işte Tam Buradayım Acaba Sana Nasıl Yardımcı Olabilirim? **Detaylar:** `i!help` \n \n **Bu Mesajı Silmek İçin Alttaki Emojiye Tıkla!** ")
        await msg.add_reaction("\N{WASTEBASKET}")
        def check(reaction, user):
          return user == message.author and str(reaction.emoji) == "\N{WASTEBASKET}"
        reaction, user = await bot.wait_for('reaction_add', timeout=None, check=check)
        await msg.delete()```
#

maybe you want to show it when the content is only the mention?

devout iris
#

ummmm

sullen shoal
#

can you please delete this we're talking

sullen shoal
slate swan
#

U need to make a list of ur commands and check against it, unless someone has a more elegant way. U can automate making the list of commands

devout iris
slate swan
#
 embed=discord.embed(title="xxxx", description="xxxx")
    embed.set_thumbnail(url="xxx")
    embed.set_image(url="xxxx")
    embed.add_field(name="cost", value="30 tokens", inline=false)
    embed.add_field(name="time remaining", value="59 minutes", inline=true)
    embed.set_footer(text="developed by asdasd")
    await channel.send(embed=embed)

What do I change about this to resolve the error AttributeError: module 'discord' has no attribute 'embed'

sullen shoal
#

and what i asked

devout iris
#

yea i read

sullen shoal
#

and what about the question

slate swan
#

u need to do something like this

devout iris
#

but i'm againly confused about ur question

slate swan
#

make a list for commands - comlist = []

#

put this in ur on ready

#
    for commands in bot.commands:
        comlist.append(commands.name)```
#

and then check against that list

sullen shoal
slate swan
#

when doing the on_message, if it matches a command being send, just process comands instead

boreal ravine
slate swan
#

be specific, there are like 6 lines

boreal ravine
slate swan
#

💀

#

oh lmfao im dumb

#

capital E

#

my bad lmao

boreal ravine
#

yeah, every class in dpy is capitalized

sullen shoal
# devout iris yeahh

what you can do is, check the length of
discord.Message.mentions and see if its 1, if its one, check if the mention is bot.user

#

if its True continue with the if statement otherwise return

devout iris
#

ah i guess i understand u i'm gonna try it now

slate swan
#

i still think what i said is more suitable to what hes tryna to do

sullen shoal
#

well your method will have to be iterated through the big list, per message

#

which is very costly in terms of performance

slate swan
#

i doubt his bot is gonna be that big

sullen shoal
#

doesnt change the fact that its costly

slate swan
#

like ur method still doesnt differentiate between a command being sent, and the bot just being mentioned

devout iris
slate swan
#

it just limits it to one mention

devout iris
#

if bot.user.mentioned_in(message) and :

#

and or new line?

sullen shoal
#

what you can do is

#

message.content == bot.user

#

not sure if thats going to work

slate swan
#

i think for what hes tryna to achieve, hes gonna have to iterate through the list, and the peformance impact wont that high

#

i done it in my bot to allow users that have been turnt into furry webhooks to still be able to use bot commands

#

i couldnt think of a more elegant way of doing it

#

it doesnt have much performance impact

#

What's wrong with this? It just gave me None even tho I reacted with: 👍
discord.utils.get(message.reactions, emoji=":thumbsup:")

sullen shoal
#

!d discord.Message.clean_content

unkempt canyonBOT
#

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

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

Note

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

sullen shoal
#

this could be used

slate swan
#
      for com in comlist:
          if message.content.lower().startswith(com):
              await bot.process_commands(message)  
              return```
#

this is what i added

#

costly but it works

#

and overall its a discord bot, the performance impact is neglible for a small bot

bitter depot
slate swan
slate swan
sullen shoal
bitter depot
slate swan
#

I dont have a win button

bitter depot
#

Note that instead of e.g 'U+1F603' you do '\u1F603' so don't just copy-paste

slate swan
#

he would need to append that to the start of com

#

and then he will have his end goal

slate swan
#

ok

sullen shoal
#

he basically has to see if the content is only the mention

slate swan
#

depends if he only wants that, or if he wants it on any mention of the bot other than a command

bitter depot
slate swan
slate swan
bitter depot
slate swan
#

it worked for a bit then broke for no reason

#

and i have to use if bot.mentioned instead

bitter depot
bitter depot
#

Then it'll work

slate swan
#

thats what i thought but it still broke

bitter depot
#

Maybe the message had a space at the end

slate swan
bitter depot
#

You messed up your parentheses

slate swan
#

What discord.py alternative should i use ?
Is there one exactly like dpy so i won't have to change my code ?

slate swan
slate swan
sullen shoal
#

@disnake simple bot this is what i got. so the if statement will basically be,

if message.clean_content.strip(' @') == bot.user.name```
slate swan
#

oh mybad u were talking to him

sullen shoal
#

@devout iris

slate swan
devout iris
sullen shoal
#

wait

devout iris
#

also

sullen shoal
#

edited

devout iris
#

now there is something strange

slate swan
#
Traceback (most recent call last):
  File "main.py", line 22, in <module>
    client.load_extension(ex)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 620, in load_extension
    self._load_from_module_spec(spec, name)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 551, in _load_from_module_spec
    raise discord.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.suggestions' raised an error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-6: truncated \UXXXXXXXX escape (suggestions.py, line 12)
``` @bitter depot
devout iris
#

@bot.event
async def on_message(message):
    if bot.user.mentioned_in(message) and len(message) == 1:
        msg = await message.channel.send("Hey, ummm... Bana Mı Seslendin? Eğer Cevabın Evet ise; işte Tam Buradayım Acaba Sana Nasıl Yardımcı Olabilirim? **Detaylar:** `i!help` \n \n **Bu Mesajı Silmek İçin Alttaki Emojiye Tıkla!** ")
        await msg.add_reaction("\N{WASTEBASKET}")
        def check(reaction, user):
          return user == message.author and str(reaction.emoji) == "\N{WASTEBASKET}"
        reaction, user = await bot.wait_for('reaction_add', timeout=None, check=check)
        await msg.delete()
    elif message.content == "sa":
        await message.reply("As")
    await bot.process_commands(message)


this event is working and when i press the emoji, bot deletin itself message and sending command

slate swan
slate swan
#

my bad i looked for 1FF4D instead of 1F44D

sullen shoal
#

thats what you told it to do

slate swan
#

why not just put the raw emoji in?

#

\👍

sullen shoal
#

you said it deletes the message after reacting?

slate swan
devout iris
#

i already want it but ur code is same of my code

#

am i wrong?

sullen shoal
#

im asking you

devout iris
#

ah

sullen shoal
#

it deletes the message after reacting?

devout iris
#

yes

sullen shoal
#

and that's from your code

slate swan
#

This:
discord.utils.get(message.reactions, emoji="👍")
Just gave me this: 👍 why, i want the amount of reactions with that emoji how can i do that

sullen shoal
#

what do you want

devout iris
#

Actually, the logic is: When I tag the bot, I want the bot to send me a help message and if I don't want to see the help message, I want it to delete the message by pressing the emoji below

sullen shoal
slate swan
sullen shoal
#

when you react

slate swan
slate swan
#

I had same problem when i made my command lol

devout iris
# sullen shoal so whats actually happening

like that;
me: @bot
bot: message | and if i press the emoji, bot deleting message (this is okay)


but when i use command with mention;

me: @bot ping
bot: message and if i press the emoji, bot deleting message and sends command's result (pong)

sullen shoal
#

the if statement isn't working

devout iris
#

may be

slate swan
#

Ngl this dudes bot is giving me a headache, good luck Myxi

sullen shoal
#

thanks

slate swan
#

Lol

sullen shoal
#

also your timeout is None it means it will wait for the reaction forever

devout iris
#

what can i do idk and i'm so confused smh

sullen shoal
sullen shoal
devout iris
#

with what?

sullen shoal
slate swan
#
speechsdk.say(audio)
AttributeError: module 'azure.cognitiveservices.speech' has no attribute 'say'```
sullen shoal
#

THAT SHIT

slate swan
#

can you help

sullen shoal
slate swan
#

i kow but

sullen shoal
#

thats a different module

slate swan
#

you are the only on

#

wich should i type

sullen shoal
#

idk i never used that module

slate swan
tawdry perch
sullen shoal
#

bro i told him to change that like 3 or 4 times but every time he just ignored it

#

afk

devout iris
#

how can i get user's pfp with id or mention?

#

which func.

slate swan
maiden fable
#

!d discord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
slate swan
devout iris
#

Well, can i get avatars from any discord user?

sullen shoal
#

any User

devout iris
#

Can I get the pfp even if the bot is on the server where that user is not present?

devout iris
sullen shoal
#

you might have to fetch it but yes i think

devout iris
#

How

sullen shoal
#

typehint it to discord.User, it should work most of the time

#

otherwise if you really wanna fetch

devout iris
sullen shoal
#

!d discord.ext.commands.Bot.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.
sullen shoal
devout iris
#

Wdym typehint

sullen shoal
#

annotate

devout iris
#

i'm really confused can i talk in a sentence lel

devout iris
#

Sorry btw my english is not very good so i'm not understand some words etc.

sullen shoal
#
foo: str```
str is the typehint
devout iris
#

Ah yea ik str

slate swan
devout iris
#

Lolllll

#

Smh

slate swan
#

Typehint lets u say what type the variable should be in the function

devout iris
#

So, what should i do...

slate swan
#

Read

hasty loom
slate swan
slate swan
#

help plz

#

anything wrong in here?

#

@sullen shoal

summer flume
#

errors?

slate swan
#

just doesnt work

wispy temple
#

How do I code in Visual studio? Can't add discord python module there.

summer flume
brazen raft
wispy temple
slate swan
brazen raft
#

Can you not use a more suited IDE for Python like PyCharm?

brazen raft
quick gust
quick gust
#

no lmao

summer flume
#

no that

brazen raft
#

Remove the second def

#

And the first process_commands

slate swan
quick gust
#

u have so many ifs

brazen raft
#

._.

quick gust
#

make it elif

slate swan
quick gust
#

elif

#

and remove the 2nd async def

brazen raft
#

@slate swan you should use discord.ext.commands.Bot, not discord.Client. Then, learn to use commands.

slate swan
#

@client.event
async def on_ready():
print("Comrade Ain't Dead")

@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith('Hello'):
await message.channel.send('Hello Comrade')

if message.content.startswith('Hi'):
await message.channel.send('Hi. Did ya nuke USA?')

if message.content.startswith('Comrade'):
await message.channel.send('Shut Up Fool')

if message.content.startswith('hello'):
await message.channel.send('Hello Comrade')

if message.content.startswith('hi'):
await message.channel.send('Hi. Did ya nuke USA?')

if message.content.startswith('LMAO'):
await message.channel.send('You Dont Laugh In Russia ')

@client.event
async def on_message(message):
if 'i solemnly swear that i am upto no good' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.add_roles(role)
await client.process_commands(message)

if then elif

async def on_message(message):
if 'michief managed' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.remove_roles(role)
await client.process_commands(message)

client.run(os.getenv("TOKEN"))

hasty loom
#

pls format like this

```py

code here

```

quick gust
#
@client.event
async def on_message(message):
  if 'i solemnly swear that i am upto no good' in message.content.lower():
    role = discord.utils.get(message.guild.roles, id=904021392998146118)
    await message.author.add_roles(role)
  elif 'michief managed' in message.content.lower():
    role = discord.utils.get(message.guild.roles, id=904021392998146118)
    await message.author.remove_roles(role)
  await client.process_commands(message)```
#

@slate swan

slate swan
#

thnx

#

waitlemme test

#

I am a rookie

quick gust
#

👍

magic ore
#

Also should use get_role instead of utils.get

#

You don't need to get the role object at all actually

#

Just pass a discord.Object

tropic briar
#

How can I check if the discord invite is advertising or not

slate swan
#

use regex to check if its an invite link

tropic briar
#

Like I can check if the url is vanity or not

slate swan
#

oh

tropic briar
#

But if less than 100 members then it would be a advertise

slate swan
#

i have an api auth key that you want to load into my code

#

but i got error

#

Like when i say something

#

It prints correctly but it doesnt speaks

#

In other code without speech recognition

#

It speaks

maiden fable
#

This is a discord bot helping channel....?

slate swan
#

I know bit is same

#

I am coding discord bot

#

Tts

pallid turtle
#

I made the suggestion of loading the API key using environmental vars, which is what you guys do with bots all the time.

maiden fable
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**.
pallid turtle
#

Slightly OT, but very much within a skillset I'm sure exists here.

maiden fable
slate swan
#

I am coding actually just assistant

#

In py

maiden fable
#

!d discord.Guild.invites returns the list of invites in a guild

unkempt canyonBOT
#

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

Returns a list of all active instant invites from the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to get this information.
slate swan
#

Without discord bot

maiden fable
slate swan
#

Bro there know onw understands me

#

And is the same

tropic briar
#

If the members are more than 500 no ban and if less than 500 then ban

sage otter
#

So what you are saying is. Everytime someone sends an invite you’ll check if someone leaves that guild and if so you’ll ban the person who sent the invite?

#

Have fun with that I guess.

surreal dust
#

I wanna MAKE my own CURRENCY BOT how do i begin with?

sage otter
#

If you're already proficient in dpy, learn data storage.

full valley
#

How do I check the version of discord.py im running

slate swan
sage otter
unkempt canyonBOT
#

discord.__version__```
A string representation of the version. e.g. `'1.0.0rc1'`. This is based off of [**PEP 440**](https://www.python.org/dev/peps/pep-0440).
rain jay
#

how can i provide a user_limit to make a channel have unlimited members using channel.edit()?

surreal dust
#

how do i make a bot which gives roles to people and himself

slate swan
#

https://replit.com/@CG158/Layton-Bot#main.py can someone help? i'm trying to make it so after the bot sends a message after the "l!puzzle" command, you can send other commands. But once the bot sends the initial message it just goes straight to the "incorrect" message and idk why, can someone help?

CG158

A Python repl by CG158

sage otter
unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
brazen chasm
#

That's one way to make a discord bot

brazen chasm
#

pls pls don't spam, your message is now on my screen twice

sage otter
brazen chasm
#

You missed my point entirely but it's np. I agree don't spoon feed

brazen chasm
slate swan
#

one second

brazen chasm
#

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

brazen chasm
#

@slate swan

brazen chasm
#

(if they're a lost cause)

#

if they display signs of wanting to learn I'll walk them through it

sage otter
#

That’s defeats the purpose of not spoonfeeding. If all fails and it comes down to you needing to spoonfeed them because of illiteracy and laziness, they don’t need to be doing what they're doing.

brazen chasm
#

Agreed but that's the situation where I get a little bit selfish

#

and use them for my own learning

slate swan
#

so when a new message is sent, the first thing that the code checks for is

        return
    if message.author.bot: return```
and if a message is "l!puzzle", then it will return a logic puzzle from a text file. If the following message is equal to the answer, it'll return a message and a different message if not. This is what should happen when the answer is wrong:
```if message.content != (str(answer)) and message.content != ('l!hint'):
      embedVar = discord.Embed(title="Incorrect", description = str(incorrect), color=0xE95124)
      await message.channel.send(embed=embedVar)```
the problem is, the bot jumps to this code immediately after sending the puzzle, which shouldn't happen
brazen chasm
#

Once I finish the code I've learned more about coding, they have their code and everyone is happy (in the short term)

sage otter
#

Are you waiting for the answer

brazen chasm
slate swan
brazen chasm
#

I don't want to steal tylers limelight here

#

Tyler, take it away.

sage otter
#

I mean he said it sends right after sending the initial message. Leads me to believe you not waiting for anything.

#

You got Bot.wait_for() in there? Somewhere

slate swan
#

i found it very confusing

tropic briar
#

How can we check if a url sent by someone is vanity or not

sage otter
#

Then how is this whole puzzle thing gonna work. This whole feature relies on user input that you already made logic for.

#

You're just not taking any in. And that’s what Bot.wait_for() | Client.wait_for() is there for.

slate swan
sage otter
#

I’m not gonna give you everything but I’ll give you a start

sage otter
#

so after the initial message put in the wait_for()

#

Put it in a try/except if you're want a timeout.

#

The event your waiting for is "message"

slate swan
#

!wait_for

sage otter
#

!d discord.Client.wait_for

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**...
sage otter
#

That’s really all

slate swan
#

so like this? discord.Client.wait_for(message)

sage otter
#

Not literally.

#

Replace discord.Client with your actual Bot or Client instance

#

And right a check that passes if all the logic you want in there checks out.

#

That’s really all

#

And handle input after that.

void saffron
#

hi

sage otter
#

Also if this is like a multi attempt thing. Put it in a while True and break out when the command is over or whatever

sage otter
tropic briar
sage otter
#

You don’t. Urls can be anything on discord. They don’t have an explicit flag that marks them as a servers vanity url or not.

tropic briar
#

It doesn't warn me if I send a url with a lots of members

#

Can we check members

sage otter
#

I mean it can detect if someone sent a vanity url matches this guilds vanity url. Through equality.

tropic briar
#

See it didn't did anything

sage otter
#

And it will warn you if you send a invite link that’s not vanity?

#

Idk then. Read it’s code.

tropic briar
#

But if I send a url with less members or something like that it will warn me

tropic briar
sullen shoal
#

i mean it may not be 100 percent accurate, but you can check if the url has too many uppercase letters and a lot of different characters that cant be easily pronounced

#

you can detect vanity urls that way

tropic briar
#

Oh ya, great idea

#

Every vanity url has all lower case letters right?

sullen shoal
sullen shoal
tropic briar
dapper cobalt
tropic briar
dapper cobalt
#

Who told you that you need so many members to get a vanity url?

sage otter
dapper cobalt
#

Also, vanity urls are a level 3 boosting reward; hence why it's so easy to get one now after Discord had decreased the boosts amount required for each level.

tropic briar
#

We need 15 boost to get that and no one will advertise a sever with so many boost and members (the server should have many members as it has 15 boost)

slate swan
#

in the bot.wait_for is there a way to tell the user that there is a typo in the expected word?

#

Can someone tell me how to add status to the bot

dapper cobalt
unkempt canyonBOT
#

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

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
sage otter
tropic briar
slate swan
slate swan
dapper cobalt
sage otter
#

Why did you cut the tb

slate swan
#

idk

slate swan
sage otter
#

Show full error pl0x

slate swan
sage otter
slate swan
#

🥲

dapper cobalt
sage otter
slate swan
#

alr

#

lemme install that rq

#

thank you

dapper cobalt
#

E.g.

await ctx.send("Send \"hi\"")
msg = await bot.wait_for("message", check=lambda m: m.content == "hi")
await ctx.send("Hello!")
#

@tropic briar I knew you're very smart.

tropic briar
#

I mean that if I send a url which is vanity

#

I know How to check but now if I put some text with upper case letters in the message then it will not detect it as vanity url

#

discord vanity url THIS

jagged root
#

Is it posible to change a channel description with a command

sage otter
#

The topic?

jagged root
#

yea

sage otter
#

Yes

jagged root
#

Could you help me ive been trying

sage otter
#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

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

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

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

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

@tropic briar The way we do it for @unkempt canyon is to just regex search for anything that looks like a discord link, and then call discord's guild API to see if it's real

jagged root
#

to code it

sage otter
#

Get a TextChannel object and call the edit method on it.

#

Not sure what else you need explained.

jagged root
#

Alright

dapper cobalt
#

What is pre_mega?

slate swan
sage otter
tropic briar
lyric moat
#
 @commands.command(name="emojiinfo", aliases=["ei"])
    async def emoji_info(self, ctx, emoji: discord.Emoji = None):
        if not emoji:
            return await ctx.invoke(self.bot.get_command("help"), entity="emojiinfo")

        try:
            emoji = await emoji.guild.fetch_emoji(emoji.id)
        except discord.NotFound:
            return await ctx.send("I could not find this emoji in the given guild.")

        is_managed = "Yes" if emoji.managed else "No"
        is_animated = "Yes" if emoji.animated else "No"
        requires_colons = "Yes" if emoji.require_colons else "No"
        creation_time = emoji.created_at.strftime("%I:%M %p %B %d, %Y")
        can_use_emoji = (
            "Everyone"
            if not emoji.roles
            else " ".join(role.name for role in emoji.roles)
        )

        description = f"""
        **General:**
        **- Name:** {emoji.name}
        **- Id:** {emoji.id}
        **- URL:** [Link To Emoji]({emoji.url})
        **- Author:** {emoji.user.mention}
        **- Time Created:** {creation_time}
        **- Usable by:** {can_use_emoji}
        
        **Other:**
        **- Animated:** {is_animated}
        **- Managed:** {is_managed}
        **- Requires Colons:** {requires_colons}
        **- Guild Name:** {emoji.guild.name}
        **- Guild Id:** {emoji.guild.id}
        """

        embed = discord.Embed(
            title=f"**Emoji Information**",
            description=description,
            colour=0x2f3136,
        )
        embed.set_thumbnail(url=emoji.url)
        await ctx.send(embed=embed)```
tropic briar
#

How does it understand that the user is advertising or not

slate swan
lyric moat
vocal magnet
sage otter
#

Interesting

vocal magnet
#

it'll be the vanity_url_code key in the partial guild object

dapper cobalt
# slate swan like this?
check = lambda m: m.content in subcat_dict.keys() and m.author == interaction.user

This is the best I could do; I can't understand what you're trying to achieve.

jagged root
slate swan
#

🥲 what is lambda?

sage otter
#

Anonymous function. Only takes one expression.

slate swan
#

👌

sage otter
vocal magnet
#

.rp lambda

lament depotBOT
#

Here are the top 5 results:

How to Use Python Lambda Functions
Functional Programming in Python: When and How to Use It
Python's reduce(): From Functional to Pythonic Style
Python Practice Problems: Parsing CSV Files
Code Evaluation With AWS Lambda and API Gateway
dapper cobalt
# slate swan 🥲 what is lambda?

Well, if you don't understand that, you can use:

def check(m, interaction):
  return m.content in subcat_dict.keys() and m.author == interaction.user

msg = await bot.wait_for("message", check=check)
#

I'm unsure if that would work, though.

slate swan
#

but that does not solve the original question

dapper cobalt
#

Which is?

jagged root
#

Can someone help me code how to change channel topic

dapper cobalt
unkempt canyonBOT
#

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

Edits the channel.

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

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

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

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

when i am waiting for apples and user types anything i want to tell them its not valid

sage otter
#

You really want spoonfeeding that bad?

jagged root
#

ik that but i cant get how to do it

jagged root
dapper cobalt
#

You get a TextChannel object, and then declare the edit method on it.

sage otter
slate swan
#

how to give my bot a status

dapper cobalt
#

F.e.

await ctx.channel.edit(name="new-channel-name")
dapper cobalt
unkempt canyonBOT
#

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

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
jagged root
slate swan
#

This is the 50th line of my 1st bot

#

lol

dapper cobalt
slate swan
#

Why all python users say not to SPOONFEED

dapper cobalt
#

Eyes really are a blessing.

slate swan
#

lol

jagged root
slate swan
dapper cobalt
sage otter
#

Because if we spoonfeed you answers. You won’t learn

slate swan
jagged root
#

but not in my case

slate nymph
#

dont we include hikari in this channel?

sage otter
dapper cobalt
#

No exceptions.

jagged root
slate nymph
#

since dpy is already dead?

sage otter
dapper cobalt
slate swan
trim meadow
#

Hello everyone, how do i add spaces between embed sentences?

slate swan
#

Ask him

jagged root
dapper cobalt
slate swan
#

he may help but not spoonfeed

slate nymph
#

okay

jagged root
slate swan
#

Like tell a part of the code maybe

dapper cobalt
sage otter
#

Dude scoopy literally gave you the code. You literally just have to change one thing 😭

dapper cobalt
#

I was about to write a paragraph because you called me "scoops".

sage otter
slate swan
#

Whats the diff between Bot and Client

sage otter
#

Just kidding pls don’t block.

dapper cobalt
slate swan
#

how do i change the whole cod to bot

#

☠️

trim meadow
#

So um, how do i get a space between embed sentences on my code? I've seen that you can add a invisible character, but im not too sure.. can anyone help me out please..?

jagged root
dapper cobalt
trim meadow
dapper cobalt
trim meadow
dapper cobalt
#

Your space button is broken?

trim meadow
#

-_-

dapper cobalt
#

Define "doesn't work".

trim meadow
#

Nevermind

#

There's no spaces on my embed message, and i wanna make some spaces between each field i add. How do i do that?

sage otter
#

Oh

#

I see what you mean

dapper cobalt
#

Do you mean a new line?

sage otter
#

Yeah just use the invisible character

#

U+200 is the Unicode

trim meadow
trim meadow
slate nymph
# slate swan how do i change the whole cod to bot
from discord.ext import commands
class Bot(commands.Bot): def __init__(self): super().__init__(command_prefix=commands.when_mentioned_or('$')) 

async def on_ready(self): print(f'Logged in as {self.user} (ID: {self.user.id})') print('------')
bot.run("token")``` 
heres an example
sage otter
#

Plug it into the name and value for the field.

dapper cobalt
slate nymph
#

why wouldnt they?

dapper cobalt
#

It seems that they just started, so classes would be pretty complicated for them.

cloud dawn
sage otter
#

If they can’t change a single param. I doubt they know much about oop

slate nymph
#

theres an easier way too

cloud dawn
#

!botvar

unkempt canyonBOT
#

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

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

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

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

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

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

cloud dawn
dapper cobalt
#

I was not surprised that I have this server mutual with about 30% of them.

cloud dawn
#

yep lol

slate swan
trim meadow
slate nymph
#

lmao

#

dont demotivate them yet its not that difficult

slate swan
tawdry perch
#

what aree ratelimits for kicking users?

trim meadow
#

i was like you too, i've been using computers since 2010, and i have been making my bot for the past 2 months. BEST HEADACHES OF MY LIFE!

dapper cobalt
slate swan
slate swan
quick gust
#

I spoonfed which is wrong

slate swan
#

lol

tropic briar
unkempt canyonBOT
#

bot/converters.py line 54

class ValidDiscordServerInvite(Converter):```
tropic briar
vocal magnet
#

Yea, our code is MIT licensed, so as long as you follow the license terms you can use it in your own bot

tropic briar
trim meadow
#

so um, does anyone know how can i add a space between a embed field?

vocal magnet
#

The code I linked isn't the only thing you would need to add for it to work no

#

you'd need to call this when appropriate and make sure you define all of the variables used

#

it can work as a reference for you though

tropic briar
#

Alright, it's hard

vocal magnet
#

It's not too bad. Make a regex that gets the invite code, call the Discord API with that invite code to see if it's real

trim meadow
tropic briar
#

I was thinking of detecting if there are upper case letters in the url or not, if there are it will warn the user

rain jay
#

is there a way to "stop" the wait_for? like, i want to cancel it

tropic briar
#

But if the user puts something after the invite with upper case then it won't work

trim meadow
sullen shoal
#

im on phone rn but let me check

tropic briar
#

Can we find a url and then check if there are any upper case letters ?

#

url + A description

#

Can we take only the url and not the other text in the message

#

@vocal magnet

vocal magnet
#

Yes, write a regex to extract the url-like things

tropic briar
#

All the letters in a vanity url are lower case and there are numbers and upper case letters in a random url

vocal magnet
#

and then check if there are uppercase letters

tropic briar
vocal magnet
#

.rp 1 regex

lament depotBOT
vocal magnet
#

This should cover the basics 😄

tropic briar
#

😁 Thanks a lot

tawdry perch
#

what are ratelimits for kicking users?

lyric moat
#
    @commands.Cog.listener()
    async def on_command_error(self, ctx, error):
        if isinstance(error, commands.CommandNotFound):
          await ctx.send(':no_entry_sign:  Failed To Find That Pannel/Command')
        elif isinstance(error, commands.MissingPermissions):
            embed = discord.Embed(color=0x2f3136, title= "", description=f'**Failed To Listen that command**\n\nYour Missing: **{(error.missing_perms)} **Permissions')
            await ctx.send(embed=embed)
        elif isinstance(error, commands.MissingRequiredArgument):
            embed = discord.Embed(color=0x2f3136, title= ' ',description= '**Missing Required Arguments**\n\nPlease Input All Required Arguments')
            await ctx.send(embed=embed)
        elif isinstance(error, commands.BotMissingPermissions):
            embed = discord.Embed(color=0x2f3136, title= '', description= f'**Bot Missing Permissions\n\nCartier Missing{(error.missing_perms)}** Permissions``')
            await ctx.send(embed=embed)```
#

i had this in replit and im in vsc and it does not work

slate swan
#

what does 'not work'

#

anything wrong

#

bcoz when i say Hi or Hello it doesnt reply

quick gust
#

change all the ifs after the 1st one to elif?

slate swan
quick gust
#

what?

slate swan
#

?@quick gust

quick gust
#

yeah try now

sullen shoal
#

anyone has some discord bot project with fastapi web dashboard? i wanna try

brittle ingot
#

fastapi web dashboard?

slate swan
maiden fable
brittle ingot
sullen shoal
brittle ingot
quick gust
slate swan
sullen shoal
maiden fable
#

But I can tell u how to do the basic authentication if u want. I have myself made a basic thing where I can get my guilds haha

slate swan
sullen shoal
quick gust
brittle ingot
slate swan
#

idk why my bump command doesnt work anymore??? Ion have errors tho

maiden fable
slate swan
sullen shoal
#

like i haven't looked up the docs of fastapi yet

#

so i gotta try after some hours

brittle ingot
maiden fable
maiden fable
brittle ingot
#

oh there is no bot 😂

#

well there could be?

maiden fable
#

Oh, hmm. Well the only things u can do with the authentication, are the things which the scopes support

brittle ingot
#

ahh okay, ill have to look into it more thanks.

#

anyways we should probably get back on topic. sorry everyone

maiden fable
slate swan
#

Sorry i took the ss from my github acc lol

shrewd barn
#

how to get into a channel with id ?

sullen shoal
#

i think

maiden fable
unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
sullen shoal
#

yes that

shrewd barn
#

thanks

slate swan
#

Anyhelp?

brittle ingot
#

you have context so you should be able to get a guild object from that context.

shrewd barn
slate swan
#

or u use bot.get_channel

shrewd barn
#

or directly id?

slate swan
#

no string

#

id as an int

shrewd barn
brittle ingot
#

does it actually bump to anywhere though?

slate swan
#

import discord
import os
import time
import discord.ext
from discord.utils import get
from discord.ext import commands, tasks
from discord.ext.commands import has_permissions, CheckFailure, check
from keep_alive import keep_alive

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

@client.event
async def on_ready():
print("Comrade Ain't Dead")

@client.event
async def on_message(message):
if message.author == client.user:
return

elif message.content.startswith('Hello'):
await message.channel.send('Hello Comrade')

elif message.content.startswith('Hi'):
await message.channel.send('Hi. Did ya nuke USA?')

elif message.content.startswith('Comrade'):
await message.channel.send('Shut Up Fool')

elif message.content.startswith('hello'):
await message.channel.send('Hello Comrade')

elif message.content.startswith('hi'):
await message.channel.send('Hi. Did ya nuke USA?')

elif message.content.startswith('comrade'):
await message.channel.send('Fuck You')

elif message.content.startswith('LMAO'):
await message.channel.send('You Dont Laugh In Russia ')

@client.event
async def on_message(message):
if 'i solemnly swear that i am upto no good' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.add_roles(role)
elif 'mischief managed' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.remove_roles(role)
await client.process_commands(message)

keep_alive()
client.run(os.getenv("TOKEN"))

quick gust
slate swan
#

Well i made a discord bot like 2 days ago and it been working great but now bump command doesnt work like the bot doesnt have access to get info from mongodb or ??

#

it doest reply to hello or Hello

slate swan
#

even with elif

sullen shoal
#

its been more than 7 hours and sherlock is still stuck with basic stuff of python syntax, i wish at some point they say fuck off to this lib for some time and learn about classes rather than telling everyine that i know to modify stuff

quick gust
sullen shoal
#

show error, code

#

thats what i help with

slate swan
brittle ingot
#

you have no errors?

slate swan
#

The bot stopped getting info from mongo db

slate swan
sullen shoal
#

they you have to show from which part it doesnt work

brittle ingot
#

Then check your mongo connection.

slate swan
#

it been working fine like 5h ago and then boom the bot stopped

sullen shoal
#

right now youre talking as if your computer started being lazy and doesnt do as ordered

slate swan
brittle ingot
#

Welp im back to creating an authentication system 😄

sullen shoal
#

im not hard, like see, we dont know what your bot does, how are we supposed to help

#

without even a single line of code being shown

slate swan
sullen shoal
#

i sound like it but im not

slate swan
slate swan
sullen shoal
#
# code 1
if 1: ...```
```py
# code 2
if 0: ...```
if we "combine" them, 
it will become, 
```py
if 1: ...
if 0: ....

although its not always that simple

#

you gotta use your brain and think how to make it work after combining them

#

like above code could also be, py if 1: ... elif 0: ....

shrewd barn
#

whats wrong?

sullen shoal
#

its discord.Guild.get_channel

#

first off all, you're not supposed to be doing stuff there

#

its not meant for that

#

you can use tasks

shrewd barn
#

when i did this:

#

when i added it:

sullen shoal
#

well.

#

you gotta think about your code now.
a channel id doesnt have any data about the guild. discord doesn't know from which guild it is. how is it supposed to know which guild its from?

#

you need an instance of discord.Guild of the guild

#

for which you can use discord.ext.commands.Bot.get_guild

#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
slate swan
#

kanalagecbir.channel.send

slate swan
maiden fable
#

await send()

shrewd barn
#

oh sorry

slate swan
shrewd barn
#

i compeletly forgot about those things, i wasnt coding for some time

maiden fable
#

Its fine haha

slate swan
maiden fable
slate swan
#

welllllllllll im working on bump bot it been like 2 days and the bot working ight but when i tried to bump my server it doesnt send the embed of my server to other servers . Also im new to Pymongo

maiden fable
#

U got any errors?

slate swan
maiden fable
#

Weird

#

Can I see some code?

maiden fable
#

Ah that didn't load before. Discord being itself

slate swan
#

Oh

slate nymph
#

ur message isnt loading

slate swan
#

wait

slate nymph
#

try sending it once more

maiden fable
#

Yea

slate swan
#

Here

hollow crown
#

len(client.users) this gives the unique users. how do we get the total users of the bot?

maiden fable
#

!d discord.Client.users

unkempt canyonBOT
#

property users: List[discord.user.User]```
Returns a list of all the users the bot can see.
maiden fable
#

Hmm it gives a list tho

hollow crown
maiden fable
#

.......?

hollow crown
#

it gives the uniqie users

#

every user counts 1 time

maiden fable
#

Then just loop through bot.guilds

#

!d discord.Client.guilds

unkempt canyonBOT
#

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

!d discord.Guild.members

unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
hollow crown
#

hmmm

maiden fable
# slate swan

Can u try printing channel and invite and see what they print?

slate swan
#

@quick gustcombine correct and @sullen shoal

slate swan
#

god

slate swan
slate swan
#

that's really bad

hollow crown
slate swan
slate swan
#

how to correct it

#

@slate swan please go read the official d.py docs and a tutorial on the library

hollow crown
slate swan
#

I don't wanna put anymore effort for someone that doesn't put in the effort to learn python basics

#

what do you think defining a function twice does?

#

No good

maiden fable
slate swan
#

Btw gm guys

#

5pm here

#

good morning

slate swan
slate swan
slate swan
kind wind
#

Why does it give me an error when I type (some of) the exact same code? Like I want to make it just talk. Why does it give me an error.

maiden fable
glass rock
#

pls help why does channel=client.get_channel('"my_id") return none?

slate swan
slate swan
slate swan
glass rock
maiden fable
slate swan
glass rock
maiden fable
quick gust
slate swan
slate swan
sick birch
slate swan
#

ID is an int

#

Its a line of integers and not a string

glass rock
glass rock
slate swan
slate swan
sick birch
# slate swan

also create a dict of messages and map them to responses, you can make this 10x easier

glass rock
#

ty all

glass rock
slate swan
slate swan
slate swan
#

for the love of god

slate swan
slate swan
slate swan
glass rock
#

ty my dudes it works perfectly when i removed ""

kind wind
#
@bot.event
async def on_member_join(member):
  notverified = member.guild.get_role(roleid)
  await member.add_roles(notverified)

Why the code doesn't work

slate swan
sullen shoal
slate swan
sick birch
kind wind
slate swan
sullen shoal
#

yeah