#discord-bots

1 messages Β· Page 661 of 1

shadow wraith
#

πŸ’€

unkempt canyonBOT
#

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

False
sick birch
#

it'll never be true

dusk narwhal
#

yeah

sick birch
#

i wonder if you can do operator overloading with different types

dusk narwhal
shadow wraith
#

this is not really related to bot development but i kind of found a way to make an error handler for a command using else and if statements

slate swan
#

My client secret is my token, correct?

dusk narwhal
#

yes

boreal ravine
#

!e

class B:
  def __str__(self):
    return 'B'

if str(B()) == 'B':
  print(True)
else:
  print(False)
``` i mean it worked πŸ—Ώ
unkempt canyonBOT
#

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

True
sick birch
#

!e

class A:
  def __init__(self, letter):
    self.letter = letter
  def __eq__(self, other):
    return self.letter == other
a = A("b")
print(a == "b")
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

True
sick birch
#

yay

dusk narwhal
#

there we go

sick birch
#

so i guess what i said before was wrong

#

you can compare an object to a string

dusk narwhal
#

rlly?

slate swan
# dusk narwhal yes

But when i go to the bot section on the Discord Bot API, it says Token there too.

dusk narwhal
#

i thought u couldnt

boreal ravine
sick birch
#

correct

boreal ravine
#

hm

sick birch
#

!e

class A:
  def __init__(self, letter):
    self.letter = letter
  def __eq__(self, other):
    print("ran a dunder")
    return self.letter == other
a = A("b")
print(a == "b")
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

001 | ran a dunder
002 | True
pliant gulch
#

this Please use pointer comparison

sick birch
#

cool stuff

slate swan
# dusk narwhal hmmm

Yeah. The client secret didn't work when I tried to run my bot. Now my bot is online when I used the token in the Bot Section of the Discord Bot API.

sick birch
#

client secret is for oauth2 flow as far as i'm aware

dusk narwhal
#

OMG IT WORKED

sick birch
#

i remember using it when i was making my log in with discord thing

shadow wraith
#
@bot.command()
async def lol(ctx, lol: None):
  if lol == None:
    await ctx.send('bru lol is nothing')
  else:
    await ctx.send('nice, lol')
dusk narwhal
#

OMG FINALLY

sick birch
#

unlike java you can't do object == None you have to do object is None

dusk narwhal
#

i spent like 2 days trying to make my own web browser to bypass shit at school and my dumbass couldnt realize how to do it and now i finally did it

shadow wraith
maiden fable
#

Not lol: None

sick birch
#

None is actually a NoneType which is technically an object

unkempt canyonBOT
pliant gulch
unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

True
pliant gulch
#

== is checking if the value is same

sick birch
#

i mean None == None

dusk narwhal
sick birch
#

nvm that doesn't make any sense

shadow wraith
#

oh

boreal ravine
dusk narwhal
#

oh yeah mb

sick birch
#

i never use the == or is, i just check for falsy or truthy values haha

pliant gulch
#

πŸ€”

boreal ravine
#

same

pliant gulch
#

That must not be very good practice

shadow wraith
#

say "aye" if you do debug print statements xD

sick birch
#

i've actually been trying to learn the debugger

maiden fable
shadow wraith
#

debug print statements = something which prints whenever a command is triggered

#

:torll:

#

in terms of discord bots

shadow wraith
boreal ravine
#

!e

b = None
if b:
  ...
else:
  print('doesn\'t exist')
``` i always do this to handle nonetypes πŸ‘€
unkempt canyonBOT
#

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

doesn't exist
shadow wraith
#

thats why regenerate exists

maiden fable
#

Uhhhhhhh

shadow wraith
maiden fable
shadow wraith
#

wtf?

maiden fable
#

🀣

pliant gulch
unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

doesnt exist
pliant gulch
maiden fable
#

And then there's me who use if statements like if not a only when I don't know what data types can be entered in the variable and when it's None or something 😐

shadow wraith
pliant gulch
#

Especially when there's like three type checkers screaming at me all at once

maiden fable
shadow wraith
#

guys we are getting off topic now

maiden fable
pliant gulch
#

My discord API wrapper is typehinted and all internals are documented

#

My contributors are never lost

#

πŸ˜”

maiden fable
sick birch
#

typescript go brrr

maiden fable
sick birch
#

never tried it but i'd like to at some point

sullen shoal
#

its great and kinda cute

maiden fable
#

Made a standalone exe which opens discord web automatically. It's just like the discord app only difference is it opens as a web not as an app

shadow wraith
#

is tabnine even good

sullen shoal
#

it is

shadow wraith
#

and isnt typehinting just code- oh i get it

sullen shoal
#
class DumbPerson: pass

def learn(person: DumbPerson): pass```
its useful in these cases where you can let the user and the IDE know what type the function accepts
maiden fable
#

Lmao the name tho

sullen shoal
shadow wraith
sick birch
#

!e

def myFunction(aString : str):
  print(aString)

anInt = 81
myFunction(anInt)
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

81
sick birch
#

this is a certified python moment

shadow wraith
#

!e

def mebeingdumbrn(string: str):
  # did you just make "string" a "str" :troll:
  print(8+2)

mebeingdumbrn()
unkempt canyonBOT
#

@shadow wraith :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 5, in <module>
003 | TypeError: mebeingdumbrn() missing 1 required positional argument: 'string'
pliant gulch
shadow wraith
#

oh wait your right

#
def mebeingdumbrn():
  # did you just make "string" a "str" :troll:
  print(8+2)

mebeingdumbrn()
sick birch
#

what does pep8 say on the matter

pliant gulch
#

For function names you are supposed to do snake case

shadow wraith
#

crab i forgot to say !e

pliant gulch
#

And same for variables

sick birch
#

euh what's snake case again

pliant gulch
#

snake_case

slate swan
#

this_is_snake_case

sick birch
#

i see

shadow wraith
#

you_just_meant_underscores_did_you

sick birch
#

definitely didn't just finish doing my java project for school

shadow wraith
#

!e

def mebeingdumbrn():
  # did you just make "string" a "str" :troll:
  print(8+2)

mebeingdumbrn()
unkempt canyonBOT
#

@shadow wraith :white_check_mark: Your eval job has completed with return code 0.

10
sick birch
#

my java naming habits would never ever leak into my python naming habits

#

πŸ‘€

shadow wraith
#

whenever im not coding discord bots i always name my variables long stuff like "long_names_like_this" or "among_ussy_gus"

sick birch
#

short & sweet is good but sometimes you gotta go big

full valley
#

How can I run a command every so often

shadow wraith
full valley
shadow wraith
#

your a user so you should run it every x hours

sick birch
full valley
sullen shoal
#

database

full valley
sullen shoal
#

!d time.perf_counter

unkempt canyonBOT
#

time.perf_counter() β†’ float```
Return the value (in fractional seconds) of a performance counter, i.e. a clock with the highest available resolution to measure a short duration. It does include time elapsed during sleep and is system-wide. The reference point of the returned value is undefined, so that only the difference between the results of two calls is valid.

