-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.py
94 lines (86 loc) · 3.95 KB
/
commands.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
import discord
from discord.ext import commands
from guild_settings import (
save_guild_settings,
set_guild_prefix,
set_guild_resources_channel,
)
from datetime import datetime
def setup_commands(bot, bot_start_time, guild_settings):
@bot.command(name="status")
@commands.has_permissions(manage_messages=True)
async def status(ctx):
print("status command called")
latency = round(bot.latency * 1000, 2)
server_count = len(bot.guilds)
user_count = sum(g.member_count for g in bot.guilds)
uptime = datetime.utcnow() - bot_start_time
status_message = (
f"**Bot Status**\n\n"
f"> Latency: {latency}ms\n"
f"> Servers: {server_count}\n"
f"> Users: {user_count}\n"
f"> Uptime: {str(uptime).split('.')[0]}\n\n"
)
website_url = "https://crackedunc.club/"
status_message += f"Visit the [site]({website_url})"
await ctx.send(status_message)
@bot.command(name="setresourcechannel")
@commands.has_permissions(manage_messages=True)
async def set_resource_channel(ctx, channel: discord.TextChannel):
print("setresourcechannel command called")
guild_id = str(ctx.guild.id)
set_guild_resources_channel(guild_id, channel.id, guild_settings)
await ctx.send(f"Resource channel set to {channel.mention}")
@bot.command(name="setapprovalchannel")
@commands.has_permissions(manage_messages=True)
async def set_approval_channel(ctx, channel: discord.TextChannel):
print("setapprovalchannel command called")
guild_id = str(ctx.guild.id)
guild_settings["guilds"][guild_id] = guild_settings["guilds"].get(guild_id, {})
guild_settings["guilds"][guild_id]["approval_channel"] = channel.id
save_guild_settings(guild_settings)
await ctx.send(f"Approval channel set to {channel.mention}")
@bot.command(name="setprefix")
@commands.has_permissions(manage_messages=True)
async def set_prefix(ctx, new_prefix: str):
print("setprefix command called")
guild_id = str(ctx.guild.id)
set_guild_prefix(guild_id, new_prefix, guild_settings)
await ctx.send(f"Prefix set to `{new_prefix}`")
@bot.command(name="help")
async def help_command(ctx):
print("help command called")
guild_id = str(ctx.guild.id)
prefix = guild_settings["guilds"].get(guild_id, {}).get("prefix", "!")
help_message = (
f"**Bot Help**\n\n"
f"`{prefix}status` - Show bot status and link.\n"
f"`{prefix}setresourcechannel <channel>` - Set resource channel.\n"
f"`{prefix}setapprovalchannel <channel>` - Set approval channel.\n"
f"`{prefix}setprefix <new_prefix>` - Change command prefix.\n"
f"`{prefix}bugreport <description>` - Submit a bug report.\n"
f"`{prefix}help` - Show this message."
)
await ctx.send(help_message)
@bot.command(name="bugreport")
async def bugreport(ctx, *, description: str):
print("bugreport command called")
dev_guild_id = 1151350764854317076
bug_report_channel_id = 1279668175188787230
bug_report_channel = bot.get_channel(bug_report_channel_id)
if bug_report_channel:
report_message = (
f"\u200B\n**report** from `{ctx.guild.name}`\n"
f"**user**: `{ctx.author}` (ID: `{ctx.author.id}`)\n"
f"**channel**: `{ctx.channel.name}` (ID: `{ctx.channel.id}`)\n"
f"**desc**:\n`{description}`"
)
await bug_report_channel.send(report_message)
await ctx.send(
"thanks for the bug report. for further assistance contact us dev at `[email protected]`."
)
else:
await ctx.send(
"bug reporting is restricted to specific servers. this shouldnt trigger, please contact me at `[email protected]`."
)