-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
161 lines (135 loc) · 4.71 KB
/
main.py
File metadata and controls
161 lines (135 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import discord
from discord.ext import commands
import os
import random
import discord.opus
import asyncio
import yt_dlp as youtube_dl
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents)
voice_clients = {}
yt_dl_opts = {"format": "bestaudio/best"}
ytdl = youtube_dl.YoutubeDL(yt_dl_opts)
ffmpeg_options = {"options": "-vn"}
2
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.tree.command(
name="hello",
description="Retrieves the live doppler radar for a station, if none given, gets CONUS.",
)
async def _space(ctx: discord.interactions.Interaction):
await ctx.response.send_message("hello")
images_directory = "images"
music_directory = "music"
images = [
os.path.join(images_directory, file)
for file in os.listdir(images_directory)
if file.endswith((".png", ".jpg", ".jpeg", ".gif"))
]
music = [
os.path.join(music_directory, file)
for file in os.listdir(music_directory)
if file.endswith((".mp3"))
]
yeehaw_phrases = [
"Yeehaw!",
"Yippee ki-yay!",
"Giddy up cowboy!",
"Howdy partner!",
"Saddle up, we've got a yeehaw coming!",
"Hold on to your hats, it's yeehaw time!",
"Yeehaw, y'all!",
"Get ready for a rootin' tootin' good time!",
"Cowboy up, it's yeehaw o'clock!",
"Y'all ready to ride the yeehaw express?",
"Buckle up, it's gonna be a wild yeehaw ride!",
"Yeehawing into the sunset!",
"Round 'em up, it's yeehaw season!",
"Yeehaw squared!",
"Double the yippee ki-yay!",
"Giddy up for round two, cowboy!",
"Howdy again, partner!",
"Saddle up, we've got another yeehaw coming!",
"Hold on tight, more yeehaw is on the way!",
"Yeehaw encore, y'all!",
"Another rootin' tootin' good time!",
"Double down on the yeehaw fun!",
"Ride the yeehaw express one more time!",
"Buckle up, the wild yeehaw ride continues!",
"Yeehawing under the moonlight!",
"Round 'em up for more yeehaw season!",
"This town ain't big enough for the both of us..",
"Yeehaw squared again!",
"Double the yippee ki-yay again!",
"Giddy up for round three, cowboy",
"Howdy again, partner!",
"Saddle up, we've got another yeehaw coming!",
]
@client.command()
async def stop(ctx):
# Check if the bot is in a voice channel
if ctx.voice_client:
# Stop playing audio
ctx.voice_client.stop()
# Disconnect from the voice channel
await ctx.voice_client.disconnect()
else:
await ctx.send("I'm not currently in a voice channel.")
@client.command()
async def yeehaw(ctx):
file_path = random.choice(images)
file = discord.File(file_path)
await ctx.send(file=file)
music_path = random.choice(music)
await ctx.send(random.choice(yeehaw_phrases))
voice_channel = ctx.author.voice.channel
voice_client = await voice_channel.connect()
voice_clients[voice_client.guild.id] = voice_client
print("________________________________________________________")
print(f"Command invoked by: {ctx.author.name} ({ctx.author.id})")
print("________________________________________________________")
print(f"Now playing music: {music_path}")
voice_client.play(discord.FFmpegPCMAudio(source=music_path))
while voice_client.is_playing():
await asyncio.sleep(1)
await voice_client.disconnect()
@client.command()
async def yeehaw_loop(ctx):
await ctx.send(random.choice(yeehaw_phrases))
file_path = random.choice(images)
file = discord.File(file_path)
await ctx.send(file=file)
voice_channel = ctx.author.voice.channel
voice_client = await voice_channel.connect()
voice_clients[voice_client.guild.id] = voice_client
print("________________________________________________________")
print(f"Command invoked by: {ctx.author.name} ({ctx.author.id})")
print("________________________________________________________")
while True:
music_path = random.choice(music)
print(f"Now playing music: {music_path}")
voice_client.play(discord.FFmpegPCMAudio(source=music_path))
while voice_client.is_playing():
await asyncio.sleep(1)
@client.command()
async def next(ctx):
if not ctx.voice_client:
await ctx.send("I'm not currently in a voice channel.")
return
ctx.voice_client.stop()
music_path = random.choice(music)
# Play the next track
ctx.voice_client.play(discord.FFmpegPCMAudio(source=music_path))
while ctx.voice_client.is_playing():
await asyncio.sleep(1)
try:
client.run(
"TOKEN_HERE"
)
except Exception as error:
print(error)