Use [`perf_counter_ns()`](https://docs.python.org/3/library/time.html#time.perf_counter_ns "time.perf_counter_ns") to avoid the precision loss caused by the [`float`](https://docs.python.org/3/library/functions.html#float "float") type.

New in version 3.3.

Changed in version 3.10: On Windows, the function is now system-wide.
sullen shoal
#

or maybe datetime module

#

depends on what you wanna do

full valley
#

well if a command hasnt been used in x minutes, i want to invoke another command

sullen shoal
#

then go with, time.perf_counter

#

subtract the last saved time from the current time, you will get the seconds

#

!e
import time
s = time.perf_counter()
time.sleep(1)
print(time.perf_counter() - s)

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

1.005091819446534
sullen shoal
#

!e
import time
s = time.time()
time.sleep(1)
print(time.time() - s)

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

1.0043056011199951
sullen shoal
#

this one works for normal use

#

not some very accurate time

full valley
#

gotcha, I just dont know how I would integrate that in terms of the usage of a command

sullen shoal
#

just save the time in database when someone invokes the command

#

!e
print(round(1.927282827288272))

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

2
full valley
#

yeah but then I needa do a check right

sullen shoal
#

check?

full valley
#

to see when it hasnt been used for x amount of time

sullen shoal
sullen shoal
#

yes task loops

verbal cairn
#

@tasks.loop(minutes=10.0)
async def loop_this(self):
channel = self.bot.get_channel(ID)
await channel.send(β€œLooping!”)

#

U should probbaly work within a cog if ur using task loops tho

full valley
#

hmm I havnt used cogs

verbal cairn
#

It’s not that bad tbh

shadow wraith
#

is it possible to make the bot accept a friend request from a specific user

slate swan
#

No

maiden fable
#

People can't even send friend request to a bot

slate swan
#

Bots don't have permission to use the relationships endpoint. This means no friends and no blocking, and also means no bots in group DMs.

hazy agate
#

sheesh

#

i made copy of @novel apex

#

see my codes

#

import discord
from discord.ext import commands
import os

client = discord.Client()

client = commands.Bot(command_prefix=".")

@client.event
async def on_ready():
await client.change_presence(status=discord.Status.online, activity=discord.Game('Coding'))
print('Bot is ready')

@client.event
async def on_message(message):
empty_array = []
modmail_channel = discord.utils.get(client.get_all_channels(), name="mod-mail")

if message.author == client.user:
return
if str(message.channel.type) == "private":
if message.attachments != empty_array:
files = message.attachments
await modmail_channel.send("[" + message.author.display_name + "]" + message.author)

      for file in files:
          await modmail_channel.send(file.url)
  else:
      await modmail_channel.send("[" + message.author.display_name + "]" + message.content)

elif str(message.channel) == "mod-mail" and message.content.startswith("<"):
member_object = message.mentions[0]
if message.attachments != empty_array:
files = message.attachments
await modmail_channel.send("[" + message.author.display_name + "]")

      for file in files:
          await member_object.send(file.url)
  else:
      index = message.content.index(" ")
      string = message.content
      mod_message = string[index:]
      await member_object.send("[" + message.author.display_name + "]" + mod_message) 

client.run("Nope")

shadow wraith
shadow wraith
hazy agate
#

where?

#

its workuing tho

shadow wraith
#

client = discord.Client() and client = commands.Bot(...)

hazy agate
#

wait

#

lets see

#

i don't see it

#

the bot is running fine

#

u can also use he code ifu want

boreal ravine
hazy agate
#

......

hazy agate
#

nothing

#

i was showing off LOL

boreal ravine
#

nice

faint echo
boreal ravine
#

I mean you could do it with user accounts but discord doesn't let you do that anymore

faint echo
#

Yep, bueno.

hazy agate
#

ayo

#

can i make a bot online for 1 year

#

or 24.7

faint echo
#

Yes, you can use a VPS.

hazy agate
#

||/||

faint echo
#

Or.... if you want some basic 24/7 you can also use Repl.it

hazy agate
#

wdymn

hazy agate
#

and pycharm

faint echo
#

Ok then you can do 24/7 there on Repl

hazy agate
#

but i need to on it again and again

faint echo
#

?

hazy agate
#

run

#

so it will be online

faint echo
#

No, here is your answer: https://youtu.be/SPTfmiYiuok?t=3542

Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it.
🚨Note: At 16:43, Replit now has a new method for environment variables. Check the docs: https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables

Along the way, you will learn to use Repl.it's built-in database and cr...

β–Ά Play video
hazy agate
faint echo
#

Its not about the person.. its about the content, follow the video if you want 24/7 on repl

slate swan
hazy agate
#

cuz i saw this vid i was doing it in node.js and it was py

maiden fable
hazy agate
#

a

#

a

faint echo
#

Idk why I am being mentioned..and cool

slate swan
#

@maiden fable stop copying mejam_cavedude

boreal ravine
hazy agate
#

why dont i have roles

slate swan
boreal ravine
maiden fable
slate swan
#

Lol

hazy agate
#

import discord
from discord.ext import commands
import os

client = discord.Client()

client = commands.Bot(command_prefix=".")

@client.event
async def on_ready():
await client.change_presence(status=discord.Status.online, activity=discord.Game('Coding'))
print('Bot is ready')

@client.event
async def on_message(message):
empty_array = []
modmail_channel = discord.utils.get(client.get_all_channels(), name="mod-mail")

if message.author == client.user:
return
if str(message.channel.type) == "private":
if message.attachments != empty_array:
files = message.attachments
await modmail_channel.send("[" + message.author.display_name + "]" + message.author)

      for file in files:
          await modmail_channel.send(file.url)
  else:
      await modmail_channel.send("[" + message.author.display_name + "]" + message.content)

elif str(message.channel) == "mod-mail" and message.content.startswith("<"):
member_object = message.mentions[0]
if message.attachments != empty_array:
files = message.attachments
await modmail_channel.send("[" + message.author.display_name + "]")

      for file in files:
          await member_object.send(file.url)
  else:
      index = message.content.index(" ")
      string = message.content
      mod_message = string[index:]
      await member_object.send("[" + message.author.display_name + "]" + mod_message) 

client.run("nope!")

boreal ravine
#

Whats wrong?

hazy agate
#

import youtube_dl
import discord
from discord.ext import commands
import os
import wikipedia

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

@client.event
async def on_ready():
await client.change_presence(status=discord.Status.online, activity=discord.Game('Helping'))
print('Bot is ready')

@client.command()
async def aah(ctx):
await ctx.send("Working on music bot pls be patient")

@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)

