first push

This commit is contained in:
Brandon4466
2023-06-05 14:00:18 -07:00
commit 5724319041

30
bot.py Normal file
View File

@@ -0,0 +1,30 @@
import discord
token = "MTA5MTE1NTg0MTMyMDc2MzUzNA.Gy-9Nx.do835DtdAXQz8Un5SGGr7WJY3u4CR-m2ytJKho"
client = discord.Client(intents=discord.Intents.all()) # Create a new client instance
tree = discord.app_commands.CommandTree(client)
@tree.command(name="status", description="Get the status of the bot.", guild=discord.Object(id=1093674638401351713))
async def status(interaction):
await interaction.response.send_message("I'm online!")
@client.event # Event decorator/wrapper
async def on_ready(): # When the bot is ready
await tree.sync(guild=discord.Object(id=1093674638401351713))
print(f'{client.user} has connected to Discord!') # Print a message to the console
@client.event # Event decorator/wrapper
async def on_message(message): # When a message is sent
channel = message.channel
if "http://" in message.content or "https://" in message.content and "bot" not in {channel.name}: # If the message contains a link and the channel is not a bot channel
try:
await message.delete()
print(f"Deleted message from @{message.author} in #{message.channel} because it contained a link.")
botchannel = client.get_channel(866994241490386956) # Get the channel with the ID 1234567890
await botchannel.send(f"Deleted message from @{message.author} in #{message.channel} because it contained a link:\n{message.content}")
except discord.errors.Forbidden:
print(f"Couldn't delete message from @{message.author} in #{message.channel} because I don't have permission.")
client.run(token) # Run the bot with the token