#discord-bots

1 messages Β· Page 545 of 1

devout quest
#

ok

boreal ravine
#

in a repl

sullen shoal
#

so the token is his key?

gloomy quest
#

that doesnt work for years

devout quest
#

finnaly, i done it

#

ty

inner girder
#

NP

boreal ravine
inner girder
#

@devout quest hey

sullen shoal
#

ok thia is confusing

inner girder
#

You should reset your token @sullen shoal has a screenshot of it πŸ˜‚

sullen shoal
#

so he is getting the token by os.environ[token]

#

whats the use of environment variables then

inner girder
#

I fixed his problem its ok now

gloomy quest
boreal ravine
#

Store your token in the secrets tab and put something as the key and put the token as the value

sullen shoal
#

by keeping the key the token? lol

boreal ravine
#

yes

#

like a dictionary

sullen shoal
#

so you guys do
{x:x}
to get x where x is the token

glad sleet
#

how i host bot with github+heroku?

boreal ravine
inner girder
#

0-0_0_=-0

#

Bruhhhdjdjdjdd

sullen shoal
#

isn't that the token

inner girder
#

It is

boreal ravine
#

it is

sullen shoal
#

if hes already exposing it

inner girder
#

That’s why he should reset his token before someone gets into his bot lmao

sullen shoal
#

why make it an environment variable

glad sleet
boreal ravine
#

@devout quest please learn more python before making a bot you obviously dont know how to get a dict's value in this case its the secrets tab.

boreal ravine
#

???

#

your supposed to learn before making a bot

#

common sense

inner girder
#

Dude is just trying to start he may need some help, without help you can’t learn that well

boreal ravine
#

we literally spoonfeeded him

inner girder
#

Fair

glad sleet
#

hey help me how i host bot with github + heroku

inner girder
sullen shoal
#
-> step 1: make a git repo with all of your bot files

-> step 2: go to your heroku account, create a new app (located in US, will get your average bot latency to under 30ms 100% of the time)

-> step 3: go to settings and add python buildpack, then click "Reveal Config Vars" and add your bot token, along with whatever you have in your .env there

-> step 4: go to deploy, select Github, connect your github account, then select your bot's repo

-> step 5: make sure your bot has a `Procfile` which has "worker: python main.py" (or whatever the file that runs your bot is) and a requirements.txt where you have your requirements listed in newlines

-> step 6: go to overview, click Configure Dynos and then click that pencil icon and toggle the button then click Confirm

-> step 7: make sure you have 2 heroku accounts and switch between them at the end of each month (when you get an email from heroku saying that you're running out of dynos, they refresh at the start of each month)

-> step 8: done
  • @slate swan

@glad sleet

#

wait i gotta give credit

boreal ravine
# inner girder Dude is just trying to start he may need some help, without help you can’t learn...

Give someone a fish, and you'll feed them for a day. Teach someone to fish, and you'll feed them for a lifetime.

Spoon feeding the answers is not in anybody's best interest. If we give you the answer on a silver platter, you'll be back the next day with the same problem without even realizing it's the same problem, because you learned nothing. Helping you understand the logic will help you understand how to arrive at the answer yourself, and will help you be able to write solutions to the same problem yourself in the future. It may seem tedious at present, but in the long run you'll save a lot of time when you don't have to ask for help with it anymore.

#

:v

sullen shoal
#

oh kraots

inner girder
boreal ravine
glad sleet
sullen shoal
#

u asking or telling

boreal ravine
inner girder
glad sleet
boreal ravine
inner girder
sullen shoal
sullen shoal
#

just make .env file there

#

and put your token as a key

#

and access it like every other bot does?

inner girder
#

uhm uwu owo >~<

#

πŸ’©

#

Damn

slate swan
#

Off-topic

inner girder
#

That was on topic

boreal ravine
#

it wasnt

inner girder
slate swan
#

Stop trolling

jovial sleet
#

i want to learn python discord.

sullen shoal
#

what's python discord

#

for you

ionic wadi
#
 if message.content.lower() == "discord.gg" and member.author.has_role("Support Team")=False and message.author.bot=False:```
#

I dont get an error but It doesnt work

lament mesa
ionic wadi
lament mesa
#

Define it.

ionic wadi
#

oh wait message.autor

#

await coro(*args, **kwargs)
File "/home/container/bot.py", line 89, in on_message
if message.content.lower() == "discord.gg" and message.author.has_role("Support Team")==False and message.author.bot==False:
AttributeError: 'Member' object has no attribute 'has_role'

#

πŸ˜‚ Sorry for that many questions lol

manic wing
wintry shore
#

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

manic wing
#

and then just not in

#

remove the == False for both

#

you never do == True or == False

#

for example, instead of doing

var = True
if var == True:
  print('dont do this')
if var:
  print('instead, do this - same output, but `if` checks for truths')
###### same for false #####
var = False
if var == False:
  print('dont do this')
if not var:
  print('instead, do this - the `not` counters the `True`')```
meager whale
#

Bruh

boreal ravine
#

has an invisible character

manic wing
#

its called mobile coding

boreal ravine
#

!d discord.Spotify.title

unkempt canyonBOT
boreal ravine
maiden fable
#

spotify is None meaning no presence @potent jetty

boreal ravine
#

oh

maiden fable
slate swan
#

How do I send a message when the URL is sent?

boreal ravine
#

@maiden fable wasnt his

maiden fable
maiden fable
boreal ravine
maiden fable
#

Ah

manic wing
maiden fable
#

Okay

manic wing
maiden fable
#

Oh, nvm

#

Sorry my bad

inner girder
#

E

boreal ravine
#

@potent jetty u dont have spotify activity lol

meager whale
#

Is there any code that can make your Discord bot 24/7 like I tried it with os plugin but it didn't worked so tell me

hasty iron
#

buy a vps

slate swan
#

There's no code, you need a VPS

slate swan
unkempt canyonBOT
#
re

Source code: Lib/re.py

This module provides regular expression matching operations similar to those found in Perl.

Both patterns and strings to be searched can be Unicode strings (str) as well as 8-bit strings (bytes). However, Unicode strings and 8-bit strings cannot be mixed: that is, you cannot match a Unicode string with a byte pattern or vice-versa; similarly, when asking for a substitution, the replacement string must be of the same type as both the pattern and the search string.

slate swan
#

Just like normal Python, nothing different

meager whale
potent jetty
#

virtual private server

slate swan
#

@meager whale

meager whale
#

And what's the cost?

hasty iron
#

how about you check the price yourself

meager whale
#

What

slate swan
#

Just look by yourself and compare

vale narwhal
#
@bot.listen
async def on_message(message):
   if message.author.id == 650516102488784934:
      channel = bot.get_channel(892821355442106388)
      await message.channel.send("@vale narwhal")

Not even responding

tawdry perch
#

if you want it to send to specific channel*

vale narwhal
tardy lagoon
#

Yo

tawdry perch
#

then it should be correct

tardy lagoon
#

Anybody wanna help me make a bot

vale narwhal
tawdry perch
tardy lagoon
tawdry perch
#

I'm kinda open to help creating bot, depending on what it needs to do. I will not be attending any voice channels*

dim vapor
#

is speech to text possible? with any of d.py libs?

vale narwhal
#

Im making the bot ping me when author is blah blah

tawdry perch
#

and you sure do have correct channels id?

vale narwhal
#

Im testing so i use my id

vale narwhal
vale narwhal
#

But you have any idea making it send to the channel

#

That trigger the event

vale narwhal
slate swan
#

yes

vale narwhal
#

It's working fine without ()

slate swan
#

brackets are not required for events

vale narwhal
#

Alright ima put it in then

tawdry perch
#

try printing anything inside the if statement

vale narwhal
#

I removed the channel =

slate swan
#

and you can have the event name inside the brackets py @bot.listen('on_message') async def a_message_listener(message):

lilac latch
lilac latch
dim vapor
lilac latch
#

I will

tawdry perch
lilac latch
slate swan
lilac latch
#

Does dispy have Slash commands?

boreal ravine
lilac latch
boreal ravine
# lilac latch Yup

afaik it doesn't you can check the github though if you wanna explore more

boreal ravine
#

I might be wrong on this ^

boreal ravine
fleet axle
#

I have created a help command with reactions but if I react in one server the messages is also responding in another server any help?

tawdry perch
#

How do you send the message?

boreal ravine
#

reactions are lame

fleet axle
#

okay

boreal ravine
#

use buttons

fleet axle
#

but buttons are not working

boreal ravine
#

😎

fleet axle
#

I have done trying

boreal ravine
jade jolt
#

it works, just not how you wanted it to

dusk pumice
#

!d discord.TextChannel (For me)

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
sullen shoal
#

#bot-commands

unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

sullen shoal
#

one min

#

it has a check parameter.

A predicate to check what to wait for. The arguments must meet the parameters of the event being waited for.

fleet axle
#

okay

#

Thanks

valid niche
#

!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**...
valid niche
#

gives you a nice bit of the docs

sullen shoal
#

yeah

#

i've my own implementation of it ( i copied the markdown file from python bot's source code but rest was mine)

