-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
123 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,65 @@ | ||
#!/usr/bin/bash | ||
import discord | ||
from discord.ext.commands import bot | ||
from constants import BOT_TOKEN | ||
import main | ||
from discord import app_commands, message | ||
|
||
intetns = discord.Intents.default() | ||
intetns.message_content = True | ||
|
||
client = discord.Client(intents=intetns) | ||
tree = app_commands.CommandTree(client) | ||
player = main.Player() | ||
|
||
@client.event | ||
async def on_ready(): | ||
await tree.sync(guild=discord.Object(id=824172801644036117)) | ||
print(f"Logged in as {client.user}") | ||
|
||
@client.event | ||
async def on_message(message): | ||
if message.author == client.user: | ||
return | ||
if message.content == ("play"): | ||
await player.play() | ||
await message.channel.send("playing") | ||
if message.content.startswith("add"): | ||
url = message.content.strip().split()[1] | ||
await player.add_to_que(url) | ||
await message.channel.send(player.que) | ||
if message.content.startswith("$hello"): | ||
await message.channel.send("hello") | ||
if message.content == "list": | ||
await message.channel.send(player.que) | ||
if message.content == "stop": | ||
player.stop() | ||
@tree.command( | ||
name="hello", | ||
description="desc", | ||
guild=discord.Object(id=824172801644036117) | ||
) | ||
async def hello(interaction: discord.Interaction, _: str) -> None: | ||
await interaction.response.send_message("Hello") | ||
|
||
@tree.command( | ||
name="stop", | ||
description="Stops the current song", | ||
guild=discord.Object(id=824172801644036117) | ||
) | ||
async def stop(interaction: discord.Interaction) -> None: | ||
player.stop() | ||
await interaction.response.send_message("playlist stopped") | ||
|
||
@tree.command( | ||
name="play", | ||
description="Starts the current playlist", | ||
guild=discord.Object(id=824172801644036117) | ||
) | ||
async def start(interaction: discord.Interaction) -> None: | ||
await player.play() | ||
await interaction.response.send_message("Playlist started!") | ||
|
||
@tree.command( | ||
name="list", | ||
description="Lists the songs that are in the playlist", | ||
guild=discord.Object(id=824172801644036117) | ||
) | ||
async def list(interaction: discord.Interaction) -> None: | ||
await interaction.response.send_message(player.que) | ||
|
||
|
||
@tree.command( | ||
name="add", | ||
description="Add a song to the playlist", | ||
guild=discord.Object(id=824172801644036117) | ||
) | ||
async def add(interaction: discord.Interaction, music: str) -> None: | ||
await player.add_to_que(music) | ||
await interaction.response.send_message(f"{music} was added to playlist") | ||
|
||
client.run(BOT_TOKEN) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters