-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices.py
115 lines (97 loc) · 3.61 KB
/
services.py
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
import discord
import asyncio
import datetime
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
bot = discord.Bot(intents=intents)
@bot.event
async def on_ready():
print(f"\nWe have logged in as: {bot.user.display_name}")
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="/help"))
@bot.event
async def on_application_command_error(ctx, error: discord.DiscordException):
if isinstance(error, commands.CommandOnCooldown):
embed = discord.Embed(
description=f"<a:denied:1300812792085090435> {error}",
color=discord.Color.red()
)
await ctx.respond(embed=embed)
else:
raise error
@bot.event
async def on_member_join(member: discord.Member):
ping_channel_id = 1302396598591950919
welcome_channel_id = 1196022863430418523
ping_channel = member.guild.get_channel(ping_channel_id)
welcome_channel = member.guild.get_channel(welcome_channel_id)
# Ping the member in the ping channel briefly
if ping_channel:
ping_message = await ping_channel.send(f"{member.mention}")
await asyncio.sleep(3)
await ping_message.delete()
# Create the welcome embed message
if welcome_channel:
member_count = len([m for m in member.guild.members if not m.bot])
suffix = "th" if 4 <= member_count % 100 <= 20 else {1: "st", 2: "nd", 3: "rd"}.get(member_count % 10, "th")
avatar_url = member.avatar.url if member.avatar else member.default_avatar.url
embed = discord.Embed(
title="Welcome to Paradise Casino! 🎰",
description=(
f"Hello, {member.mention}! We're excited to have you here. 🎉\n\n"
f"📋 **Make sure to:**\n"
f"> Read the <#1197073841252466709> for server guidelines.\n"
f"> Ask questions in <#1195705939651743824> if needed.\n"
f"> Use `/help` to view all bot commands!\n\n"
f"🎊 You are our **{member_count}{suffix}** member!"
),
color=discord.Color.gold()
)
embed.set_thumbnail(url=avatar_url)
embed.set_footer(text=f"User ID: {member.id}")
embed.timestamp = discord.utils.utcnow()
await welcome_channel.send(embed=embed)
@bot.slash_command(name='shutdown')
@commands.is_owner()
async def shutdown(ctx: discord.ApplicationContext):
"""Shut down the bot."""
embed = discord.Embed(
title="Shutdown",
description="Shutting down the bot...",
color=discord.Color.red()
)
await ctx.respond(embed=embed)
await bot.close()
start_time = datetime.datetime.now()
@bot.slash_command(name='uptime')
async def uptime(ctx: discord.ApplicationContext):
"""Check how long the bot has been running."""
now = datetime.datetime.now()
delta = now - start_time
days, remainder = divmod(delta.total_seconds(), 86400)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(remainder, 60)
formatted_uptime = f"{int(days)}d {int(hours)}h {int(minutes)}m {int(seconds)}s"
embed = discord.Embed(
title="⏱ Bot Uptime",
description=f"The bot has been running for **{formatted_uptime}**.",
color=discord.Color.blurple()
)
await ctx.respond(embed=embed)
cogs = [
'cogs.tickets',
'cogs.other',
'cogs.self_roles',
'cogs.fun',
'cogs.verify',
'cogs.utility',
'cogs.stats',
'cogs.todo',
"cogs.vc"
]
for cog in cogs:
try:
bot.load_extension(cog)
except Exception as e:
print(e)
bot.run("TOKEN")