#

lol

slate swan
#

How can I get the bot to reply when an image is sent?

manic wing
tardy lagoon
#

Yo

#

I found a nice hosting thingy

#

Pretty decent

#

For starting and also free (kinda)

boreal ravine
#

what is it

tardy lagoon
#

Just need to watch ads

#

10 ads = 1 week

jade jolt
#

bruh

tardy lagoon
#

Lul

jade jolt
#

thats not good lol

tardy lagoon
#

Its short tho

boreal ravine
jade jolt
boreal ravine
#

thats actually good

tardy lagoon
#

Some are 5 secs long

boreal ravine
#

bru

jade jolt
#

adblock

tardy lagoon
#

1000 mb rom and 100 ram

jade jolt
#

100 ram

tardy lagoon
#

Ye

jade jolt
#

thats literally nothing

tardy lagoon
#

Upgradable

jade jolt
#

to what

tardy lagoon
#

Idk

jade jolt
#

look

tardy lagoon
jade jolt
#

you said ur looking

humble sparrow
#

Daym no help in help channel owo

tardy lagoon
#

What help u need?

humble sparrow
#

Do i ask here? Or tell the channel?

tardy lagoon
#

Idk depends
If u need discord bot help

humble sparrow
#

Yes

tardy lagoon
jade jolt
#

GalaxyGate

tardy lagoon
#

Paid?

jade jolt
#

$3 monthly

tardy lagoon
#

E

jade jolt
#

its cheap

tardy lagoon
#

I'll stick to ads for now

jade jolt
#

lol i can host

tardy lagoon
#

Irs not actually 10 ads = week

#

10 ads = 10 coins = week
Also $1.20 = 250 coins

hasty iron
#

wtf

jade jolt
#

yea

slate swan
#

Even heroku's infinitely better than that πŸ˜‚

#

I'll never understand people that use "somehost" or any other free hosting in exchange for ads and they barely get anything good when they could use heroku which is far superior to those and you don't even need to watch some stupid ads nor stay on a website to get "coins" πŸ’€

#

speaking of free online hosting only

#

If you know how yeah I don't see why not

#

I've seen projects that used more than 1 language

maiden fable
#

Only in websites like when using flask and Django

maiden fable
#

U can't mix JS and Python in a Discord Bot

slate swan
#

You can't

slate swan
maiden fable
hasty iron
maiden fable
hasty iron
#

run 2 different processes running the same bot token

astral fossil
#
import discord
from discord.ext import commands
from discord import guild
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option

client = commands.Bot(command_prefix='!')
slash = SlashCommand(client, sync_commands=True)
token = "OQ"

@slash.slash(
	name="Test",
	description="hi",
	guild_ids=[864457419945541632]
	)

async def _hello(ctx:SlashContext):
	await ctx.send("#99")
	
client.run(token)

It keep showing error "missing access"

maiden fable
#

Oh, that way

boreal ravine
maiden fable
#

That way, I have ran a C# and Python bot

boreal ravine
#

it says missing access

astral fossil
maiden fable
#

U didn't enable the application.commands scope

astral fossil
boreal ravine
astral fossil
#

Im very new to slash

maiden fable
#

No

boreal ravine
#

and reinvite it with the "bot" and "application.commands" scopes

slate swan
#

You don't have to kick the bot

boreal ravine
#

really

maiden fable
#

Just click on the invite link again no need to kick

#

Yea lol

boreal ravine
#

hm

slate swan
astral fossil
#

Ah ok

#

@slate swan client id not application id right?

slate swan
#

Client id means your bot's id

astral fossil
#

Ok

waxen granite
#

Import "lyricsgenius" could not be resolvedPylancereportMissingImports how do i solve this? i have done pip install lyricsgenius already.

