#discord-bots

1 messages · Page 439 of 1

unkempt canyonBOT
maiden fable
#

message.content 7408_shrekstare

sage mural
maiden fable
#

Indeed

#

Mhhm

slate swan
#

Tysm

sage mural
#

did it work?

slate swan
#

Haven't test it, like I said I'm not on pc

sage mural
#

ah my bad

maiden fable
#

?

slate swan
maiden fable
#

You can

#

U should be able to

slate swan
#

!d discord.PermissionOverwrite

unkempt canyonBOT
#

class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.

Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.

The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.

`x == y` Checks if two overwrites are equal.

`x != y` Checks if two overwrites are not equal.

`iter(x)` Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
slate swan
#

PermissionOverwrite, yes

inner orbit
#

I guess you can do it by using APIs

sage mural
#

try await ctx

vagrant brook
#

get_role isn't a coroutine

#

You don't have to await it

sage mural
#

oh yeah

#

the bot needs admin

#

as its changing roles

#

and permissions

#

you can set it to be admin in the developer page

#

but give it a admin role and try

vagrant brook
#

Manage Channels permissions should work

slate swan
sinful comet
#

How do I get my bot to detect when a user has changed their status to contain certain words?

#

I have all intents enabled

vagrant brook
#

!d discord.on_member_update

unkempt canyonBOT
#

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

This is called when one or more of the following things change...
past ermine
#

Hi, so I have the following code or line

cur.execute(f'''INSERT INTO GUILD_{ctx.guild.id} (user_id) VALUES ({x.id})''')
``` and i need it to ignore if the(user_id) already exists
full lily
#

i strongly suggest avoiding the use of f strings in sql queries

#

you can get into some nasty sql injection problems

vagrant brook
#

I'm not sure if this is the appropriate place to ask about SQL

past ermine
#

but it's for a discord bot

#

so?

vagrant brook
sage mural
#

you can still sql

#

but here you cannot

#

as it's just grabbing the guild id

vagrant brook
#

!d discord.on_guild_channel_create

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
sinful comet
vagrant brook
slate swan
#

How do I edit embed?

vagrant brook
#

Does it even make sense to have access and do not have access to something at the same time

vagrant brook
vagrant brook
sinful comet
sinful comet
slate swan
minor kestrel
#

Can I do the bot to transmit video when connected to a discord channel?

slate swan
#

Bots can't stream

#

if you need to share a video file in a text channel. yes

sinful comet
vagrant brook
manic wing
#

nice indenting

limber mountain
#
ADS is ready to moderate.
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Orange\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Orange\Desktop\ADS custom discord bot\ADS.py", line 181, in on_message
    await level_up(users, message.author, message)
  File "C:\Users\Orange\Desktop\ADS custom discord bot\ADS.py", line 202, in level_up
    levels = json.load(g)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 2 (char 1)
``` what is wrong
vagrant brook
#

before and after

vagrant brook
#

Probably empty or sth ig

limber mountain
#

not working

#
ADS is ready to moderate.
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Orange\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Orange\Desktop\ADS custom discord bot\ADS.py", line 181, in on_message
    await level_up(users, message.author, message)
  File "c:\Users\Orange\Desktop\ADS custom discord bot\ADS.py", line 202, in level_up
    levels = json.load(g)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 293, in load 
    return loads(fp.read(),
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 2 (char 1)
``` seee
limber mountain
minor kestrel
#

Are there any docs or something more specific to learn how to use discord-py-interactions?? Because the official documentation web isn't working and isn't enough with the examples give in GitHub

slate swan
#
@bot.event
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id == 882642949287051265:
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)

        if payload.emoji.name == 'Roblox':
            role = discord.utils.get(guild.roles, name='Roblox')
        elif payload.emoji.name == 'Minecraft':
            role = discord.utils.get(guild.roles, name='Minecraft')
        else:
            role = discord.utils.get(guild.roles, name=payload.emoji.name)

        if role is not None:
            member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
            if member is not None:
                await member.add_roles(role)
                print("Completed")
            else:
                print("Member not found")
        else:
            print("Role not found")

@bot.event
async def on_raw_reaction_remove(payload):
    message_id = payload.message_id
    if message_id == 882642949287051265:
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)

        if payload.emoji.name == 'Roblox':
            role = discord.utils.get(guild.roles, name='Roblox')
        elif payload.emoji.name == 'Minecraft':
            role = discord.utils.get(guild.roles, name='Minecraft')
        else:
            role = discord.utils.get(guild.roles, name=payload.emoji.name)

        if role is not None:
            member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
            if member is not None:
                await member.remove_roles(role)
                print("Completed")
            else:
                print("Member not found")
        else:
            print("Role not found")```
#
NameError: name 'client' is not defined```
#

what am i doing wrong?

vagrant brook
#

Should be bot as I see in your code

#

!d discord.Embed.set_footer

unkempt canyonBOT
#

set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.
marsh depot
#

ty

spring flax
#

you didn't define client and you used client in your code @slate swan

slate swan
#

oh ok

#

so i change that to bot

spring flax
#

Yes

slate swan
#

Hello...
Is it possible to get the remaining cooldown time of a mentioned Member?

#

Like if a member used f!daily which can be done every 24 h

Is it possible for others to see how much time is left for that member?

maiden fable
unkempt canyonBOT
willow vine
#

if im using bot instead of client do i use
discord_client or discord_bot

willow vine
#

it will work?

slate swan
maiden fable
#

Use it in on_command_error

maiden fable
willow vine
#

sorry im new ;-;

hearty edge
#

Has anyone tried hikari?

compact field
#

guys how can i convert string of message object to message object ?

spring flax
#

huh

maiden fable
spring flax
slate swan
compact field
slate swan
#

I know it works on command_error

#

:(

maiden fable
compact field
slate swan
#

Okk I will see!

maiden fable
maiden fable
#

Yea

#

Or u can also look into disnake

hearty edge
compact field
maiden fable
#

Indeed lmao

compact field
#

str to message object

sweet pilot
#

how to check whether a message is available?

sage chasm
#

Good morning ! I would like to know if it would be possible to use Pydroid to run a program acting on discord, and if so, how to link Pydroid to discord? On computer, I used my terminal to link the two, but on Android I have no idea how I could do it, and if it would even be possible! Thank you in advance for your answers

#

Another question ... If this is not possible, would you have a python program hosting solution other than Heroku which only offers 500h of activity? I headed to Naglito, but at the moment their servers are all in use, and unfortunately I can't find any other hosting solutions at the moment.

sweet pilot
#

why does it start with good morning and end with evenning

sage chasm
#

Lol

exotic kelp
hasty iron
#

you already have the object if the repr is printed or something

exotic kelp
#

put the string in the eval() function

hasty iron
unkempt canyonBOT
#

object.__repr__(self)```
Called by the [`repr()`](https://docs.python.org/3.10/library/functions.html#repr "repr") built-in function to compute the “official” string representation of an object. If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment). If this is not possible, a string of the form `<...some useful description...>` should be returned. The return value must be a string object. If a class defines [`__repr__()`](https://docs.python.org/3.10/reference/datamodel.html#object.__repr__ "object.__repr__") but not [`__str__()`](https://docs.python.org/3.10/reference/datamodel.html#object.__str__ "object.__str__"), then [`__repr__()`](https://docs.python.org/3.10/reference/datamodel.html#object.__repr__ "object.__repr__") is also used when an “informal” string representation of instances of that class is required.

This is typically used for debugging, so it is important that the representation is information-rich and unambiguous.
sweet pilot
#

wdym try to get the message

sweet pilot
sage chasm
#

Yeah

iron shadow
#

Hello im having trouble on this code
@client.event
async def on_ready():
print("We have logged in as {0.user}")
.format(client))
error message:
File "main.py", line 9
.format(client))
^
SyntaxError: invalid syntax

