Skip to content

Commit aa336db

Browse files
Fix for duplicate channels
1 parent 9837a54 commit aa336db

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

CONTRIBUTING.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Job Openings Automated Guidelines
1+
# FinTwit-Bot Guidelines
22

33
## Code Formatting and Linting
44

5-
Job Openings Automated uses [Black](https://black.readthedocs.io/en/stable/index.html) with default values for automatic code formatting, along with [ruff](https://docs.astral.sh/ruff/). We also use [NumPy-style docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html) for documenting the code. As part of the checks on pull requests, it is checked whether the code still adheres to the code style. To ensure you don't need to worry about formatting and linting when contributing, it is recommended to set up the following:
5+
FinTwit-Bot uses [Black](https://black.readthedocs.io/en/stable/index.html) with default values for automatic code formatting, along with [ruff](https://docs.astral.sh/ruff/). We also use [NumPy-style docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html) for documenting the code. As part of the checks on pull requests, it is checked whether the code still adheres to the code style. To ensure you don't need to worry about formatting and linting when contributing, it is recommended to set up the following:
66

77
- Integration in VS Code:
88
- For [Black](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter)
@@ -42,17 +42,21 @@ When submitting a pull request, please follow these guidelines:
4242
To ensure a smooth and transparent merging process, we have established the following policy for merging pull requests:
4343

4444
1. **Review and Approval**:
45+
4546
- Pull requests must be reviewed and approved by at least one project maintainer.
4647
- Reviews from other contributors are encouraged but not required.
4748

4849
2. **Passing Checks**:
50+
4951
- All pull requests must pass continuous integration (CI) checks, including tests and linters.
5052
- Ensure there are no merge conflicts with the `main` branch.
5153

5254
3. **Documentation**:
55+
5356
- If your pull request introduces new features or changes existing functionality, update the relevant documentation.
5457

5558
4. **Labeling**:
59+
5660
- Use appropriate labels (e.g., `bug`, `enhancement`, `documentation`) to categorize the pull request.
5761

5862
5. **Merging**:
@@ -62,25 +66,30 @@ To ensure a smooth and transparent merging process, we have established the foll
6266
## Branch Management Policy
6367

6468
1. **Branch Naming Conventions**:
69+
6570
- Use descriptive names for your branches to make it clear what feature or fix is being worked on.
6671
- Common prefixes include `feature/`, `bugfix/`, `hotfix/`, and `chore/`.
6772
- Example: `feature/add-login-page`, `bugfix/fix-navbar-issue`.
6873

6974
2. **Creating Branches**:
75+
7076
- Always create branches from the latest version of the `main` branch.
7177
- Use short-lived branches for new features, bug fixes, or any changes to the codebase.
7278

7379
3. **Pull Requests**:
80+
7481
- Ensure your branch is up-to-date with `main` before opening a pull request.
7582
- Provide a clear and detailed description of the changes in your pull request.
7683
- Link to any relevant issues or discussions.
7784

7885
4. **Merging Branches**:
86+
7987
- Ensure all CI checks pass before merging.
8088
- Preferably use "Squash and merge" to maintain a clean commit history.
8189
- Obtain necessary approvals from maintainers or reviewers before merging.
8290

8391
5. **Deleting Merged Branches**:
92+
8493
- After a branch has been successfully merged into `main`, it should be deleted.
8594
- This helps keep the repository clean and reduces clutter.
8695
- You can delete the branch directly on GitHub after merging, or use the following Git command:

curl_example.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Replace all contents of this file with the following:
2-
1. Go to Twitter.com
2+
1. Go to x.com (using Chrome as browser, otherwise the cURL will be a different format)
33
2. Login
44
3. On the home timeline (click on following) press F12, this will open devtools in Chrome
55
4. Go to the Network section

src/util/disc.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,32 @@ async def get_channel(
125125
The discord.TextChannel object of the channel with the given name.
126126
"""
127127

128+
# Loop over all the guilds the bot is in
128129
for guild in bot.guilds:
130+
# Find the guild with the given name from the .env file
129131
if guild.name == guild_name:
132+
# Loop over all the channels in the guild
130133
for channel in guild.channels:
134+
# Find the channel with the given name
131135
if channel.name == channel_name:
136+
# If there is no given category name return the first one
132137
if category_name is None:
133138
return channel
134139
else:
140+
# Otherwise find it in the given category
135141
if channel.category:
136142
if channel.category.name == category_name:
137143
return channel
138144

139-
logger.info(
145+
logger.warning(
140146
f"Channel named: {channel_name}, with category {category_name} not found in guild: {guild_name}.\nCreating it..."
141147
)
142148

143-
# If the channel is not found, create it
149+
# If the channel is not found, create it (with a category if given)
144150
if category_name:
145151
category = discord.utils.get(guild.categories, name=category_name)
146152
channel = await guild.create_text_channel(channel_name, category=category)
153+
return channel
147154

148155
# Maybe read the category from the config file
149156
channel = await guild.create_text_channel(channel_name)

0 commit comments

Comments
 (0)