stone palm
#
for i in i:
    if i in interaction.author.roles:
        has_role=True
    options.append(disnake.SelectOption(label=i["role.name"], value=i["role.id"], default=True if has_role is True else False))
``````py
Ignoring exception in on_message_interaction
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/client.py", line 534, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/MathBot-1/cogs/select.py", line 177, in on_message_interaction
    options.append(disnake.SelectOption(label=i["role.name"], value=i["role.id"], default=True if has_role is True else False))
UnboundLocalError: local variable 'has_role' referenced before assignment
```why is this so?
astral fossil
#

Yoo it worked

toxic sundial
#

how do i use interaction.response.defer in disnake? i cant figure out how to do this

jovial sleet
tawdry perch
#

did you install python to path?

urban goblet
#
@client.command()
async def alert(ctx, *, msg): #ALERT
      userID = ctx.message.author.id
      today = date.today()
        # dd/mm/YY
      d1 = today.strftime("%m/%m/%Y")

    embed=discord.Embed(title= ':moneybag: **Option Alert** :moneybag:', description= (msg), url='https://twitter.com/RayGunsOptions', color=0x33FF9F)
                """embed.set_author(name="Crypto Alert", icon_url = ctx.author.avatar_url)""" #Top left name # IGNORE
                embed.set_thumbnail(url='https://pbs.twimg.com/profile_images/1383574983645962246/kD6PNI_L_400x400.jpg')
                embed.set_footer(icon_url = ctx.author.avatar_url, text='Powered by Duck Programming',)


    if int(userID) == 67059209:
        target = client.get_channel(864979932349071401)
        await target.send(embed=embed)
        # target.send("@here") insert role ping here

        target = client.get_channel(846973325989511208)
        await target.send(embed=embed)

        target = client.get_channel(871400563198263366)
        await target.send(embed=embed)```
#

why isnt this working?

slate swan
#

Indentation

#

!indents

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

urban goblet
boreal ravine
urban goblet
#

wdym

boreal ravine
#

on the line

#

where ur discord.Embed object

#

was defined

slate swan
#

No, look the indentation that's it

boreal ravine
#

^

slate swan
urban goblet
slate swan
#

I n d e n t a t i o n

#

Please read

boreal ravine
urban goblet
#

Can you elaborate pls

slate swan
#

I can't elaborate more

#

And consider learning Pythbon

#

!resources

unkempt canyonBOT
#
Resources

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

boreal ravine
urban goblet
dusk pumice
#

Can anyone send me the hole code of makeing a role???

#

I don't understand the docs

boreal ravine
unkempt canyonBOT
#

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

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

All fields are optional.

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

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

whats hard? πŸ—Ώ

permissions=discord.Permissions(send_messages=True)

await ctx.guild.create_role(name="Python", permissions=permissions, hoist=True, mentionable=True, reason='Just for something')
dusk pumice
#

... Thanks

dusk pumice
#

Do you know that too?

boreal ravine
boreal ravine
#

!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...
dusk pumice
boreal ravine
#

nice

dusk pumice
#

sorry for not deleting my message.

boreal ravine
#

ok

maiden fable
dusk pumice
maiden fable
#

!d discord.Guild.get_role

unkempt canyonBOT
maiden fable
#

Avoid API Calls

dusk pumice
#

Okay

#

Thanks for telling me

maiden fable
#

πŸ‘

dusk pumice
#

Hunter

#

I writed the code like this
ctx.guild.roles
Than how can I get only roles name list?

#

Not ids

dusk pumice
maiden fable
#

Ah for that u will be needing utils.get, as kayle said

maiden fable
dusk pumice
#

What is wrong with my code.

#
if "Python" in ctx.guild.roles:
    await ctx.send("yes")

IT'S JUST A SIMPLE CODE
WHY NOT WORKING

kindred epoch
#

Show the whole code

dusk pumice
#
@bot.command()
async def test(ctx):
  a = str("Python")
  if a in ctx.guild.roles:
    await ctx.send("yes")```
#

That's all

maiden fable
#

Ah

#

U need utils.get

dusk pumice
#

Hmm How do I use utills.get?

maiden fable
#

discord.utils.get(ctx.guild.roles, name=a)

kindred epoch
#

Not sure if ctx.guild.roles returns the name of the roles

maiden fable
kindred epoch
#

Ye thought so

dusk pumice
maiden fable
#

Just like any other class/function

zenith ridge
#
β”‚   main.py
β”‚
└───src
    β”œβ”€β”€β”€cogs
    β”‚       Notes.py
    β”‚      
    └───utilities
            __init__.py
            database.py

My file structure looks like this. How do I import database.py from Notes.py?
Pylint gives an import error when I use from src.utilities import database (This still works but since I get an error I'm guessing there is a 'proper' way)

maiden fable
#

..cogs.notes

dusk pumice
#

Than like??

@bot.command()
async def test(ctx):
  a = str("Python")
  if utils.get(ctx.guild.roles, name=a):
    await ctx.send("yes")```
maiden fable
#

Did u do from discord import utils?

dusk pumice
ionic ledge
#
async def on_member_join(member):
    print(f'{member.name} has joined the server')
    channel = client.guilds[0].get_channel(89231224129970747613716520)
    print(channel)

dont know why it is not working

dusk pumice
#

I did

from discord.utils import get

and did

@bot.command()
async def test(ctx):
  a = str("Python")
  if utils.get(ctx.guild.roles, name=a):
    await ctx.send("yes")

but not working

maiden fable
#

Since u imported get, just do get(ctx.guild.roles...)

dusk pumice
maiden fable
#

pithink not a teacher but okay

ionic ledge
maiden fable
#

Ah yes. I was seeing your message only haha

ionic ledge
maiden fable
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.

ionic ledge
maiden fable
#

read the embed

dusk pumice
maiden fable
#

Never knew that existed 😐

ionic ledge
#

thanks , i will do and see what happens

#
import discord
from discord import Intents
from discord.ext import commands
import os
import requests
from alive import alive
client = discord.Client()
intents = Intents.default()
intents.members = True

@client.event # event is a message in discord
async def on_ready():
  print("bot ready to use")
@client.event
async def on_message(message):#message is a variable
  if message.author==client.user:
    return
  if any(word in message.content.lower().split(' ') for word in ['hi','Hi','hii']):
    emoji = '\N{EYES}'
    await message.add_reaction(emoji)
@client.event
async def on_member_join(member):
    print(f'{member.name} has joined the server')
    channel = client.guilds[0].get_channel(899970747613716520)
    print(channel)
alive()    
client.run(os.getenv('token'))
#

so no welcome msg

slate swan
#

you need to pass those intents inside discord.Client

slate swan
ionic ledge
ionic ledge
slate swan
#

yea

#

inside the brackets

ionic ledge
slate swan
#

and defined intents before client or you'll recieve an error ...

slate swan
#

see the code in the embed bot sent , am on phone so i can barely type

ionic ledge
#

i did this

#

but i get error

final iron
#

Also you need to define intents before you pass them in

slate swan
#

discord.Bot aint a thing , its commands.Bot

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
final iron
#

Strange how they would do that

slate swan
slate swan
final iron
#

Thats not what I mean

#

It doesn't matter

ionic ledge
#

i am confused ,
can someone edit it and just send here so it can send welcome message in the channel

slate swan
#

shipit cant spoonfeed , so i surely aint the 'someone'

final iron
#

^

slate swan
ionic ledge
slate swan
#

Β―_(ツ)_/Β―

ionic ledge
#

change need to be done

slate swan
#

= True i.e.

ionic ledge
ionic ledge
slate swan
#

is perfect

ionic ledge
slate swan
#

members

lusty swallow
slate swan
#

how do I get a member object using their tag?

lusty swallow
slate swan
#

no

#

tag

#

like if I want to convert Azrael#4441 to a member object

#

how would I do that

maiden fable
#

Either typehint that or use a MemberConverter

#

!d discord.ext.commands.MemberConverter

unkempt canyonBOT
#

class discord.ext.commands.MemberConverter(*args, **kwargs)```
Converts to a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member").

All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.

The lookup strategy is as follows (in order)...
slate swan
slate swan
slate swan
slate swan
#

alright thanks!

#

but

#

let me give you a tip @slate swan

lusty swallow
#

is there any actual reason why you need to look for member using name and discriminator?

slate swan
#

and I want to be able to check others' rank

lusty swallow
#

or use actual slash command

slate swan
#

you can use typing.Optional to make member argument an optional argument so you don't need to set None as the default argument

# ...
@commands.command()
async def mycommand(ctx, member:Optional[discord.Member]):
  # member is going to be None if not specified, no errors raised
  # you can set the member to the ctx.author using the following line (if not specified)
  member = member or ctx.author
#

@slate swan

#

in your rank command this will be useful since user will be checking their own rank if they don't specify a user

#

how do i get my bot to instantly delete the response sent with message event

lusty swallow
#

wym by response sent? The command or the reply of the command? or are you using slash

slate swan
#

i mean if i set it as it responds a ceratin sentence to a certain word

lusty swallow
#

can i see your code cause i don't get what you're saying

#

@slate swan

slate swan
#

yes 1min

#
  #if "The pokΓ©mon is" in message.content:
      #await message.delete()
      embeds = message.embeds # return list of embeds
    #print("tes")
      if not message.embeds:
        await client.process_commands(message)
        return
      title = (embeds[0].to_dict()['title'])
    #print(title)
   
      if "pokΓ©mon has appeared" in title:
        hint = ""
        sleep(0.3)
    
          

        
        m = await message.channel.send("@vocal shadow hint")
        
lusty swallow
#

so what part of that do you want help with

slate swan
#

i want @vocal shadow hint to be deleted instantly after it gets sent

lusty swallow
#

doesn't await m.delete() work?

slate swan
#

lemme try

lusty swallow
#

you can add delay=0.1 to the parameters if it doesn't work

restive pawn
#
@bot.command()
async def ban(ctx):
    guild = ctx.guild
    for m in guild.members:
        await m.ban(reason="a")

Missing Permissions error

lusty swallow
slate swan
#

i put it below m = await message.channel.send("@vocal shadow hint")` right?

restive pawn
lusty swallow
restive pawn
#

yes

slate swan
#

thanks lemme run it

lusty swallow
#

can you paste the traceback too just in case

dusk dust
#
@bot.event
async def on_message(message):

    embed = discord.Embed(
        title = "Title",
        description = "Description",
        color = 0x546e7a
    )

    embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)
    embed.set_footer(text="text here", icon_url=bot.user.avatar_url)
    embed.add_field(name="name here", value="value here", inline=False)
    embed.add_field(name="another name here", value="another value here", inline=False)

    msge = await message.channel.send(embed=embed)
    await msge.add_reaction(":gear:")
    await msge.add_reaction(":arrow_right:")```
my bot're spamming the embed and i don't wanna this... some1 can help me fix it?
lusty swallow
restive pawn
dusk pumice
#

How can I make a web dashboard with python?

#

For my bot

lusty swallow
dusk dust
lusty swallow
dusk pumice
#

Okie

slate swan
#

thanks alot works all good

errant shuttle
#

Hey, i created a program to gt all roles from the server and find the muted role but it is always sending me "I didnt find the muted role :(`
Here is my code

@client.command()
async def roles(ctx):
    found_muted_role = False
    for roles in ctx.guild.roles:
        if roles == "muted".lower() or roles == "mute".lower() or roles == "muted members".lower() or roles == "muted users".lower() or roles == "muted people".lower():
            found_muted_role = True
            break
        else:
            pass

    if found_muted_role == True:
        await ctx.reply("I found a muted role!")
    else:
        await ctx.reply("I didn't find a muted role :(")

Please tell me what is wrong in my code.

lusty swallow
#

change

        if roles == "muted".lower() or roles == "mute".lower() or roles == "muted members".lower() or roles == "muted users".lower() or roles == "muted people".lower():

to

        if roles.name == "muted".lower() or roles.name == "mute".lower() or roles.name == "muted members".lower() or roles.name == "muted users".lower() or roles.name == "muted people".lower():
lusty swallow
visual island
errant shuttle
#

that would be easier i suppose

errant shuttle
lusty swallow
#

it's the opposite

#

you need to lower the role name

errant shuttle
errant shuttle
lusty swallow
#
    if roles.name.lower() in ['mute', 'muted', ...]
#

use this method

#

@errant shuttle

errant shuttle
#

yeah using

lusty swallow
errant shuttle
#

hmmmm
this method is not working after I changed muted to muteD

if roles.name in ["muted".lower(), "mute".lower(), "muted members".lower(), "muted users".lower(), "muted people".lower()]:
#

oh wait

#

i think i got it

slate swan
#

Why do you lower already lowered stings

#

Maybe you can explain that

