From 92fb4e5a52ef4570152de7e973fb2df762b4efcf Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sat, 10 Feb 2024 23:25:06 -0500 Subject: [PATCH 01/28] update readme for more details. Added example .env. Added discord icon to /af profile embed. Added commented out code for clearing terminal on bot run if need in main.py. --- README.md | 84 ++++++++++++++++++++++++++++++-------------- src/main.py | 4 ++- src/trade/attacks.py | 2 +- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 519bf16..fbfb2aa 100644 --- a/README.md +++ b/README.md @@ -6,48 +6,78 @@ The goal is for this to be a multipurpose bot for Paints & Shells! Current funct Open for anyone to contribute to. -## Setup Python venv +## Setup -For mac: +1. If you don’t have Python installed, [install it from here](https://www.python.org/downloads/). -``` -$ python -m venv venv -$ source venv/bin/activate -$ pip install -r requirements.txt -``` +2. Clone this repository. -For windows: +3. Navigate into the project directory: -``` -$ python -m venv venv -$ venv/Scripts/activate -$ pip install -r requirements.txt -``` + ```bash + cd Shells + ``` + +4. Create a new virtual environment: + + #### For mac: + + ```bash + $ python -m venv venv + $ source venv/bin/activate + ``` + + #### For windows: + + ```bash + $ python -m venv venv + $ venv/Scripts/activate + ``` + +5. Install the requirements: -## Running locally + ```bash + pip install -r requirements.txt + ``` -1. You'll need to create a discord bot at https://discord.com/developers/applications -2. Create a .env file, with `DISCORD_TOKEN={your token}` +6. Make a copy of the example environment variables file: -#### Turning on Presence Intents + ```bash + cp .env.example .env + ``` -For your local bot, you'll need to go to https://discord.com/developers/applications -Settings -> Privileged Gateway Intents -Turn on all 3 Presence Intents. +### Discord Bot -#### Local DB - Firebase +1. You'll need to [create a discord bot](https://discord.com/developers/applications) and invite it to your server. + +2. To turn on Presence Intents, go to your bot's [settings](https://discord.com/developers/applications), `Bot -> Privileged Gateway Intents`, and turn on all 3 Presence Intents. + +3. Fill in the .env file with your bot token. + + ##### * Bot Role Permissions + * Once your bot has joined your server, be sure to give it a role with permissions to "Manage Messages" + + +### Local DB - Firebase 1. Create a [Firebase project](https://console.firebase.google.com/u/0/) -2. Go to "Realtime Database" and create a database, copy the link you see (should end with firebase.io.com). Save this to your .env file as `FIREBASE_DATABASE_URL` -3. Go to Project Settings > Service Accounts > Generate New Private Key +2. Go to `Build -> Realtime Database` and create a database, copy the link you see (should end with firebase.io.com). Save this to your .env file as `FIREBASE_DATABASE_URL` +3. Go to `Project Settings -> ⚙️ -> Service Accounts -> Generate New Private Key` and download the JSON file. 4. Drag the downloaded file into this directory. Change the name to `firebase_key`. 5. Set FIREBASE_KEY in your .env to the path of this key. -##### Possible Firebase issues -* is your test database public? Check in Realtime Database > Rules + ##### * Possible Firebase issues + * Is your test database public? Check in Realtime Database > Rules -##### Bot Role Permissions -* Once your bot has joined your server, be sure to give it a role with permissions to "Manage Messages" + +### Running the bot + +Run the app using python or python3 depending on your system (make sure you are in the src directory): + +```bash +cd src +python main.py +``` ## Database Schema diff --git a/src/main.py b/src/main.py index 15aa5f0..6294e76 100644 --- a/src/main.py +++ b/src/main.py @@ -34,8 +34,10 @@ async def setup_hook(self): await self.load_extension(extension) async def on_ready(self): + # Clear terminal screen + # os.system('cls' if os.name == 'nt' else 'clear') return - # await self.change_presence(activity=discord.Game('with your mo')) + # await self.change_presence(activity=discord.Game('with your mom')) async def firebase_setup(): database_url = os.getenv('FIREBASE_DATABASE_URL') diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 290f64d..ae00f49 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -305,7 +305,7 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info += f"User: **{v_username}**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" - embed_profile = discord.Embed(title=f"**{user}'s Profile**", description=profile_info, color=discord.Colour.light_embed()) + embed_profile = discord.Embed(title=f"**{user}'s Profile**", description=profile_info, color=discord.Colour.light_embed(), icon_url=interaction.user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 0e55f8e3490e4fa833dffc43961ce31925bfc2f5 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sat, 10 Feb 2024 23:25:27 -0500 Subject: [PATCH 02/28] update readme for more details. Added example .env. Added discord icon to /af profile embed. Added commented out code for clearing terminal on bot run if need in main.py. --- .env.example | 6 ++++++ ...hells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .env.example create mode 100644 src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..7f59e58 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +# Discord bot token +DISCORD_TOKEN = 'example' + +# Firebase credentials +FIREBASE_DATABASE_URL = 'https://example.firebaseio.com' +FIREBASE_KEY = 'example' \ No newline at end of file diff --git a/src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json b/src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json new file mode 100644 index 0000000..fff34b0 --- /dev/null +++ b/src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json @@ -0,0 +1,13 @@ +{ + "type": "service_account", + "project_id": "shells-mf", + "private_key_id": "7cbdd07e3ce8b6ec5d1c03eb5add42ce9eaa1dd1", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCUjNsMPtBsGtOB\nlOj7iYv8h3KK709RTJRzmy26H5n1yUzgO/Lx1u85h+oBz+U2WtTfYmn/HpV4wA7T\nrLOfAZKFpCxJp/5C15dsj3FmGMLunOENwPeK4voupSH9O/5ZsICA3YU3kzzpVPBw\n8/in+aNm/nxXxIVUadKX2V6aM5SvdmjXIENH7MYPz4cKQrXMTew/vGQPDgUwIdM+\nRN+tzb8qiQratwLwOHGYCrSYaopT5Dvf2594pxMYyiMw/wDsKhuWNxZiyDBxrewg\n5X9f+41L6QQ/zjKCtZDRKyUhvz1ATDDTvXkyHvfwujn4yGa0qbypEVX5qcNBAqI7\nO193cBSBAgMBAAECggEAEDiraNRpJQzu4L0WjfUwrKRLzUEhq7KNmWwuG598y/qt\n4uSY/HCokeM2GfmOQZe8nCIeigXYc6WhWNsIiEn/KonJbkeie8EYH3owe2Ij0zOd\nXcefIHL1t+c/ZWxKM5gTCD9oXy+8XIxybxstIYagocwTXvAuUQ/3N668ZmFQkLJW\nWgOn0xKad/qbeiRmuyYGmW+J6x6QIaoLOPmFQR+OEkanlUpwKPy3rIf82ZfSF7ro\ncpJ5yWqr+Yu3PFSxP1sd1C+oc1ko149Hd+mqCuKheXWXbUkzHwxDrt8o1c9FbIID\n8H5ob1is9OIyK8BOwlIfqzi2no0pEkQA28OmDkpNmQKBgQDHLNKmIL7TVyMJdJwb\nuApmyGnXjjGc8o3VATVsiV42HswHcl1wmlUexH0LOgUwAYxdWcGqH9/Ea1mbfIL1\ndp92JJn7e0HD2PKhe6GkcpxPZ92M14y4mzt4vddjU5ubGvGAhNbWMQcy35JPUuII\njdagSKQQuDXaLcyCK+rjECU8tQKBgQC+7omSroGd2aJ53482M+4t3NZokKeijuF/\nGvYUV50nt5hjXfmv+Zn3y+R3P+4jFp9VrhQ42g8RtvvZyA3iEdClE0QwkF0MJfjD\nourSMnoKLfuELp+BXyMkiXyVQLG1yt85gpixW4UKmuOpi6TsUlPDmM6lj7qlARKQ\nUdTiI+vkHQKBgQCQxY/HmP2beDbLZKsjqr5Ev1/PglelkNhu/xXp8l88T15V+1bX\nxhYg6wlI479piXaRU/BkzA5GIxFa50H5UWPO6APUu16uED8sCUUQ1w2u2fw7p2Ft\nvceYl8S7OcZdE1R+6g+OWMy2ubMLXV9WgGKE1sgKLxtVnvyLkYiFyvKGEQKBgFPR\n3p2BdK+6koSUa4etJpwFvi7rilxoA4DMckmd6QU9qW2+HNZvanOJlEPx0fafgNWZ\ndZE70a/CODB0jfu4PHOr0JzNU7v4k4w3YoVi2YbMhwWRfj7KaGAq54GShDG93V+f\nAK+j8PUl6FpPTtjcj59n3xh5z8OOg/rNofqhMHbVAoGBAIgfJLB5QsmF4a2K/yvD\nZHiweMaPBTbgibGd2kcCBhrzwAN9YainTyROTq0hdEzV4tKx6xaNSwM3D/5iCM8L\nxOtJvA0DcFcaU/D4bjr0VmZdlhwoI20iXrJRDh1ZpX3s7oq4isq6fzkHmtSxVuhV\nMHdQz6NOon25m67jan1mnpIh\n-----END PRIVATE KEY-----\n", + "client_email": "firebase-adminsdk-6qdvo@shells-mf.iam.gserviceaccount.com", + "client_id": "112454422990581811766", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-6qdvo%40shells-mf.iam.gserviceaccount.com", + "universe_domain": "googleapis.com" +} From 6c012905f2081968329537038b0caf3ee78db5b0 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sat, 10 Feb 2024 23:28:01 -0500 Subject: [PATCH 03/28] update readme for more details. Added example .env. Added discord icon to /af profile embed. Added commented out code for clearing terminal on bot run if need in main.py. --- README.md | 6 +++--- .env.example => src/.env.example | 0 ...hells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json | 13 ------------- 3 files changed, 3 insertions(+), 16 deletions(-) rename .env.example => src/.env.example (100%) delete mode 100644 src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json diff --git a/README.md b/README.md index fbfb2aa..ba2b5ea 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Open for anyone to contribute to. 3. Navigate into the project directory: ```bash - cd Shells + cd Shells/src ``` 4. Create a new virtual environment: @@ -62,8 +62,8 @@ Open for anyone to contribute to. 1. Create a [Firebase project](https://console.firebase.google.com/u/0/) 2. Go to `Build -> Realtime Database` and create a database, copy the link you see (should end with firebase.io.com). Save this to your .env file as `FIREBASE_DATABASE_URL` -3. Go to `Project Settings -> ⚙️ -> Service Accounts -> Generate New Private Key` and download the JSON file. -4. Drag the downloaded file into this directory. Change the name to `firebase_key`. +3. Go to `Project Settings -> ⚙️ -> Service Accounts -> Generate New Private Key` and download the JSON file as `firebase_key.json`. +4. Drag the downloaded file into this directory. 5. Set FIREBASE_KEY in your .env to the path of this key. ##### * Possible Firebase issues diff --git a/.env.example b/src/.env.example similarity index 100% rename from .env.example rename to src/.env.example diff --git a/src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json b/src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json deleted file mode 100644 index fff34b0..0000000 --- a/src/shells-mf-firebase-adminsdk-6qdvo-7cbdd07e3c.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "service_account", - "project_id": "shells-mf", - "private_key_id": "7cbdd07e3ce8b6ec5d1c03eb5add42ce9eaa1dd1", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCUjNsMPtBsGtOB\nlOj7iYv8h3KK709RTJRzmy26H5n1yUzgO/Lx1u85h+oBz+U2WtTfYmn/HpV4wA7T\nrLOfAZKFpCxJp/5C15dsj3FmGMLunOENwPeK4voupSH9O/5ZsICA3YU3kzzpVPBw\n8/in+aNm/nxXxIVUadKX2V6aM5SvdmjXIENH7MYPz4cKQrXMTew/vGQPDgUwIdM+\nRN+tzb8qiQratwLwOHGYCrSYaopT5Dvf2594pxMYyiMw/wDsKhuWNxZiyDBxrewg\n5X9f+41L6QQ/zjKCtZDRKyUhvz1ATDDTvXkyHvfwujn4yGa0qbypEVX5qcNBAqI7\nO193cBSBAgMBAAECggEAEDiraNRpJQzu4L0WjfUwrKRLzUEhq7KNmWwuG598y/qt\n4uSY/HCokeM2GfmOQZe8nCIeigXYc6WhWNsIiEn/KonJbkeie8EYH3owe2Ij0zOd\nXcefIHL1t+c/ZWxKM5gTCD9oXy+8XIxybxstIYagocwTXvAuUQ/3N668ZmFQkLJW\nWgOn0xKad/qbeiRmuyYGmW+J6x6QIaoLOPmFQR+OEkanlUpwKPy3rIf82ZfSF7ro\ncpJ5yWqr+Yu3PFSxP1sd1C+oc1ko149Hd+mqCuKheXWXbUkzHwxDrt8o1c9FbIID\n8H5ob1is9OIyK8BOwlIfqzi2no0pEkQA28OmDkpNmQKBgQDHLNKmIL7TVyMJdJwb\nuApmyGnXjjGc8o3VATVsiV42HswHcl1wmlUexH0LOgUwAYxdWcGqH9/Ea1mbfIL1\ndp92JJn7e0HD2PKhe6GkcpxPZ92M14y4mzt4vddjU5ubGvGAhNbWMQcy35JPUuII\njdagSKQQuDXaLcyCK+rjECU8tQKBgQC+7omSroGd2aJ53482M+4t3NZokKeijuF/\nGvYUV50nt5hjXfmv+Zn3y+R3P+4jFp9VrhQ42g8RtvvZyA3iEdClE0QwkF0MJfjD\nourSMnoKLfuELp+BXyMkiXyVQLG1yt85gpixW4UKmuOpi6TsUlPDmM6lj7qlARKQ\nUdTiI+vkHQKBgQCQxY/HmP2beDbLZKsjqr5Ev1/PglelkNhu/xXp8l88T15V+1bX\nxhYg6wlI479piXaRU/BkzA5GIxFa50H5UWPO6APUu16uED8sCUUQ1w2u2fw7p2Ft\nvceYl8S7OcZdE1R+6g+OWMy2ubMLXV9WgGKE1sgKLxtVnvyLkYiFyvKGEQKBgFPR\n3p2BdK+6koSUa4etJpwFvi7rilxoA4DMckmd6QU9qW2+HNZvanOJlEPx0fafgNWZ\ndZE70a/CODB0jfu4PHOr0JzNU7v4k4w3YoVi2YbMhwWRfj7KaGAq54GShDG93V+f\nAK+j8PUl6FpPTtjcj59n3xh5z8OOg/rNofqhMHbVAoGBAIgfJLB5QsmF4a2K/yvD\nZHiweMaPBTbgibGd2kcCBhrzwAN9YainTyROTq0hdEzV4tKx6xaNSwM3D/5iCM8L\nxOtJvA0DcFcaU/D4bjr0VmZdlhwoI20iXrJRDh1ZpX3s7oq4isq6fzkHmtSxVuhV\nMHdQz6NOon25m67jan1mnpIh\n-----END PRIVATE KEY-----\n", - "client_email": "firebase-adminsdk-6qdvo@shells-mf.iam.gserviceaccount.com", - "client_id": "112454422990581811766", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-6qdvo%40shells-mf.iam.gserviceaccount.com", - "universe_domain": "googleapis.com" -} From d6580daafb1700b7fd71cf9597a55297bb0186c9 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sat, 10 Feb 2024 23:35:32 -0500 Subject: [PATCH 04/28] update readme for more details. Added example .env. Added discord icon to /af profile embed. Added commented out code for clearing terminal on bot run if need in main.py. Minor debug print change in setup.py --- README.md | 3 +-- src/setup.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba2b5ea..10ace06 100644 --- a/README.md +++ b/README.md @@ -72,10 +72,9 @@ Open for anyone to contribute to. ### Running the bot -Run the app using python or python3 depending on your system (make sure you are in the src directory): +Run the app using python or python3 depending on your system (make sure you are in the `Shells/src` directory): ```bash -cd src python main.py ``` diff --git a/src/setup.py b/src/setup.py index ed2a269..49c5b20 100644 --- a/src/setup.py +++ b/src/setup.py @@ -22,7 +22,7 @@ async def sync(self, ctx): try: self.bot.tree.copy_global_to(guild=ctx.guild) synced = await self.bot.tree.sync() - print(synced) + print(f"Synced {len(synced)} commands/n") await ctx.send("Synced") except discord.HTTPException as e: await ctx.send("Failed" + str(e)) From ed51264850a924441d7c08c90b42cc2bd17e6c3e Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 01:41:14 -0500 Subject: [PATCH 05/28] update readme. Fixed embed to include profile pic and profile viewiblity/mention --- README.md | 2 +- src/trade/attacks.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10ace06..eb2cfe3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The goal is for this to be a multipurpose bot for Paints & Shells! Current funct Open for anyone to contribute to. -## Setup +## Python Setup 1. If you don’t have Python installed, [install it from here](https://www.python.org/downloads/). diff --git a/src/trade/attacks.py b/src/trade/attacks.py index ae00f49..64e68bf 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -305,7 +305,8 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info += f"User: **{v_username}**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" - embed_profile = discord.Embed(title=f"**{user}'s Profile**", description=profile_info, color=discord.Colour.light_embed(), icon_url=interaction.user.avatar) + embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) + embed_profile.set_author(name=interaction.user.mention + "'s Profile", icon_url=interaction.user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From dfaf842be7432688adbb4b1711af119624c15fb7 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 02:16:49 -0500 Subject: [PATCH 06/28] update readme and moved .env.example outside src folder --- README.md | 19 ++++++++++--------- src/.env.example | 6 ------ src/trade/attacks.py | 3 ++- 3 files changed, 12 insertions(+), 16 deletions(-) delete mode 100644 src/.env.example diff --git a/README.md b/README.md index eb2cfe3..6b97504 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,19 @@ Open for anyone to contribute to. 2. Clone this repository. -3. Navigate into the project directory: +3. Make a copy of the example environment variables file: + ```bash + cd Shells + cp .env.example .env + ``` + +4. Navigate into the project src directory: ```bash cd Shells/src ``` -4. Create a new virtual environment: +5. Create a new virtual environment: #### For mac: @@ -34,17 +40,12 @@ Open for anyone to contribute to. $ venv/Scripts/activate ``` -5. Install the requirements: +6. Install the requirements: ```bash pip install -r requirements.txt ``` -6. Make a copy of the example environment variables file: - - ```bash - cp .env.example .env - ``` ### Discord Bot @@ -61,7 +62,7 @@ Open for anyone to contribute to. ### Local DB - Firebase 1. Create a [Firebase project](https://console.firebase.google.com/u/0/) -2. Go to `Build -> Realtime Database` and create a database, copy the link you see (should end with firebase.io.com). Save this to your .env file as `FIREBASE_DATABASE_URL` +2. Go to `Build -> Realtime Database` and create a database, copy the link you see (ie. `https://example.firebaseio.com`). Save this to your .env file as `FIREBASE_DATABASE_URL` 3. Go to `Project Settings -> ⚙️ -> Service Accounts -> Generate New Private Key` and download the JSON file as `firebase_key.json`. 4. Drag the downloaded file into this directory. 5. Set FIREBASE_KEY in your .env to the path of this key. diff --git a/src/.env.example b/src/.env.example deleted file mode 100644 index 7f59e58..0000000 --- a/src/.env.example +++ /dev/null @@ -1,6 +0,0 @@ -# Discord bot token -DISCORD_TOKEN = 'example' - -# Firebase credentials -FIREBASE_DATABASE_URL = 'https://example.firebaseio.com' -FIREBASE_KEY = 'example' \ No newline at end of file diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 64e68bf..5830790 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -306,7 +306,8 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) - embed_profile.set_author(name=interaction.user.mention + "'s Profile", icon_url=interaction.user.avatar) + embed_profile.set_author(name=f'{interaction.user.mention}' + "'s Profile", icon_url=interaction.user.avatar) + embed_profile.set_thumbnail(url=message_url) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 6f0cdf66ea56caf565aacb5afc4838381311c3d8 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 02:19:11 -0500 Subject: [PATCH 07/28] update readme and moved .env.example outside src folder --- src/trade/attacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 5830790..74286ad 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -306,7 +306,7 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) - embed_profile.set_author(name=f'{interaction.user.mention}' + "'s Profile", icon_url=interaction.user.avatar) + embed_profile.set_author(name=f'{interaction.user.mention}\'s Profile', icon_url=interaction.user.avatar) embed_profile.set_thumbnail(url=message_url) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From e5999a0058d61c5b98d9937d4ec5dd177b4481c5 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 02:23:13 -0500 Subject: [PATCH 08/28] update readme and moved .env.example outside src folder --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6b97504..08d972d 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,13 @@ Open for anyone to contribute to. 2. Clone this repository. -3. Make a copy of the example environment variables file: - ```bash - cd Shells - cp .env.example .env - ``` - -4. Navigate into the project src directory: +3. Navigate into the project directory: ```bash - cd Shells/src + $ cd Shells ``` -5. Create a new virtual environment: +4. Create a new virtual environment: #### For mac: @@ -40,12 +34,17 @@ Open for anyone to contribute to. $ venv/Scripts/activate ``` -6. Install the requirements: +5. Install the requirements: ```bash - pip install -r requirements.txt + $ pip install -r requirements.txt ``` +6. Make a copy of the example environment variables file: + + ```bash + $ cp .env.example .env + ``` ### Discord Bot @@ -76,7 +75,8 @@ Open for anyone to contribute to. Run the app using python or python3 depending on your system (make sure you are in the `Shells/src` directory): ```bash -python main.py +$ cd src +$ python main.py ``` ## Database Schema From 73633fb197679a0ff6f4df9f67dd6ecb724893a6 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 02:23:33 -0500 Subject: [PATCH 09/28] update readme and moved .env.example outside src folder --- .env.example | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..7f59e58 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +# Discord bot token +DISCORD_TOKEN = 'example' + +# Firebase credentials +FIREBASE_DATABASE_URL = 'https://example.firebaseio.com' +FIREBASE_KEY = 'example' \ No newline at end of file From 4e1ff62eb1c912d4559a83fd58a77d3e87d1d4e7 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 03:11:35 -0500 Subject: [PATCH 10/28] minor readme fix. Updated profile in attacks to include profile mention and profile avatar though theres 2 options to have avatar displayed. --- README.md | 18 +++++++++--------- src/trade/attacks.py | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 08d972d..710335e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Open for anyone to contribute to. 3. Navigate into the project directory: ```bash - $ cd Shells + cd Shells ``` 4. Create a new virtual environment: @@ -23,27 +23,27 @@ Open for anyone to contribute to. #### For mac: ```bash - $ python -m venv venv - $ source venv/bin/activate + python -m venv venv + source venv/bin/activate ``` #### For windows: ```bash - $ python -m venv venv - $ venv/Scripts/activate + python -m venv venv + venv/Scripts/activate ``` 5. Install the requirements: ```bash - $ pip install -r requirements.txt + pip install -r requirements.txt ``` 6. Make a copy of the example environment variables file: ```bash - $ cp .env.example .env + cp .env.example .env ``` ### Discord Bot @@ -75,8 +75,8 @@ Open for anyone to contribute to. Run the app using python or python3 depending on your system (make sure you are in the `Shells/src` directory): ```bash -$ cd src -$ python main.py +cd src +python main.py ``` ## Database Schema diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 74286ad..fb2ada1 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -302,12 +302,12 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): #v_oclink = f"[{v_oclink}]({v_oclink})" v_notes = specified_user.get("notes") - profile_info += f"User: **{v_username}**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" + profile_info += f"User: **<@{user.id}>**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) - embed_profile.set_author(name=f'{interaction.user.mention}\'s Profile', icon_url=interaction.user.avatar) - embed_profile.set_thumbnail(url=message_url) + embed_profile.set_thumbnail(url=user.avatar) + embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=interaction.user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 5ed85ef58072c414654d3b815bdb3f0610928690 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 03:14:42 -0500 Subject: [PATCH 11/28] minor readme fix. Updated profile in attacks to include profile mention and profile avatar though theres 2 options to have avatar displayed. --- src/trade/attacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index fb2ada1..8083225 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -306,7 +306,7 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) - embed_profile.set_thumbnail(url=user.avatar) + # embed_profile.set_thumbnail(url=user.avatar) embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=interaction.user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 1ac88eb7fdbe600b7b664971009ccedb840dcb51 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 14:26:18 -0500 Subject: [PATCH 12/28] removed .env.example and updated readme. --- .env.example | 6 ------ README.md | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index 7f59e58..0000000 --- a/.env.example +++ /dev/null @@ -1,6 +0,0 @@ -# Discord bot token -DISCORD_TOKEN = 'example' - -# Firebase credentials -FIREBASE_DATABASE_URL = 'https://example.firebaseio.com' -FIREBASE_KEY = 'example' \ No newline at end of file diff --git a/README.md b/README.md index 710335e..7b97686 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,22 @@ Open for anyone to contribute to. pip install -r requirements.txt ``` -6. Make a copy of the example environment variables file: +6. Make an environment variables file: ```bash - cp .env.example .env + touch .env ``` +7. Fill in the .env file with the following: + + ```bash + DISCORD_TOKEN=your_discord_bot_token + FIREBASE_DATABASE_URL=your_firebase_database_url + FIREBASE_KEY=firebase_key.json + ``` + + * Replace `your_discord_bot_token` with your bot's token. + * Replace `your_firebase_database_url` with your Firebase database URL. + * Replace `firebase_key.json` with the path to your Firebase key file. ### Discord Bot From 471c6a4dad9acd637e82630107e3d259f7186e32 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 14:37:09 -0500 Subject: [PATCH 13/28] fixed minor mistake with wrong avatar being displayed --- src/trade/attacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 8083225..5040ca8 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -307,7 +307,7 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) - embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=interaction.user.avatar) + embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From a31f75e94a4203bee1c7ccdc40dee2027dc2f424 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 17:24:13 -0500 Subject: [PATCH 14/28] branch test --- src/trade/attacks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 5040ca8..6ffbac9 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -304,9 +304,19 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info += f"User: **<@{user.id}>**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" + # embed manipulation for a specific message id. + fetch_atk_message = await interaction.channel.fetch_message(message_id) + if fetch_atk_message.embeds: + print("contains an embed") + for embed in fetch_atk_message.embeds: + print(embed.title) + print(embed.description) + print(embed.image.url) + # Profile Embed embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) + embed_profile.set_image(url=fetch_atk_message.embeds[0].image.url) embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 980ac42d3d9a679511358cd16a91ef4f92c9a9ae Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 17:25:26 -0500 Subject: [PATCH 15/28] undo branch test --- src/trade/attacks.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 6ffbac9..5040ca8 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -304,19 +304,9 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info += f"User: **<@{user.id}>**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" - # embed manipulation for a specific message id. - fetch_atk_message = await interaction.channel.fetch_message(message_id) - if fetch_atk_message.embeds: - print("contains an embed") - for embed in fetch_atk_message.embeds: - print(embed.title) - print(embed.description) - print(embed.image.url) - # Profile Embed embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) - embed_profile.set_image(url=fetch_atk_message.embeds[0].image.url) embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 0bc96b9ed72d43db2e17bc06f285a45d760a92cf Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 18:45:50 -0500 Subject: [PATCH 16/28] Extract image from most recent attack to display on profile embed --- src/trade/attacks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 5040ca8..f079af3 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -304,9 +304,13 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info += f"User: **<@{user.id}>**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" + # embed manipulation for a specific message id (most recent attack). + fetch_atk_message = await interaction.channel.fetch_message(message_id) + # Profile Embed embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) + embed_profile.set_thumbnail(url=fetch_atk_message.embeds[0].image.url) embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 9802afa1f472a1b9a5c3e1db2cf982cba0f8eeb1 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 20:05:38 -0500 Subject: [PATCH 17/28] beta version pagination of profile attacks --- src/trade/attacks.py | 45 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index f079af3..06fc037 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -263,6 +263,12 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info = "" user_dictionary = self.db_ref_users.get() + # list of attack Message Objects + atk_msgs = [] + + # list of defense Message Objects + def_msgs = [] + if user_dictionary == None: profile_info = "No users have been logged" else: @@ -288,6 +294,10 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): for message_id in sent_dictionary: message_url = f"https://discord.com/channels/{interaction.guild.id}/{interaction.channel.id}/{message_id}" v_sent += f"[{message_id}]({message_url})\n" + + # add to list of attack Message Objects + msg_obj = await interaction.channel.fetch_message(message_id) + atk_msgs.append(msg_obj) received_dictionary = specified_user.get("attacks_received") v_received = "" @@ -298,22 +308,47 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): message_url = f"https://discord.com/channels/{interaction.guild.id}/{interaction.channel.id}/{message_id}" v_received += f"[{message_id}]({message_url})\n" + # add to list of defense Message Objects + msg_obj = await interaction.channel.fetch_message(message_id) + def_msgs.append(msg_obj) + v_oclink = specified_user.get("oclink") #v_oclink = f"[{v_oclink}]({v_oclink})" v_notes = specified_user.get("notes") profile_info += f"User: **<@{user.id}>**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" - - # embed manipulation for a specific message id (most recent attack). - fetch_atk_message = await interaction.channel.fetch_message(message_id) # Profile Embed embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) - embed_profile.set_thumbnail(url=fetch_atk_message.embeds[0].image.url) embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) - await interaction.response.send_message("", embed=embed_profile, ephemeral=True) + # pagination of attack images using left and right buttons + atk_view = View() + if len(atk_msgs) > 0: + # index tracker for attack images + atk_view.index = 0 + + atk_view.add_item(Button(label="<", style=discord.ButtonStyle.primary)) + atk_view.add_item(Button(label=">", style=discord.ButtonStyle.primary)) + embed_profile.set_image(url=atk_msgs[atk_view.index].embeds[0].image.url) + + async def next_button_callback(interaction: discord.Interaction): + # edit embed image to next attack using index + embed_profile.set_image(url=atk_msgs[(atk_view.index+1) % len(atk_msgs)].embeds[0].image.url) + atk_view.index = (atk_view.index+1) % len(atk_msgs) + await interaction.response.edit_message(embed=embed_profile, view=atk_view) + + async def prev_button_callback(interaction: discord.Interaction): + # edit embed image to previous attack using index + embed_profile.set_image(url=atk_msgs[(atk_view.index-1) % len(atk_msgs)].embeds[0].image.url) + atk_view.index = (atk_view.index-1) % len(atk_msgs) + await interaction.response.edit_message(embed=embed_profile, view=atk_view) + + atk_view.children[0].callback = prev_button_callback + atk_view.children[1].callback = next_button_callback + + await interaction.response.send_message("", embed=embed_profile, view=atk_view, ephemeral=True) @af.command(name="editprofile", description="Allows exisitng users to add links to OCs and preference notes (blanks fields stay the same)") async def editprofile(self, interaction: discord.Interaction, new_oc_link: str = "", new_notes: str = ""): From dc6a33906592995d0a9be772e1644a8419b5fc10 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Mon, 12 Feb 2024 00:08:35 -0500 Subject: [PATCH 18/28] added feature to view attacks and defense images with buttons to navigate. Have fun with it. Excuse the source code uglyness --- src/trade/attacks.py | 66 +++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 06fc037..24e00b6 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -322,33 +322,67 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) + embed_profile.set_footer(text="Art Fight Profile", icon_url=interaction.guild.icon.url) # pagination of attack images using left and right buttons - atk_view = View() - if len(atk_msgs) > 0: - # index tracker for attack images - atk_view.index = 0 + view_images = View() + # index and mode tracker + view_images.index = 0 + view_images.mode = None + atk_msgs_exist = atk_msgs and len(atk_msgs) > 0 + def_msgs_exist = def_msgs and len(def_msgs) > 0 + + # atk and def image mode buttons |atk| |def| + if atk_msgs_exist: + view_images.add_item(Button(label="Attacks", style=discord.ButtonStyle.primary)) + view_images.mode = atk_msgs + if def_msgs_exist: + view_images.add_item(Button(label="Defenses", style=discord.ButtonStyle.primary)) + view_images.mode = def_msgs if view_images.mode == None else atk_msgs + + if view_images.mode: + view_images.add_item(Button(label="<", style=discord.ButtonStyle.primary)) + view_images.add_item(Button(label=">", style=discord.ButtonStyle.primary)) + embed_profile.set_image(url=view_images.mode[view_images.index].embeds[0].image.url) + + async def atk_button_callback(interaction: discord.Interaction): + view_images.mode = atk_msgs + view_images.index = 0 + embed_profile.set_image(url=view_images.mode[0].embeds[0].image.url) + embed_profile.set_footer(text="Art Fight Profile | Attacks Sent", icon_url=interaction.guild.icon.url) + await interaction.response.edit_message(embed=embed_profile, view=view_images) - atk_view.add_item(Button(label="<", style=discord.ButtonStyle.primary)) - atk_view.add_item(Button(label=">", style=discord.ButtonStyle.primary)) - embed_profile.set_image(url=atk_msgs[atk_view.index].embeds[0].image.url) + async def def_button_callback(interaction: discord.Interaction): + view_images.mode = def_msgs + view_images.index = 0 + embed_profile.set_image(url=view_images.mode[0].embeds[0].image.url) + embed_profile.set_footer(text="Art Fight Profile | Attacks Received", icon_url=interaction.guild.icon.url) + await interaction.response.edit_message(embed=embed_profile, view=view_images) async def next_button_callback(interaction: discord.Interaction): # edit embed image to next attack using index - embed_profile.set_image(url=atk_msgs[(atk_view.index+1) % len(atk_msgs)].embeds[0].image.url) - atk_view.index = (atk_view.index+1) % len(atk_msgs) - await interaction.response.edit_message(embed=embed_profile, view=atk_view) + embed_profile.set_image(url=view_images.mode[(view_images.index+1) % len(view_images.mode)].embeds[0].image.url) + view_images.index = (view_images.index+1) % len(view_images.mode) + await interaction.response.edit_message(embed=embed_profile, view=view_images) async def prev_button_callback(interaction: discord.Interaction): # edit embed image to previous attack using index - embed_profile.set_image(url=atk_msgs[(atk_view.index-1) % len(atk_msgs)].embeds[0].image.url) - atk_view.index = (atk_view.index-1) % len(atk_msgs) - await interaction.response.edit_message(embed=embed_profile, view=atk_view) + embed_profile.set_image(url=view_images.mode[(view_images.index-1) % len(view_images.mode)].embeds[0].image.url) + view_images.index = (view_images.index-1) % len(view_images.mode) + await interaction.response.edit_message(embed=embed_profile, view=view_images) - atk_view.children[0].callback = prev_button_callback - atk_view.children[1].callback = next_button_callback + view_children_indexer = 0 + if atk_msgs_exist: + view_images.children[view_children_indexer].callback = atk_button_callback + view_children_indexer += 1 + if def_msgs_exist: + view_images.children[view_children_indexer].callback = def_button_callback + view_children_indexer += 1 + view_images.children[view_children_indexer].callback = prev_button_callback + view_images.children[view_children_indexer+1].callback = next_button_callback + - await interaction.response.send_message("", embed=embed_profile, view=atk_view, ephemeral=True) + await interaction.response.send_message("", embed=embed_profile, view=view_images, ephemeral=True) @af.command(name="editprofile", description="Allows exisitng users to add links to OCs and preference notes (blanks fields stay the same)") async def editprofile(self, interaction: discord.Interaction, new_oc_link: str = "", new_notes: str = ""): From 3937ccc6bc603953ab58a95a7c3daf5b55acd06f Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Mon, 12 Feb 2024 00:15:38 -0500 Subject: [PATCH 19/28] fixed bug where if user was not registered, users name caused an exception --- src/trade/attacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 24e00b6..35da96b 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -321,7 +321,7 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): # Profile Embed embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) - embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) + embed_profile.set_author(name=f'{user.name}\'s Profile', icon_url=user.avatar) embed_profile.set_footer(text="Art Fight Profile", icon_url=interaction.guild.icon.url) # pagination of attack images using left and right buttons From cf1342c25c0ae4f85ae62392f7d6e81637340aa5 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Mon, 12 Feb 2024 17:37:43 -0500 Subject: [PATCH 20/28] Added .env descriptor to readme. Updated /attack to include "Art Fight" to confirmation Messages. --- README.md | 6 +++--- src/trade/attacks.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b97686..b60c9f4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Open for anyone to contribute to. 2. Clone this repository. -3. Navigate into the project directory: +3. Navigate into the `Shells` project directory: ```bash cd Shells @@ -40,12 +40,12 @@ Open for anyone to contribute to. pip install -r requirements.txt ``` -6. Make an environment variables file: +6. Make an environment variables file (`.env`) You should still be in the `Shells` directory: ```bash touch .env ``` -7. Fill in the .env file with the following: +7. Fill in the `.env` file with the following: ```bash DISCORD_TOKEN=your_discord_bot_token diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 35da96b..6a22fcb 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -100,6 +100,7 @@ async def callback_4(interaction: discord.Interaction): ) async def callback_5(interaction: discord.Interaction): confirm_embed = discord.Embed(title="Confirm Attack", color=discord.Colour.light_embed(), description=f"Size: **{select_1.values[0]}**\nFinish: **{select_2.values[0]}**\nColor: **{select_3.values[0]}**\nShading: **{select_4.values[0]}**\nBackground: **{select_5.values[0]}**\n") + confirm_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content=None, embed=confirm_embed, view=view_6) select_5.callback = callback_5 view_5 = View() @@ -186,6 +187,7 @@ async def success_callback(interaction: discord.Interaction): self.db_ref_users.update(victim_info) confirmation_embed = discord.Embed(title="**Attack Successfully Sent!**", color=discord.Colour.light_embed()) + confirmation_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=confirmation_embed, view=None) success_button.callback = success_callback @@ -195,6 +197,7 @@ async def success_callback(interaction: discord.Interaction): cancel_button = Button(label="Cancel Attack" ,style=discord.ButtonStyle.danger) async def cancel_callback(interaction: discord.Interaction): cancel_embed = discord.Embed(title="**Attack Cancelled**", description="(feel free to dismiss this message)", color=discord.Colour.light_embed()) + cancel_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=cancel_embed, view=None) cancel_button.callback = cancel_callback From 4802027532f31701cd01061035d5fe78b939194d Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Mon, 12 Feb 2024 22:11:28 -0500 Subject: [PATCH 21/28] revert to pre profileIMage feature --- src/trade/attacks.py | 80 ++------------------------------------------ 1 file changed, 2 insertions(+), 78 deletions(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 6a22fcb..a0b1d3e 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -100,7 +100,6 @@ async def callback_4(interaction: discord.Interaction): ) async def callback_5(interaction: discord.Interaction): confirm_embed = discord.Embed(title="Confirm Attack", color=discord.Colour.light_embed(), description=f"Size: **{select_1.values[0]}**\nFinish: **{select_2.values[0]}**\nColor: **{select_3.values[0]}**\nShading: **{select_4.values[0]}**\nBackground: **{select_5.values[0]}**\n") - confirm_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content=None, embed=confirm_embed, view=view_6) select_5.callback = callback_5 view_5 = View() @@ -187,7 +186,6 @@ async def success_callback(interaction: discord.Interaction): self.db_ref_users.update(victim_info) confirmation_embed = discord.Embed(title="**Attack Successfully Sent!**", color=discord.Colour.light_embed()) - confirmation_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=confirmation_embed, view=None) success_button.callback = success_callback @@ -197,7 +195,6 @@ async def success_callback(interaction: discord.Interaction): cancel_button = Button(label="Cancel Attack" ,style=discord.ButtonStyle.danger) async def cancel_callback(interaction: discord.Interaction): cancel_embed = discord.Embed(title="**Attack Cancelled**", description="(feel free to dismiss this message)", color=discord.Colour.light_embed()) - cancel_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=cancel_embed, view=None) cancel_button.callback = cancel_callback @@ -266,12 +263,6 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info = "" user_dictionary = self.db_ref_users.get() - # list of attack Message Objects - atk_msgs = [] - - # list of defense Message Objects - def_msgs = [] - if user_dictionary == None: profile_info = "No users have been logged" else: @@ -297,10 +288,6 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): for message_id in sent_dictionary: message_url = f"https://discord.com/channels/{interaction.guild.id}/{interaction.channel.id}/{message_id}" v_sent += f"[{message_id}]({message_url})\n" - - # add to list of attack Message Objects - msg_obj = await interaction.channel.fetch_message(message_id) - atk_msgs.append(msg_obj) received_dictionary = specified_user.get("attacks_received") v_received = "" @@ -311,81 +298,18 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): message_url = f"https://discord.com/channels/{interaction.guild.id}/{interaction.channel.id}/{message_id}" v_received += f"[{message_id}]({message_url})\n" - # add to list of defense Message Objects - msg_obj = await interaction.channel.fetch_message(message_id) - def_msgs.append(msg_obj) - v_oclink = specified_user.get("oclink") #v_oclink = f"[{v_oclink}]({v_oclink})" v_notes = specified_user.get("notes") profile_info += f"User: **<@{user.id}>**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" + - # Profile Embed embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) embed_profile.set_author(name=f'{user.name}\'s Profile', icon_url=user.avatar) - embed_profile.set_footer(text="Art Fight Profile", icon_url=interaction.guild.icon.url) - - # pagination of attack images using left and right buttons - view_images = View() - # index and mode tracker - view_images.index = 0 - view_images.mode = None - atk_msgs_exist = atk_msgs and len(atk_msgs) > 0 - def_msgs_exist = def_msgs and len(def_msgs) > 0 - - # atk and def image mode buttons |atk| |def| - if atk_msgs_exist: - view_images.add_item(Button(label="Attacks", style=discord.ButtonStyle.primary)) - view_images.mode = atk_msgs - if def_msgs_exist: - view_images.add_item(Button(label="Defenses", style=discord.ButtonStyle.primary)) - view_images.mode = def_msgs if view_images.mode == None else atk_msgs - - if view_images.mode: - view_images.add_item(Button(label="<", style=discord.ButtonStyle.primary)) - view_images.add_item(Button(label=">", style=discord.ButtonStyle.primary)) - embed_profile.set_image(url=view_images.mode[view_images.index].embeds[0].image.url) - - async def atk_button_callback(interaction: discord.Interaction): - view_images.mode = atk_msgs - view_images.index = 0 - embed_profile.set_image(url=view_images.mode[0].embeds[0].image.url) - embed_profile.set_footer(text="Art Fight Profile | Attacks Sent", icon_url=interaction.guild.icon.url) - await interaction.response.edit_message(embed=embed_profile, view=view_images) - - async def def_button_callback(interaction: discord.Interaction): - view_images.mode = def_msgs - view_images.index = 0 - embed_profile.set_image(url=view_images.mode[0].embeds[0].image.url) - embed_profile.set_footer(text="Art Fight Profile | Attacks Received", icon_url=interaction.guild.icon.url) - await interaction.response.edit_message(embed=embed_profile, view=view_images) - - async def next_button_callback(interaction: discord.Interaction): - # edit embed image to next attack using index - embed_profile.set_image(url=view_images.mode[(view_images.index+1) % len(view_images.mode)].embeds[0].image.url) - view_images.index = (view_images.index+1) % len(view_images.mode) - await interaction.response.edit_message(embed=embed_profile, view=view_images) - - async def prev_button_callback(interaction: discord.Interaction): - # edit embed image to previous attack using index - embed_profile.set_image(url=view_images.mode[(view_images.index-1) % len(view_images.mode)].embeds[0].image.url) - view_images.index = (view_images.index-1) % len(view_images.mode) - await interaction.response.edit_message(embed=embed_profile, view=view_images) - - view_children_indexer = 0 - if atk_msgs_exist: - view_images.children[view_children_indexer].callback = atk_button_callback - view_children_indexer += 1 - if def_msgs_exist: - view_images.children[view_children_indexer].callback = def_button_callback - view_children_indexer += 1 - view_images.children[view_children_indexer].callback = prev_button_callback - view_images.children[view_children_indexer+1].callback = next_button_callback - - await interaction.response.send_message("", embed=embed_profile, view=view_images, ephemeral=True) + await interaction.response.send_message("", embed=embed_profile, ephemeral=True) @af.command(name="editprofile", description="Allows exisitng users to add links to OCs and preference notes (blanks fields stay the same)") async def editprofile(self, interaction: discord.Interaction, new_oc_link: str = "", new_notes: str = ""): From 8aa7d1dbff97098392c642a603fcdb637f563ee4 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sun, 11 Feb 2024 17:25:26 -0500 Subject: [PATCH 22/28] undo branch test Updates: Modified Readme & Added avatar to /profile (#4) * update readme for more details. Added example .env. Added discord icon to /af profile embed. Added commented out code for clearing terminal on bot run if need in main.py. Minor debug print change in setup.py * update readme. Fixed embed to include profile pic and profile viewiblity/mention Extract image from most recent attack to display on profile embed beta version pagination of profile attacks added feature to view attacks and defense images with buttons to navigate. Have fun with it. Excuse the source code uglyness fixed bug where if user was not registered, users name caused an exception Added .env descriptor to readme. Updated /attack to include "Art Fight" to confirmation Messages. revert to pre profileIMage feature fixed small bug with /profile throwing exception if person not registered in database --- README.md | 6 +++--- src/trade/attacks.py | 12 +----------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7b97686..b60c9f4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Open for anyone to contribute to. 2. Clone this repository. -3. Navigate into the project directory: +3. Navigate into the `Shells` project directory: ```bash cd Shells @@ -40,12 +40,12 @@ Open for anyone to contribute to. pip install -r requirements.txt ``` -6. Make an environment variables file: +6. Make an environment variables file (`.env`) You should still be in the `Shells` directory: ```bash touch .env ``` -7. Fill in the .env file with the following: +7. Fill in the `.env` file with the following: ```bash DISCORD_TOKEN=your_discord_bot_token diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 6ffbac9..a0b1d3e 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -304,20 +304,10 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): profile_info += f"User: **<@{user.id}>**\nPoints: **{v_points}**\nRank: **{rank}**\n\nAttacks Sent:\n{v_sent}\nAttacks Received:\n{v_received}\nOC Link:\n**{v_oclink}**\n\nNotes:\n**{v_notes}**\n" - # embed manipulation for a specific message id. - fetch_atk_message = await interaction.channel.fetch_message(message_id) - if fetch_atk_message.embeds: - print("contains an embed") - for embed in fetch_atk_message.embeds: - print(embed.title) - print(embed.description) - print(embed.image.url) - # Profile Embed embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) # embed_profile.set_thumbnail(url=user.avatar) - embed_profile.set_image(url=fetch_atk_message.embeds[0].image.url) - embed_profile.set_author(name=f'{v_username}\'s Profile', icon_url=user.avatar) + embed_profile.set_author(name=f'{user.name}\'s Profile', icon_url=user.avatar) await interaction.response.send_message("", embed=embed_profile, ephemeral=True) From 068d10945ce4a817261c7d978016d02819c1e9ce Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Tue, 13 Feb 2024 15:45:32 -0500 Subject: [PATCH 23/28] Added ArtFight to bots attack messages --- src/trade/attacks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index a0b1d3e..0622f56 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -100,6 +100,7 @@ async def callback_4(interaction: discord.Interaction): ) async def callback_5(interaction: discord.Interaction): confirm_embed = discord.Embed(title="Confirm Attack", color=discord.Colour.light_embed(), description=f"Size: **{select_1.values[0]}**\nFinish: **{select_2.values[0]}**\nColor: **{select_3.values[0]}**\nShading: **{select_4.values[0]}**\nBackground: **{select_5.values[0]}**\n") + confirm_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content=None, embed=confirm_embed, view=view_6) select_5.callback = callback_5 view_5 = View() @@ -186,6 +187,7 @@ async def success_callback(interaction: discord.Interaction): self.db_ref_users.update(victim_info) confirmation_embed = discord.Embed(title="**Attack Successfully Sent!**", color=discord.Colour.light_embed()) + confirmation_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=confirmation_embed, view=None) success_button.callback = success_callback @@ -195,6 +197,7 @@ async def success_callback(interaction: discord.Interaction): cancel_button = Button(label="Cancel Attack" ,style=discord.ButtonStyle.danger) async def cancel_callback(interaction: discord.Interaction): cancel_embed = discord.Embed(title="**Attack Cancelled**", description="(feel free to dismiss this message)", color=discord.Colour.light_embed()) + cancel_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=cancel_embed, view=None) cancel_button.callback = cancel_callback From e4c1d55f5feedc9992ea26dfc09f78f814bd7a4f Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Tue, 13 Feb 2024 20:46:20 -0500 Subject: [PATCH 24/28] Fixed minor misunderstanding with Add Art Fight to the bot's attack message --- src/trade/attacks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 0622f56..55ff147 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -117,6 +117,7 @@ async def success_callback(interaction: discord.Interaction): score_calculation = trade.utils.size_calc(select_1.values[0]) + trade.utils.finish_calc(select_2.values[0]) + trade.utils.color_calc(select_3.values[0]) + trade.utils.shading_calc(select_4.values[0]) + trade.utils.background_calc(select_5.values[0]) content = f"{interaction.user.mention} has attacked {victim.mention} for {score_calculation} points!" final_embed = discord.Embed(title=f"{interaction.user.name}: {message}", description="", color=discord.Colour.light_embed()) + final_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) final_embed.set_image(url="attachment://image.png") image_file = await image.to_file(filename="image.png") sent_message = await interaction.channel.send(content=content, embed=final_embed, file=image_file, view=None) From 51340fb67d80ad03fa3b32461ce2766044a674a8 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Tue, 13 Feb 2024 21:10:05 -0500 Subject: [PATCH 25/28] /attack minor ui updates --- src/trade/attacks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 55ff147..9f3988a 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -116,8 +116,9 @@ async def success_callback(interaction: discord.Interaction): score_calculation = trade.utils.size_calc(select_1.values[0]) + trade.utils.finish_calc(select_2.values[0]) + trade.utils.color_calc(select_3.values[0]) + trade.utils.shading_calc(select_4.values[0]) + trade.utils.background_calc(select_5.values[0]) content = f"{interaction.user.mention} has attacked {victim.mention} for {score_calculation} points!" - final_embed = discord.Embed(title=f"{interaction.user.name}: {message}", description="", color=discord.Colour.light_embed()) - final_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) + final_embed = discord.Embed(title="", description="", color=discord.Colour.light_embed()) + final_embed.set_author(name=f"{interaction.user.name}: {message}", icon_url=interaction.user.avatar.url) + final_embed.set_footer(text="Art Fight", icon_url=interaction.guild.icon.url) final_embed.set_image(url="attachment://image.png") image_file = await image.to_file(filename="image.png") sent_message = await interaction.channel.send(content=content, embed=final_embed, file=image_file, view=None) @@ -366,7 +367,7 @@ async def viewattack(self, interaction: discord.Interaction, attack_id: str): @commands.has_permissions(administrator=True) async def deleteattack(self, interaction: discord.Interaction, attack_id: str): - permitted_users = ["skarpetky", "spectregray", "___bryant"] + permitted_users = ["skarpetky", "spectregray", "___bryant", "silentvoice._."] curr_attacks = self.db_ref_attacks.get() if not (interaction.user.name in permitted_users): await interaction.response.send_message("You don't have permission to delete attacks", ephemeral=True) From 31c372b5e0eb5244689701123b47e7604e5e299f Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Tue, 13 Feb 2024 21:10:05 -0500 Subject: [PATCH 26/28] /attack minor ui updates --- src/trade/attacks.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/trade/attacks.py b/src/trade/attacks.py index 55ff147..9e1c4ea 100644 --- a/src/trade/attacks.py +++ b/src/trade/attacks.py @@ -114,15 +114,26 @@ async def success_callback(interaction: discord.Interaction): #self.db_ref_users.update({0: "siblings are user ids"}) #self.db_ref_attacks.update({0: "siblings are message ids"}) + await interaction.response.defer() + score_calculation = trade.utils.size_calc(select_1.values[0]) + trade.utils.finish_calc(select_2.values[0]) + trade.utils.color_calc(select_3.values[0]) + trade.utils.shading_calc(select_4.values[0]) + trade.utils.background_calc(select_5.values[0]) - content = f"{interaction.user.mention} has attacked {victim.mention} for {score_calculation} points!" - final_embed = discord.Embed(title=f"{interaction.user.name}: {message}", description="", color=discord.Colour.light_embed()) - final_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) + + content = f"{victim.mention} you have been attacked by {interaction.user.mention}!" + # embed_content = f"**{interaction.user.mention}** has attacked **{victim.mention}** for {score_calculation} points!" + + final_embed = discord.Embed(title="", description="", color=discord.Colour.light_embed()) + final_embed.set_author(name=f"{interaction.user.name} : {message}", icon_url=interaction.user.avatar.url) + final_embed.set_footer(text=f"Art Fight", icon_url=interaction.guild.icon.url) final_embed.set_image(url="attachment://image.png") image_file = await image.to_file(filename="image.png") sent_message = await interaction.channel.send(content=content, embed=final_embed, file=image_file, view=None) - content += f" **attack id: {sent_message.id}**" + + content += f"\n **Attack Id: {sent_message.id}**" + # embed_content += f"\n **Attack Id: {sent_message.id}**" + # final_embed.description = embed_content await sent_message.edit(content=content) + # await sent_message.edit(embed=final_embed) + attack_info = {sent_message.id: { "attacker":interaction.user.id, "victim":victim.id, @@ -190,7 +201,8 @@ async def success_callback(interaction: discord.Interaction): confirmation_embed = discord.Embed(title="**Attack Successfully Sent!**", color=discord.Colour.light_embed()) confirmation_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) - await interaction.response.edit_message(content="", embed=confirmation_embed, view=None) + await interaction.edit_original_response(content="", embed=confirmation_embed, view=None) + # await interaction.edit_original_response(embed=confirmation_embed, view=None) success_button.callback = success_callback ########## @@ -310,9 +322,11 @@ async def profile(self, interaction: discord.Interaction, user: discord.Member): embed_profile = discord.Embed(title='', description=profile_info, color=discord.Colour.light_embed()) - # embed_profile.set_thumbnail(url=user.avatar) embed_profile.set_author(name=f'{user.name}\'s Profile', icon_url=user.avatar) + # footer_info = f"Search Keyword: \nfrom:{self.bot.user.name}#{self.bot.user.discriminator} mentions: {user.name}" + # embed_profile.set_footer(text=footer_info, icon_url=interaction.guild.icon.url) + await interaction.response.send_message("", embed=embed_profile, ephemeral=True) @af.command(name="editprofile", description="Allows exisitng users to add links to OCs and preference notes (blanks fields stay the same)") @@ -366,7 +380,7 @@ async def viewattack(self, interaction: discord.Interaction, attack_id: str): @commands.has_permissions(administrator=True) async def deleteattack(self, interaction: discord.Interaction, attack_id: str): - permitted_users = ["skarpetky", "spectregray", "___bryant"] + permitted_users = ["skarpetky", "spectregray", "___bryant", "silentvoice._."] curr_attacks = self.db_ref_attacks.get() if not (interaction.user.name in permitted_users): await interaction.response.send_message("You don't have permission to delete attacks", ephemeral=True) From 74b76efc4e1d2a96faa183c0c6aef77a34da5247 Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sat, 2 Mar 2024 15:34:01 -0500 Subject: [PATCH 27/28] Update: Modified ReadMe and bot's attack messages to sel file structure --- src/artfight/attacks.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/artfight/attacks.py b/src/artfight/attacks.py index 8694748..9dc537b 100644 --- a/src/artfight/attacks.py +++ b/src/artfight/attacks.py @@ -103,6 +103,7 @@ async def callback_4(interaction: discord.Interaction): ) async def callback_5(interaction: discord.Interaction): confirm_embed = discord.Embed(title="Confirm Attack", color=discord.Colour.light_embed(), description=f"Size: **{select_1.values[0]}**\nFinish: **{select_2.values[0]}**\nColor: **{select_3.values[0]}**\nShading: **{select_4.values[0]}**\nBackground: **{select_5.values[0]}**\n") + confirm_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content=None, embed=confirm_embed, view=view_6) select_5.callback = callback_5 view_5 = View() @@ -117,13 +118,19 @@ async def success_callback(interaction: discord.Interaction): #self.db_ref_attacks.update({0: "siblings are message ids"}) score_calculation = artfight.utils.size_calc(select_1.values[0]) + artfight.utils.finish_calc(select_2.values[0]) + artfight.utils.color_calc(select_3.values[0]) + artfight.utils.shading_calc(select_4.values[0]) + artfight.utils.background_calc(select_5.values[0]) - content = f"{interaction.user.mention} has attacked {victim.mention} for {score_calculation} points!" - final_embed = discord.Embed(title=f"{interaction.user.name}: {message}", description="", color=discord.Colour.light_embed()) + content = f"{victim.mention} you have been attacked by {interaction.user.mention}!" + # embed_content = f"**{interaction.user.mention}** has attacked **{victim.mention}** for {score_calculation} points!" + final_embed = discord.Embed(title="", description="", color=discord.Colour.light_embed()) + final_embed.set_author(name=f"{interaction.user.name} : {message}", icon_url=interaction.user.avatar.url) final_embed.set_image(url="attachment://image.png") image_file = await image.to_file(filename="image.png") sent_message = await interaction.channel.send(content=content, embed=final_embed, file=image_file, view=None) - content += f" **attack id: {sent_message.id}**" + + content += f"\n **Attack Id: {sent_message.id}**" + # embed_content += f"\n **Attack Id: {sent_message.id}**" + # final_embed.description = embed_content await sent_message.edit(content=content) + attack_info = {sent_message.id: { "attacker":interaction.user.id, "victim":victim.id, @@ -189,6 +196,7 @@ async def success_callback(interaction: discord.Interaction): self.db_ref_users.update(victim_info) confirmation_embed = discord.Embed(title="**Attack Successfully Sent!**", color=discord.Colour.light_embed()) + confirmation_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=confirmation_embed, view=None) success_button.callback = success_callback @@ -198,6 +206,7 @@ async def success_callback(interaction: discord.Interaction): cancel_button = Button(label="Cancel Attack" ,style=discord.ButtonStyle.danger) async def cancel_callback(interaction: discord.Interaction): cancel_embed = discord.Embed(title="**Attack Cancelled**", description="(feel free to dismiss this message)", color=discord.Colour.light_embed()) + cancel_embed.set_author(name="Art Fight", icon_url=interaction.guild.icon.url) await interaction.response.edit_message(content="", embed=cancel_embed, view=None) cancel_button.callback = cancel_callback @@ -243,7 +252,7 @@ async def view(self, interaction: discord.Interaction, attack_id: str): @af.command(name="delete", description="deletes the specified attack and readjusts your score") async def delete(self, interaction: discord.Interaction, attack_id: str): - permitted_users = ["skarpetky", "spectregray", "___bryant"] + permitted_users = ["skarpetky", "spectregray", "___bryant", "silentvoice._."] curr_attack = self.db_ref_attacks.child(attack_id.strip()).get() if curr_attack is None: From d51b757feea642e9c84bb92b37535d40740315fc Mon Sep 17 00:00:00 2001 From: Matthew Zou Date: Sat, 2 Mar 2024 15:51:24 -0500 Subject: [PATCH 28/28] minor footer icon fix --- src/artfight/attacks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/artfight/attacks.py b/src/artfight/attacks.py index 9dc537b..9a803d8 100644 --- a/src/artfight/attacks.py +++ b/src/artfight/attacks.py @@ -118,10 +118,13 @@ async def success_callback(interaction: discord.Interaction): #self.db_ref_attacks.update({0: "siblings are message ids"}) score_calculation = artfight.utils.size_calc(select_1.values[0]) + artfight.utils.finish_calc(select_2.values[0]) + artfight.utils.color_calc(select_3.values[0]) + artfight.utils.shading_calc(select_4.values[0]) + artfight.utils.background_calc(select_5.values[0]) + content = f"{victim.mention} you have been attacked by {interaction.user.mention}!" # embed_content = f"**{interaction.user.mention}** has attacked **{victim.mention}** for {score_calculation} points!" final_embed = discord.Embed(title="", description="", color=discord.Colour.light_embed()) final_embed.set_author(name=f"{interaction.user.name} : {message}", icon_url=interaction.user.avatar.url) + final_embed.set_footer(text=f"Art Fight", icon_url=interaction.guild.icon.url) + final_embed.set_image(url="attachment://image.png") image_file = await image.to_file(filename="image.png") sent_message = await interaction.channel.send(content=content, embed=final_embed, file=image_file, view=None)