#Music Bot.
1 messages · Page 1 of 1 (latest)
Error is pretty much self explanatory
ja den habe ich behoben bekommen jetzt kommt aber folgendes:
dc@vmd115250:~/bot$ python3 main.py
main.py:18: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(help_cog(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
main.py:19: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(music_cog(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2023-07-06 18:20:45 INFO discord.client logging in using static token
Traceback (most recent call last):
File "main.py", line 22, in <module>
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 777, in start
await self.login(token)
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 609, in login
raise TypeError(f'expected token to be a str, received {token.class.name} instead')
TypeError: expected token to be a str, received NoneType instead
dc@vmd115250:~/bot$
TypeError: expected token to be a str, received NoneType instead
Bot can't get token
My man can't read errors
German 🇬🇪
bedeutet er findet den token nicht oder wie
yes
bot.run(os.getenv("token"))
Add token to your env
Excited to create your first bot? Once you install Pycord, you can start right
Also pls dont use "/" as a prefix with commands.Bot()
in welches verzeichniss muss die .env datei rein ?
Am einfachsten ist es, wenn du es einfach neben der Main File hast
from dotenv import load_dotenv
Ändere es zu discord.Bot wenn du nur noch slash_commands Benutzt
Und entferne das mit dem prefix bei discord.Bot
äh wie soll das dann heißen ?
Benutzt du nur slash commands?
Also dann brauchst du intents
okay und wie würde ich das machen?
Was soll das jetzt heißen?
dc@vmd115250:~/bot$ python3 main.py
main.py:19: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(help_cog(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
main.py:20: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(music_cog(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
dc@vmd115250:~/bot$
kommt es immer noch, wenn du load_extensions("") benutzt?
so sieht die main jetzt aus
GNU nano 4.8 main.py
import discord
from discord.ext import commands
import os
#import all of the cogs
from help_cog import help_cog
from music_cog import music_cog
from dotenv import load_dotenv
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!',intents=intents)
#remove the default help command so that we can write out own
bot.remove_command('help')
#register the class with the bot
bot.add_cog(help_cog(bot))
bot.add_cog(music_cog(bot))
#start the bot with our token
token = str(os.getenv("TOKEN"))
Du musst es nicht importieren, wenn du bot.load_extension benutzt
okay was ,muss ich den ändern?
bot.load_extension("name")
und was soll ich dafür raus nehemn?
bot.add_cog
Das ist das schon am laden
ok und was für ein name kommt dann da rein?
von der Datei
also so ?
bot.load_extension("help_cog")
bot.load_extension("music_cog")
versuch es
kommt das
dc@vmd115250:~/bot$ python3 main.py
main.py:20: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
bot.load_extension("help_cog")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
main.py:21: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
bot.load_extension("music_cog")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Zeig mal deine pip list
dc@vmd115250:~/bot$ pip list
Package Version
aiohttp 3.8.4
aiosignal 1.3.1
async-timeout 4.0.2
attrs 23.1.0
certifi 2019.11.28
chardet 3.0.4
charset-normalizer 3.1.0
colorama 0.4.6
command-not-found 0.3
dbus-python 1.2.16
discord 2.3.1
discord.py 2.3.1
distro 1.4.0
distro-info 0.23ubuntu1
ezcord 0.1.4
frozenlist 1.3.3
idna 2.8
language-selector 0.1
multidict 6.0.4
netifaces 0.10.4
pip 20.0.2
py-cord 2.4.1
PyGObject 3.36.0
pymacaroons 0.13.0
PyNaCl 1.3.0
python-apt 2.0.1+ubuntu0.20.4.1
python-dotenv 1.0.0
PyYAML 5.3.1
requests 2.22.0
setuptools 45.2.0
six 1.14.0
ssh-import-id 5.10
typing-extensions 4.7.1
ubuntu-advantage-tools 8001
ufw 0.36
urllib3 1.25.8
wheel 0.34.2
yarl 1.9.2
youtube-dl 2021.12.17
dc@vmd115250:~/bot$
🇩🇪
wie kann ich die am besten dieinstallieren
Das ist basic Python?
ja
.tag learnpython
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
habe jetzt discord.py, discord, py-cord und ezcord deinstalliert und py-cord installiert
Dann versuch es nochmal
kommt das Traceback (most recent call last):
File "/home/dc/.local/lib/python3.8/site-packages/discord/cog.py", line 780, in _load_from_module_spec
setup = getattr(lib, "setup")
AttributeError: module 'help_cog' has no attribute 'setup'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 20, in <module>
bot.load_extension("help_cog")
File "/home/dc/.local/lib/python3.8/site-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/home/dc/.local/lib/python3.8/site-packages/discord/cog.py", line 783, in _load_from_module_spec
raise errors.NoEntryPointError(key)
discord.errors.NoEntryPointError: Extension 'help_cog' has no 'setup' function.
ach, du hast nichtmal richtige cogs erstellt
Was meinst du grad genau?
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
ist das nicht daas hier ?
```await self.play_music(ctx)
@commands.command(name="pause", help="Pauses the current song being played")
async def pause(self, ctx, *args):
if self.is_playing:
self.is_playing = False
self.is_paused = True
self.vc.pause()
elif self.is_paused:
self.is_paused = False
self.is_playing = True
self.vc.resume()
@commands.command(name = "resume", aliases=["r"], help="Resumes playing with the discord bot")
async def resume(self, ctx, *args):
if self.is_paused:
self.is_paused = False
self.is_playing = True
self.vc.resume()
@commands.command(name="skip", aliases=["s"], help="Skips the current song being played")
async def skip(self, ctx):
if self.vc != None and self.vc:
self.vc.stop()
#try to play next in the queue if it exists
await self.play_music(ctx)
@commands.command(name="queue", aliases=["q"], help="Displays the current songs in queue")
async def queue(self, ctx):
retval = ""
for i in range(0, len(self.music_queue)):
# display a max of 5 songs in the current queue
if (i > 4): break
retval += self.music_queue[i][0]['title'] + "\n"
if retval != "":
await ctx.send(retval)
else:
await ctx.send("No music in queue")
@commands.command(name="clear", aliases=["c", "bin"], help="Stops the music and clears the queue")
async def clear(self, ctx):
if self.vc != None and self.is_playing:
self.vc.stop()
self.music_queue = []
await ctx.send("Music queue cleared")
@commands.command(name="leave", aliases=["disconnect", "l", "d"], help="Kick the bot from VC")
async def dc(self, ctx):
self.is_playing = False
self.is_paused = False
await self.vc.disconnect()```
könntest du da mal eventuell mit drüber schauen?
.tag codeblock
Please put your code in a code block:
```py
Here is your Code
```
That makes reading code in Discord a lot easier:
print("This is an example.")
Hattest du dir den Link angeschaut?
ja wie oben gefragt ist das nicht das was ich in einer anderen datei stehen habe?
Es fehlt die Klasse und so weiter
Welche Klasse genau meinst du grade ich kann dir grade nicht ganz folgen
wie das bei dem link
wenn ich die beiden vergleiche fehlt folgendes
def setup(bot): # this is called by Pycord to setup the cog
bot.add_cog(Greetings(bot)) # add the cog to the bot
bot.load_extension('cogs.greetings')
cogs_list = [
'greetings',
'moderation',
'fun',
'owner'
]
for cog in cogs_list:
bot.load_extension(f'cogs.{cog}')
?
Das bei dem Link sind die Datein mit den cogs, von der Main Datei würdest du diese laden
also muss das einfach in die main datei eingeführt werden
Das mit der Klasse kommt in den cog
ich kann dir aktuell nicht folgen, was du mit Klassen meinst
Jetzt das soweit geklappt nur das jetzt folgendes kommt
Traceback (most recent call last):
File "main.py", line 19, in <module>
bot.run(os.getenv("MYTOKEN"))
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 717, in run
return future.result()
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 696, in runner
await self.start(*args, **kwargs)
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 659, in start
await self.login(token)
File "/home/dc/.local/lib/python3.8/site-packages/discord/client.py", line 509, in login
raise TypeError(
TypeError: token must be of type str, not NoneType
Das erklärt sich von selbst