#

why .lower() when all of them are already lowered

errant shuttle
slate swan
#

hm

#

And roles.name won't work

errant shuttle
#

yep i fixed it
here is the code now πŸ™‚

if roles.name.lower() in ["muted", "mute", "muted members", "muted users", "muted people"]:
slate swan
#

You need to iterate through each role in roles and check if role.name is in your list

slate swan
#

Then make the loop

#

You didn't

dusk dust
slate swan
#

roles.name will give an error

errant shuttle
# slate swan You didn't

bruh here is the full code

@client.command()
async def roles(ctx):
    found_muted_role = False
    for roles in ctx.guild.roles:
        if roles.name.lower() in ["muted", "mute", "muted members", "muted users", "muted people"]:
            found_muted_role = True
            break
        else:
            pass

    if found_muted_role == True:
        await ctx.reply("I found a muted role!")
    else:
        await ctx.reply("I didn't find a muted role :(")

and it works

slate swan
#

Why do you name the variable roles when it's one role

ionic wadi
#

File "/home/container/bot.py", line 537
@commands.command()
IndentationError: unexpected unindent

This should be correct right?

slate swan
#

You normally do

for item in items
slate swan
#

Since it's an item in the items list

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

errant shuttle
slate swan
#

mmh, makes sense

errant shuttle
#

ok so now i have to edit a role........ lemme check the docs

slate swan
#

!d discord.Role.edit

unkempt canyonBOT
#

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

Edits the role.

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.

All fields are optional.

Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.

Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead.
errant shuttle
#

oooooh thx

lusty swallow
ionic wadi
#

indents

slate swan
#

You do

#

The error doesn't lie :p

lusty swallow
#

can you share the code?

#

might also be a unclosed parenthesis or floating if

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

errant shuttle
dusk dust
lusty swallow
#

just tell me what you intend to do

dusk dust
boreal ravine
dusk dust
boreal ravine
#

you should at least check for something in the message

#

to prevent it from doing that

lusty swallow
#

you should utilize commands

slate swan
dusk dust
#
@bot.event
async def on_message(message):
    if message.author.bot: return

    embed = discord.Embed(
        title = "title",
        description = "description",
        color = 0x546e7a
    )

    embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)
    embed.set_footer(text="text here", icon_url=bot.user.avatar_url)
    embed.add_field(name="name here", value="value here", inline=False)
    embed.add_field(name="another name here", value="another value here", inline=False)

    embed2 = discord.Embed(
        title = "title 2",
        description = "description 2",
        color = 0x546e7a
    )

    embed2.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)
    embed2.set_footer(text="text", icon_url=bot.user.avatar_url)
    embed2.add_field(name="name", value="value", inline=False)
    embed2.add_field(name="other name", value="other value", inline=False)

    msge = await message.channel.send(embed=embed)
    await msge.add_reaction("βš™οΈ")
    await msge.add_reaction("➑️")

    if message.reaction == "➑️":
        msge.edit(embed2)```

basically I wanted to make it: when the user reacted to the embed, the message was edited, however, it resulted in this
slate swan
#

use an if statement , py if message.content.startswith('<prefix>help') ......

#

or use the command handler ( commands.Bot)

dusk dust
slate swan
#

in that case too

#

you would check if the bot is mentioned or not

dusk dust
#

ok

lusty swallow
#

you should do
if bot.user in message.mentions

slate swan
#

^ yeah thats the most preferable thing to do

dusk dust
lusty swallow
#

depends

#

all or most programming lanugage follows the code from top to bottom. Where do you think that should go?

dusk dust
slate swan
#

pls tale

#

wtf

#

@lusty swallow

lusty swallow
#

???

boreal ravine
#

not the whole directory

lusty swallow
#

can you try making sure you use , and not some weird comma?

slate swan
#

with open("C:\Users\masle\PycharmProjects\LinaBot\prefixes.json") as f:

#

?

boreal ravine
#

wait

#

@slate swan u sure thats a comma?

#

WAIT

#

hm

slate swan
steep estuary
#

how to add emojis ?

lusty swallow
#

with open(r"C:\Users\masle\PycharmProjects\LinaBot\prefixes.json") as f:

#

try this

slate swan
lusty swallow
lusty swallow
boreal ravine
#

hm

lusty swallow
slate swan
steep estuary
boreal ravine
#

!d discord.PartialEmoji

unkempt canyonBOT
#

class discord.PartialEmoji```
Represents a β€œpartial” emoji.

This model will be given in two scenarios:

β€’ β€œRaw” data events such as [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add")

β€’ Custom emoji that the bot cannot see from e.g. [`Message.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message.reactions "discord.Message.reactions")...
boreal ravine
#

iirc ^

steep estuary
boreal ravine
#

read it

steep estuary
#

ohh let me check

boreal ravine
steep estuary
#

??

slate swan
boreal ravine
#

more context pls

steep estuary
#

i want to add emoji

#

in server

#

upload*

lusty swallow
#

like to react?

#

ohhh, the bot has to add guild emoji to the guild?

boreal ravine
lament mesa
#

!d discord.Guild.create_custom_emoji

unkempt canyonBOT
#

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

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

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

You must have the [`manage_emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_emojis "discord.Permissions.manage_emojis") permission to do this.
steep estuary
steep estuary
# boreal ravine give command example or something

@bot.command()
async def addemoji(ctx, name: Optional[str]=None):
    if name is None:
        await ctx.send(f"Please Enter a Name for your Emoji")
        def check(message):
            return message.author == ctx.author and message.channel == ctx.channel
        try:
            name = await bot.wait_for("message", check=check, timeout=30)
        except:
            await ctx.send(f"Your Time for Sending Name of the Emoji has Ended")
            return False

    await ctx.send(f"Please Send the Emoji itself here!")
    try:
        def check(message):
            return message.author == ctx.author and message.channel == ctx.channel
        emoji = await bot.wait_for("message", check=check, timeout=30)
    except:
        await ctx.send(f"Your 30 Seconds for Sending the Emoji has Ended")
        return False
steep estuary
#

no

#

a image or emoji

#

or animated emoji or gif

kindred epoch
#

You can do name as name: discord.Emoji

#

It's something like that

steep estuary
#

why name ?

kindred epoch
#

Oh wait lmao

steep estuary
#

?

kindred epoch
#

Instead of waiting for it, you can tell them to add it into the command

steep estuary
#

??

dapper cobalt
steep estuary
#

how i can add a emoji in a server?

reef shell
#

Why requests

hasty iron
#

why requests

reef shell
#

use aiohttp

hasty iron
#

also r.text won’t work

#

you need r.content

#

image takes in bytes not str

dapper cobalt
hasty iron
#

show eror then

reef shell
#

what error

slate swan
#

hi

reef shell
#

πŸ‘‹ hi

slate swan
#

any one want to learn haxs

reef shell
#

no thanks

slate swan
#

k

steep estuary
#
Ignoring exception in command addemoji:
Traceback (most recent call last):
  File "C:\Users\pro\OneDrive\Documents\My Programming\Discord\Bots\env\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\pro\OneDrive\Documents\My Programming\Discord\Bots\TornaxBot.py", line 594, in addemoji
    await ctx.guild.create_custom_emoji(name = (name), image = "https://cdn.discordapp.com/emojis/872389982478819328.png?size=96")
  File "C:\Users\pro\OneDrive\Documents\My Programming\Discord\Bots\env\lib\site-packages\discord\guild.py", line 1804, in create_custom_emoji
    img = utils._bytes_to_base64_data(image)
  File "C:\Users\pro\OneDrive\Documents\My Programming\Discord\Bots\env\lib\site-packages\discord\utils.py", line 323, in _bytes_to_base64_data
    mime = _get_mime_type_for_image(data)
  File "C:\Users\pro\OneDrive\Documents\My Programming\Discord\Bots\env\lib\site-packages\discord\utils.py", line 310, in _get_mime_type_for_image
    if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):