sage chasm
#

can someone answer my question please ...?

compact field
hasty iron
compact field
hasty iron
#

you cant

iron shadow
compact field
hasty iron
#

you cant convert a str -> other object

#

its just impossible

compact field
exotic kelp
hasty iron
#

are you saving a message object?

compact field
hasty iron
#

if you are, save its id and fetch it later when you need it

iron shadow
#

now its displaying this

#

File "main.py", line 9
'.format(client))
^
SyntaxError: EOL while scanning string literal

exotic kelp
hasty iron
sweet pilot
#

in your phone?

sage chasm
#

Yes

#

Forget the first question

#

do you know a way to host a discord bot for free?

ionic moss
#

?tag vps

ionic moss
#

wrong server

sage chasm
#

Aws ?

ionic moss
#

aws

sweet pilot
#

I use aws

#

amazon web services

sage chasm
#

It's free ?

ionic moss
#

yes for one year i guess

sweet pilot
#

they offer 1 year free plan with 750 hours worth of servers per month

sage chasm
#

Ok thanks

ionic moss
#

np

sage chasm
#

I will try to do that

ionic moss
#

mk

sage chasm
sweet pilot
sweet pilot
sweet pilot
#

well, if you are an student, just ask for your mom's or dad's credit card

#

it won't cost you anything, it's just for verification

sage chasm
#

there are no other solutions / sites?

sweet pilot
#

best solutions require credit cards bro

#

you can ask for a credit card right?

sweet pilot
slate swan
#

AWS doesn't need credit card if you are a student

sweet pilot
slate swan
#

You need to send proof of begin a student

sweet pilot
#

its god damn hard

slate swan
#

Yeah ik

sweet pilot
#

I have tried maybe 5-6 times for github student

#

still no luck

slate swan
#

¯\_(ツ)_/¯

cloud dawn
#

raspberri pi latest model from 100 bucks can handle around 2k servers

slate swan
#

Wow

compact field
#

guys how can i get message with id ?

cloud dawn
#

uses your own internet speed tough.

sage chasm
#

Hum thanks for your answers, I'll try

sweet pilot
#

heat issues and stuff?

#

and as of my country, we have 1MBps connections

#

yup

cloud dawn
compact field
sweet pilot
#

so, self hosting is not a good feat when internet is bad

wide bloom
#
async def ticket(ctx):
    guild = ctx.guild
    member = ctx.author
    admin_role = get(guild.roles, name="Admin")
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(read_messages=False),
        guild.me: discord.PermissionOverwrite(read_messages=True),
        admin_role: discord.PermissionOverwrite(read_messages=True)
    }
    channel = await guild.create_text_channel(f"ticket-{str(ctx.author.display_name)}", overwrites=overwrites)
#

AttributeError: 'NoneType' object has no attribute 'id'

#

this gives this error

#

