#Allgemeine Hilfe
1 messages · Page 32 of 1
ja
Aber ist schon ironisch nach der aussage xd
ist eine sache zwischen uns da hast du dich ´nicht einzumischen 😉
Cric Eartman
Dann klär das in den Dm's, aber nicht hier
ok Cric Eartman
Wie sich Bobby nach der Aussage fühlt:
https://tenor.com/view/gentleman-giga-chad-sigma-male-gif-25702945
sowas schreibst du dann und brauchst dabei hilfe xD

lmao
junge wer bist du denn jetzt hahah stifte kein fitna
Nimms ihm nicht böse, gibt paar Menschen, die keine Errors lesen können
wait
Link button?
In wiefern, "ins on ready"?
Du machst nen link button und schickst ihn irgendwo halt ab
Link Button weiß man was gemeint ist Bobby
ich weiß aber warum ins on ready
Wird bestimmt seine gründe haben.
server = discord.ui.Button(label="Support Server", url="link")```
und eben dann noch view.add_item(server)
ja ich auch xD
Asso persistent
🤔
url buttons sind automatisch persistant
Idk ignorier das
ein easteregg zum 1.april
Also, wie timo sagte, sind die Buttons wohl automatisch persistent
Aber wenn du andere Buttons hast, die du persistent machen möchtest, kannst du dich hier orientieren
wow

Maschine 💪
Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.
Leuudeee nicht hier
weiss einer die mehr button machen
?
also wie kann man bei ein code mehr button machen
einfach mehrere buttons in ein view machen
geht bei mir nicht
https://discord.com/invite/codingkeks[]()Bester Server EU-West
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
,,
hat nicht bei dir gunktioniert brd
kann ich irgendiwe mehr als ein bot auf einem server hosten?
z.B. bei .env :
TOKEN = ASIJDIUASHDJOUAI SHDUHASVZDHASCZDNZSCD, ASUDHAUHSDUAIHSDUOAHUSIDHAS
halt ein komma machen
Du kannst mit deinem Coden nur einen Bot runnen
das kommt drauf an auf was für einem server du sie hostest, bzw welcher anbieter
#1019974414487535736 message
#1098241669243076650
weiss jeamdn was da los ist? ```Traceback (most recent call last):
File "C:\Users\Pfist\PycharmProjects\NoePixel\venv\lib\site-packages\discord\cog.py", line 774, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\Pfist\PycharmProjects\NoePixel\cogs\ticket.py", line 90, in <module>
class UserChoiceView(discord.ui.View()):
File "C:\Users\Pfist\PycharmProjects\NoePixel\venv\lib\site-packages\discord\ui\view.py", line 183, in init
loop = asyncio.get_running_loop()
RuntimeError: no running event loop
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Pfist\PycharmProjects\NoePixel\main.py", line 21, in <module>
bot.load_extension(f"cogs.{filename[:-3]}")
File "C:\Users\Pfist\PycharmProjects\NoePixel\venv\lib\site-packages\discord\cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Pfist\PycharmProjects\NoePixel\venv\lib\site-packages\discord\cog.py", line 777, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.ticket' raised an error: RuntimeError: no running event loop```
keksboth hosting
class UserChoiceView(discord.ui.View()) -> class UserChoiceView(discord.ui.View)
stimmt danke
Wie mache ich das so das in ein ModalTextFeld nur zahlen geschrieben werden?
das kannst du leider nur prüfen, nachdem der user auf senden gedrückt hat
Code:
@slash_command(description="make the bot say something")
@commands.has_permissions(administrator=True)
async def say(self, ctx, Title, Text):
embed = discord.Embed(
title=f"{Title}",
description=f"{Text}",
color=discord.Color.red()
)
await ctx.respond(embed=embed)```
Error:
```IndentationError: expected an indented block after function definition on line 12
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/main.py", line 21, in <module>
bot.load_extension(f"cogs.{filename[:-3]}")
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 777, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.Custom' raised an error: IndentationError: expected an indented block after function definition on line 12 (Custom.py, line 13)```
@commands.has_permissions(administrator=True) ist falsch eingerückt
ah ok
Das embed ein tab nach rechts
ja stimmt
Bzw alles bei embed
Das embed ein tab nach rechts
alles nach say() eins rechts
ein tab bzw 4 leertatsen

ctx.respond ist schon richtig
okay danke
Ah stimmt xD
Jmd Bock mir zu erklären wir Modals funktionieren?
Also wie man die Codes und auf das was die beinhaltet bekommt? Xd
Wieso wird das callback vom modal nd respondet?
@discord.ui.button(label="Loslegen", style=discord.ButtonStyle.gray, emoji=f"🎈", custom_id="loslegen", row=2)
async def button_callback3(self, button, interaction):
with open('accounts.json', 'r', encoding='utf-8') as f:
accounts = json.load(f)
if str(interaction.user.id) in accounts:
await interaction.response.send_message("Du hast bereits einen Account.", ephemeral=True)
return
else:
await interaction.response.send_modal(accountmodal(title="Account erstellen"))
import discord
from discord.ext import commands
from discord.commands import slash_command
class Test(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(description="make the bot say something")
@commands.has_permissions(administrator=True)
async def text(self, ctx, title, text):
embed = discord.Embed(
title=f"{title}",
description=f"{text}",
color=discord.Color.red()
)
await ctx.respond(embed=embed)
def setup(bot):
bot.add_cog(Test(bot))``` hier ist er fix
schau am besten auf timos github nach
da kannst du runterkopieren und auf deine bedürfnisse anpassen du musst dann ein paar zusammenhänge knüpfen und dann kannst du machen was du willst
was meist du ?
Will ja mit jmd call das geht besser. Tuto hab ich schon angeschaut
das callback vom accountmodal was der button respondet geht nicht
ich weiss sehr nicht
hab grad keine zeit
hast du ein error
aber probier doch einfach mal ein bisschen rum und frag wen etwas nicht geht
Also callback wird nd getriggert?
nein
ja
Hatte ich auch… haste in der view davor noch mehr Button? Also in der class
komm du ein error in discord ?
nein ist nur ein button in der view
ja das normale wenn beim absenden des modals nichts passiert
Ig: diese Interaktion ist fehlgeschlagen
hab noch nh view mit nem button wo es aber geht
Dann nenn das callback mal callback und nd callback3. Also die 3 weg
save
Ig: diese Interaktion ist fehlgeschlagen ?
ja genau
mach ich moment
Du hast 1 Wort verändert 
wie kann ich einen user permissions zu einem channel geben?
Beim erstellen?
ne später
channel definieren dann channel.set_permissions
ok danke
hat nichts gebracht
Zeig mal den Code auf nem screen
wait ich schick dir nen screenshot per dm
was muss ich dann angeben?
hat sich erledigt
Ok
wie kann man auf die jetzige zeit zugreifen?
datetime.datetime.now()
muss ich dafür was importieren?
jo danke mach ich dann morgen 👍
Und wenn du es dir leichter machen magst noch From datetime Import datetime dann musst du nur Datetime.now schreiben
jo danke
kd 🙂
unterstrich statt .
import discord
from discord.ext import commands
from discord.commands import slash_command
class Boostime(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="bosttime", descriptime="zeigt dir die Boostzeit an!")
async def boostime(self, ctx):
boostzeit = ctx.author.premium_since
if boostzeit is None:
await ctx.respond(content="du hast keinen Boost!")
else:
boostzeit = ctx.author.premium_since
boostzeit = boostzeit.strftime("%d.%m.%Y %H:%M:%S")
await ctx.respond(content=f"dein Boost läuft bis zun:{boostzeit}")
def setup(bot):
bot.add_cog(Boostime(bot))``` hier hab dem code gefix
weiss ein wie kann man so was in embeds machen
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
Code auf Github
► https://github.com/tibue99/tutorial-bot
Tutorial Playlist
► https://youtube.com/playlist?list=PLwRWzD1Sw5lXZApchxorxeBQ_P_Fjdsj1
Discord Developer Portal
► https://discord.com/developers/applications
Pycord
Docs ► https://docs.pycord.dev/
Guide ► https://guide.pycord.dev/i...
if result2 == 0:
@commands.has_permissions(administrator=True)
embed = discord.Embed(
title="Level system Deaktiviert!",
description="Aktiviere das Levelsystem für den Befehl.",
color=discord.Color.red()
)
embed.set_thumbnail(url=self.bot.user.avatar.url)
await ctx.respond(embed=embed)
if result2 == 1:
desc = ""
counter = 1
async with aiosqlite.connect(self.DB) as db:
async with db.execute(
"SELECT user_id, guild_name, xp FROM users WHERE msg_count > 0 ORDER BY xp DESC LIMIT 3"
) as cursor:
async for user_id, guild_name, xp in cursor:
if guild_name == ctx.guild:
desc += f"{counter}.<@{user_id}> - {xp} XP\n"
counter += 1
else:
print("keine rankings gefunden")
embed = discord.Embed(
title="Rangliste",
description=desc,
color=discord.Color.yellow()
)
embed.set_thumbnail(url=self.bot.user.avatar.url)
await ctx.respond(embed=embed)
Expected function or class declaration after decorator
wann ist result 0 oder 1
wie würdest du das machen?
ob es integer ist oder wenn nur Zahlen
wenn du mich meinst das wird asu der datenbank gelsen und über buttons eingestellt aber das ist ja nciht der punkt sondern das nach dem @commands... die funktion erwartet wird
🤨
warum so skeptisch am schauen?
Tatsächlich verstehe ich nicht was du meinst
naja der result null ist ein wert aus der datenbank und ich möchte wenn er null ist das user den befehl nicht ausführen können
Und wieso kommt der Wert aus der db kannst den doch einf mit if member.has_permissions machen 🤨
der wert hat mit den permissions nichts direkt zu tun der ist für einen allgemeinen check nötig aber der has permissions ist die frage gewesen
und wie das ist doch etwas das nur bei @commands.permission geht oder nicht?
Nö
weil passiert gar nichts ausser das member keine has_permissions hat
Hm eig schon
hast du in den docs eine nverweis drauf grade zur hand?
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
Code auf Github
► https://github.com/tibue99/tutorial-bot
Command Checks für Variante 2
► https://gist.github.com/Painezor/eb2519022cd2c907b56624105f94b190
Tutorial Playlist
► https://youtube.com/playlist?list=PLwRWzD1Sw5lXZApchxorxeBQ_P_Fjdsj1
Discord Developer Portal
► https://discord.com...
schau evtl mal hier
da ist es immernoch nicht so drinnen wie ich es brauche hatten wir gestern ja schonmal das thema xD
es soll nach der if abfrage im slash command asugeführt werden xD
denn wenn die andere bedingung erfüllt wird soll code ausgeführt werden xD
gibt mehrere Möglichkeiten, schau Mal in den Docs bei member (guild_permission) oder bei permission_for
also bei guild permission werdeichnicht schlau was die id ziffern sind die als ausgabe zurück kommen xD also wüsste ich nicht wie ich die abgleichen soll xD
schau dir Mal an von welchen Typ die Rückgabe ist
permissions zummindes im permission_for
aber im guild_permissions steht nichts bei
zur not kannst du dir den Typ auch immer Printen lassen in Python
dann kannst du in den Docs nachschauen, was du mit diesem Typ machen kannst
aber was ich nicht ganz verstehe ist wie würde ich das nun prüfen
schau Mal in den Docs was du alles mit dem Typ "permission" machen kannst
naja könnte sie abgleichen aber da steht mir nich eindeutig genug wie ich das prüfe denn es bringt mir ja nichts wenn da random buchstaben abgeglichen werden muss ja wissen wie die gegenseite auszusehen hat
wieso random Buchstaben? ich bin nicht ganz sicher, welche Gegenseite du meinst, aber schau Mal was es dort alles für Attribute gibt, die kannst du alle nutzen
also ich bekomme angezeigt das es diese klasse gibt bei permissions . class discord.Permissions(permissions=0, **kwargs)
da gehen diese vergleiche x == y Checks if two permissions are equal.
aber das bringt mir nichts da ich nicht weiss was ich vor dem fragezeichen eingeben soll da egal was ich wie eingebe nichts klappt
welches Fragezeichen? schau dir lieber die Attribute an
nanana
Attribute anschauen
nicht die Vergleiche
das ist nur wenn du 2 permission Objekte vergleichen willst
so bin aber jetzt auch schlafen, gute Nacht 
gute nacht
besteht die möglichkeit wenn ein user eine gewisse permission nicht erfüllt den befehl unsichtbar zu machen also dass er ihn nicht angezeigt bekommt? also per code nicht integration.
Kann man in einem modal als input einen user verlangen?
könntest nh userid verlangen und im callback checken ob es nh richtige member id is
ja aber ob es halt wie beim slash cmd geht
nein das geht nicht
schade
weiss wie geht das ?
discord. default_permissions ist die einzige Möglichkeit
bot muss verifiziert sein glaube ich
wie geht das ?
ab 75 servern
wie geht das ?
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
Code auf Github
► https://github.com/tibue99/tutorial-bot
Tutorial Playlist
► https://youtube.com/playlist?list=PLwRWzD1Sw5lXZApchxorxeBQ_P_Fjdsj1
Discord Developer Portal
► https://discord.com/developers/applications
Pycord
Docs ► https://docs.pycord.dev/
Guide ► https://guide.pycord.dev/i...
Aber ist der dann nicht immer unsichtbar? Weil der möchte ja nach der Default permission eine Funktion oder Klasse haben
nur wenn der User die Berechtigung nicht hat
genau und dass soll ja nicht immer so sein weil ich müsste ja mit berechtigungen arbeiten die nicht für normale user gedacht sind verstehst du wie ich meine
ok anders es soll so sein das der status aus der datenbank genommen wird ist er 0 soll der befehl unsichtbar sein und nur admins können den sehen und wenn der1 ist sollen ihn die user nutzen können.
wüsste nicht wie das geht
ok mies schade danke
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Mein Hosting* ► https://tidd.ly/3gJufg6
Code auf Github ► https://github.com/tibue99/tutorial-bot
PYCORD
Docs ► https://docs.pycord.dev/
Guide ► https://guide.pycord.dev/introduction/
Discord Server ► https://discord.gg/pycord
Discord Developer Portal ► https://discord...
nein
warte ich send dir mein code
guck dm
error:
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 774, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/container/cogs/Custom.py", line 6, in <module>
class Test(commands.Cog):
File "/home/container/cogs/Custom.py", line 22, in Test
@command.has_permissions(administrator=True)
NameError: name 'command' is not defined. Did you mean: 'commands'?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/main.py", line 22, in <module>
bot.load_extension(f"cogs.{filename[:-3]}")
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 777, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.Custom' raised an error: NameError: name 'command' is not define```
Code:
```py
@slash_command(description="Clear an amount of messages")
@command.has_permissions(administrator=True)
async def clear(self, ctx, amount):
await ctx.channel.purge(limit=amount)
await ctx.respond(f"Cleared {amount} messages")
ups hab bei den permissions ein s vergessen
Application Command raised an exception: TypeError: '>' not supported between instances of 'str' and 'int'
hm
gemäss den tos von discord ist es verboten musik bon yt abzuspielen nutze am besten eine gratis api musst mal googeln
hab dem dir dem fix gesend
amount muss nen int sein
hast recht
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 774, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 936, in exec_module
File "<frozen importlib._bootstrap_external>", line 1074, in get_code
File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\Rysii\OneDrive\Desktop\ZyroFN bot\cogs\AutoDelete.py", line 14
if isinstance(message.author, discord.Member):
^
IndentationError: expected an indented block after 'if' statement on line 12
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\ZyroFN bot\main.py", line 149, in <module>
bot.load_extension(f"cogs.{filename[:-3]}")
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 777, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.AutoDelete' raised an error: IndentationError: expected an indented block after 'if' statement on line 12 (AutoDelete.py, line 14)
import asyncio
import discord
from discord.ext import commands
class AutoDelete(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message):
if message.channel.id == (108779928507829871):
if isinstance(message.author, discord.Member):
# Überprüfen, ob das Mitglied eine bestimmte Rolle hat
role = discord.utils.get(message.guild.roles, name='[Community]')
if role in message.author.roles:
# Löschen der Nachricht
await asyncio.sleep(3)
await message.delete()
def setup(bot):
bot.add_cog(AutoDelete(bot))
kann wer helfen
schau dir am besten ein grundlegendes Tutorial zu If Bedingungen in Python an, bzw schau dir die einrückung bei python an

Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\mahzz\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\mahzz\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1164, in on_connect
await self.sync_commands()
File "C:\Users\mahzz\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 738, in sync_commands
app_cmds = await self.register_commands(
File "C:\Users\mahzz\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 531, in register_commands
prefetched_commands = await self._bot.http.get_guild_commands(
File "C:\Users\mahzz\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 365, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
du hast wahrscheinlich bei debug_guilds eine server ID angegeben, auf die der bot keinen zugriff hat
ups hast recht timo 👍
code ist im error
Hast du dem Bot eine Dm geschrieben?
Weil wenn du ihm eine Dm Nachricht schickst, dann gibt es keine message.guild
Nein ist nur ein on_message event
Ja, und der wird auch ausgelöst, wenn du dem Bot per Direkt Nachrichten eine Nachricht sendest
Okay, was wäre die Lösung

Denk mal bisschen nach..
Wenn es in Dm's keinen message.guild gibt..
Was kann man dann machen?
Richtig. Überprüfen ob es dms sind

Wie
das tutorial zu den pycord docs hat mir wenig geholfen sry
Denk mal bisschen nach...
if not message.guild:
return
Ist das so schwer? lmao
man kann auch fragen beantworten ohne jedes mal was respektloses dahinter zu schreiben
fahr mal einen gang runter es weiss nicht jeder alles auwendig
achso danke
reicht einmal xD
habe schon angefangen dann wollte ich es auch zu ende bringen xD
bringt mir aber nichts
immer noch der gleiche error 💀
du könntest es mit try, except machen
zeig mal den code
try & except noch nie benutzt
ne brauche den ganzen
schau mal im internet nach ist wirklich sehr nützlich bei zb solchen sachen
Ich bevorzuge diesen channel hier mehr 
Wo setzt du es denn ein?
hier:
@commands.Cog.listener()
async def on_message(self, message):
if not message.guild:
return
lvl5 = discord.utils.get(message.guild.roles, id=1034925220002017280)
lvl10 = discord.utils.get(message.guild.roles, id=1034925534523695215)
lvl20 = discord.utils.get(message.guild.roles, id=1034925953434001489)
lvl30 = discord.utils.get(message.guild.roles, id=1034926492112654417)
lvl40 = discord.utils.get(message.guild.roles, id=1034926920481112095)
lvl50 = discord.utils.get(message.guild.roles, id=1034927048902320148)
if message.author.bot:
return
with open('accounts.json', 'r', encoding='utf-8') as f:
accounts = json.load(f)
if message.author.id in accounts and message.author.id not in data:
data[str(message.author.id)]["credits"] = 0
data[str(message.author.id)]["message_count"] = 0
hab den code geschickt ⬆️
das bringt eigentlich nix weil ein error geworfen wird weil er message.guild noicht findet
aua
muss ich dafür jz guild definieren 💀
@urban glen mach mal am anfang py try: dummy = message.guild except: #den code, den du ausführen willst, wenn eine dm kommt #den code wenn keine dm kommt
try & excepts 
Ich heule gleich
warum
hast du mit message.guild schon
Meiner Meinung nach sollte man try / except's so oft vermeiden, wie möglich xD
Noch nie benutzt 
stimmt
warum
warum also was ist der nachteil
Besser is xD
if & else ist doch eig. das gleiche oder
hab keine ahnung weil ich try & except noch nie eingesetzt hab
@urban glen mach mal das was ich geschickt habe oben
nein überhaupt nicht
Nein?
Gibt halt sehr viele Menschen die try und except blöcke falsch verwenden
also lvl5 = discord.utils.get(dummy.guild.roles, id=1034925220002017280)
... so oder? @umbral goblet
ja aber in diesem kontext sind sie sehr sinnvoll
Vorallem ```py
except:
pass
nein nein
warte
hab's ja auch noch nie benutzt hab dich 2x drauf hingewiesen 💀
if und else ist auf deutsch eig nur wenn und wenn nicht
naja, mit if not message.guild überprüft man, ob eine Guild nicht vorhanden ist, und mit return wird es ab da dann abgebrochen sozusagen
@commands.Cog.listener()
async def on_message(self, message):
try:
dummy = message.guild
except:
# code der ausgeführt werden soll wenn eine dm gesendet wurde und nicht eine nachricht auf dem server
return
lvl5 = discord.utils.get(message.guild.roles, id=1034925220002017280)
lvl10 = discord.utils.get(message.guild.roles, id=1034925534523695215)
lvl20 = discord.utils.get(message.guild.roles, id=1034925953434001489)
lvl30 = discord.utils.get(message.guild.roles, id=1034926492112654417)
lvl40 = discord.utils.get(message.guild.roles, id=1034926920481112095)
lvl50 = discord.utils.get(message.guild.roles, id=1034927048902320148)
if message.author.bot:
return
with open('accounts.json', 'r', encoding='utf-8') as f:
accounts = json.load(f)
if message.author.id in accounts and message.author.id not in data:
data[str(message.author.id)]["credits"] = 0
data[str(message.author.id)]["message_count"] = 0```
nein dann wird geprüft ob message.guild true oder false ist
aber message.guild existiert nicht
ja, wenn nicht vorhanden dann true (aufgrund des not) wenn vorhanden, dann false
Noe logischerweise ist es dann false true
weil not guild true ist
bis eine guild es ist
@urban glen probierst du den Code auch auf nem Server?
ja aber guild ist ja kein bool?!
oder verstehe ich da was falsch
Einiges.
warum meinst du
nein natürlich nicht ahhahahaa 💀
if not message.guild:
-> true (wenn eine guild nicht existiert / NoneType zurückgegeben wird)
-> false (wenn eine guild existiert)
Hast du noch andere on_message events?
geht es?
ja habe mich verlesen sry habe gemeint er gibt ein attributerror zurück aber guild existiert schon er ist einfach none
Wenn none ist, dann existiert keine Guild
Sein on_message wird noch irgendwo anders getriggert, außerhalb eines servers
nein
bin dabei es zu testen moment
@umbral goblet hat tatsächlich funktioniert danke 👑
kd
weiß immer noch nicht wozu dieses dummy dienen soll aber ja
try:
dummy = message.guild
einfach damit versucht wird auf message.guild zuzugreiffen
andersrum
schau dir am bestem das mit try except nochmal genau an
^
Und wenn das nicht klappt, geht es zum except über
genau
datetime
mcdonalds 
oder aufm Stück Salami 😮
Hilfe
zeit = datetime.now()
accounts[str(interaction.user.id)] = {"username": self.children[0].value, "password": self.children[1].value, "created_at": f"{zeit}"}
from datetime import datetime
❤️
weiss wer was ich mit ein discord bot und api machen kann
requests?
ja
Links abrufen.
PS C:\Users\Ich\Downloads\Files\Bot> & C:/Users/Ich/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/Ich/Downloads/Files/Bot/main.py
Traceback (most recent call last):
File "c:\Users\Ich\Downloads\Files\Bot\main.py", line 2, in <module>
from discord.commands import Option
File "C:\Users\Ich\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\__init__.py", line 27, in <module>
from .core import *
File "C:\Users\Ich\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 49, in <module>
from ..enums import MessageType, SlashCommandOptionType, try_enum
ImportError: cannot import name 'SlashCommandOptionType' from 'discord.enums' (C:\Users\Ich\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\enums.py)```
Was hab ich da falsch installiert?
Mit pip krieg ich`s nicht gefixt
Filtere ich so nach Tags?
Wie kann ich denn einen zweiten Button definieren? Mit await channel.send(embed=embed, view=DeleteButton(), Button2()) geht es ja leider nicht.
Bitte Ping bei Antwort 🙂
Danke, hat sich schon wer gemeldet. 😄
musst die in ein View machen
fortnite
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: OperationalError: no such column: user```
async def addwarn(ctx, reasom, user, mod):
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("INSERT INTO warns VALUES (?, ?, ?, ?), (user, reason, time, mod)")
await db.commit()```
Kann mir da wer helfen ?
deine tabelle hat keine user-spalte
Ok
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: OperationalError: no such column: user_id
async def addwarn(ctx, reason, user, mod):
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("INSERT INTO warns VALUES (?, ?, ?, ?), (user_id, reason, time, mod_id)", (user.id, reasom, datetime.datetime.now().timestamp(), mod.id))
await db.commit()```
schau dir die syntax vom insert befehl nochmal genau an
OKAY
danke
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("SELECT reason FROM warns WHERE user_id = ?", (member.id))
data = await cursor.fetchone()```
```sql
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: OperationalError: near "=": syntax error```
Entweder ich bin kommplett dumm oder auch nicht
es muss auf jeden fall ein komma hinter member.id
jap
weil es ein tuple ist
ich weiss lieder nicht wie kann ich da helfen
?
was meist du mit pip geht nicht ?
denke
guck mal bitte hast du py-cord runder geladen
stell am besten direkt deine frage, wenn du nur so etwas fragst weiß niemand ob er dir helfen kann oder nicht
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
Links aus dem Video
GitHub ► https://github.com/
Code auf Github ► https://github.com/tibue99/tutorial-bot
Discord Developer Portal ► https://discord.com/developers/applications
Pycord
Docs ► https://docs.pycord.dev/
Guide ► https://guide.pycord.dev/introduction/
Discord Server ► https://dis...
hab ich
warte ich mache kurz mein code fretig
fortnite
hör mal auf
nein ich mein sowas wie ein wetter command mit ner wetter api
@cloud cedar Shreib hier weiter
was jetzt
sende error und code hier
ok
Code: ```py
import discord
from discord.ext import commands
from discord.commands import slash_command, Option
import aiosqlite
class warn(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
async with aiosqlite.connect("warns.db") as db:
await db.execute(
"""
CREATE TABLE IF NOT EXISTS users(
user_id INTEGER PRIMARY KEY,
warn_count INTEGER DEFAULT 0
)
"""
)
@slash_command(description = "Warne einen User")
async def warn(self, ctx, message, user: Option(discord.member), reason: Option(str, "Warum?")):
async with aiosqlite.connect("warns.db") as db:
await db.execute(
"INSERT OR IGNORE INTO users (user_id) VALUES (?)", (user.id,)
)
await db.execute(
"UPDATE users SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id)
)
await db.commit()
embed = discord.Embed(title="Verwarnung", color=discord.Color.brand_red(), description=(f"{user} wurde verwarnt!"))
ctx.respond(embed = embed, ephemeral = True)
def setup(bot):
bot.add_cog(warn(bot))```
ERROR:
angehängte.txt
gar nicht, du kannst aber mehrere elemente zu einem view hinzufügen
das M bei discord.Member muss groß geschrieben werden
JA ER IST ONLINE!!! danke

async def addwarn(ctx, reason, user, mod):
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("INSERT INTO warns (user_id, reason, time, mod_id) VALUES (?, ?, ?, ?)", (user.id, reason, datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), mod.id))
await cursor.execute("UPDATE warns SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id))
await db.commit()```
```py
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: parameters are of unsupported type```

kannst du den ganzen error schicken?
warte
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "E:\Community Bots\Own Community\cogs\warns.py", line 28, in warn
await addwarn(ctx, reason, member, ctx.author)
File "E:\Community Bots\Own Community\cogs\warns.py", line 71, in addwarn
await cursor.execute("UPDATE warns SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id))
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 31, in _execute
return await self._conn._execute(fn, *args, **kwargs)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 137, in _execute
return await future
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 110, in run
result = function()
ValueError: parameters are of unsupported type
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\ezcord\bot.py", line 183, in _error_event
raise error
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: parameters are of unsupported type
async def addwarn(ctx, reason, user, mod):
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("INSERT INTO warns (user_id, reason, time, mod_id) VALUES (?, ?, ?, ?)", (user.id, reason, datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), mod.id))
await cursor.execute("UPDATE warns SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id,))
await db.commit()```das komma muss noch hin nach user.id
neuer error?
nope
async def addwarn(ctx, reason, user, mod):
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("INSERT INTO warns (user_id, reason, time, mod_id) VALUES (?, ?, ?, ?)", (user.id, reason, datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), mod.id))
await cursor.execute("UPDATE warns SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id),)
await db.commit()```
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "E:\Community Bots\Own Community\cogs\warns.py", line 28, in warn
await addwarn(ctx, reason, member, ctx.author)
File "E:\Community Bots\Own Community\cogs\warns.py", line 71, in addwarn
await cursor.execute("UPDATE warns SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id),)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 31, in _execute
return await self._conn._execute(fn, *args, **kwargs)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 137, in _execute
return await future
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 110, in run
result = function()
ValueError: parameters are of unsupported type
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\ezcord\bot.py", line 183, in _error_event
raise error
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\pogod\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: parameters are of unsupported type
ohh habe das nicht gesehen
aber jetzt ist das so aber ich will das der nur den count updatet wie mache ich das ?
du musst nur das untere statment ausführen weil das ober macht jedes mal eine neue zeile. also beim ersten war dann nur das erste und bei den anderen malen das 2
ok
jo
INSERT OR IGNORE machen
ne macht immernoch mehr
error
keiner
code?
async def addwarn(ctx, reason, user, mod):
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("INSERT OR IGNORE INTO warns (user_id, reason, time, mod_id) VALUES (?, ?, ?, ?)", (user.id, reason, datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), mod.id))
await cursor.execute("UPDATE warns SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id,))
await db.commit()```
hast du die user_id als primary key festgelegt?
ne
nope
code
async def addwarn(ctx, reason, user, mod):
db = await aiosqlite.connect("warns.db")
async with db.cursor() as cursor:
await cursor.execute("INSERT OR IGNORE INTO warns (user_id, reason, time, mod_id) VALUES (?, ?, ?, ?)", (user.id, reason, datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), mod.id))
await cursor.execute("UPDATE warns SET warn_count = warn_count + 1 WHERE user_id = ?", (user.id,))
await db.commit()
kannst du in dings machen
warte ich mache nochmal die db neu
ja das musst du einmal machen wenn du die tabelle struktur ändesrt
und nur noch das mit den reason funktioniert so nicht weil du kannst dan nur eine reason speichern
ohh danke
ja
wie kann ich das machen ?
du könntest es als json speichern und es dann als string in der db speichern
ist halt am einfachste
oder du könntest einfach immer die neuste speichern
okay
Traceback (most recent call last):
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1164, in on_connect
await self.sync_commands()
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 719, in sync_commands
registered_commands = await self.register_commands(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 599, in register_commands
registered = await register("bulk", data, _log=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 371, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 48: Application command names must be unique
``` weiss ein wo ist er error
code?
es ist in kein code error
er bot start
ah du hast 2 commands mit dem selben namen
hast du gesehen?
hab nach geguckt hab kein
die funktionen gibt es 2 die glecih heissen
hab schon nach geguckt
er sagt ja application names must be unique

komm mal coding
ja warte
denn zeig ich dir
dein internet ist auch gut
Bist du da ?_
technische probleme...
scheisse
ey sry geht nicht
schau am besten einfach nochmal ob es irgendwelche funktionen gibt, die gleich heissen
ich hatte 2 mal dem gleich commad
💀
ok aber jetzt gehts oder?
ja
nice
was warum
passiert machmal halt ausversehen
wie heißt es in python wenn ich jemand timeouten will
hast du ein Datenbank
ja ich code mir der db SQLite
same
warum fragst du das
brauche man dafür ein Datenbank
ne ich will denn ja nur timeouten weiß gerade aber nicht wie
ich code seber an das
wie machst du das
Okay danke :D
meinst du member.timeout?
Ja hab schon gefunden bei mir ist es user.timeout
jo, gibt entweder user.timeout oder user.timeout_for
runde klammern hinter BoostTime()
Bei nem Levelsystem müsste man doch
if new_level != old_level:
abfragen, um einen Level-Up zu checken oder?
das sind einf 2 variablen
könnte man kommt drauf an wie man die definiert xD
Rein von der Logik her.
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
Code auf Github ► https://github.com/tibue99/tutorial-bot
Discord Developer Portal ► https://discord.com/developers/applications
Pycord
Docs ► https://docs.pycord.dev/
Guide ► https://guide.pycord.dev/introduction/
Discord Server ► https://discord.gg/pycord
Heute schauen wir uns an, wie der ...
Das ist aber zu früh um 11:41 aufgenommen worden 🙂

Oder so?
if old_level == new_level:
return
else:
# levelup
import discord
from discord.ext import commands
from discord.commands import slash_command, Option
import aiosqlite
class warn(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
async with aiosqlite.connect("warns.db") as db:
await db.execute(
"""
CREATE TABLE IF NOT EXISTS users(
user_id INTEGER PRIMARY KEY,
warn_count INTEGER DEFAULT 0
)
"""
)
@slash_command(description = "Warne einen User")
async def warn(self, ctx, warnuser: Option(discord.Member)):
async with aiosqlite.connect("warns.db") as db:
await db.execute(
"INSERT OR IGNORE INTO users (user_id) VALUES (?)", (warnuser.id,)
)
await db.execute(
"UPDATE users SET warn_count = warn_count + 1 WHERE user_id = ?", (warnuser.id)
)
await db.commit()
embed = discord.Embed(title="Verwarnung", color=discord.Color.brand_red(), description=(f"{warnuser.mention} wurde verwarnt!"))
ctx.respond(embed = embed, ephemeral = True)
def setup(bot):
bot.add_cog(warn(bot))```
Code
Error: ValueError: parameters are of unsupported type
komma hinter warnuser.id
klar, wenn du unbedingt 2 zeilen mehr schreiben willst geht das auch 😄
Merci. 😄
Mal 'ne Frage zu den Cooldowns. Im moment habe ich:
@commands.cooldown(1, 180, commands.BucketType.user)
Im Code.
Kann man das so abändern, dass der cooldown zwar userbezogen ist, sich allerdings auf einen Server beschränkt?
Also das jemand der meinen Bot auf 2 oder mehr servern hat das Command auf beiden Servern 1x ausführen kann und für beide unabhängige Cooldowns laufen?
wie kann man in einer funktion ausserhalb der cog klasse auf die guild zu greifen?
Datenbank 
Die mitgeben 🤔
ein Command muss nicht in einer Cog sein 🙂
das meine ich nicht : ```py
async def result_check():
async with aiosqlite.connect(f"main.db") as db:
async with db.execute("SELECT levelactive FROM active WHERE guild_id = ?", (guild.id,)) as cursor:
print(ctx.guild.id)
result = await cursor.fetchone()
result2 = result[0]
if result2 == 0:
return True
das habe ich ausserhalb der klasse und wenn dies true wiedergibt wird ein slash command erstellt. aber offensichtlich fehlt mir die guild id wo der scuhen soll in der datenbank. und wie kann ich da jetzt drauf zu greifen?
Ja ich weiß auch wieso ig.
na dann sag ma xD
ich weiss auch wieso aber wie löse ich das xD
Ich denke mal, du insertest die Id mit nem on_guild_join Even… machst ja das was ich dir gezeigt habe
Und na klar is dann nichts in der nd wenn er nd neu auf Server gejoint ist
nein ich rede davon das der bei guild.id die guild id braucht um zu suchenwie greife ich darauf zu lasss die datenbank mal datenbank sein xD
Wo verwendest du das Event? Wenn es keine Guild Id gibt wo es drauf zugreifen kann dann gehts natürlich auch nd
schau mal dort
kannst die guild id da nd bekommen
okay das ist meine frage gewesen wie kann ich das dann am besten machen?
Naja ich hab’s ja gemacht das das erst getestet wird nachdem der Command ausgeführt wurde und wenn es deaktiviert ist kommt halt dann „levelsystem deaktiviert“ als ctx.respond
Soll ich dazu besser ein eigenes Thema aufmachen?
Ich glaube auch blind zu sein, finde die Dinger in der Dokumentation nicht.
ist das nicht immer so?
Nö. Wenn ich auf server A einen Slash Befehl gebe und auf Server B den selben geht das auf Server B nicht, weil der Cooldown läuft.
hm
du köntest ein custom cooldown system mit einer datenbank bauen
oder ein event 🙂
d.py oder py-cord
@app_commands.check.cooldown(1, 180, key=lambda i: (i.guild.id, i.user.id)
Das macht doch niemand! (Ich auf dem Weg, das schnell zu coden:)
Auf den Weg ins Himmelland vorbei an den Erdkern 🙂
Genau.
ich möchte ja dass der befehl dann nicht gezeigt wird :/
Benutze einfach discord.py 😉
Ich weiß. Ich weiß jedoch nicht, wie man das in Py-Cord umsetzen könnte.
aber in discord.py weißt du es 😮
Ich weiß nichtmal, wie man in discord.py nen Slash-Command erstellt 
Und wir kehren um zurück zum Erdkern

Bäck tu se Fjuhtscha
Oder so ähnlich
idk
deswegen kam mir die idee mit der if abfrage aber ka wie ich dann die guild dynamisch übergeben kann oder drauf zugreifen
Weiß wer wie man wenn ein command auf discord ausgeführt wird was mit nem raspberry pi machen kann?
@tawdry leaf
Hab' eine viel einfachere Lösung gefunden. statt "user" wird "member" eingesetzt, schon tut es was es soll.
... hoffe ich wenigstens 😂
Auf jeden Fall wirds damit morgen getestet.
wo meinst du
@commands.cooldown(1, 180, commands.BucketType.user) <- da
dann hat er des doch trz auf beiden server
sollte nicht, ein user hat auf verschiedenen servern verschiedene user objekte
*member-objekte
also sollte er wenigstens.
steckt ja auch ne andere ID drinne
Ich gehe erstmal raus, überprüfe die These morgen.
okay
gib einfach ein ich glaube nach gewisser zeiz wird man automatisch ausgelogt
Wie kann man machen das man einen command ausführen kann und dann idt er gesperrt bis Sonntag 0 Uhr und dann kann man ihn wieder einmal ausführen und dann idt er wieder bis zum nächsten Sonntag gesperrt
evtl mit einer datenbank, wo du speicherst wer den command ausgeführt hast
Ich hab die db eh schon weil ich da die lotto zahlen speichern aber wie mach ich das es am Sonntag um 0 Uhr zurückgesetzt wird und man dann denn command wieder machen kann
zum beispiel mit einem task loop
Aber kann man denn nicht immer nur alle paar Stunden oder Tage ausführen und nicht zu bestimmten Uhrzeit oder
doch
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
UTC Zeitzone
► https://time.is/de/UTC
Code auf Github
► https://github.com/tibue99/tutorial-bot
Tutorial Playlist
► https://youtube.com/playlist?list=PLwRWzD1Sw5lXZApchxorxeBQ_P_Fjdsj1
Discord Developer Portal
► https://discord.com/developers/applications
Pycord
Docs ► https://docs.pycord....
Ok danke
Wie kann ich da denn Tag festlegen
Und das mach ich einfach i mein Task loop und lass es immer um 0uhr ausführen und wenn es Sonntag ist macht er es und sonst einfach nichts
Also egal welches emoji forrmat ich nutze bekomem ich imme rdas
Traceback (most recent call last):
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 324, in dispatch
await value.callback(interaction)
File "c:\Users\jurek\Documents\Development\Python\DC Bots\Xenority\Xenority-Main-Pycord-V2\cogs\verify.py", line 89, in callback
emoji = await commands.PartialEmojiConverter().convert(None, self.children[2].value)
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 839, in convert
raise PartialEmojiConversionFailure(argument)
discord.ext.commands.errors.PartialEmojiConversionFailure: Couldn't convert ":weary:" to PartialEmoji.
ROle Button
Ignoring exception in modal <cogs.verify.Add_URL_Button object at 0x00000240F96D37C0>:
Traceback (most recent call last):
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 324, in dispatch
await value.callback(interaction)
File "c:\Users\jurek\Documents\Development\Python\DC Bots\Xenority\Xenority-Main-Pycord-V2\cogs\verify.py", line 89, in callback
emoji = await commands.PartialEmojiConverter().convert(None, self.children[2].value)
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 839, in convert
raise PartialEmojiConversionFailure(argument)
discord.ext.commands.errors.PartialEmojiConversionFailure: Couldn't convert ":weary:" to PartialEmoji.
1 Minute ist Um
1 Minute ist Um
Ignoring exception in modal <cogs.verify.Add_URL_Button object at 0x00000240F96D37C0>:
Traceback (most recent call last):
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 324, in dispatch
await value.callback(interaction)
File "c:\Users\jurek\Documents\Development\Python\DC Bots\Xenority\Xenority-Main-Pycord-V2\cogs\verify.py", line 89, in callback
emoji = await commands.PartialEmojiConverter().convert(None, self.children[2].value)
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 839, in convert
raise PartialEmojiConversionFailure(argument)
discord.ext.commands.errors.PartialEmojiConversionFailure: Couldn't convert "<:weary:>" to PartialEmoji.
ROle Button
Ignoring exception in modal <cogs.verify.Add_URL_Button object at 0x00000240F97AC280>:
Traceback (most recent call last):
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 324, in dispatch
await value.callback(interaction)
File "c:\Users\jurek\Documents\Development\Python\DC Bots\Xenority\Xenority-Main-Pycord-V2\cogs\verify.py", line 89, in callback
emoji = await commands.PartialEmojiConverter().convert(None, self.children[2].value)
File "C:\Users\jurek\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 839, in convert
raise PartialEmojiConversionFailure(argument)
discord.ext.commands.errors.PartialEmojiConversionFailure: Couldn't convert ":StatusOffline_xenority: " to PartialEmoji.```
**CODe**
```emoji = await commands.PartialEmojiConverter().convert(None, self.children[2].value)
if emoji.is_custom_emoji:
print("Ja")```
zur not kannst du emojis auch direkt im code nutzen, custom emojis mit der ID
aber man kann die ja eingeben da kann cih die ja schlecht im code einfach reinschreiben
stimmt
ich kenne mich damit nicht aus, aber ich denke nicht dass man da einfach None reinschreiben kann bei ctx
habs mit nem context getestet, das funktioniert
kannst da kein None reinhauen
ich bin mir nd sicher aber ich glaub du darfst am ende kein komma mehr setzen
von discord components rate ich ab, pycord etc haben alles nötige dafür schon
code:
from discord.ext import commands
import discord
from discord import slash_command, Member
from discord.ext import commands, tasks
from discord.commands import SlashCommandGroup
import aiosqlite
import random
from datetime import time, timezone, datetime
class Lotto(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.DB = "casino.db"
@commands.Cog.listener()
async def on_ready(self):
self.lotto.start()
async with aiosqlite.connect(self.DB) as db:
await db.execute(
"""
CREATE TABLE IF NOT EXISTS lotto (
user_id INTEGER PRIMARY KEY,
money INTEGER DEFAULT 0,
zahl1 INTEGER,
zahl2 INTEGER,
zahl3 INTEGER,
zahl4 INTEGER,
zahl5 INTEGER,
last_reset TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
"""
)
ich möchte in dem on_reeady event meinen loop starten aber wenn ich denn Bot starte kommt dieser Error
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Basti\PycharmProjects\CC×System\cogs\casino\lotto.py", line 19, in on_ready
self.lotto.start()
AttributeError: 'SlashCommandGroup' object has no attribute 'start'
```
ist das deinen ganzen code?
nein
also in dem cog
ja da ist noch mehr
async def check_user(self, user_id):
async with aiosqlite.connect(self.DB) as db:
await db.execute(
"INSERT OR IGNORE INTO lotto (user_id) VALUES (?)", (user_id,)
)
await db.commit()
@tasks.loop(
time=time(18, 16, 0, tzinfo=timezone.utc)
)
async def lotto(self):
day = datetime.now().strftime("%A")
if day == "Sunday":
print("Sunday")
zahl1 = random.randint(1, 49)
zahl2 = random.randint(1, 49)
zahl3 = random.randint(1, 49)
zahl4 = random.randint(1, 49)
zahl5 = random.randint(1, 49)
lotto = SlashCommandGroup("lotto")
@lotto.command()
async def zahlen(self, ctx, lotto1: int, lotto2: int, lotto3: int, lotto4: int, lotto5: int):
await self.check_reset()
await self.check_user(ctx.author.id)
if lotto1 < 0 or lotto1 > 50 or lotto2 < 0 or lotto2 > 50 or lotto3 < 0 or lotto3 > 50 or lotto4 < 0 or lotto4 > 50 or lotto5 < 0 or lotto5 > 50:
await ctx.respond("Bitte gib eine Zahl zwischen 1 und 49 ein!")
return
async with aiosqlite.connect(self.DB) as db:
await db.execute(
"UPDATE lotto SET zahl1 = ?, zahl2 = ?, zahl3 = ?, zahl4 = ?, zahl5 = ? WHERE user_id = ?",
(lotto1, lotto2, lotto3, lotto4, lotto5, ctx.author.id)
)
await db.commit()
await ctx.respond(f"Deine Zahlen wurden gespeichert!")
def setup(bot):
bot.add_cog(Lotto(bot))
der erro sagt halt, dass self.lotto.start() nicht existiert
aber es ist ja da
versteh ich gerade nciht weil im on_ready das erste ist es doch
ja aber was führt das aus?
na das soll denn loop starten
ah ja der ist ja im zweiten code teil habe ich nicht gesehen
ach so
weiß halt nicht was das beim error ganz unten ist weil ich ja bei denn imports glaube ncihts falsch gemacht hab oder
nein hat nichts mit import zu tun
kannst du mal screenshot vom ganzen ncode schicken
ja die slashcommandgroup kann nicht glecih heissen wie der task die heissen beide lotto
ah ok
gehts?
ja aber ich hätte noch eine Frage wo ich nicht zurecht komme könntest du mal talk?
nein gerade nicht sry aber schreib doch eifach
in dem code setz ich ja die lotto zahlen und das können ganz viele user machen halt alle auf dem server und ich möchte jetzt das am Sonntag um 0 Uhr random eine zahl von 1-49 genommen wird. Das hab ich schon abeer wie kann ich jetzt überprüfen welcher user genau diese Zahl hat und dem dann das geld geben!
du speicherst die zahlen und die user id in einer db und dann machst du mit einem task immer um dei zeit, die du willst wählst du die ids aus der datenbank, wo die zahlen übereinstimmen und dann die coins kannst du auch in einer datenbank speichern und dann mithilfe der id denen die coins geben
braucht jmd hilfe?
warum fragst du?
ja so weit war ich schon aber wie bekomm ich die user id von dem der die passende Zahl hat
weil ich helfen will?
SELECT id FROM datenbank WHERE zahlen = lotto_zahlen
ok ich versuch es mal
ok
@tasks.loop(
time=time(18, 49, 0, tzinfo=timezone.utc)
)
async def lotto_loop(self):
day = datetime.now().strftime("%A")
if day == "Sunday":
print("Sunday")
zahl1 = random.randint(1, 49)
zahl2 = random.randint(1, 49)
zahl3 = random.randint(1, 49)
zahl4 = random.randint(1, 49)
zahl5 = random.randint(1, 49)
async with aiosqlite.connect(self.DB) as db:
async with db.execute("Select user_id from lotto where zahl1 = ?", (zahl1,)) as cursor:
result = await cursor.fetchone()
sind jetzt in der result alle ids die die passende Zahl haben
select und wher müssen in caps sein
hab ich noch nie gemacht und es geht
ok ist mir neu aber wenn es geht
ja sollte
ok
aber es checkt halt nur zahl1
die anderen hab ich jetzt auch schon gemacht
ok nice
wie kann ich eine spalte in der Tabelle auf 0 setzten bei allen User id ohne jede User id dafür erst zu getten
einfach das where weglassen?
ähm such mal in google nach sql eine spalte auf 0 setzten weiss es gerade nicht auswendig
wie meinst du das?
await db.execute("UPDATE lotto SET zahl1 = 0, zahl2 = 0, zahl3 = 0, zahl4 = 0, zahl5 = 0")
await db.commit()
das soll für alle user_ids passieren
ah du meinst das bei jedem user sozusagen die auf 0 gesetzt werden nh
wenn man nen command ausführt oder wenn die dem server joinen??
ist in einem task loop wird jeden sonntag um 0 uhr gemacht
ah also jeden sonntag um 0 sollen alle auf 0 gesetzt werden
ja
was passiert denn wenn du das so machst?
ka hab davor noch errors der code kommt nichtmal so weit xD
einem
würde ne for schleife machen
Das ist der Loop wo ist da der fehler der Printet nur Sunday mehr nicht
hab es in allen 5 rein es wird nur das erste result1 gemacht danach belibt der code da stehen weil die 2te Zahl wird nichtmehr geprintet
man kann es in einem sql statment machen
also print(1) wird noch gemacht?
joa welches? 👀
warte ich google schnell
hmm wahrscheinlich sage ich jtzr was komplett dummes: mach mal vor jedes SELECT Dings nen async with aiosqlite.connect
UPDATE your_table SET zahlen= 0
ui merk ich mir
ich muss sagen der bing chat ist echt nützlich
xD
ich muss nur nach oben scrollen nach dem suchen und er gibt mir antworten
if member is None:
member == ctx.author
Member ist schließlich nd required
oder auf True xD

wenn man es auf der datenbank als user id speichert geht es sowieso glaube ich?
weil die datenbank ja dann wieder die gleiche user id endeckt
Ja das ist auch richtig so
import re
aso

ich dachte namens re gibs kein import
diese slash commands haben schon eine differenzierung zu prefix
aber das geht noch?
kein wunder das ich nicht prefix mache
die haben alles anders
das geht noch bestimmt
ok
mit py bitte
sonst lösche ich prefix commands von ganz discord 
und timo hilft mir dabei auf süß
dann gehen alle deine codes nicht mehr
du musst alles neu in slash_commands schreiben
Mach es
mach mal prints und schau bis wohin der code ausgeführt wird
wie kann ich bei dem rank command statt dem username den nickname anzeigen?
author.display_name
@solid ingot du bist ja Bro deswegen frage ich gleich dich. Weiß du ob so etwas auch mit py-cord geht ?
Jap
Professionelle Anleitung wie man richtig copy pastet:
- you runterladen code
- you fragen chatgpt nach requirements.txt
- you betteln nach Hilfe
- you bekommen errors
- you bekommen keine errors mehr
- you haben kopiert
Oder einfach eine gute Anleitung schreiben xD
discord.py ist besser 🙂
ihhh
Raus mit de Viecher
Not true xD
Jede lib hat ihre vor und Nachteile
Du sagtest not True und kommst nun damit 😅
Doppelmoral
In der Datenbank gibt es begruessung nicht
Falsch geschrieben oder so
Schick nochmal Code hab das Problem auch manchmal
Machst du eig aktuell noch Bots?
Ja klar
nein
😂😂
raus! 
Ich sage Nein
Warum wird nur der dritte Button angezeigt?
deine callback methoden müssen unterschiedlich heißen, bei dir heißen aktuell alle 3 methoden "button"
haha danke 💀
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\cogs\botinfo.py", line 19, in botinfo
await ctx.respond(embed=embed)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\context.py", line 282, in respond
return await self.interaction.response.send_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\interactions.py", line 825, in send_message
await self._locked_response(
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\interactions.py", line 1090, in _locked_response
await coro
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\webhook\async_.py", line 219, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\ezcord\bot.py", line 158, in _error_event
raise error
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\cogs\ban.py", line 29, in on_application_command_error
await ctx.respond(f"There has been an error: ```{error}```", ephemeral=True)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\context.py", line 282, in respond
return await self.interaction.response.send_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\interactions.py", line 825, in send_message
await self._locked_response(
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\interactions.py", line 1090, in _locked_response
await coro
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\webhook\async_.py", line 221, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.```
code :
import discord
from discord.ext import commands
from discord.commands import slash_command
class botinfo(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="botinfo", description="Shows information about the bot.")
async def botinfo(self,ctx):
embed = discord.Embed(title="Bot Information", color=discord.Color.blurple())
embed.set_thumbnail(url=ctx.bot.user.avatar.url)
embed.add_field(name="Bot Name", value=ctx.bot.user.name, inline=True)
embed.add_field(name="Bot ID", value=ctx.bot.user.id, inline=True)
embed.add_field(name="Bot Created On", value=ctx.bot.user.created_at.strftime("%m/%d/%Y %H:%M:%S"), inline=True)
embed.set_footer(text=f"Made by ama#0004", icon_url="https://cdn.discordapp.com/attachments/1090638128932462675/1098916204132962445/static_7.png")
await ctx.respond(embed=embed)
def setup(bot):
bot.add_cog(botinfo(bot))```
def __init__(self, ctx, message, *args, **kwargs):
super().__init__(*args, **kwargs)
self.message = message```
Wieso kann ich meine message in beim modal callback evrwenden message... geht nicht er findet das ned
Kannst du bitte deine Frage noch mal richtig stellen
ich kann das message objekt nicht im callback nutzen weil es ned gefunden wird
wie meinst du das genau? kommt ein error? ist self.message None?
Jetzt geht das ausm nix komsicha ebr gut, jetzt hääte ich noch ne frage kann ich irgnewie wenn ich eine view bearbeiten wenn eine view vorher vorhanden war adden so das ich sozusagen einen button zu den 2 anderen adden kann
view.add_item()
und da einfach meinen button rein? richtig also den ich adden will
aber
wie kann ich die and4ere view bekommen?
welche?
Naja ich will über kontaxt einen button an ne msg machen abe rich knn ja ned einfach view = view... amchen da ich da ja nur den einen button habe den ich im code habe aber was ist wenn ann der msg schon nen button hängt da will ich einen ádden und nicht den alten erstezten
an deiner message ist ein view. zu diesem view kannst du einen button hinzufügen, und dann die nachricht mit dem view bearbeiten
ja aber wie komme ich an die view weil so wie ichsgemacht ahbe gehts ned
view = VIew()
View.add_item(button)
senden
Was machst du da 🫣
import discord
from discord import slash_command
from discord.ext import commands, tasks
from datetime import time, timezone, datetime
import random
class verifizieren(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cogs.listerner()
async def on_ready(self):
self.verifizieren.start()
@tasks.loop(
time=time(22, 0, 0, tzinfo=timezone.utc)
)
async def verifizieren(self):
random_number = random.randint(1, 100000)
class Modal(discord.ui.Modal):
def __init__(self, bot, *args, **kwargs):
self.bot = bot
super().__init__(
discord.ui.InputText(
label="",
placeholder="Gebe hier die Zahl ein ",
style=discord.InputTextStyle.long
),
*args,
**kwargs
)
async def callback(self, interaction):
try:
await interaction.response.send_message(self.children[0].value)
except:
await interaction.response.send_message("Fehler")
return
Wie kann ich die random_number an das Modal übergeben
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
Code auf Github ► https://github.com/tibue99/tutorial-bot
Discord Developer Portal ► https://discord.com/developers/applications
Pycord
Docs ► https://docs.pycord.dev/
Guide ► https://guide.pycord.dev/introduction/
Discord Server ► https://discord.gg/pycord
Heute klären wir eine Frage, die ...
Schau dir das mal an da wird es erklärt wie man sachen übergibt
Aber ich frage mich warum du das in einem Task Loop hast?
damit jede Nacht eine neue Zahl für das verifizieren genommen wird und nicht immer die selbe ist
dazu hast du doch random
Dafür brauchst du keinen Taskloop, generiere einfach immer eine neue Zahl wenn man auf den Button drückt oder was auch immer das Modal triggert
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\cogs\untime.py", line 14, in untimeout
timeouts = await self.untimeout()
^^^^^^^^^^^^^^^^
TypeError: ApplicationCommand.__call__() missing 1 required positional argument: 'ctx'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\ezcord\bot.py", line 191, in _error_event
raise error
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: ApplicationCommand.__call__() missing 1 required positional argument: 'ctx'
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\cogs\untime.py", line 14, in untimeout
timeouts = await self.untimeout()
^^^^^^^^^^^^^^^^
TypeError: ApplicationCommand.__call__() missing 1 required positional argument: 'ctx'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\cogs\ban.py", line 30, in on_application_command_error
raise error
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\ezcord\bot.py", line 191, in _error_event
raise error
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\Rysii\OneDrive\Desktop\Ama discord bot\venv\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: ApplicationCommand.__call__() missing 1 required positional argument: 'ctx'
import discord
from discord.ext import commands
from discord.commands import slash_command
class untimeout(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(description="Untimeout")
async def untimeout(self, ctx, member: discord.Member):
timeouts = await self.untimeout()
if member.id in timeouts:
await self.remove_timeout(member.id)
await ctx.send(f"{member.mention} wurde erfolgreich ent-timeoutet!")
else:
await ctx.send(f"{member.mention} ist nicht getimeoutet!")
def setup(bot):
bot.add_cog(untimeout(bot))```
kann wer helfen
timeouts = await self.untimeout()
was machst du mit der zeile?
oh fuck
das muss so ein ).
:
oder komm das
async def callback(self, interaction):
if self.children[0].value == str(self.zahl):
role1 = interaction.guild.get_role(1100134956551901194)
role2 = interaction.guild.get_role(1100852860280909874)
role3 = interaction.guild.get_role(1100786285989343242)
role4 = interaction.guild.get_role(1100850918733389845)
role5 = interaction.guild.get_role(1100851004280406097)
role6 = interaction.guild.get_role(1100851015005261874)
role7 = interaction.guild.get_role(1100851040456298516)
role8 = interaction.guild.get_role(1100851054012272680)
if role1 in interaction.user.roles:
await interaction.user.remove_roles(role1)
await interaction.user.add_roles(role2, role3, role4, role5, role6, role7, role8)
await interaction.response.send_message("Du bist nun verifiziert")
else:
await interaction.response.send_message("Du hast dich schon verifiziert")
else:
await interaction.response.send_message("Schau nochmal ob du die richtige Zahl eingegeben hast!")
error:
Ignoring exception in modal <cogs.verifizieren.verifizieren.verifizieren.Modal object at 0x000001B6126D9360>:
Traceback (most recent call last):
File "C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 341, in dispatch
await value.callback(interaction)
File "C:\Users\Basti\PycharmProjects\CC×System\cogs\verifizieren\verifizieren.py", line 42, in callback
await interaction.user.add_roles(role2, role3, role4, role5, role6, role7, role8)
File "C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 1007, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
hab auch ein error
gehts es jerzt ?
eine der rollen wurde anscheinend nicht geunden und ist deswegen None
Ich bin davor mit easypil anzufangen, gibt es aber irgendein Trick wodurch man vereinfacht die position vom bild bekommt wo der text hin soll?
paint
Okay, aber wie genau :kekw:
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
Links aus diesem Video
Easy-PIL Docs ► https://easy-pil.readthedocs.io/
Space Bild ► https://github.com/tibue99/tutorial-bot/blob/main/Einzelvideos/Easy-PIL/space.png
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Mein Hosting* ► https://tidd.ly/3gJufg6
Code auf Github ► https://github.com/tibue99/tutorial-bot
PYCO...
dass wird da doch nd gezeigt oder?
doch
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\neu discord bot\cogs\test.py", line 15, in on_ready
await db.execute(
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiosqlite\core.py", line 184, in execute
cursor = await self._execute(self._conn.execute, sql, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiosqlite\core.py", line 129, in _execute
return await future
^^^^^^^^^^^^
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiosqlite\core.py", line 102, in run
result = function()
^^^^^^^^^^
sqlite3.OperationalError: table reports already exists```
import discord
from discord.ext import commands
from discord.commands import slash_command, Option
import aiosqlite
class warn(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.db = "report.db"
@commands.Cog.listener()
async def on_ready(self):
async with aiosqlite.connect(self.db) as db:
await db.execute(
"""
CREATE TABLE reports (
guild_id INT,
user_id INT,
modid INT,
grund TEXT)
""")
await db.execute(
"""
CREATE TABLE check (
id INT PRIMARY KEY,
serverid INT,
count INT)
"""
)
@commands.Cog.listener()
async def on_member_join(self, member):
id = int(member.id+member.guild.id)
async with aiosqlite.connect(self.db) as db:
await db.execute("INSERT OR IGNORE INTO check (id, serverid, count) VALUES (?,?,0)", (id, member.guild.id))
@slash_command(description="Warn a Member!")
async def warn(self, ctx, user: Option(discord.User, "The User you want to warn"), reason: Option(int, "The Reason, why you want to warn the Member!")):
async with aiosqlite.connect(self.db) as db:
await db.execute("INSERT INTO reports (guild_id, user_id, modid, grund) VALUES (?,?,?;?)",
(ctx.guild.id, user.id, ctx.author.id, reason))
await db.commit()
await db.execute("UPDATE check SET count = count + 1 WHERE id = ?", (user.id+ctx.guild.id,))
async with db.execute("SELECT count FROM check WHERE id = ?", (user.id+ctx.guild.id,)) as cursor:
count = await cursor.fetchone()
count2 = count[0]
if count2 == 3:
await user.ban(reason="3x Warned")
await ctx.respond(f"{user.mention} got banned because he got 3x warned!", ephemeral=True)
embed = discord.Embed(
title="Warn",
description=f"{user.mention} got warned!",
color = discord.Color.random()
)
embed.add_field(name="`Warn-Reason`",value=f"**reason**")
embed.add_field(name="`Responsible Moderator`",value=f"**{ctx.author.mention}**")
embed.add_field(name="`Warned User`",value=f"**{user.mention}**")
embed.set_author(name="PANTHEON")
embed.set_footer(text="PANTHEON")
embed.set_thumbnail(url=ctx.author.display_avatar_url)
channel = await self.bot.get_channel("1100759291524304957")
if channel == None:
await ctx.respond("The Log-Channel is not valid, please insert it again! ", ephemeral=True)
else:
await ctx.respond(f"{user.mention} got warned!", ephemeral=True)
await channel.send(embed=embed)
def setup(bot):
bot.add_cog(warn(bot))```
Du erstellst einen Table der schon existiert, du musst CREATE TABLE IF NOT EXISTS {tableName} benutzen
begrueßung ist None, deswegen kannst du [0] nicht verwenden
None[0] geht nicht
prüfen ob es none ist
nope
also du solltest es natürlich prüfen bevor du [0] nutzt, denn das geht bei None nicht
Ja. Dann musst du auch nicht mehr result = result[0]
Schreiben
Eif nur
msgcount, xp = await cursor.fetchone
guten nachmitag leute
wie bekomm ich den User#2133 ?
als beispiel.
ich möchte den user name und den tag bekommen
.name .discrimator
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
Ty
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\neu discord bot\cogs\hshshs.py", line 19, in warn
async with aiosqlite.connect(self.db) as db:
^^^^^^^
AttributeError: 'Mod' object has no attribute 'db'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\ezcord\bot.py", line 191, in _error_event
raise error
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Mod' object has no attribute 'db'
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\neu discord bot\cogs\hshshs.py", line 19, in warn
async with aiosqlite.connect(self.db) as db:
^^^^^^^
AttributeError: 'Mod' object has no attribute 'db'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\OneDrive\Desktop\neu discord bot\cogs\ban.py", line 30, in on_application_command_error
raise error
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\ezcord\bot.py", line 191, in _error_event
raise error
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
await injected(ctx)
File "C:\Users\Rysii\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Mod' object has no attribute 'db'
import aiosqlite
import discord
from discord.ext import commands
import sqlite3
from discord.commands import slash_command
from discord.commands import Option
class Mod(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.conn = sqlite3.connect('database.db')
self.cursor = self.conn.cursor()
self.cursor.execute('''CREATE TABLE IF NOT EXISTS warns
(user_id TEXT, mod_id TEXT, reason TEXT)''')
self.conn.commit()
@slash_command()
async def warn(self, ctx, user: Option(discord.User, "The User you want to warn"),reason: Option(int, "The Reason, why you want to warn the Member!")):
async with aiosqlite.connect(self.db) as db:
await db.execute("INSERT INTO reports (guild_id, user_id, modid, grund) VALUES (?,?,?;?)",(ctx.guild.id, user.id, ctx.author.id, reason))
await db.commit()
await db.execute("UPDATE checking SET count = count + 1 WHERE id = ?", (user.id + ctx.guild.id,))
async with db.execute("SELECT count FROM checking WHERE id = ?", (user.id + ctx.guild.id,)) as cursor:
count = await cursor.fetchone()
count2 = count[0]
if count2 == 3:
await user.ban(reason="3x Warned")
await ctx.respond(f"{user.mention} got banned because he got 3x warned!", ephemeral=True)
embed = discord.Embed(
title="Warn",
description=f"{user.mention} got warned!",
color=discord.Color.random()
)
embed.add_field(name="`Warn-Reason`", value=f"**reason**")
embed.add_field(name="`Responsible Moderator`", value=f"**{ctx.author.mention}**")
embed.add_field(name="`Warned User`", value=f"**{user.mention}**")
embed.set_author(name="PANTHEON")
embed.set_footer(text="PANTHEON")
embed.set_thumbnail(url=ctx.author.display_avatar_url)
channel = await self.bot.get_channel("1100759291524304957")
if channel == None:
await ctx.respond("The Log-Channel is not valid, please insert it again! ", ephemeral=True)
else:
await ctx.respond(f"{user.mention} got warned!", ephemeral=True)
await channel.send(embed=embed)
def setup(bot):
bot.add_cog(Mod(bot))```
du musst nen self.db. = "blabla.db"
hinzufügen
wo ?
na bei der class wo du auch self.bot = bot machst
code
import aiosqlite
import discord
from discord.ext import commands
import sqlite3
from discord.commands import slash_command
from discord.commands import Option
class Mod(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.db = "report.db"
self.conn = sqlite3.connect('database.db')
self.cursor = self.conn.cursor()
self.cursor.execute('''CREATE TABLE IF NOT EXISTS warns
(user_id TEXT, mod_id TEXT, reason TEXT)''')
self.conn.commit()
@slash_command()
async def warn(self, ctx, user: Option(discord.User, "The User you want to warn"),reason: Option(int, "The Reason, why you want to warn the Member!")):
async with aiosqlite.connect(self.db) as db:
await db.execute("INSERT INTO reports (guild_id, user_id, modid, grund) VALUES (?,?,?;?)",(ctx.guild.id, user.id, ctx.author.id, reason))
await db.commit()
await db.execute("UPDATE checking SET count = count + 1 WHERE id = ?", (user.id + ctx.guild.id,))
async with db.execute("SELECT count FROM checking WHERE id = ?", (user.id + ctx.guild.id,)) as cursor:
count = await cursor.fetchone()
count2 = count[0]
if count2 == 3:
await user.ban(reason="3x Warned")
await ctx.respond(f"{user.mention} got banned because he got 3x warned!", ephemeral=True)
embed = discord.Embed(
title="Warn",
description=f"{user.mention} got warned!",
color=discord.Color.random()
)
embed.add_field(name="`Warn-Reason`", value=f"**reason**")
embed.add_field(name="`Responsible Moderator`", value=f"**{ctx.author.mention}**")
embed.add_field(name="`Warned User`", value=f"**{user.mention}**")
embed.set_author(name="PANTHEON")
embed.set_footer(text="PANTHEON")
embed.set_thumbnail(url=ctx.author.display_avatar_url)
channel = await self.bot.get_channel("1100759291524304957")
if channel == None:
await ctx.respond("The Log-Channel is not valid, please insert it again! ", ephemeral=True)
else:
await ctx.respond(f"{user.mention} got warned!", ephemeral=True)
await channel.send(embed=embed)
def setup(bot):
bot.add_cog(Mod(bot))```
is das der ganze
ja
du hast ja auch bei VALUES statt nem , nen ; gesetzt
was muss da hin?
bei der erstem db connection wo du in reports guild id etc. insertest hast du bei VALUES vor dem letztem ? ein ; statt einem , gesetzt
könnst du kurz call?
wie kann ich einen task jeden tag um eine bestimmte Uhrzeit ausführen lassen ?
Mein Discord Server
► https://discord.gg/zfvbjTEzv6
UTC Zeitzone
► https://time.is/de/UTC
Code auf Github
► https://github.com/tibue99/tutorial-bot
Tutorial Playlist
► https://youtube.com/playlist?list=PLwRWzD1Sw5lXZApchxorxeBQ_P_Fjdsj1
Discord Developer Portal
► https://discord.com/developers/applications
Pycord
Docs ► https://docs.pycord....
Hallo leute ich bräuchte hilfe bei etwa . undzwar wenn ich in meinem Ticketsystem 2 ticket systeme erstelle schickt es in das was als erstes erstellt wurde message und in das 2te nicht. es schickt per dm zwar das es den channel createt hat aber danach geht es nicht weiter
Hier der code:
msg = await interaction.user.send(f" Creating your Ticket (Usually takes 2-4 Seconds)...")
ticket = await interaction.guild.create_text_channel(
name=ticket_name.replace("{user}", str(interaction.user.name)),
category=discord.utils.get(interaction.guild.categories, id=category_id), topic=f"📨 Ticket for {interaction.user.name} | Createt at {time.strftime('%d.%m.%Y | %H:%M:%S')}")
await ticket.set_permissions(interaction.guild.default_role, view_channel=False, send_messages=False)
if role1 != "0":
await ticket.set_permissions(
discord.utils.get(interaction.guild.roles, id=role1),
view_channel=True,
send_messages=True,
read_message_history=True,
add_reactions=True,
attach_files=True,
embed_links=True,
)
if role2 != "0":
await ticket.set_permissions(
discord.utils.get(interaction.guild.roles, id=role2),
view_channel=True,
send_messages=True,
read_message_history=True,
add_reactions=True,
attach_files=True,
embed_links=True,
)
if role3 != "0":
await ticket.set_permissions(
discord.utils.get(interaction.guild.roles, id=role3),
view_channel=True,
send_messages=True,
read_message_history=True,
add_reactions=True,
attach_files=True,
embed_links=True,
)
await ticket.set_permissions(
interaction.user,
view_channel=True,
send_messages=True,
read_message_history=True,
add_reactions=True,
attach_files=True,
embed_links=True,
)
await msg.edit(content=f" Your Ticket has been created! {ticket.mention}")
em = discord.Embed(
title= f"Ticket for `{interaction.guild.id}`",
description= f"{createtext.replace('{user}', f'{interaction.user.mention}')} ",
color=col
)
em.set_footer(text=f"Ticket ID: {ticket_id2}")
em.set_thumbnail(url=interaction.guild.icon.url)
em1 = discord.Embed(
title= f"**A Staff Member will claim the Ticket soon!**",
description=f"Dear {interaction.user.mention}! \n *Please wait until a Staff Member, claimed your Ticket!*",
color=col
)
em1.set_footer(text=f"Ticket ID: {ticket_id2}")
em1.set_thumbnail(url=interaction.guild.icon.url)
ticket_id1 = ticket_id2
await ticket.send(content=f" {interaction.user.mention} | <@{role1}> | <@{role2}>| <@{role3}>", embeds=[em, em1], view=Ticketcomp(ticket_id1))
was soll noch passieren?
Kann ich für den gesamten bot commands in DMs deaktivieren oder muss ich das für jeden Command einzeln machen?
na quasie das selbe wie im bild unten link
aber obwohl es das gleiche system ist schickt es die nachicheten nicht ab sonder nur bis zu dem punkt
Soweit ich weiß nur bei jedem Command einzeln.
es gibt auf jeden Fall Checks für den ganzen bot, vlt kann man das darüber machen, die hab ich aber auch noch nie wirklich benutzt
könnte ich eig Mal mein Video dazu machen
Ja gut dann halt eine Zeile mehr pro Command kann ich auch mit leben. Danke für die fixe Antwort
Hallo, kann hier jemand etwas discord.py?
ja
Ja, hat sich schon geklärt
import aiosqlite
import discord
from discord.ext import commands
import sqlite3
from discord.commands import slash_command
from discord.commands import Option
class Mod(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.db = "report.db"
self.conn = sqlite3.connect('database.db')
self.cursor = self.conn.cursor()
self.cursor.execute('''CREATE TABLE IF NOT EXISTS warns
(user_id TEXT, mod_id TEXT, reason TEXT)''')
self.conn.commit()
@slash_command()
async def warn(self, ctx, user: Option(discord.User, "The User you want to warn"),reason: Option(int, "The Reason, why you want to warn the Member!")):
db = await aiosqlite.connect('database.db')
await db.execute("INSERT INTO reports (guild_id, user_id, modid, grund) VALUES (?,?,?,?)",(ctx.guild.id, user.id, ctx.author.id, reason))
await db.commit()
await db.execute("UPDATE checking SET count = count + 1 WHERE id = ?", (user.id + ctx.guild.id,))
async with db.execute("SELECT count FROM checking WHERE id = ?", (user.id + ctx.guild.id,)) as cursor:
count = await cursor.fetchone()
count2 = count[0]
if count2 == 3:
await user.ban(reason="3x Warned")
await ctx.respond(f"{user.mention} got banned because he got 3x warned!", ephemeral=True)
embed = discord.Embed(
title="Warn",
description=f"{user.mention} got warned!",
color=discord.Color.random()
)
embed.add_field(name="`Warn-Reason`", value=f"**reason**")
embed.add_field(name="`Responsible Moderator`", value=f"**{ctx.author.mention}**")
embed.add_field(name="`Warned User`", value=f"**{user.mention}**")
embed.set_author(name="PANTHEON")
embed.set_footer(text="PANTHEON")
embed.set_thumbnail(url=ctx.author.display_avatar_url)
channel = await self.bot.get_channel("1100759291524304957")
if channel == None:
await ctx.respond("The Log-Channel is not valid, please insert it again! ", ephemeral=True)
else:
await ctx.respond(f"{user.mention} got warned!", ephemeral=True)
await channel.send(embed=embed)
def setup(bot):
bot.add_cog(Mod(bot))```
kann wer helfen
Dir fehlt eine Spalte in deiner Datenbank
Hmm hast su schon mal in den Docs geguckt?
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
CODE:
@slash_command(description="assign a role to a member")
@command.has_permisions(administrator=True)
async def role(ctx: user, role):
member = ctx.guild.get_member(user.id)
if role in member.roles:
await member.remove_roles(role)
await ctx.send(f"Removed {role.name} from {user.mention}")
else:
await member.add_roles(role)
await ctx.send(f"Added {role.name} to {user.mention}")```
**ERROR:**
```IndentationError: expected an indented block after function definition on line 41
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/main.py", line 23, in <module>
bot.load_extension(f"cogs.{filename[:-3]}")
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 777, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.Admin' raised an error: IndentationError: expected an indented block after function definition on line 41 (Admin.py, line 42)```
alles, was innerhalb der role methode steht, muss eins nach rechts eingerückt werden
also alles unter async def
ok aber hab jetzt syntax error line 44 weiß du warum?
bitte benutze die antwort funktion nicht zum pingen, sondern zum antworten
ohne deine zeile 44 zu sehen ist das für mich sehr schwer zu beurteilen
await member.remove_roles(role)
weiss wer warum der das nd ändert
wdym?
Timo?
schick Mal den Code wo das Teil getriggert wird und bitte in ein Code Block
Ping?
@slash_command(description="assign a role to a member")
@command.has_permisions(administrator=True)
async def role(ctx: user, role):
member = ctx.guild.get_member(user.id)
if role in member.roles:
await member.remove_roles(role)
await ctx.send(f"Removed {role.name} from {user.mention}")
else:
await member.add_roles(role)
await ctx.send(f"Added {role.name} to {user.mention}")```
hab ausversehen ohne py gesesndet
sehe da eigentlich kein error
für syntax
oder komma?
erstmal im async ctx, user:discord.Member, role:discord.Role
und teste dann Mal neu
muss nicht das bei role auch was mit guild sein?
nop
ok
soll ich dan sagen
await user.remove_roles(role)```
jup
okay
@slash_command(description="assign a role to a member")
@command.has_permisions(administrator=True)
async def role(ctx, user:discord.Member, role:discord.Role):
if role in user.roles:
await user.remove_roles(role)
await ctx.send(f"Removed {role.name} from {user.mention}")
else:
await user.add_roles(role)
await ctx.send(f"Added {role.name} to {user.mention}")```
IndentationError: expected an indented block after function definition on line 41
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/main.py", line 23, in <module>
bot.load_extension(f"cogs.{filename[:-3]}")
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.10/site-packages/discord/cog.py", line 777, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.Admin' raised an error: IndentationError: expected an indented block after function definition on line 41 (Admin.py, line 42)```
42 ist if role
aso hab vergessen
@urban glen einrücking ist falsch
ja habs bemerkt
"command is not definied"
ups bei den permissions
commands
"discord.errors.ExtensionFailed: Extension 'cogs.Admin' raised an error: AttributeError: module 'discord.ext.commands' has no attribute 'has_permisions'"
digga
ich kann nicht schreiben
permissions*
2 m
bruh Englisch kackt rein
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "/home/container/cogs/Admin.py", line 37, in on_application_command_error
raise error
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 375, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'roles'
ohh
hab self vergessen
er sagt das die guild none ist obwohlt es nicht so kann mir mir bitte werhelfen
Mach slash commands ;)
icon_url
hey mal eine frage, will relativ viele bilder vom bot senden lassen, aber wenn ich die ja alle einzelnt halt per attachment einbinde dann ist das sehr viel code, gibts irgendeinen weg das besser zu machen? Weil wenn ich einfach alle links sende, dann werden die ja auch angezeigt und das sieht nicht so geil aus
wie genau?
also du machst /image und hast dann optionen und die sollen geschickt werden oder wie
ja so unegfähr, und dann werden dir halt relativ viele bilder geschickt
aber ich müsste um sie als nachricht zu senden sie entweder als link schicken, wo der link dann sichtbar ist, oder jeden einzeln halt in meinem code einbinden so:
gesendetba = discord.File("Banner/gesendet.png", filename="gesendet.png")
Geht das einfacher?
Kann ich beim benutzen dieser Option die everyone Rolle ausblenden?
@rolemenu.command(name = "add", description = "Fügt eine Rolle zu einem Rollenmenü hinzu")
@discord.default_permissions(administrator = True)
async def add(self, ctx, role: Option(discord.Role), emote: Option(str)):
Wollte es für einen simplen Weg benutzen Rollen zu einem Rolemenu hinzuzufügen aber die everyone Rolle ist etwas störend weil es damit so aussieht:
@everone ist keine rolle

Ignoring exception in modal <cogs.verifizieren.verifizieren.VerifyModal object at 0x000001ECE41D1510>:
Traceback (most recent call last):
File "C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 341, in dispatch
await value.callback(interaction)
File "C:\Users\Basti\PycharmProjects\CC×System\cogs\verifizieren\verifizieren.py", line 49, in callback
await interaction.response.send_message("Du bist nun Verifiziert.", ephemeral=True)
File "C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 825, in send_message
await self._locked_response(
File "C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 1090, in _locked_response
await coro
File "C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 219, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
code
class VerifyModal(discord.ui.Modal):
def __init__(self, bot, **kwargs) -> None:
self.bot = bot
self.zahl = str(random.randint(1000, 9999))
super().__init__(**kwargs, title=f'{self.zahl}')
self.add_item(discord.ui.InputText(
label=f"Gib die Zahl ein: {self.zahl}",
placeholder=f"{self.zahl}",
required=True,
min_length=4,
max_length=4
))
async def callback(self, interaction: discord.Interaction):
user = interaction.user
if self.children[0].value == self.zahl:
if role1 in interaction.user.roles:
await interaction.user.remove_roles(role1)
try:
await user.add_roles(role2, role3, role4, role5, role6, role7, role8)
except discord.errors.Forbidden:
embed = discord.Embed(
color=discord.Colour.red(),
title="Fehler",
description="Es ist ein Fehler aufgetreten. Dies kann mehrere Gründe haben. \n\n- Ich habe keine Berechtigung, die Rolle zu vergeben. \n- Die Rolle ist höher als meine. \n- Die Rolle ist höher als meine. \n\nBitte überprüfe die Berechtigungen und versuche es erneut."
)
await interaction.response.send_message(embed=embed, ephemeral=True)
await interaction.response.send_message("Du bist nun Verifiziert.", ephemeral=True)
else:
await interaction.response.send_message("Du bist schon Verifiziert", ephemeral=True)
else:
await interaction.response.send_message("Die Zahl ist falsch", ephemeral=True)
warum kommt da Unknown interaction
das kommt meistens, wenn dein bot länger als 3 sekunden zum antworten braucht
F
Kann ja sein, aber man weiß ja mit Kontext von dem Screenshot was ich meine...
doch
ich glaube das geht leider nicht, du könntest höchstens eine fehlermeldung auasgeben wenn der user @ everyone ausgewählt hat
if select.values[0]== "everyone":
Schade, aber denke mache es dann eh eher so
await ctx.respond("Bitte ping die Rolle, die du hinzufügen möchtest")
while True:
try:
msg = await self.bot.wait_for("message", timeout = 30, check = lambda m: m.author == ctx.author and m.channel == ctx.channel)
except asyncio.TimeoutError:
await ctx.respond("Du hast zu lange Gebraucht die nächste Rolle hinzuzufügen", ephemeral = True)
break
else:
if msg.role_mentions:
role = msg.role_mentions[0]
await ctx.respond(f"Rolle: {role}")
break
else:
await ctx.respond("Bitte ping eine Rolle", ephemeral = True)
Funktioniert so ja auch und ist glaube ich auch etwas entspannter (also jetzt funktionierts noch nich weil die hälfte fehlt aber whatever) kann ich ja auch quasi if role.name == "here" or "everyone": benutzen zum checken oder?
Bitte drückt mir kein "versuchs doch einfach" 💀
ja sollte
@ here ist gar keine rolle oder?
hmm
das mit dem namen sollte gehen, ich mach das aber immer mit guild.default_role
Es wird halt als mentionable angezeigt deswegen dachte ichs
müsse auch eine Rolle sein
obwohl
achja, und das role.name == bezieht sich bei dieser abfrage aktuell nur auf "here", nicht auf "everyone"
Aber ist das nich blöd weils dann nochmal extra die guild fetchen muss?
musst du nicht
yeye war nur als anschau beispiel gemeint ^^
Alles klar, danke auf jeden Fall für die Auskunft wie immer eine Freude :^)
kann auch sein dass bei "everyone" noch ein @ davor muss wenn du den name prüfst

yup
ye
ach das gibt ja dann eh nur true oder false right? Ja gut dann spare ich mir des andere
jo
der ändert den zeiger nicht egal was ich mach
weisst du wie es geht
zeiger 🤔
wie kann ich attachments als nachricht senden, finde nichts in den docs
Will halt relativ viele bilder mit einer nachricht versenden
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
du kannst attachments zu files umwandeln und dann senden
kann ich dann nicht auch einfach direkt die bilder als files importieren?
wie meinst du das genau?
also ich will halt einfach bilder per dm verschicken
Ich kann das ja entweder im dem ich den link sende den man dann sieht was nervt oder das bild anhänge, das heißt ich muss das bild ja erstmal in einem ordner meines bots haben, und dann einzelnt alle bilder reinkriegen in den code, mit z.b. discord.File(..)
Und das dann senden, oder geht das anders/einfacher? habe glaube meine erste frage falsch formuliert
Bzw. andere frage
Habe jetzt mal versucht das ganze einfach als file normal zu speichern und als dm zu senden aber kriege einen Fehler
bannerinfo = discord.File("blau/infos.png", filename="infos.png")
bannerserver = [bannerinfo]
await ch.send(file=bannerserver )
discord.errors.InvalidArgument: file parameter must be File
wenn du eine liste von files hast, musst du files= statt file= schreiben
danke
Aber kann man eigentlich auch ganze ordner zu eine file machen? So das ich nicht jeden einzelnt mit discord.File reinladen muss?
du könntest eine for schleife machen
glaube weiß was du meinst, aber wie kann ich dann jede datei hinzufügen? Weil man ja immer discord.File(banner/dennamen) machen muss
folder_path = "/ordner/"
files = []
for filename in os.listdir(folder_path):
if os.path.isfile(os.path.join(folder_path, filename)):
files.append(discord.File(os.path.join(folder_path, filename)))
Und beim abschicken dann:
await ctx.send(files=files)
Also bin nicht sicher ob das so klappen würde, aber kannst es testen
was genau ist dieses os
Eine standard python library
ok aber warum genau hast du ordner in den hier / müssen die nicht so \ sein oder irre ich mich?
Ist glaube von system zu system unterschiedlich.
Bei mir geht's mit /, bei anderen mit \
jo habe irgendwie probleme den pfad richtig anzugeben
Zeig doch mal deine Anordnung
muss ich den von meinen privaten daten angeben? also C:\User usw?
C:\Users\gianl\PycharmProjects\discordbot\blau
also, im blau ordner sind die bilder die ich schicken will
Ich meine als screenshot
was genau willst du als screenshot sehen?
Und in welcher Datei befindest du dich?
folder_path = "../blau/"
oder
folder_path = "./blau/"
Eins von beiden denke ich, teste mal
Wenns nicht geht, dann kann dir maybe wer anders helfen
warum . ?
sorry habe mic mit os noch nie beschäftigt
Klappt...habe nur zu viele als 10 bilder drinne
Das muss ich nochmal ändern
habe eine neue view(dropdown) hinzugefügt seitdem kommt beim starten der fehler
discord.errors.ExtensionFailed: Extension 'cogs.banner' raised an error: TypeError: module() takes at most 2 arguments (3 given)
Woran liegt das? Ich finde einfach nicht den fehler
Ein select menu benötigt meines wissens nach nur "self" und "interaction"
||Korrigiert mich wenn ich falsch liege||
Obwohl wait
habe das in einer anderen select menü auch und klappt, brauche ich ja um z.b. select.values oder so zu machen
.

meinste du in discord?
Ja
Aber alles gut
Hast ja als Datei geschickt xD
Also ich kann das manuell bei mir ändern
habe ich aber er speichert das nie
Bin ich blind
Mir wird gesagt er kann diesesn pfad nicht finden
folder_pathblau = "./bannerlibrary/blau/serververwaltung/informationen"```
weshalb?
In welcher Datei befindest du dich?
Schick mal ganzen Screenshot
ich bin in einen cog
oder ist was mit ./ falsch?
Probier mal ../
Und wenn das auch nd geht, dann probier mal mit Backslashes
ok
Kann jemand hier discord.py?