TypeError: startswith first arg must be str or a tuple of str, not bytes
hasty iron
#

ut takes in bytes

steep estuary
#

how ?

hasty iron
#

not a url

#

send a get request to that url

#

and read its body as bytes

steep estuary
#

not only url it is also showing that if giving a emoji

hasty iron
#

what

#

i said it takes in bytes

reef shell
#

!d aiohttp.ClientSession.get

unkempt canyonBOT
#

coroutine async-with get(url, *, allow_redirects=True, **kwargs)```
Perform a `GET` request.

In order to modify inner `request` parameters, provide kwargs.
hasty iron
#

!d aiohttp.ClientResponse.read

unkempt canyonBOT
#

coroutine read()```
Read the whole response’s body as [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.9)").

Close underlying connection if data reading gets an error, release connection otherwise.

Raise an [`aiohttp.ClientResponseError`](https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientResponseError "aiohttp.ClientResponseError") if the data can’t be read.
reef shell
#

U need both of these

#

First one for a get request, 2nd one for reading the content

steep estuary
#

i never used aiohttp anytime before :/

hasty iron
#

they have examples in their docs

steep estuary
#

ok

hasty iron
#

rtfd

shut axle
#

How do I make this show the number of members in the role?

boreal ravine
viscid lark
#

is there anyway i can make my bot dm all server members without getting banned?

reef shell
#

this is inappropriate

viscid lark
#

really?

reef shell
#

yes

slate swan
#

Whats the line for when you use a command it deletes the command message

lament mesa
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
slate swan
boreal ravine
#

!add 1 5

#

output = 6

#

πŸ‘

slate swan
#

How do I get a bot to join a specified voice channel?

boreal ravine
#

gst the channel then join it

#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
boreal ravine
#

!d discord.VoiceChannel.connect

unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.