h e l p :(

cloud dawn
floral jacinth
#

how can i get current time in a var?

wide bloom
#

-_- why

wide bloom
#

use return (variable name)

floral jacinth
wide bloom
floral jacinth
#

show it then xD

wide bloom
#

lol sure

slate swan
#

does anybody know the solution for this problem
it doesnt read the message (start) it just ignores it and it doesnt give me a error

@client.event
async def on_message(message):
if message.content == "start":
channel = await message.guild.create_text_channel("newchannel")
await message.channel.send("start 2")

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

spring flax
#

!intents

slate swan
#

ok thanks

cloud dawn
junior zenith
#

anybody heard anything about discord.py being deprecated/archived by its creator?

sweet pilot
junior zenith
#

appreciate it

sweet pilot
#

check out the pins

cloud dawn
junior zenith
sweet pilot
wide bloom
#
From datetime import datetime

Time = today.strftime("%I:%M")
Print(time)
iron shadow
#

can someone help me how to make a token hidden to the public?

wide bloom
#

Use "%H" for 24hour clock tike

#

Time*

sage chasm
#

Water Heberg

#

Free

#

@sweet pilot

sweet pilot
full lily
#

You mean hide it in your code?

ionic moss
iron shadow
#

thanks

sweet pilot
ionic moss
#

for example, bot.run(os.getenv('token')) ('token' is just the name of the variable, the variable's key is hidden in that variable)

dusky patio
#

guys how can i get content of message in self-bot ?

iron shadow
#

wait so i just do os.getenv('token')

ionic moss
dusky patio
#

no doesn t work in self-bot

ionic moss
#

then idk sorry

sweet pilot
#

what's the library

cloud dawn
#

We don't give help here regarding a self-bot this is against ToS

#

Please stop mentioning this here.

compact field
#

we dont have ctx in on message

ionic moss
#

there

cloud dawn
ionic moss
#

sent :D

ionic moss
#

deleted

sweet pilot
#

no need to get him banned

ionic moss
#

its against discord tos

sweet pilot
#

yeah

#

and breaking tos will ban him

ionic moss
#

yeah

sweet pilot
#

I mean no need to do that 😅

ionic moss
#

yeah i know what you mean

cloud dawn
#

No, breaking ToS will get a verbal warn first. Then if he/she still ask about it after a verbal warning it will be a mute etc.

ionic moss
#

kk

sweet pilot
#

is using discord bot clients against tos @cloud dawn

full lily
#

yes?

cloud dawn
full lily
#

They've been cracking down lately, I've heard

#

My bad. I thought he was asking about self bots

sweet pilot
cloud dawn
sweet pilot
languid jungle
#

@dusky patio Hello, as per rule 5, we will not help with self bots as they are against Discord's ToS. Please re-read our rules.

cloud dawn
dusky patio
#

@languid jungleWe need this for a good job, not an illegal one

cloud dawn
sweet pilot
sweet pilot
sweet pilot
thick pebble
cloud dawn
# sweet pilot if it's against tos, it's illegal right?

No a ToS is not going against the law. They can ban you from the API and send a warning to the user. If the user will not comply the company can make a Cease and Desists letter (Most likely will not happen). Take Groovy for example.

#

It's not like abusing the API will have the FBI raid your house.

thick pebble
#
        elif isinstance(error, commands.MessageNotFound):
            await ctx.send(f"**Error!** You must use this command in the same channel the counter is in")

can someone tell me why this doesnt catch the Message Not Found error

thick pebble
open brook
#

how to remove a cog completely from help command

cloud dawn
iron shadow
#

is this how im supposed to run a enviroment variable on repl
client.run(os.environment("token"))

open brook
#

like shud I just use hidden=False in the class

cloud dawn
#

I think you can do that lemme check

open brook
#

ok lemme try it out

cloud dawn
#

Can't find it very fast but you can also just skip it inside mapping.

#

!source

unkempt canyonBOT
cloud dawn
#

Could you dir mapping?

marsh depot
#

Can anybody help me?
I've been trying to get this command to work for 20 minutes but I can't

@bot.command()
async def stop(ctx): # TODOS LOS SERVERS
    voice_client = ctx.message.guild.voice_client
    user_channel = ctx.message.author.voice.channel
    bot_channel =  bot.user.voice_client
    if not ctx.message.author.voice:
        await ctx.reply("**{}** necesitas estar conectado a un canal de voz".format(ctx.message.author.name))
        return
    if voice_client.is_connected():
        if user_channel and bot_channel == voice_client:
            channel = ctx.message.author.voice.channel
            await voice_client.disconnect()
            EmbedMusic = discord.Embed(tilte='\n', description=f':octagonal_sign: {ctx.author.mention}, Me salí con éxito de <#{channel.id}> ', color=0xcd5c5c)
            await ctx.send(embed=EmbedMusic)
        else:
            await ctx.reply("**{}** ya estoy conectado a un canal de voz".format(ctx.message.author.name))                      
    if voice_client == None:
        await ctx.reply("El bot no está conectado a ningún canal de voz")```

Erros -> 

Ignoring exception in command stop:
Traceback (most recent call last):
File "C:\Users\vixez\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\vixez\Documents\WOLFM00N\DISCORD\BOTS\JapanWave\CODE\py\pruebas.py", line 1108, in stop
bot_channel = bot.user.voice_client
AttributeError: 'ClientUser' object has no attribute 'voice_client'

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

Traceback (most recent call last):
File "C:\Users\vixez\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\vixez\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\vixez\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ClientUser' object has no attribute 'voice_client'```

open brook
cloud dawn
cloud dawn
marsh depot
#

and what i cant change to my bot work

hasty iron
open brook
void fox
#

How do I paste it into the embed! for example??

gleaming torrent
#

Heya, how do I prevent mass mentions? I know how to use len(). But dont know what to type.

gleaming torrent
#

Will try

#

Thank you anyways @cloud dawn

cloud dawn
unkempt canyonBOT
#

Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.

for i in range(len(my_list)):
    do_something(my_list[i])

The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:

for item in my_list:
    do_something(item)

Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.

cloud dawn
#

Just notice how the len is used disregard the for loop.

void fox
gleaming torrent
cloud dawn
gleaming torrent
cloud dawn
#

[#help-carrot](/guild/267624335836053506/channel/696840664435916950/)
Just copy this

gleaming torrent
#

?

vocal shoal
#

so..i want to make my discord bot open source, should i put a license on the github repository? and if yes what license do u think fits well?

#

ok sorry i will remove it

cloud dawn
gleaming torrent
cloud dawn
vocal shoal
#

someone asked me to not adverstive...

slate swan
#

anyone here moving to rust

vagrant brook
#

len(bot.guilds)

cloud dawn
#

id_list = [guild.id for guild in bot.guilds]

cinder horizon
#

any good module or sm api for anime search commands?

hasty iron
#

you can use my api wrapper for anilist (you can find it in my github) or make your own

grim oar
#

miku

#

don't use nino, it bad

waxen tangle
#

how would i go about making a poll command? struggling about how to pass in 2 different options and put them on an embed?

waxen tangle
#
@client.command()
async def poll(ctx, *, text):
    pollEm = discord.Embed(title='Test',
                           color=discord.Color.random(),
                           description=text,
                           timestamp=datetime.utcnow())
    pollEm.set_author(name=f"{client.user}", icon_url=client.user.avatar_url)
    await ctx.send(embed=pollEm)```
cloud dawn
#

What is the result?

waxen tangle
#

i wanna add like 1️⃣ and 2️⃣ on different lines of the embed if i can figuree out how to take in 2 separate things and display them, maybe seperate both options by a ,

waxen tangle
hasty iron
#

do something like (ctx, *polls):

waxen tangle
#

and takes in a text

hasty iron
#

polls will be a tuple then

cloud dawn
hasty iron
#

what

cloud dawn
#

!e ```py
def somefunc(*, someargs):
print(someargs)

somefunc('a', 'b', 'c')

hasty iron
#

???

round quarry
#

What are the requirements to program the bot?

waxen tangle
#

?

cloud dawn
hasty iron
#

what

#

do something like (ctx, *polls): -> polls will be a tuple then

cloud dawn
hasty iron
#

doing *, polls will make polls a keyword argument

willow vine
#

someone told i could use voice_bot instead of voice_client
it doesn't work it says, Context has no attribute voice_bot
what do i do?

hasty iron
hasty iron
#

!d discord.ext.commands.Context.voice_client

unkempt canyonBOT
#

voice_client```
A shortcut to [`Guild.voice_client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.voice_client "discord.Guild.voice_client"), if applicable.
willow vine
#

work

hasty iron
#

what?

#

its Context.voice_client no matter what

willow vine
#

oh

#

okay thanks

cloud dawn
hasty iron
#

you tried it but you have no idea

cloud dawn
stiff nexus
#

can 2 members own a guild?

hasty iron
#

no

#

only 1 has ownership

gloomy coral
slate swan
#

So I have a debug command to see what permissions my bot has. I used {dict(ctx.me.guild_permissions)}.

How can I make it so that if a permission is true then it will do something else with it and not send it. And if it's false it does send the permission it needs?

rain bolt
#

How to set a command on the user ?

slate swan
slate swan
#

Is that what you mean?

rain bolt
slate swan
#

So just do a check to see if the command user is the owner.

rain bolt
#

I know about the roll, I do not know only about the user

slate swan
slate swan
rain bolt
slate swan
#

You're welcome

spark dragon
#

How do I make join/leave events in a specifik channel?

#

Specific*

slate swan
spark dragon
slate swan
#

use the on_member_join event

spark dragon
#

@quaint axle.event?

#

bruh

#

sorry for the ping lol

slate swan
#

Just use backqoutes or

#

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

cloud dawn
#

!source

unkempt canyonBOT
slate swan
#

on_member_join(member) and on_member_remove(member)

#

!d discord.on_member_join CH_PepeSip

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").

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

Ty : )

slate swan
#

also, the bottom part is important @spark dragon

#

make sure to have intents on

#

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

stiff nexus
#

how do i get my bots uptime in the new timestamp formate??

slate swan
#

How I add the pfp of the person that did the command and the time in the footer?

@bot.command()
@commands.has_permissions(manage_messages = True)
async def clear(ctx, amount : int):
  await ctx.channel.purge(limit=amount)
  emb=discord.Embed(title="Messages deleted successfully", description="🧹")
  emb.add_field(name=f"Responsible moderator : {ctx.author.name}", value=f"Responsible channel {ctx.channel.mention}")
  emb.set_footer(title= #pfp | "Today at" #time,)
  msg=await ctx.send(embed=emb, delete_after=4)
vocal shoal
#

how do i get the default channel of a server?

slate swan
#
    @bot.event
    async def on_message(self, msg):
        if is_bot:
            return
        data = await get_leveling_data()
        xp = data[f"{guild.id} - {user.id}"]["xp"]
        lvl = data[f"{guild.id} - {user.id}"]["lvl"]
        to_the_next_lvl = data[f"{guild.id} - {user.id}"]["to_the_next_lvl"]
        if len(msg.clean_content) > 3:
            xp += 1
        if xp > to_the_next_lvl or xp == to_the_next_lvl:
            data[f"{guild.id} - {user.id}"]["xp"] = xp - to_the_next_lvl
            data[f"{guild.id} - {user.id}"]["to_the_next_lvl"] = round(to_the_next_lvl ** 1.02)
            data[f"{guild.id} - {user.id}"]["lvl"] += 1
        data[f"{guild.id} - {user.id}"]["user's_last_message"] = str(cnt)
        data = await get_public_leveling_data()
        xp = data[str(user.id)]["globalxp"]
        lvl = data[str(user.id)]["globallvl"]
        to_the_next_lvl = data[str(user.id)]["globalto_the_next_lvl"]
        if len(msg.clean_content) > 3:
            xp += 1
        if xp > to_the_next_lvl or xp == to_the_next_lvl:
            data[str(user.id)]["globalxp"] = xp - to_the_next_lvl
            data[str(user.id)]["globalto_the_next_lvl"] = round(to_the_next_lvl ** 1.02)
            data[str(user.id)]["globallvl"] += 1
        data[str(user.id)]["globaluser's_last_message"] = str(cnt)
        await bot.process_commands(msg)```
Do someone know why isn't it adding to the user xp?
vocal shoal
slate swan
#

?

#

Like this

vocal shoal
slate swan
#

Okay

high flame
#

icon_url

spring flax
#

!d discord.Embed.set_footer

unkempt canyonBOT
#

set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.
spring flax
#

@slate swan

slate swan
#

Oh thanks

flat solstice
#

!d discord.ext.commands.Context.reply

unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message "discord.Message").

New in version 1.6.
flat solstice
# unkempt canyon

Does this thisbeautiful reply to msgs like users do (like I am doing here)? or is it literally just to send a normal response? and if it is the former; does it ping on reply by default or do I have to do somehting to make that happen

vocal plover
#

it replies to the message, and pings

flat solstice
#

okay cool

vocal plover
#

to send a normal response its just send()

flat solstice
#

yeah i was looking for the reply and ping one, just checking i understood it right

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

        embed = discord.Embed(title = f"{member.name}#{member.discriminator}", description = f"Status: **{member.status}**\n*{member_status}*", colour = member.colour)
        embed.set_author(name = f"{member.id}", icon_url = member.avatar_url)
        embed.set_thumbnail(url = member.avatar_url)
        await ctx.reply(embed = embed)```
spring flax
#

Uhhhh

slate swan
#

did you restart/reload the cog for the changes to apply?

spring flax
#

You saved the changes?

slate swan
#

Try to restart your bot

spring flax
#

Bruh autocorrect

flat solstice
#

yeah i reloaded the cog twice, i'll try a bot restart. yes I saved
okay reloaded the whole bot and it's still doing the same thing

slate swan
#

Did you modify core files?

#

Or have a custom context?

flat solstice
#

nope

slate swan
flat solstice
#

okay all good. I done goofed and was reloading the wrong file 😂 😠

crude crow
#

!source

unkempt canyonBOT
floral jacinth
#
    @commands.command()
    async def a(self, ctx, member: discord.Member):
        await ctx.message.delete()
        await ctx.send(f"ehi {member.mention}, {random.choice(insulti)}")```

why it doesn't delete the message sent by user
slate swan
#

await it

floral jacinth
#

ye sorry

#

i deleted

slate swan
#

any error?

crude crow
#

!d discord

#

uh

slate swan
#

#bot-commands @crude crow unless you're helping anyone

hoary gust
#

!random

slate swan
hoary gust
slate swan
#

alr

#

whats cog ?

#

\think

knotty fossil
#

guys anyone know how i can send ephemeral messages aka Only you can see this embeds ?

pale turtle
#

You need InteractionResponse object

viscid meteor
#

on discord.py i tried doing the
publish()
command and for some reason it wont work

#

is there any restriction on this command or smth

#

can i not send embeds?

knotty fossil
drifting quest
#

Okay hey @bronze wigeon how should I get started considering I know nothing about python or discord bots

#

I need this asap

#

But I don't know nothing about python or stuff

bronze wigeon
drifting quest
#

I'm desperate you can say

bronze wigeon
#

I could tell

drifting quest
bronze wigeon
#

it depends on how you learn and how well you learn it

hasty iron
#

whats your condition

drifting quest
#

Well I might be honest I'm not a really fast or good learner

drifting quest
#

As soon as possible

hasty iron
#

why

bronze wigeon
#

Then it may take awhile, it may take months, weeks, years, it's not immediate

drifting quest
#

Years!?

bronze wigeon
hasty iron
#

why are you trying to do it as fast as possible

#

take your time

bronze wigeon
#

^

#

I can't react but I would use this

drifting quest
# hasty iron why

Cause the current developer in the server is stepping down and I wanna learn and make the bot

#

But I know nothing

hasty iron
#

you aren’t obligated to take the spot of developer

#

take your time, learn python and then become a dev for that server

drifting quest
#

Yeah that's what I'm trying

bronze wigeon
#

You clearly aren't

drifting quest
#

But I wanna do it fast don't wanna take much time

hasty iron
#

you’re trying to jump in discord.py without any knowledge

drifting quest
bronze wigeon
hasty iron
#

did you ever code? other languages

bronze wigeon
hasty iron
#

yes

drifting quest
hasty iron
#

How much Python do I need to know?

discord.py is ultimately a complicated Python library for beginners. There are many concepts in there that can trip a beginner up and could be confusing. The design of the library is to be easy to use -- however the target audience for the library is not complete beginners of Python.

With that being said, beginners tend to use this library quite liberally anyway and while I appreciate the endeavour and tenacity it should be noted that asking for help here does take up the valuable time of volunteers. As a result certain knowledge is required before you can actively participate in the help channels:

  • The difference between instances and class attributes.
    • e.g. guild.name vs discord.Guild.name or any variation of these.
  • How to use data structures in the language.
    • dict/tuple/list/str/...
  • How to solve NameError or SyntaxError exceptions.
  • How to read and understand tracebacks.

This list is not exhaustive

If these concepts are confusing -- please feel free to complete a smaller and simpler project first before diving into the complexities that is asynchronous programming in Python. The Python help channel (#738572311107469354) or the Python server (https://discord.gg/python) could also be a place to go for basic Python help.

#

read that

drifting quest
bronze wigeon
#

You're essentially trying to run before trying to walk

#

So learn to walk, before trying to run

#

Hopefully that makes sense

drifting quest
#

I don't wanna do that positively but I wanna do it fast it's just that :((

bronze wigeon
#

You'll get confused on how to fix any errors if you don't know what the errors mean, and python helps you also learn those errors

#

You're trying to become the top dog in programming for that server but it's not that easy

hasty iron
#

if you do it as fast as possible it’s probably going to take you like 3-4 weeks

drifting quest
#

3-4 weeks seems nice a year seems horrible

hasty iron
#

async programming is going to take you a while though, it’s really complicated

bronze wigeon
drifting quest
#

Async?

pliant gulch
#

Those 3-4 weeks are gonna be a pain and quite intensive if you don't even understand the basics though lol

bronze wigeon
hasty iron
#

asynchronous

pliant gulch
#

You will be stuck for an hour on something such as indentation

#

It doesn't matter the speed imo, rather the efficiency

bronze wigeon
#

You would need to learn python asynchronous stuff before trying discord.py because, you'll get very lost very quickly

#

and you could use non-async functions however, it won't work very well

drifting quest
#

I'm not trying to push myself too much as I have University stuff also but still how much shall it take on an average

hasty iron
#

3 months then

#

or 2

#

it really depends on you

drifting quest
#

I want to learn it fast but when I think of it the way I rate I wanna learn it at doesn't comply with my life

pliant gulch
#

If your doing university why are you branching into something new and vast as programming? It will take a lot of your university time

drifting quest
#

I have other stuffs

drifting quest
bronze wigeon
pliant gulch
#

Making a discord bot rather then having extra time for university

drifting quest
#

So it's a bad idea then?

hasty iron
#

focus on your uni for now

bronze wigeon
#

Because to my knowledge you have to like, make a bot and prove you are able to make a bot for them, which may mean you spend all your time learning, just to not even get that 100% chance of being accepted

hasty iron
#

when you have more free time, start with python

pliant gulch
#

If your university offers, why not take a python class or something alike

drifting quest
#

Nah I'm doing medicine enough load already

slate swan
#

bruh

pliant gulch
#

If your going into medicine you def won't have time for any discord bots

drifting quest
#

And above that it doesn't give python classes

bronze wigeon
#

Medicine > Programming

drifting quest
#

If it would have I sure would have gone

slate swan
#

then get comfortable first and then you will see if you actually have time

hasty iron
drifting quest
hasty iron
#

then why did you do medicine

bronze wigeon
#

it's mostly based on commission

slate swan
#

what you just said is contradictory to your actions taken

bronze wigeon
#

where someone will pay you to make something

flat solstice
#

If I want to have by bot use the reply feature to reply to a msg but I don't want it to ping \I'd need to add reply(allowed_mentions = False right?

drifting quest
drifting quest
hasty iron
#

nobody becomes good at java at lightning speed

bronze wigeon
#

I think what you're not understanding is programming no matter how easy will take time, python is the easiest to learn and it will still take time

drifting quest
bronze wigeon
#

C++ will take a long time too, no matter what lang / form of lang it will take over a week

slate swan
#

this channel is the most off topic out of any topical help channels in this server lol

bronze wigeon
drifting quest
#

Get it?

hasty iron
#

then once you spend 2-3 months learning, after you make the bot those months are going to be wasted

drifting quest
#

Nah I'll need them to maintain the bot ig

bronze wigeon
#

Once the bot is perfect for the server your learning will have been wasted and you'll regret it

lament mesa
#

Just add an existing bot

bronze wigeon
drifting quest
#

So I'll maintain it

hasty iron
#

what if the server dies

bronze wigeon
#

What if they find someone better

drifting quest
bronze wigeon
#

what if they figure it out on their own

drifting quest
#

It's not that a big community lol

bronze wigeon
#

So the server is likely to die

#

Meaning your education is more likely to have been wasted

drifting quest
#

Maybe yes maybe no

#

My main focus should be my education nonetheless

#

I'm not putting programing first

hasty iron
#

how are you planning to balance bot development and your uni studies

drifting quest
#

No idea tbh

bronze wigeon
hasty iron
#

what if the server owners demand something big

bronze wigeon
#

You will either dedicate your time to learning python that may be useless once that server dies or you will dedicate your time to learning medicine that could save someone's life and make you a good income, so

hasty iron
#

drop out of uni to make a discord bot 👍

drifting quest
#

Hell no lol

bronze wigeon
#

/s

#

They were being sarcastic but still

#

we do believe you should learn medicine before learning a discord bot

hasty iron
#

focus on your university studies

#

a discord bot can wait

lament mesa
#

Tbh I felt like it was a waste after making a bot

bronze wigeon
#

what's the format for the things where it makes

- Something``` Red
and
  • Something
drifting quest
#

Yang or something

bronze wigeon
#

Hm

drifting quest
#

There were codes I saw

bronze wigeon
#

Not a code lang

hasty iron
#

css makes stuff yellow iirc

bronze wigeon
#

you can do like ```py
print()

hasty iron
#

with discord markdown

#

i forgot red, but i don’t think there is something for green

bronze wigeon
#
+ Hello
- Hello
/Hello

nope

#

nothing like I need it to do

#

lemme ask in ot

drifting swift
#
@client.event
async def on_message(message):
    await client.process_commands(message)
    if message.type == discord.MessageType.premium_guild_subscription:
        chan = message.guild.get_channel(channelid)
        embed = discord.Embed(color=0x36393F)
        embed.set_author(name=str(message.author), icon_url=message.author.avatar_url)
        embed.description = "thanks for getting us to "+message.guild.premium_subscription_count+" boosts"
        await chan.send(embed=embed)
bronze wigeon
#

Alright so,

drifting swift
#

do yall see anything wrong with this code?

drifting quest
#

Wth is this

drifting swift
#

i cant exactly test it multiple times

bronze wigeon
drifting quest
#

Complicated holy moly

#

Didn't understand a single thing

flat solstice
drifting swift
drifting quest
slate swan
twilit adder
#

anyone know if i can send the whole error on the on_command_error event?

bronze wigeon
#
Pros and Cons of learning discord.py vs learning medicine
__Learning Medicine__
Pros:
+ You can save people
+ You already paid
+ You get a decent income
+ It helps for yourself
Cons:
+ There aren't really any cons, you learn useful stuff

__Learning Discord.py (and trying to learn it quickly)__
Pros:
+ You learn how to make a discord bot 
+ You learn some python syntax (Very little)
+ You may learn to maintain it (until that small server dies)
Cons:
- You don't learn anything helpful for the future
- You waste your time learning discord.py when you could spend it on medicine
- You aren't likely to make a decent income
- You most likely do worse in your medicine

@drifting quest

slate swan
#

bruh

lament mesa
slate swan
#

these guys lol

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

hasty iron
#

discord.py doesn’t really teach you alot of asyncio

bronze wigeon
slate swan
#

do you know what my name means

hasty iron
#

its just asyncio.wait_for or something like that

vocal plover
slate swan
#

if you do i suggest you not talking about it here lol

slate swan
lament mesa
bronze wigeon
bronze wigeon
vocal plover
#

You learn things by doing them, if you do enough dpy you'll pick up python as you go

proven elm
#

Anyone know why I get this issue with my code


During handling of the above exception, another exception occurred:

  File "C:\Users\Twist\Desktop\Coding\Python\Discord Bot\discordbot.py", line 16, in <module>
    my_secret = os.environ['DISCORDBOTTOKEN']```
bronze wigeon
#

But they want to learn discord.py as fast as possible as well as learning medicine which will most def not work well together unless he wants lots of stress

slate swan
#

Also, you're not supposed to learn dpy without python notlikeblob It's a pain which can't be cured by a medicine
Having even a bit of knowledge of python speeds up and makes it easy and dpy actually makes a lot more sense then

lament mesa
drifting quest
#

Ok thanks guys specially@bronze wigeon I might do my medical for now might look into this bot stuff somewhere in future

final iron
#

Does anyone know any good guides for using asyncpraw in discord.py because I can't find any recent ones

slate swan
hasty iron
#

even the library itself doesn’t use much of asyncio

slate swan
#

prolly the best way would be just playing with asyncio itself

bronze wigeon
slate swan
hasty iron
slate swan
lament mesa
bronze wigeon
slate swan
#

nothing too complex but still

hasty iron
#

ive only seen asyncio.wait_for and asyncio.get_event_loop

bronze wigeon
slate swan
hasty iron
#

other than creating tasks and stuff

proven elm
#

During handling of the above exception, another exception occurred:

  File "C:\Users\Twist\Desktop\Coding\Python\Discord Bot\discordbot.py", line 16, in <module>
    my_secret = os.environ['DISCORDBOTTOKEN']```
#

Anyone know how to fix this error?

slate swan
#

cooldown mapping uses a weird type of semaphore too iirc?

hoary gust
#

Guys suggest me a cmd for my bot

hasty iron
#

ok well maybe locks as well

slate swan
#

it does then lol

pliant gulch
slate swan
#

its not an asyncio.Semaphore because danny needed to access something i cant recall atm

full lily
slate swan
#

so he created its own class

pliant gulch
#

I see wonder what caused for this work around

proven elm
full lily
#

you would set it

slate swan
#

found it

#

class _Semaphore:
"""This class is a version of a semaphore.

If you're wondering why asyncio.Semaphore isn't being used,
it's because it doesn't expose the internal value. This internal
value is necessary because I need to support both `wait=True` and
`wait=False`.

An asyncio.Queue could have been used to do this as well -- but it is
not as inefficient since internally that uses two queues and is a bit
overkill for what is basically a counter.
jagged root
#

How do i make so code doesnt work if channel description not in there int his code:

async def suggest(ctx, *, query):```
jagged root
#

i only want the code to work in a given channel

#

if not return

manic wing
#
@bot.command()
async def suggest(ctx, *, query):
  if not channel.topic:
    return```
jagged root
#

in this code

async def suggest(ctx, *, query):```
#

ok

#

ill test that

manic wing
#

i already did

#

xd

jagged root
#
        return```
@manic wing
#

like this?

manic wing
#
@bot.command()
async def suggest(ctx, *, query):
  if channel.topic != 'Make a suggestion by typing !suggest here.':
    return
#

both work

jagged root
#

k

#

doesnt work

oblique cobalt
jagged root
oblique cobalt
jagged root
#

that what would do

#

only works if message topic is on there

#

?

oblique cobalt
jagged root
#

ok

#

ill test

oblique cobalt
#

Make sure to replace "Message here"

jagged root
#

ik

#

and indent return

oblique cobalt
#

U dont have to

#

Onelining like that works

jagged root
#

oh

#

k

bitter anchor
#

Hey! I'm working on a fork of discord.py with a team of developers, and we just released slash command support in our public alpha today! If you'd like to learn more about our project, it's in my status and about me page. Our goal is to maintain a sustainable discord api wrapper for python, now that discord.py has been archived.

manic wing
oblique cobalt
bitter anchor
jagged root
# oblique cobalt Onelining like that works
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 70, in on_message
    if "Content Creator Videos" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 83, in test
    if "Content Creator Videos" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 124, in on_message
    if "Team Recruitment Chat" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 141, in test
    if "Team Recruitment Chat" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 222, in on_message
    embed_mess = await message.channel.send(embed=embed)
UnboundLocalError: local variable 'embed' referenced before assignment
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 235, in on_message
    if "WI" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 253, in on_message
    if "NoLI" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 268, in on_message
    if "RO" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 306, in on_message
    if "NOS" not in message.channel.topic:
TypeError: argument of type 'NoneType' is not iterable
#

XD

#

Didnt work

jagged root
#

it isnt

#

i added the topic to the channel

oblique cobalt
#

From error, it is.

bitter anchor
#

there is a channel that the bot can see that doesnt have a topic set

#

you could try

jagged root
#

i swear its there

bitter anchor
#
if message.channel.topic and "NOS" not in message.channel.topic:
jagged root
#

k

bitter anchor
#

i'm not saying its that channel

#

just a channel

bitter anchor
manic wing
#

eqeunos is going to make the best one lol

bitter anchor
#

thats subjective

manic wing
#

im not part of his developing team im just moral support

jagged root
#

'message' is not defined

oblique cobalt
#

Can you both kindly move this to somewhere else ?

manic wing
jagged root
#
async def suggest(ctx, *, query):
    embed = discord.Embed(
        color=0xff0000,
        description=
        f":bust_in_silhouette: ❘ **User :**\n\n{ctx.author.mention}\n\n:bulb: ❘ **Suggestion :**\n\n{' '.join(ctx.message.content.split(' ')[1:])}"
    )
    if message.channel.topic and "Make a suggestion by typing !suggest here." not in message.channel.topic:
      return
    embed.set_thumbnail(url=ctx.author.avatar_url)
    channel = bot.get_channel(880935427123605584)
    msg = await channel.send(embed=embed)
    await msg.add_reaction("![random](https://cdn.discordapp.com/emojis/882692198720753665.webp?size=128 "random")")
    await msg.add_reaction("![random](https://cdn.discordapp.com/emojis/882693977390866483.webp?size=128 "random")")
    em = discord.Embed(
        description=
        f"{ctx.message.author.mention} ![random](https://cdn.discordapp.com/emojis/882692198720753665.webp?size=128 "random") Succesfully sent your suggestion to [#880935427123605584](/guild/267624335836053506/channel/880935427123605584/)",
        colour=0xff0000)
    await ctx.send(embed=em, delete_after=20)```
bitter anchor
#

We started 4 days ago, have 1k members, and just released alpha

jagged root
#

full code so yall can see

oblique cobalt
oblique cobalt
jagged root
#

k

oblique cobalt
#

or define message by taking ctx.message

manic wing
bitter anchor
#

In this world, if you're not first, you're last

jagged root
#

now code works but in all channels

oblique cobalt
bitter anchor
jagged root
#

nvm

#

fixed

#

thanks guys

oblique cobalt
#

lul

#

no problem

proven elm
#

why is it saying unknown words etc?

bronze wigeon
#

How could I go about using a bot token with raw http requests to authorize like, sending a message

proper acorn
#

can i have discord libraly link to learn?

oblique cobalt
manic wing
proven elm
#

I edited it

manic wing
unkempt canyonBOT
#
Out of the question.

No documentation found for the requested symbol.

proven elm
#

I get this too though

manic wing
#

!d discord .

unkempt canyonBOT
#

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

Creating a Bot account is a pretty straightforward process.

flat solstice
#

If I want to have my bot use the reply feature to reply to a msg but I don't want it to ping I'd need to add reply(allowed_mentions = False right?

manic wing
flat solstice
pliant gulch
#

Just set it as False

#

and it isn't allowed_mentions

#

mention_author

flat solstice
#

okay thanks. i didn't see mention_author anywhere on the docs about the reply command

slate swan
proven elm
slate swan
proven elm
#

true I will

#

also why is it not logging the join and leaves

#

oh now I leaked it fuck

blazing beacon
#

reset it

proven elm
#

done but why is it not logging join leaves

vale pendant
#

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

blazing beacon
#

cause that ^

flat solstice
proven elm
#

so now I just put intents=intents) by the comman_prefix bit

vale pendant
#

Mhm

proven elm
#

wait no done

#

aha thank you it works now

wooden viper
#

does anyone know how to deploy discord bots in heroku

#

im having a lot of trouble

somber musk
#

How can I make embeds for a discord bot and make it mute members for specific amounts of warn, pls help I'm very confused

broken turtle
#
@bot.event
async def on_member_join(member):
    await member.guild.get_channel(868696187497234435).send(f'hi')
#

tried coding a join message. the problem is that the bot runs but it does not pop up any sort of message when a member joins the guild

dapper cobalt
unkempt canyonBOT
#

class discord.Embed(**kwargs)```
Represents a Discord embed.

`len(x)` Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
somber musk
#

Leme read that thanks guys

broken turtle
dapper cobalt
#

!d discord.Guild.get_channel

unkempt canyonBOT
dapper cobalt
broken turtle
#

thats what im doing

#

channel exists

slate swan
#

f string obsession

dapper cobalt
broken turtle
#

yes

dapper cobalt
#

Do you have member intents enabled?

slate swan
#

if not, member would be nonetype

#

NoneType object has no attribute guild

dapper cobalt
#

Try to print member.

somber musk
#

@broken turtle did it work?

proven elm
#

I am getting a random not defined error anyone know the solution?

slate swan
#

import random

proven elm
#

ahhhh

#

ty

somber musk
#

What are you making?

broken turtle
# somber musk <@695992064843841627> did it work?

i figured out the solution

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

@bot.event
async def on_member_join(member):
    await member.guild.get_channel(868696187497234435).send(f" Hi and welcome to the server {member.mention}")

slate swan
#

oof

#

apologies then

somber musk
#

Because im trying to make somrthing similar to you

#

something*

dapper cobalt
somber musk
dapper cobalt
raven pewter
#

How to make it where i @botname and it responds with a message

somber musk
#

oh ok

dapper cobalt
unkempt canyonBOT
#

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

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

Warning

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

oh

#

i guess i need to check that

#

im gonna google how to turn that on

#

ig

raven pewter
dapper cobalt
#

@somber musk Settings > Advanced

broken turtle
somber musk
somber musk
proven elm
#

Where is the discord bot module documentation?

#

where it talks about most of the import stuff

somber musk
#

thats my code, what did i do wrong to make it not work

broken turtle
dapper cobalt
#

!d discord

unkempt canyonBOT
#

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

Creating a Bot account is a pretty straightforward process.

somber musk
#

oh ok ty

dapper cobalt
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

proven elm
dapper cobalt
proven elm
#

it just shows how to invite a bot

proven elm
#

ty

somber musk
broken turtle
#

I dont know. It just works tbh

somber musk
#

wut

broken turtle
#

@somber musk what error are you gettung

somber musk
#

There's no error it just doesn't work and says half the imports aren't used

#

Like the imports you told me

fervent dust
#
@commands.Cog.listener()
    async def on_message(self, message):
        with open("./veriler/antispam.json", "r") as config:
            data = json.load(config)

        if data.get(str(message.guild.id)) == True:  #errors
            def check (message):
                return (message.author == message.author and (datetime.datetime.utcnow() - message.created_at).seconds < 15)

            if message.author.guild_permissions.administrator:
                return 

            if len(list(filter(lambda m: check(m), self.client.cached_messages))) >= 8 and len(list(filter(lambda m: check(m), self.client.cached_messages))) < 12:
                await message.channel.send(f"{message.author.mention} Lütfen Spam yapma!")
            elif len(list(filter(lambda m: check(m), self.client.cached_messages))) >= 12:
                embed = discord.Embed(title = f"**Kullanıcı atıldı {message.author.guild.name}**", description = f"Sebep : Spam.", color = 0xff0000)
                await message.author.send(embed = embed)
                await message.author.kick() 
                await message.channel.send(f"{message.author.mention} Spam yaptığı için sunucudan atıldı !") 

#

Not worked

slate swan
fervent dust
#

event part, but there is a problem in the database part, it does not prevent spam

somber musk
#

^

proven elm
hasty iron
#

!d discord.on_member_update

unkempt canyonBOT
#

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

This is called when one or more of the following things change...
hasty iron
#

it takes in two arguments

slate swan
proven elm
slate swan
#

Read the docs

hasty iron
proven elm
#

I am but I dont quite understand

#

@hasty iron

hasty iron
#

the docs explain it well

proven elm
#

doesn't explain how to use it in my code

hasty iron
#

Parameters do

proven elm
#

@hasty iron okay so now it shows that I have updated my account information with the message I gave however doesn't show change was made

hasty iron
#

what

#

you have the change yourself

#

you have to check*

slate swan
#
@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.Member, *, reason = None):
    await member.ban(reason = reason)
    if member != None:
        embed = discord.Embed(
            title=f'{member} has been Banned',
            description=f'{member.mention} has been Banned',
            colour=0xf6dbd8
        )
        embed.add_field(name='Reason :', value=f'{reason}', inline=True)
        embed.set_thumbnail(url='')

        embed.add_field(name='Banned by :', value=f'{ctx.author.mention}')
        await ctx.message.reply(embed=embed)
    if member.id is None:
        eeee = discord.Embed(color=0xf6dbd8,
                        description="Ban")
        eeee = add.add_field(name="Usage", value="``^ban [Member] [Reason]``")
        await ctx.send(embed=eeee)
        return
    if member.id == ctx.author.id:
        e = discord.Embed(color=0xf6dbd8,
                          description="Error | you cannot ban yourself")
        await ctx.send(embed=e)
        return
    if member.top_role >= ctx.author.top_role:
        ee = discord.Embed(color=0xf6dbd8,
                           description="Error | you cannot ban that user")
        await ctx.send(embed=ee)
        return
    if reason is None:
        reason = "no reason provided"
        return```
how can i adjust the source so that when someone does ^ban it replys with the command usage instructions? as seen i have it defined as eeee, but it dosnt work for some reason
#

the ban function itself is fine, but its the if bits that dont work

vale pendant
#

you have to check it on a command error handler

#

that's what I did

#

commands.MissingRequiredArgument

final iron
#

So im creating a command with asyncpraw and im wondering if its possible for the user to be able to choose which subreddit the image is coming form?

#

Like a command ?subreddit meme

#

Then it displays an image from that subreddit

#

Wait nvm I did it

proven elm
#
  File "C:\Users\Twist\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Twist\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Twist\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: mutual_friends() takes 1 positional argument but 2 were given```
#

Anyone know how to fix this?

#

trying to get mutual friends via .mutuals @

final iron
#

send the code?

proven elm
#

@client.command()
async def mutuals(ctx, member: discord.Member):
    await member.mutual_friends()
wise prairie
#

what are some recommended hosting sites for a discord.py bot? I'm using contabo but it goes down way too frequently + they don't have 24/7 support

slate swan
#
@bot.command()
async def poll(ctx, question, option1=None, option2=None):
    if question is None:
        await ctx.reply(f"`Usage` - ^poll \"Question\" \"Option One\" \"Option Two\"")
    else:
        await ctx.channel.purge(limit=1)
        embed = discord.Embed(title=f"New Poll", color=0xf6dbd8)
        embed = embed.add_field(name="Question:", value=f"**{question}**")
        embed = embed.add_field(name="Options:", value=f"**✅ = {option1}**\n\n**❎ = {option2}**")
        embed = await ctx.send(embed=embed)
        await embed.add_reaction('✅')
        await embed.add_reaction('❎')```
error message wont print, any ideas?
somber musk
wise prairie
wise prairie
#

plus I need a database

slate swan
# somber musk Error

discord.ext.commands.errors.MissingRequiredArgument: question is a required argument that is missing.

somber musk
wise prairie
slate swan
wise prairie
#

like, !poll test or what

#

what's the specific command you are running

slate swan
#

^poll "question" "opt1" "opt2"

#

but im trying to make an exception so when you only do "^poll" it gives you instructions on how to use the cmd

wise prairie
final iron
#

I tried to make an error handler but its not functioning could I have some help on it?

        if isinstance(error, commands.MissingRequiredArgument):
            embed_2=discord.Embed(description=f"You need to supply a subreddit. Example: <prefix>reddit <subreddit>",
                                  timestamp=ctx.message.created_at,
                                  color=0xff0000)
            embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
            embed.set_footer(text="Epic Bot | Discord bot |", icon_url="https://cdn.discordapp.com/embed/avatars/1.png")

            await ctx.send(embed=embed_2)
            return
wise prairie
#

so do an =none

vale pendant
vale pendant
slate swan
final iron
wise prairie
vale pendant
#

You check if the command is missing a required argument then make a embed explaikng how to use it.

wise prairie
# final iron Inside a command

you need to put this in a bot event for on command error. Here's my equivalent in my bot:

@bot.event
async def on_command_error(ctx, error):
    error = getattr(error, "original", error)
    if isinstance(error, commands.CommandNotFound):
        pass
vale pendant
#
@bot.command(name="blah")
async def _blah(ctx):
   #do stuff

@_blah.error
async def _blah_error(ctx,error):
  if isintance(error,commands.MissingRequiredArgument):
      await ctx.send("Usage: !blah")```
#

@slate swan

final iron
wise prairie
#

hey Ritz, where do you host your bot? Think02

#

or is it not big enough to host proper

vale pendant
#

I host locally, not big enough yet.

wise prairie
#

ah, fair enough

vale pendant
#

Not big enough to the point where I want to pay for it.

proven elm
#

getting a "bots cannot use this endpoint" error when tryna get mutual friends

wise prairie
#

yea yea, I'm in the state where I gotta host. Contabo worked for a bit but they've been unreliable

wise prairie
vale pendant
#

Yeah if you want a good hosting you have to pay for it.

final iron
vale pendant
wise prairie
slate swan
vale pendant
#

I spelled it wrong

proven elm
slate swan
#

ya i corrected it

vale pendant
#

isinstance

wise prairie
slate swan
#

ohhh

wise prairie
final iron
wise prairie
#

Why do bots have message content if discord is just gonna remove our access to it >_>

somber musk
vale pendant
vale pendant
#

shhh

slate swan
#

Does anyone know how I can make a Discord bot with an AI? I was doing a quick research in Machine Learning stuff and I thought to myself "You know what? I need to troll my friends with it".

#

👀

wicked atlas
#

Welp, that's basically just giving a chatbot access to sending and reading messages

slate swan
#

Thats the point. Honestly I'm new with Python even though i made chatbots or other programms.

pure reef
#

mhm

#

embed*

#

async def on_guild_join

#

no ctx

#

do yeww want it to send to every server ?

#

to yeww or a certain channel

#

for channel in bot.guilds:
await channel.send("stuff stuff")

i believe i kinda took a break from discord for like 7 months so

#

but i believe that's how it is

pliant gulch
#

This would send it to EVERY channel in the guild

#

Its in a for-loop