Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
NotJINXZ committed May 27, 2023
1 parent d769d39 commit bed9de2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ config.py
data.json
temp.py
testing.py
hook.py
19 changes: 15 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ async def rotate_status():
await bot.change_presence(activity=activity)
await asyncio.sleep(30) # Change the interval as desired

async def guild_updater():
if not statsupdater_enabled:
return

if botsgg_token and botsgg_token != "":
requests.post(f"https://discord.bots.gg/api/v1/bots/{bot.user.id}/stats", json={"guildCount": bot.guilds.count}, headers={"Content-Type": "application/json", "Authorization": statsupdater_enabled(botsgg_token)})

if botsfordiscord_token and botsfordiscord_token != "":
requests.post(f"https://discords.com/bots/api/bot/" + str(bot.user.id), json={"server_count": bot.guilds.count}, headers={"Authorization": str(botsfordiscord_token)})

await asyncio.sleep(600)

async def log_action(server_id, action, user=None, description=None):
webhook_url = get_logging_webhook_value(str(server_id))
Expand Down Expand Up @@ -395,7 +406,7 @@ async def verify(interaction: Interaction, member: discord.Member = None):
await interaction.response.send_message(embed=embed, ephemeral=True)
return

@bot.tree.command(name="config_verifiedrole")
@bot.tree.command(name="config_verifiedrole", description="Set a role to be given apon successful verification.")
@app_commands.commands.describe(role="The verified role to give.")
async def config_verifiedrole(interaction: discord.Interaction, role: discord.Role):
if not interaction.user.guild_permissions.administrator:
Expand All @@ -413,7 +424,7 @@ async def config_verifiedrole(interaction: discord.Interaction, role: discord.Ro
embed = success_embed(f"Successfully linked the role: {role.mention}.")
await interaction.response.send_message(embed=embed)

@bot.tree.command(name="config_staffrole")
@bot.tree.command(name="config_staffrole", description="Set a role to be used for staff.")
@app_commands.commands.describe(role="The staff role (Will have access to most features)")
async def config_staffrole(interaction: discord.Interaction, role: discord.Role):
if not interaction.user.guild_permissions.administrator:
Expand Down Expand Up @@ -451,15 +462,15 @@ def is_valid_webhook(webhook: str) -> bool:

return True

@bot.tree.command(name="config_logswebhook")
@bot.tree.command(name="config_logswebhook", description="Set a channel to be used for logging")
@app_commands.commands.describe(channel="The channel where the webhook will be created for logging purposes.")
async def config_logswebhook(interaction: discord.Interaction, channel: discord.TextChannel):
if not interaction.user.guild_permissions.administrator:
await interaction.response.send_message(embed=error_embed("You do not have permission to run this command."), delete_after=10)
return

webhook = await channel.create_webhook(name=f"{application_name} - Logging", avatar="https://beta.jinxz.dev/u/pSv5U9.jpg")
set_logging_webhook(str(interaction.guild.id), str(webhook.url))
set_logging_webhook(str(interaction.guild.id), webhook.url)

await interaction.response.send_message(embed=success_embed(f"Successfully created and set the logging webhook in channel {channel.mention}"), ephemeral=True)
return
Expand Down
6 changes: 5 additions & 1 deletion config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ mongo_connection_uri = "" # Replace with your mongodb connection uri
# Status configuration
statuses = ["github.com/NotJINXZ", "/verify", "Best verification bot!", "${member_count} members in {$server_count} servers"] # You may have as many statuses as you like. (It switches every 60s). You may use these as well: ${server_count} and ${member_count}. You can also specify different types for each status using something like this: "/verify:::watching"
status_type = "streaming" # Choose the desired status type: competing, playing, streaming, listening, watching
streaming_url = "https://www.twitch.tv/its_jinxz" # Replace with your streaming URL if applicable
streaming_url = "https://www.twitch.tv/its_jinxz" # Replace with your streaming URL if applicable
# Automatic guild updater for bot lists.
statsupdater_enabled = False
botsgg_token = "" # discord.bots.gg
botsfordiscord_token = "" # botsfordiscord.com
32 changes: 32 additions & 0 deletions stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from config import token
import discord

bot = discord.Client(intents=discord.Intents.all())

@bot.event
async def on_ready():
print("Bot Information:")
print("Username: {}".format(bot.user.name))
print("Discriminator: {}".format(bot.user.discriminator))
print("User ID: {}".format(bot.user.id))
print("Server Count: {}".format(len(bot.guilds)))
print("Member Count: {}".format(sum(len(guild.members) for guild in bot.guilds)))
print("Bot is connected to the following servers:")
for guild in bot.guilds:
print("- {} (ID: {})".format(guild.name, guild.id))
print(" Member Count: {}".format(len(guild.members)))
# print(" Channels:")
# for channel in guild.channels:
# print(" - {} (ID: {})".format(channel.name, channel.id))
print("---------------")

# Shard Information
print("Shard Information:")
print("Shard ID: {}".format(bot.shard_id))
print("Total Shards: {}".format(bot.shard_count))
print("---------------")

await bot.close()
# raise SystemExit

bot.run(token)

0 comments on commit bed9de2

Please sign in to comment.