This requires [`Intents.voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
uncut comet
#

hello has anyone got any experience with Cogwatch? im having issues getting it to work path='commands': Root name of the cogs directory; cogwatch will only watch within this directory -- recursively. does this mean that i need to set the name to the folder name where the cogs are contained?

slate swan
#

no point in "somelowercasestring".lower()

uncut comet
#

anyone know of a good method to reload cogs after they have been edited without restarting the bot?

rustic onyx
#

when a webhook sends a message, will the bot consider it for an on_message?

slate swan
#

Yes?

rustic onyx
#

ok thanks

slate swan
#

how do you delete a message after its executed

#

I did

await delete(*, delay=None) 

but it says delete is not defined

rustic onyx
#

how can I avoid the bot from performing something if the one who triggered the command was the same bot

#

I was thinking doing if message.author != (bot author):

slate swan
rustic onyx
#

but idk what should I write in (bot author)

slate swan
slate swan
slate swan
rustic onyx
slate swan
silk epoch
#

hello why I test to start a python program it not work but work to start with cmd ?

rustic onyx
#

but not when the bot sends the mssage

slate swan
rustic onyx
#

yeah

#

I just do bot.user?

slate swan
#

yes

rustic onyx
#

cool

slate swan
#

if in a cog, self.bot.user

rustic onyx
#

thanks

#

yup

#

thanks πŸ™‚

slate swan
uncut comet
#

anyone know of a good method to reload cogs after they have been edited without restarting the bot?

reef shell
#

!d discord.ext.commands.Bot.reload_extension

unkempt canyonBOT
#

reload_extension(name, *, package=None)```
Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
uncut comet
#

have you got a link/example

#

ah thanks

slate swan
maiden fable
#

BTW @slate swan

#

Do u know something?

slate swan
maiden fable
# slate swan Hm?

Think what would happen if someone uses the unlock command in staff channel(s)

slate swan
#

Nothing?

#

lol

maiden fable
#

You sure?

slate swan
#

Yes

maiden fable
#

Now think

slate swan
#

Yes nothing will happen lmao

#

It all depends on how your perms are setup

maiden fable
#

Won't it allow everyone to see the channel pithink

slate swan
#

No! Its editing the send message perms not the view channel perms

maiden fable
#

Oh hmm mb

slate swan
#

the view channel perms is disabled for everyone and enabled for staff roles

maiden fable
#

Anyways as for your question...

#

Just make a dict and map it like channel-id: old-perms and update it whenever the lock command is used. when an unlock cmd is used, just read from that dict and delete the dict key if the unlock is successful. This is the safest way imho

vocal plover
#

It's only safe until your bot restarts halfway through a lockdown

maiden fable
#

Lmao true

#

(That happened once with me and Dyno with a mute cmd)

#

I muted about 10 ppl but Dyno restarted in the meantime and RIP those ppl

reef shell
#

dyno and carl bot goes offline when you need them most Kek

maiden fable
#

True

slate swan
#

key error occured while getting '815358648225366037', you should handle this
also you might've stored IDs as integers so it can't retrieve from '815358648225366037' as its a string

valid niche
#

at least they should be now, if they aren't shame on them

slate swan
valid niche
#

like even in my bot i use a database for all infractions, including mutes

maiden fable
hasty iron
#

jokes on you, it uses the much superior JSON

valid niche
#

stop

maiden fable
#

LMAO

valid niche
#

you can always use ohnodb (ahem @vocal plover)

maiden fable
#

What is that pithink

slate swan
#

what's that

maiden fable
slate swan
#

πŸ˜‚

maiden fable
#

Ikr lmao

slate swan
#

oh it's alec's

maiden fable
#

Oh it belongs to Alec

#

🀣 just saw

slate swan
#

yeah

#

πŸ˜‚

stone palm
#

hmmm

slate swan
#

the whole code is just 177 lines

maiden fable
#

uses in production

slate swan
#

πŸ˜‚

vocal plover
boreal ravine
#

ohnodb?

valid niche
#

There is Alec

vocal plover
#

If I catch anyone here seriously use that you will be executed by firing squad

boreal ravine
#

hm

valid niche
#

Remember: it’s so bad, but so well optimized

boreal ravine
#

@maiden fable give link

valid niche
#

!pypi ohnodb

unkempt canyonBOT
boreal ravine
#

ty

vocal plover
#

I'll publish V2 soon

valid niche
vocal plover
#

Nah

#

You'll see

maiden fable
valid niche
#

Ngl the import antigravity is in my opinion the best Easter egg in python

tawdry perch
maiden fable
#

BTW I can use an async function in run_until_complete, right?

tawdry perch
#

I see, yes it is

errant shuttle
#

guys, how do i create a role on nextcord?

maiden fable
#

!d discord.Guild.create_role

unkempt canyonBOT
#

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

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

All fields are optional.

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

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

Winks to @maiden fable

maiden fable
#

πŸ˜‰

errant shuttle
dapper cobalt
#

Because it is.

errant shuttle
kindred epoch
#

@vocal plover I might just move to ohnodb

dapper cobalt
maiden fable
#

How to run an async function with an AbstractEventLoop pithink

#

without awaiting it in my code ^^^

dapper cobalt
maiden fable
#

No

dapper cobalt
#

Ok I'm sorry.

kindred epoch
#

Ohnodb > postgres 🀫

maiden fable
#

I have been working on this since the last 2 hours I ain't in a joking mood rn

valid niche
maiden fable
valid niche
#

oh you want to run an async function upon init?

maiden fable
#

Mhm

#

Any ideas?

#

I cannot call asyncio.run() from a running loop so it is a bummer

valid niche
#

use async definded classmethod?

maiden fable
ionic pebble
#

Did that one discord.py library go out of existence like the developer said it was going to

maiden fable
#

Where will I run it?

valid niche
#

just no more updates

#

before it breaks we'll be in march 2022

ionic pebble
#

what are people moving to? or is it being forked

maiden fable
#

Nah it won't break

#

!d discord.Intents.messages

unkempt canyonBOT
ionic pebble
#

it will break if people don't switch to slash commands though?

valid niche
maiden fable
maiden fable
valid niche
valid niche
maiden fable
#

Mb lemme edit it

valid niche
#

it's made from scratch

maiden fable
#

There

valid niche
#

thanks :D

maiden fable
#

Forgot about that

#

Anyways do u know pithink

#

How to run the async function now

valid niche
#

but yeah because we rewrite it will be a lot longer before we got it fully up and running, where forks could almost instantly spring into action

maiden fable
#

Mhm

valid niche
#

copying a SO example

import asyncio

dsn = "..."

class Foo(object):
    @classmethod
    async def create(cls, settings):
        self = Foo()
        self.settings = settings
        self.pool = await create_pool(dsn)
        return self

async def main(settings):
    settings = "..."
    foo = await Foo.create(settings)
maiden fable
#

Oh hmm

hollow agate
#
async def mute(ctx, user : discord.Member, duration = 0,*,unit = None):``` Anyway to make this work with `.mute @Someone#0171 10s`?
valid niche
#

i have a regex set if you want, I don't mind others using it

hollow agate
#

Yes, please!

valid niche
#

it is sad that danny quit at a bit of an "annoying" time, due to the fact that discord is soon going to enforce slash commands to bigger bots, meaning libraries have little time to take over.

Although finally having a huge change in the library market is also a good sthing

hollow agate
#

Thank you so much!

tawdry perch
valid niche
maiden forum
#

how to detect if a webhook is created

maiden fable
#

Mhm

maiden fable
unkempt canyonBOT
#
Not in my house!

No documentation found for the requested symbol.

maiden fable
#

Breh

tawdry perch
hollow agate
valid niche
#

!d discord.on_webhooks_update

unkempt canyonBOT
#

discord.on_webhooks_update(channel)```
Called whenever a webhook is created, modified, or removed from a guild channel.

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

ah yea

hollow agate
#

I don't know much about cogs :P

maiden fable
#

that s

maiden forum
valid niche
valid niche
hollow agate
#

It says typing isn't defined.

#

Ah, nevermind... gotta import it πŸ˜…

valid niche
#

yeah i use a lot of typehints

#

mainly for the union and optional things

maiden fable
#

DUDE PYTHON HAVING A STROKE

#
    await hunai.__ai_session.update_channel_cache()
AttributeError: 'HunAI' object has no attribute '__ai_session'

but

class HunAI(Client):

    def __init__(self, session: ClientSession):
        super().__init__(session, TOKEN)  # type: ignore
        self.loop = get_running_loop()
        self.__ai_session = AIRequest(self)
#

πŸ‘

tawdry perch
#

is this part of your AI bot?

hollow agate
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: type object 'datetime.datetime' 
has no attribute 'timedelta'``` ```py
@client.command()
async def tempmute(ctx, member: typing.Union[discord.Member, discord.User, discord.Object], time, *, reason=None):
    await ctx.message.delete()
    if isinstance(member, discord.Member):
        if member.top_role >= ctx.author.top_role:
            await ctx.send("You cannot mute this person")
            return
    else:
        member = member if isinstance(member, discord.User) else await ctx.bot.fetch_user(member.id)

    if not member:
        raise commands.BadArgument("User was not found")

    weeks = int((re.findall(r"(\d+)w", time) or "0")[0])
    days = int((re.findall(r"(\d+)d", time) or "0")[0])
    hours = int((re.findall(r"(\d+)h", time) or "0")[0])
    minutes = int((re.findall(r"(\d+)m", time) or "0")[0])

    timedelta = datetime.timedelta(
        weeks=weeks,
        days=days,
        hours=hours,
        minutes=minutes
    )
    endtime = datetime.datetime.utcnow() + timedelta

    embed = discord.Embed(title=f'You have been temporary muted from {ctx.guild.name}. You have been muted until {endtime}.',
                            color=discord.Color.green())
    if reason:
        embed.add_field(name='Reason:', value=f'{reason}', inline=False)
    embed.add_field(name='If you have questions:', value=f'If you have questions about this action, or would like '
                                                             f'to appeal it. Please contact the staff team. '
                                                             f'You were muted by {ctx.author.mention}', inline=False)
    try:
        await member.send(embed=embed)
    except discord.Forbidden:
        await ctx.send('Could not send DM to user')

    muterole = ctx.guild.get_role(872910398209282078)
    await member.add_roles(muterole)

    async with ctx.bot.pool.acquire() as con:
        try:
            result = await con.fetchrow("INSERT INTO tempmutes(uid, executor, timedate, endtime, reason) VALUES($1, $2, "
                                                "CURRENT_TIMESTAMP(1), $3, $4) RETURNING muteid", member.id, ctx.author.id, endtime, reason)
            muteid = result[0]
        except Exception as error:
            print(error)

    embed = discord.Embed(title=f' ', description=f' ',
                            color=discord.Color.green())
    embed.set_footer(
        text=f'Action performed by {ctx.author} | Case {muteid}')
    embed.set_author(name=f'Case {muteid} | Temp mute | {member}')
    embed.add_field(name='End time', value=f'{endtime}', inline=False)
    if reason:
        embed.add_field(name=f'Reason', value=f'{reason}', inline=False)
    await ctx.send(embed=embed)
    await ctx.bot.logchannel.send(embed=embed)  ``` @valid niche
hollow agate
#
import discord
import random
import json
import os
import datetime
import asyncio
import traceback
import sys
import re
import pytz
import aiosqlite
import typing

from discord.ext.commands import has_permissions, MissingPermissions
from datetime import datetime
from discord.ext import commands
from discord.ext import tasks
from discord.ext.commands.errors import BadArgument```
#

Possibly :P

maiden fable
valid niche
#

i just import datetime, you did from datetime import datetime

tawdry perch
hollow agate
#

Ah

valid niche
#

since you need a timedelta here

maiden fable
tawdry perch
#

make it to actual AI πŸ‘€

valid niche
#

and you need to access it differently

maiden fable
#

since it shows in the typehint list

valid niche
#

it's defined by the __

maiden fable
#

Yea ik but before in 3.9 it used to work 🀣

valid niche
#

if you do

class foo:
  def __init__(self):
    self.__hidden = "a"

bar = foo()
print(bar._foo__hidden)
```  you can access it
maiden fable
#

ooh

hasty iron
maiden fable
#

thanks

hasty iron
#

and never should like the way you did

maiden fable
tawdry perch
#

He broke the Python

maiden fable
#

Lmao

tawdry perch
#

the AI is too powerful

maiden fable
#

True

valid niche
#

also frick i broke disthon

maiden fable
#

lmao

hasty iron
#

lol just use lefi

#

superior in every way

maiden fable
#

lol

unkempt jacinth
#

Anyone know the behaviour to make a bot paste the hyperlink and then also paste out the preview embed that would normally happen for when users paste links. For example posting a link to a tweet, shows you what the tweet says - but when my bot posts the same link, no embed with what the tweet says is posted.

hasty iron
#

probably the bot doesn’t have embed permissions

unkempt jacinth
#

I've given it admin privs in my server.

tawdry perch
#

does the discord have good API docs?

valid niche
#

yes

#

especially for python, because in the few examples they give it's all in python

tawdry perch
#

I never ever realized I can scroll down the page

valid niche
#

oh boi

tawdry perch
#

I literally though the intro was only thing ;-;

valid niche
#

there's a LOT to the docs

hasty iron
#

what

valid niche
#

the documents are huge

hasty iron
#

"oh there is a sidebar, must be useless"

maiden fable
#

🀣

tawdry perch
#

I wanted to read it like 5 months ago but I did not realize the slide bar lemon_angrysad

#

why...

hasty iron
#

how

tawdry perch
#

I did not see this

#

Im fking dumb

hasty iron
#

that’s not it, even if you didn’t see the scrollbar there is more content

tawdry perch
#

there is not a lot of it in the intro section

hasty iron
#

you can see more stuff in the sidebar?

tawdry perch
#

I hate myself

hasty iron
#

you don’t have to scroll

tawdry perch
#

this, yes. But not what I wanted to see

slate swan
#

TypeError: 'EmbedProxy' object is not callable?

hasty iron
#

don’t call it

tawdry perch
#

I do hate myself, how can I miss such a thing

#

well, now that I found them πŸ˜† . I can start asking a lot of annoying questions

maiden fable
#

🀣

tawdry perch
#

luckily there is unbm feature (possibly) up coming

slate swan
#

?tag IR

novel apexBOT
#

This is not a Modmail thread.

maiden fable
#

LMAO

tawdry perch
#

what?

slate swan
#

just a quick Q, trying to install the pip install -u
is there a way of going about that herE?

#

!rewrite

#

?rewrite

maiden fable
#

So I think I need some basic Python help :c

lusty swallow
slate swan
tawdry perch
slate swan
maiden fable
maiden fable
tawdry perch
#

no I don't think so

slate swan
#

just installing the latest version of pip

slate swan
slate swan
#

yes, that

#
pip install -U pip
slate swan
maiden fable
# slate swan just installing the latest version of pip
            elif ai_cnl:
                channel: TextChannel
                for cnl in msg.server.channels:  # type: ignore
                    cnl: Union[VoiceChannel, TextChannel]
                    if cnl.id in self.ai_channels:
                        channel = msg.server.get_channel(cnl.id)  # type: ignore
                        break
                    else:
                        continue
                if channel:  # type: ignore

channel referenced before assignment (don't ask about the lib)

#

Oops

#

wrong mention

#

@tawdry perch ^^^

slate swan
maiden fable
#

sorry trix

tawdry perch
#

what about it?

maiden fable
tawdry perch
#

nothing

lusty swallow
#

you guys type hint mid function?

maiden fable
#

Anyways I'mma open a help channel

tawdry perch
#

is the channel supposed to be a param?

slate swan
#

sure thing. ill try and do that now

#

your quesiton is not related to bot development