@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)

@client.command()
async def a(ctx):
await ctx.send("sheesh sheesh sheesh sheesh sheesh sheesh sheesh sheesh")

@client.command()
async def play(ctx, url: str):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
except PermissionError:
await ctx.send("Wait for the current playing music to end or use the 'stop' command")
return

boreal ravine
#

Bruh

hazy agate
#

voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='General')
await voiceChannel.connect()
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)

ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
     ydl.download([url])
# for file in os.listdir("./"):
#     if file.endswith(".mp3"):
#         os.rename(file, "song.mp3")
voice.play(discord.FFmpegPCMAudio(url))

@client.command()
async def leave(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_connected():
await voice.disconnect()
else:
await ctx.send("The bot is not connected to a voice channel.")

@client.command()
async def pause(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_playing():
voice.pause()
else:
await ctx.send("Currently no audio is playing.")

@client.command()
async def resume(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_paused():
voice.resume()
else:
await ctx.send("The audio is not paused.")

@client.command()
async def stop(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
voice.stop()

client.run("Nah")

boreal ravine
#

Wtf

maiden fable
#

!code dude

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.

hazy agate
#

bunch of

maiden fable
#

And yea stop spamming code

hazy agate
#

!slap @maiden fable

boreal ravine
#

Bruh.

sullen shoal
maiden fable
faint echo
hazy agate
#

yea + that old man

boreal ravine
hazy agate
#

i was seeing his video and it was 1hr something and i got confused + he didn't add the github page to copy paste

boreal ravine
#

Bruh

#

😐

faint echo
hazy agate
#

πŸ™‚

faint echo
boreal ravine
#

Why do you even need the github to copy

#

Copying is bad, it's common sense

full valley
#

does ctx.author.roles contain the role name strings or id's

sullen shoal
# faint echo Interesting opinion, why is it bad for the context of what I mentioned earlier?

because his code is old now and there are better ways to do it. Replit uses shared ip, its not meant to be used to host stuff uses third party API with rate limits because it uses shared ip meaning if 50 people are using machine (which is pretty nomal in case of replit) all those requests will be counted as from one bot and every bot which is being hosted with that ip will be rate limited pretty soon if they all together send 10k requests in 10 minutes

boreal ravine
#

!d discord.Member.roles <=

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [β€˜@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
faint echo
#

Great post tho

sullen shoal
#

how to implement 24/7 on your repl.it bot
what you tryna say with that then

faint echo
#

Go up more mate

sullen shoal
#

Or.... if you want some basic 24/7 you can also use Repl.it
why are you suggesting that?

#

just buy vps or host locally, you got two options

hazy agate
#

i dont need

faint echo
boreal ravine
#

I mean you can use replit to host 24/7, it isn't that big of a deal; It's their choice if they wanna use it not yours or you could use heroku which is an alternative or you could go find a free host yourself (railway, CDH, etc)

faint echo
#

Please read prior to posting.

sullen shoal
faint echo
full valley
sullen shoal
slate swan
#

if i.name in ...

slate swan
#

Considering staff_role is also a string

full valley
#

staff role was an id

slate swan
#

Check i.id or i.name for both, either use the ID or the name string

maiden fable
boreal ravine
#

he doesn't wanna find a role

#

he wants to check if a role is in a members roles

maiden fable
#

He can see if it returns None or not

#

Β―_(ツ)_/Β―

boreal ravine
maiden fable
valid galleon
#

so i want to regularly update my bot, but at the same time i dont want it to keep going offline very often. is there anyway to make sure that i can update it without the bot going offline for very long or it running in multiple instances? it also uses a database to log how many messages a user has sent in all the guilds, so if i do have to update, i will have to first put the bot offline in heroku, then download the git repo, update it, reupload the files and then switch it on.

#

is connecting to the repo and directly developing on it a good idea?

slate swan
#

At this point stop using Heroku and get a real hoster made for bots that isn't volatile.

boreal ravine
slate swan
#

That's for what lambdas are used

maiden fable
#

!d discord.utils.find

unkempt canyonBOT
#

discord.utils.find(predicate, seq)```
A helper to return the first element found in the sequence that meets the predicate. For example:

```py
member = discord.utils.find(lambda m: m.name == 'Mighty', channel.guild.members)
```  would find the first [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") whose name is β€˜Mighty’ and return it. If an entry is not found, then `None` is returned.

This is different from [`filter()`](https://docs.python.org/3/library/functions.html#filter "(in Python v3.9)") due to the fact it stops the moment it finds a valid entry.
maiden fable
#

I did the opposite but u get the idea

boreal ravine
#

do I need to iterate through it or something

maiden fable
#

No

#

utils.find automatically iterates through the seq

boreal ravine
#

but it's only returning one value

#

I have both kayle and a moderator role

maiden fable
#

That's what it does

#

It returns the first value it finds

boreal ravine
#

o

maiden fable
#

!d filter

unkempt canyonBOT
#

filter(function, iterable)```
Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which supports iteration, or an iterator. If *function* is `None`, the identity function is assumed, that is, all elements of *iterable* that are false are removed.

Note that `filter(function, iterable)` is equivalent to the generator expression `(item for item in iterable if function(item))` if function is not `None` and `(item for item in iterable if item)` if function is `None`.

See [`itertools.filterfalse()`](https://docs.python.org/3/library/itertools.html#itertools.filterfalse "itertools.filterfalse") for the complementary function that returns elements of *iterable* for which *function* returns false.
maiden fable
#

Sorry my bad*

boreal ravine
#

hm

#

Nice worked

maiden fable
#

Cool

#

BTW u can also do return list(b)

#

@boreal ravine

boreal ravine
#

hm

slate swan
#

im tryna make an 8ball command

#

and im stuck here

slate swan
#

Example

await ctx.send("")
 await ctx.send("")
slate swan
#

Just delete the space

#

space?

slate swan
#

where 😟

#

In the coro

#

sorry, i litterally just learnt python a day ago

#

or the basics

#

In await

#

Before await add a space

#

i did

#

it j says that

#

Align await ctx.... with responses

#

!indents

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

slate swan
slate swan
#

You know replying with ping and pinging me won't help

#
async def .....
    responses = ......
    await ctx.....
#

This is very basic Python

slate swan
# unkempt canyon

I'd recommend to learn a little bit more and take a look at this ^

pulsar pilot
#

How to make my bot online?

boreal ravine
boreal ravine
pulsar pilot
#

I dont know how

slate swan
#

put ur disc bot token in

pulsar pilot
#

Then

boreal ravine
#

bru

slate swan
#

bru

pulsar pilot
#

?

faint echo
#

Hey mod, could you provide more of your code? or if you did could you mention me on your response?

slate swan
#

put ur discord bot token where it says token

pulsar pilot
faint echo
# slate swan

As you can see your await ctx.send(..... is outside of the function.

#

press tab before await.

pulsar pilot
#

Im new here

faint echo
#

Welcome

slate swan
pulsar pilot
#

Idk how ro code

#

But i want to make bot

slate swan
#

is there a way to press the new containers/buttons with discord.py 2.0?

boreal ravine
#

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

faint echo
# slate swan

If its Repl.it just give it some time.. it tends to be slow
I don't recommend repl.it btw, use a VPS.

( saying this before someone tries to roast me again )

pulsar pilot
boreal ravine
boreal ravine
faint echo
slate swan
#

but thankyou so much

#

❀️

faint echo
#

No problem and its totally fine to use a test bot with repl.it but when you upgrade to the real thing bot you should do a VPS.

slate swan
boreal ravine
#

!d discord.ui.View <=

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
boreal ravine
#

!d discord.ui.Select <=

unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Select.values "discord.ui.Select.values").

New in version 2.0.
boreal ravine
#

There are examples in the github if your stuck by the way

slate swan
#

this should be good enough, ty very much

boreal ravine
#

πŸ‘Œ

slate swan
#

it isnt now

#

its gone back to the same mistake

faint echo
# slate swan

go before await and press shift + tab, then press tab again.

obsidian ledge
#

how do i make a command that like when i say "!add ___" then it adds the thing i said to a list?

faint echo
#

I could give you the entire code but that means you wouldn't be learning

obsidian ledge
#

okay

#

ill try ig

faint echo
#

If you can't then come back... and we will help you out again

prisma spoke
#
    @commands.command(name='pause')
    async def _pause(self, ctx: commands.Context):
        """Pauses the currently playing song."""

        if not ctx.voice_state.is_playing and ctx.voice_state.voice.is_playing():
            ctx.voice_state.voice.pause()
            await ctx.message.add_reaction('⏯')
            await ctx.send("Successfully paused the song!")

    @commands.command(name='resume')
    async def _resume(self, ctx: commands.Context):
        """Resumes a currently paused song."""

        if not ctx.voice_state.is_playing and ctx.voice_state.voice.is_paused():
            ctx.voice_state.voice.resume()
            await ctx.message.add_reaction('⏯')
            await ctx.send("Successfully resumed the song!")``` 
```py
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/ROG.py", line 799, in on_command_error
    raise error
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/ext/commands/bot.py", line 995, in invoke
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 887, in invoke
    await self.prepare(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 823, in prepare
    await self.call_before_hooks(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 761, in call_before_hooks
    await self._before_invoke(instance, ctx)  # type: ignore
  File "/home/container/ROG.py", line 713, in ensure_voice_state
    raise commands.CommandError('You are not connected to any voice channel.')
nextcord.ext.commands.errors.CommandError: You are not connected to any voice channel.```

music cmd pause and resume gave this error
#

but the bot is playing music

slate swan
#

:((

faint echo
slate swan
#

Hello.

#

he also uses nextcord

faint echo
slate swan
#

can i use help for two commands?

#

will it show two messages?

faint echo
#

Help is used to show commands on your cogs/bot.

If you want to redo the help command you will need to understand completely recreate it with a class.
There is a bunch of info on it online.

slate swan
#

i dont think so because you need to mention someone to do the whous one

faint echo
#

To create the whois command you will need to define a function with whatever name you want, put 2 parameters (ctx, user)
then you will get info from user

#

and display it by using ctx.send

slate swan
#

k

#

@faint echo @client.command(aliases=['user','info']) async def whois(ctx, member : nextcord.Member): embed = nextcord.Embed(title = member.name , description = member.mention , color = nextcord.Colour.blurple()) embed.add_field(name = "ID", value = member.id , inline = True) embed.set_thumbnail(url = member.avatar_url) embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}") await ctx.send(embed.embed)

#

my code

faint echo
slate swan
#

only the whois one

#

😦

faint echo
#

Oh embed.embed is wrong

slate swan
#

Ignoring exception in command None:
nextcord.ext.commands.errors.CommandNotFound: Command "whois" is not found

slate swan
faint echo
#
async def whois(ctx, member : nextcord.Member):
    embed = nextcord.Embed(title = member.name , description = member.mention , color = nextcord.Colour.blurple())
    embed.add_field(name = "ID", value = member.id , inline = True)
    embed.set_thumbnail(url = member.avatar_url)
    embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}")
    await ctx.send(embed = embed)  # embed.embed is wrong
red sundial
#

should i still learn discord.py when its not being updated anymore?

boreal ravine
#

what are you on about

slate swan
red sundial
slate swan
faint echo
red sundial
boreal ravine
faint echo
slate swan
#

sry

#

i understood it wrong sry

boreal ravine
#

!d discord.ext.commands.Bot.get_channel <= don't think you can get a channel with context. you can also do discord.Guild.get_channel

unkempt canyonBOT
slate swan
#

?

#

yeah

#

oh wow

boreal ravine
#

save the channel you got in a variable, then send it

#
channel = ...
await channel.send(**kwargs)
slate swan
#

@faint echo still the same error? Why?

boreal ravine
#

you don't need msg.send

#

you already got the channel, just do await channel_1.send()

#

sad

slate swan
#

@slate swan r u the owner? lol

#

or just an admin or mod

#

LOL

#

he is the co?

#

lol

#

@faint echo new error nextcord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.

boreal ravine
#

pass in something as the argument

#

you don't just make a function with a parameter, but then you don't pass in something as the argument

#

!e

def b(x):
  return x
print(b())
unkempt canyonBOT
#

@boreal ravine :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | TypeError: b() missing 1 required positional argument: 'x'
slate swan
#
async def whois(ctx, member : nextcord.Member):
    embed = nextcord.Embed(title = member.name , description = member.mention , color = nextcord.Colour.blurple())
    embed.add_field(name = "ID", value = member.id , inline = True)
    embed.set_thumbnail(url = member.avatar_url)
    embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}")
    await ctx.send(embed = embed)```
boreal ravine
#

^^

#

Whats the error?

#

oh nice

slate swan
#

what is it

boreal ravine
#

cool

#

did you solve it? I already see the issue lol

#

return isn't a function

#

it's a keyword, you don't use anything after it except certain keywords

boreal ravine
#

IDs are integers, not strings

obsidian ledge
#

how do i make a command that renames a channel topic?

boreal ravine
#

fuck

#

!d discord.TextChannel.edit <=

obsidian ledge
#

sadge

unkempt canyonBOT
#

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

Edits the channel.

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

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

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

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

you can use that to rename channel topics etc

obsidian ledge
#

alr

slate swan
#

kayle

#

the old error is back

#
nextcord.ext.commands.errors.CommandNotFound: Command "whois" is not found```
#

show ur code

#
async def whois(ctx, member : nextcord.Member):
    if member == None:
        await ctx.reply("Please pass in who's id you wanna see")
    else:
        embed = nextcord.Embed(title = member.name , description = member.mention , color = nextcord.Colour.blurple())
        embed.add_field(name = "ID", value = member.id , inline = True)
        embed.set_thumbnail(url = member.avatar_url)
        embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}")
        await ctx.send(embed = embed)```
#

@slate swan

#

@slate swan umm

digital forge
#

if message.content.startswith('/text'):
content = message.content[5:len(message.content)]
list = content.lower().split()
end = list[0]

      if end not in extensions:
          end = '.txt'
          f = open('text.' + end,'w')
          f.write(content)
      else :
          f = open('text.' + end , 'w')
          f.write(content[len(end) + 2 : len(content)])
          print(content[len(end) + 2: len(content)])
      
      
      await message.author.send(file = discord.File('text.'+end))

      f.close()
      os.remove('text.' + end)

whenever it sends a file , the file is empty help

boreal ravine
boreal ravine
#

no

#

!paste <=

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

@boreal ravine

#

@boreal ravine

boreal ravine
#

yes

slate swan
#

@boreal ravinewhats wrong?

boreal ravine
#

try doing $who

slate swan
#

i changed it

boreal ravine
#

yeah

slate swan
#

ok

#

add $ before the who

#

?

boreal ravine
#

your prefix Β―_(ツ)_/Β―

slate swan
#

i asked bec getting more errors

boreal ravine
#

whats the error now

slate swan
#

9 syntax errors

boreal ravine
slate swan
boreal ravine
#

simple python lol

slate swan
#

will it work after that?

#

@boreal ravine kayle

boreal ravine
slate swan
#

kk

boreal ravine
#

btw if you still get the command not found error go to discord.gg/dpy cause i only know 1 reason why that error raises

slate swan
velvet tinsel
#

I’ve been banned from dpy server so I can’t join

modest plover
#

Rip

boreal ravine
tawdry perch
#

I'm banned from there as well

boreal ravine
#

Why were you banned

tawdry perch
#

uh... πŸ‘€

tawdry perch
#

nothing

boreal ravine
#

why were you banned then

tawdry perch
#

πŸ‘€ .

boreal ravine
#

smh

slate swan
#

You miss the @

slate swan
#

Any errors?

#

Ignoring exception in command None:
nextcord.ext.commands.errors.CommandNotFound: Command "whois" is not found

#

Did you rerun the bot?

#

ofc

#
@commands.has_permissions(kick_members=True)
async def whois(ctx, member: nextcord.Member):
    embed = nextcord.Embed(title = member.name , description = member.mention , color = nextcord.Colour.blurple())
    embed.add_field(name = "ID", value = member.id , inline = True)
    embed.set_thumbnail(url = member.avatar_url)
    embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}")
    await ctx.send(embed = embed)```
#

@slate swan

#

Show full cose

#

*code

#

@slate swan dm?

#

wait

#

!paste

slate swan
slate swan
#

alright

#

@slate swan

#

@slate swan so whats wrong??

slate swan
boreal ravine
#

you cant use split attribute on a class

slate swan
#

oh wait i need to remove the unban one

#

its useless

boreal ravine
#

and having a ban command that long is really bad practice, I could make a simple unban command in like 3 lines

slate swan
#

@slate swan your code is outdated

#

member.avatar_url is invalid in nextcord

#

!d nextcord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User.avatar "nextcord.User.avatar")
slate swan
#

so what should i use

#

use this instead

#

with .url

#

like this property avatar.url?

#

nah mate

#

member.avatar.url

#

now should i check?

#

and here , it works well

#

oof lemme rerun and check

#

@slate swan

#

not working fo me

#

any new error?

#

or is it the same

#

Ignoring exception in command None:
nextcord.ext.commands.errors.CommandNotFound: Command "whois" is not found
.

#

@slate swan ill try restarting my editor

#

@slate swan check if its working for u

#

yea and "save" the code before doing it

#

kk

boreal ravine
#

imagine he doesn't have autosave on his ide

slate swan
#

ok working now thanks

slate swan
#

@slate swan thanks :3

#

yw

tawdry perch
#

vsc is broken or smth but afaik, the indent is correct

slate swan
#

mix of tabs and spaces ig

tawdry perch
#

I alrd restarted the vsc and I did not even touch the code and it broke

slate swan
#

what error do you get on running

tawdry perch
#

interesting, it works ;-; but the error stays

slate swan
#

hm hover on the red line and see what it says

slate swan
honest shoal
#
if word in message.content:

here how can I have a dataset in "word" which will contain some other words as string

tawdry perch
#

Inconsistent use of tabs and spaces in indentation

slate swan
tawdry perch
tawdry perch
tough lance
#
any(word in message.content for word in dataset)
slate swan
#

what does it mean when its "outside function"

lament mesa
#

some keywords only can be used inside functions, like yield, return and await can only be used in coroutine functions

boreal ravine
#

ids are already unique

#

unless if you pass in an id that isn't a user object

tawdry perch
#

wym compare?

boreal ravine
#

your comparing it

#

using a comparison operator

tawdry perch
#

oh you mean that, I have no idea what I was doing when II did that

boreal ravine
#

and the user variable is useless

velvet tinsel
velvet tinsel
#

We don’t talk about that

graceful mulch
#

hUh

#

my bot is having a big blunder

velvet tinsel
#

ok

graceful mulch
#

Pls help

#

So the errors are

boreal ravine
#

yes

graceful mulch
#

That forbidden

#

discord.errors.Forbidden: 403 Forbidden (error code: 50007): Cannot send messages to this user

#

object member not subscriptive

maiden fable
lament mesa
#

the user probably have they're dms closed

graceful mulch
#

is the error object 'member not subsriptive'

graceful mulch
boreal ravine
graceful mulch
#

No

boreal ravine
#

yes

tawdry perch
#

I'm in need of a lot of code rewriting but I don't have energy to do that

graceful mulch
#

Just like ...

boreal ravine
graceful mulch
boreal ravine
graceful mulch
#
@client.command(aliases=['bal'])
async def balance(ctx ,user: discord.Member = None):
  
  if user is None:
    #test
    await open_account(ctx.author)
    user = ctx.author

    users = await get_bank_data()

    wallet_amt = users[str(user.id)]["wallet"]
    bank_amt = users[str(user.id)]["bank"]
    em = discord.Embed(title=f'{ctx.author.name} Balance',color = discord.Color.blurple())
    em.add_field(name="Wallet Balance", value=f'֍{wallet_amt}')
    em.add_field(name='Bank Balance',value=f'֍{bank_amt}')
    await ctx.send(embed= em)
  else:
    await open_account(user)

    users = await get_bank_data()

    wallet_amt = users[str(user.id)]["wallet"]
    bank_amt = users[str(user.id)]["bank"]

    em = discord.Embed(title=f'{user} Balance',color = discord.Color.blurple())
    em.add_field(name="Wallet Balance", value=f'֍{wallet_amt}')
    em.add_field(name='Bank Balance',value=f'֍{bank_amt}')
    await ctx.send(embed= em)```
boreal ravine
#

bruh.

tawdry perch
#

It's also so messy file structure that it's hard to read in editor

graceful mulch
#

now check

tawdry perch
#

I have so many features that I would have to implement but it takes so long

graceful mulch
#

So

boreal ravine
#

just do it

#

rome wasn't built in a day

graceful mulch
#

Whats is your point

#

ik

#

PLS HELP ME

boreal ravine
tawdry perch
#

I don't have a lot of time ;-;

graceful mulch
#

wait

boreal ravine
tawdry perch
#

I'm trying to stay doing a feature but I start doing another one and I end up with about 4 unworking commands most of time

graceful mulch
#

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

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/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: 'Member' object is not subscriptable

unkempt canyonBOT
#

Hey @graceful mulch!

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

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

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

https://paste.pythondiscord.com

boreal ravine
#

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

graceful mulch
#

Ignoring exception in command balance:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 811, in balance
await open_account(user)
File "main.py", line 1372, in open_account
user[str(user.id)]['career'] = 'None'
TypeError: 'Member' object is not subscriptable

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

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/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: 'Member' object is not subscriptable
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 1649, in on_message
await level_up(users, message.author,message.channel, message.guild)
File "main.py", line 1721, in level_up
await user.send('{} has leveled up to Level {} in {}'.format(user.mention, lvl_end,server))

#

File "/opt/virtualenvs/python3/lib/python3.8/site-packages/dislash/application_commands/_modifications/old.py", line 160, in send_with_components
data = await send_message(state.http, channel.id, content, tts=tts, embed=embed,
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50007): Cannot send messages to this user

tawdry perch
#

Their DMs are closed

boreal ravine
#

hmm

graceful mulch
#

I asked them

tawdry perch
#

"cannot send messages to this user" and it raised forbidden

graceful mulch
#

what about the balance command thing

boreal ravine
graceful mulch
#

to it

graceful mulch
#

Whats this not subscriptibe

tawdry perch
graceful mulch
#

but why cant I do the balance part

tawdry perch
#

You are getting a member object from somewhere?

graceful mulch
#

no

boreal ravine
#

ah

graceful mulch
#

a discord.Member

#

simple

shadow wraith
#

how to set slowmode with the bot (for custom slowmodes like 3s, 6s)

boreal ravine
#
  File "main.py", line 811, in balance
    await open_account(user)
  File "main.py", line 1372, in open_account
    user[str(user.id)]['career'] = 'None'
TypeError: 'Member' object is not subscriptable
``` show line 1372
graceful mulch
boreal ravine
unkempt canyonBOT
#

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

Edits the channel.

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

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

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

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

Here is it sir

shadow wraith
#

pithink show me an example

boreal ravine
graceful mulch
#

wait

shadow wraith
#

i understand from those

graceful mulch
boreal ravine
#

ur json whatever is called users

tawdry perch
boreal ravine
#

why do you need an example if you understand already

graceful mulch
#

Here is what the json looks like

shadow wraith
#

no i mean

#

i meant i only understand from examples :troll:

boreal ravine
tawdry perch
#

You mean you want premade code?

boreal ravine
#

then come here back and tell me what dont you understand πŸ™

shadow wraith
#

ok ig

graceful mulch
#

I think i got an error solved

boreal ravine
#

yes

graceful mulch
#

the last two had user

#

not users

boreal ravine
shadow wraith
#

oh yeah and ctx.channel.edit(...) also works right?

graceful mulch
#

It is working

boreal ravine
#

i literally told you to do that πŸ™ƒ

graceful mulch
#

Love it

graceful mulch
#

Thank you

shadow wraith
boreal ravine
#

πŸ‘Œ

graceful mulch
#
import discord
from discord.ext import commands


class Slowmode(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.Cog.listener()
    async def on_ready(self):
        print("Slowmode cog loaded successfully")

    @commands.command(aliases=["slow"], description="Changes the slowmode of channel")
    @commands.has_permissions(manage_channels=True)
    async def slowmode(self, ctx, seconds: int):
        if seconds <= 21600 and seconds > 0:
            embed = discord.Embed(Title=f"Slowmode ", color=0xFF0000)

            embed.add_field(
                name=f"Slowmode Changed !",
                value=f"Slowmode is now set to {seconds} seconds",
            )
            embed.set_image(
                url="https://media1.tenor.com/images/27b559e217424b733741a34f4a5c24c6/tenor.gif"
            )

            embed.set_footer(
                text=f"Requested By: {ctx.author.name}",
                icon_url=f"{ctx.author.avatar_url}",
            )

            await ctx.channel.edit(slowmode_delay=seconds)

            await ctx.send(embed=embed)

        else:
            await ctx.send("Slowmode cannot be more than 21600 seconds or 0 and less")

    @commands.command(aliases=["rslow"], description="Changes slowmode back to 0")
    @commands.has_permissions(manage_channels=True)
    async def resetslow(self, ctx):

        embed = discord.Embed(Title=f"Slowmode ", color=0xFF0000)

        embed.add_field(name=f"Slowmode Changed !", value=f"Slowmode is now set to 0")

        embed.set_footer(
            text=f"Requested By: {ctx.author.name}", icon_url=f"{ctx.author.avatar_url}"
        )

        await ctx.channel.edit(slowmode_delay=0)

        await ctx.send(embed=embed)


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

You can use this cog

#

@shadow wraith

graceful mulch
#

Example

#

Given

boreal ravine
#
  1. dont spoonfeed
  2. you dont need a whole cog for changing slowmode
graceful mulch
#

<@&267628507062992896> pls remove the slowmode

shadow wraith
boreal ravine
#

...

shadow wraith
#

oh

boreal ravine
#

uh oh

slate swan
shadow wraith
#

i get it so ctx.channel.edit(slowmode_delay=int)

graceful mulch
shadow wraith
#

got it

neon harbor
boreal ravine
graceful mulch
#

:wow:

tawdry perch
#

did someone just ping admins to get rid of slowmode..?

#

ye ik

shadow wraith
graceful mulch
#

Hello

boreal ravine
#

theres a nsfw check iirc

#

!d discord.ext.commands.is_nsfw

unkempt canyonBOT
#

@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.

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

Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
boreal ravine
tawdry perch
#

I just realized I have made 2 mute commands, 1 that just mutes and second that mutes as well, but has a timer (tempmute)

#

as well the tempmute does not even work, because it never unmutes for some reason ;-;

boreal ravine
#

sad

tawdry perch
#

I remember the good time when it worked... (I still have not even touch the code but it just broke)

lament mesa
#

relatable

tawdry perch
#

I can't even push my current changes to guthub;-;

#

Now I found out why.. Conflicting histories, requires merging lemon_angrysad

tame marsh
#
@bot.event
async def on_raw_reaction_add(payload:disnake.RawReactionActionEvent):
    member = disnake.utils.get(bot.get_all_members(), id=payload.user_id)
    if payload.message_id == 916440449122701382:
        if payload.emoji == "πŸŽ“":
            print("hi")    
            await member.edit(roles=[disnake.Object(915935303628361780)])
        elif payload.emoji.name == ":youtube:916431078909181962":
            await member.edit(roles=[disnake.Object(915935303653531658)])
        elif payload.emoji.name == ":youtubeping:916434557115457586":
            await member.edit(roles=[disnake.Object(915935303607406625)])
        elif payload.emoji == "🎭":
            await member.edit(roles=[disnake.Object(915935303317991433)])
        elif payload.emoji == "πŸ’―":
            await member.edit(roles=[disnake.Object(915935303607406623)])```
does someone know why this isnt working?
maiden fable
#

What's the error

tame marsh
#

none

#

it gets called but but nothing else

#

so if i do before the member define print("hi")

maiden fable
#

Is it printing hu?

tame marsh
#

ill get sth

maiden fable
#

Hi*

tame marsh
maiden fable
#

Okay

tame marsh
#

forgott to remove that

#

but it doesnt get filtered

maiden fable
#

So it isn't printed?

tame marsh
#

no

maiden fable
#

Ah

tame marsh
#

it only prints of i put it before the message or after the message check

maiden fable
#

Try printing payload.emoji

tame marsh
#

but not later

#

its reloading 1 sec

maiden fable
#

Sire

#

Sure***

tame marsh
#

thanks for you help

tame marsh
maiden fable
#

The same one?

tame marsh
#

yes

maiden fable
#

Hmm

tame marsh
#

and it goes to the checks now

maiden fable
#

Try printing the message id then

tame marsh
#

lol

#
2021-12-08T11:03:19.453777+00:00 app[worker.1]: πŸŽ“
2021-12-08T11:03:20.116824+00:00 app[worker.1]: :youtubeping:
2021-12-08T11:03:20.116836+00:00 app[worker.1]: youtubeping
2021-12-08T11:03:20.855127+00:00 app[worker.1]: :youtube:
2021-12-08T11:03:20.855146+00:00 app[worker.1]: youtube
2021-12-08T11:03:21.404070+00:00 app[worker.1]: πŸ’―
2021-12-08T11:03:21.404084+00:00 app[worker.1]: πŸ’―
2021-12-08T11:03:24.877535+00:00 app[worker.1]: 🎭
2021-12-08T11:03:24.877543+00:00 app[worker.1]: 🎭```
#
async def on_raw_reaction_add(payload:disnake.RawReactionActionEvent):
    member = disnake.utils.get(bot.get_all_members(), id=payload.user_id)
    print(payload.emoji)
    if payload.message_id == 916440449122701382:
        print(payload.emoji.name)
        if payload.emoji == "πŸŽ“":  
            await member.edit(roles=[disnake.Object(915935303628361780)])
        elif payload.emoji.name == ":youtube:916431078909181962":
            await member.edit(roles=[disnake.Object(915935303653531658)])
        elif payload.emoji.name == ":youtubeping:916434557115457586":
            await member.edit(roles=[disnake.Object(915935303607406625)])
        elif payload.emoji == "🎭":
            await member.edit(roles=[disnake.Object(915935303317991433)])
        elif payload.emoji == "πŸ’―":
            await member.edit(roles=[disnake.Object(915935303607406623)])```
#

@maiden fable so the message check works

#

but where does it fail?

maiden fable
#

Hmm

#

Wait wait wait

tame marsh
#

after the emoji check

#

oh

#

i see....

maiden fable
#

Haha u see now?

tame marsh
#

thats why the custom emojis arent working

#

but still

maiden fable
#

The emoji is a custom one, seems like

tame marsh
#

yes

maiden fable
tame marsh
#

that gives it with <>

maiden fable
#

U can't compare a custom emoji

#

Ah the full name?

#

Not recommended

#

If the person changes the emoji name, your code breaks. But the emoji id never changes

tame marsh
#

so it uses it over nitro perms

maiden fable
#

Okay

slate swan
#

why sql database isnt getting updated in a gethub repo after a discord command is used i am using heroku to host

tame marsh
#

i could try printing member

tame marsh
visual island
slate swan
#

there are some people saying to push the repo and i tried and keep getting errors i installed git and even added the path

tiny ibex
#

Bots have to pass the nsfw filter too?

lament mesa
tiny ibex
slate swan
#

used and got these 2 errors

error: failed to push some refs to 'origin'
error: src refspec main does not match any

lament mesa
slate swan
lament mesa
#

run it again

slate swan
lament mesa
slate swan
#

cannot do anything

grim oar
#

Using vim +1

#

Btw how to save in it

wild imp
#

guys anyway i could get free vps without cc

slate swan
#

no

grim oar
#

Yes but people want you to believe there's none ;)

wild imp
#

sad really need one but oo yeah ik i

wild imp
#

it could help me in more ways

grim oar
#

But it comes with a huge cost so I wont

wild imp
#

breh

#

np but i really need one xD.
i am trying to find vps for months

#

free*

grim oar
slate swan
#
@Blank.event
async def on_message_edit(before, after):
    await Blank.process_command(after)```Will this work??
wild imp
grim oar
wild imp
#

ok lol

slate swan
maiden fable
#

Ah yea

#

That's gonna work then

slate swan
#

!e```
class a:
a=1

class b:
print(a)```

unkempt canyonBOT
#
Did you mean ...

empty-json
except
environments
enumerate
exit()
for-else

slate swan
#

.

maiden fable
#

Lol

slate swan
#

.help eval

#

!d help

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
slate swan
grim oar
#

πŸ₯΄ what you doing

slate swan
#

idk :>

#

!e```py
class a:
a=1

class b:
print(a.a)```

#

why not evaluating -_-

grim oar
#

call b

slate swan
#

why b

grim oar
#

b()

slate swan
#

ooo lel

#

!e```
class a:
a=1

class b:
print(a)```

b()

unkempt canyonBOT
#
Did you mean ...

empty-json
except
environments
enumerate
exit()
for-else

slate swan
#

whit

grim oar
#

Bro moment

slate swan
#

!e```
class a:
a=1

class b:
print(a)

b()```

supple thorn
slate swan
#

nvm

supple thorn
#

!e

class a:
    a=1

class b:
     print(a)

b()
unkempt canyonBOT
#

@supple thorn :white_check_mark: Your eval job has completed with return code 0.

<class '__main__.a'>
supple thorn
slate swan
#

guys anyone know any rest api which can save image in their server (from link) and return the new link??

mystic grotto
#

uhm

royal lichen
#

What's the error?

tawdry perch
mystic grotto
#

so when i run the program the bot comes online and all

boreal ravine
royal lichen
#

At the bottom of the traceback what type of exception is it?

mystic grotto
#

there is an attribute error and a runtime error

boreal ravine
mystic grotto
#

im kinda a noob to python so sorry if i seem dumb

royal lichen
boreal ravine
#

just show the full error

mystic grotto
#

ya wait

boreal ravine
#

it's find_one

royal lichen
#

I already answered this yesterday I think? You've called find.one not find_one

mystic grotto
#

LOL

#

must be another time i called the variable

#

not varible sry

royal lichen
#

its still there

mystic grotto
#

you get what i mean

boreal ravine
#

show line 51

mystic grotto
#

k i changed it

boreal ravine
#

try it again ig

mystic grotto
#

ye

velvet tinsel
#

Hi Kayle

boreal ravine
#

yo

#

πŸ‘‹

velvet tinsel
#

how are You

#

all the mods hate me

boreal ravine
boreal ravine
velvet tinsel
mystic grotto
boreal ravine
mystic grotto
#

rntime error: event loop is closed

#

runtime*

boreal ravine
#

yes, but show the full error

velvet tinsel
#

full error

#

Maybe wrong token

boreal ravine
#

πŸ—Ώ

mystic grotto
#

yeah im covering up my IRL name

#

LOL

boreal ravine
#

ah ok

velvet tinsel
#

No

#

You didn’t show the entire error

mystic grotto
#

i am sending it calm

royal lichen
#

They're gonna post it, they're just covering their name

mystic grotto
#

but yeah sending the full error

royal lichen
boreal ravine
#

calm down πŸ’€ πŸ˜‚

mystic grotto
#

bruh its another error when im calling on pymongo

boreal ravine
mystic grotto
mystic grotto
boreal ravine
mystic grotto
#

so i changed the url and im not getting an error with that anymore

tardy swallow
#

so i printed a list of user roles and it looks like this:
[<Role id=776775547580579872 name='@everyone'>, <Role id=918105235463995403 name='2'>, <Role id=816361294257061938 name='1'>]
How do I get only the roles IDs?

mellow basin
#

yo i need help when i join my server i dont get a private dm form the bot why is that?

#

or it is not giving roles

boreal ravine
mystic grotto
boreal ravine
#

hm

mystic grotto
#

i checked my code multiple times

boreal ravine
mystic grotto
#

ik

boreal ravine
#

are there any more errors that might help

mystic grotto
#

no

#

this is the only error im getting

boreal ravine
#

hmm

mellow basin
#

umm

#

help

mystic grotto
#

i keep getting the same error

loud junco
#
@bot.command(name='ping')
@commands.cooldown(1, 1, commands.BucketType.user)
#

i have many command like this

#

how do i show different cooldown?

mystic grotto
#

omfg i think i found the error, i made a variable called levelamt but where i needed to use it i called levelnum

final iron
lament mesa
boreal ravine
mystic grotto
#

nvm im still getting the same error

#

bruh moment

loud junco
#

i wanna make a command to show all of them

boreal ravine
#

O

mellow basin
boreal ravine
#

hmm

loud junco
#

i have the buckettype thing

#

but idk how to show

#
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandOnCooldown):
    await ctx.send(f'This command is on cooldown, you can use it in **{round(error.retry_after, 2)}** seconds')
  else:
    raise error
tame marsh
loud junco
#

its like this

mellow basin
mystic grotto
#

bruh still

sage otter
mystic grotto
#

the second part is when i shut it down, the first part is when i send a message on the server. its a leveling bot fyi

sage otter
#

If so this is normal behavior. This has already been acknowledged in discord.py. Especially normal for windows users.

#

As far as the shutdown part

mystic grotto
#

no but there is a huge error which comes when i send a message, and on top of that

  1. my xp is not being counted
  2. i know that because i checked the database where i am storing the xp
sage otter
#

have you shown code yet…

mystic grotto
#

i shared it yest but no one was able to help

#

ill share again

#

@sage otter

visual island
#

@mystic grotto can you show the entire traceback?

mystic grotto
#

its really long

#

ill send a full ss

visual island
#

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

mystic grotto
#

you mean the thing that happens in the console when i run it and send a message right

visual island
#

yes

mystic grotto
#

ok wait