added .rolecolor command
updated changelog
This commit is contained in:
parent
55e3a80405
commit
16025b74e3
9 changed files with 182 additions and 31 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -2,6 +2,22 @@
|
||||||
|
|
||||||
*a,c,f,r,o*
|
*a,c,f,r,o*
|
||||||
|
|
||||||
|
## [6.0.13] - 23.03.2025
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Added `.linkfix <old> <new>` command
|
||||||
|
- If bot sees a message with the old link, it will reply to the message with a fixed (new) link
|
||||||
|
- ex: `.linkfix twitter.com vxtwitter.com`
|
||||||
|
- Added `.roleicon role <icon_url / server_emoji>` command to set the icon of a role
|
||||||
|
- Added a captcha option for `.fish`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- fixed youtube stream notifications in case invalid channel was provided
|
||||||
|
- `.lcha` (live channel) will now let you override an existing channel template even if you're at the limit
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- removed `.xpglb` as it is no longer used
|
||||||
|
|
||||||
## [6.0.12] - 20.03.2025
|
## [6.0.12] - 20.03.2025
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>true</ImplicitUsings>
|
<ImplicitUsings>true</ImplicitUsings>
|
||||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||||
<Version>6.0.12</Version>
|
<Version>6.0.13</Version>
|
||||||
|
|
||||||
<!-- Output/build -->
|
<!-- Output/build -->
|
||||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||||
|
|
|
@ -241,5 +241,78 @@ public partial class Administration
|
||||||
TimestampTag.FromDateTime(DateTime.UtcNow.Add(timespan.Time), TimestampTagStyles.Relative)))
|
TimestampTag.FromDateTime(DateTime.UtcNow.Add(timespan.Time), TimestampTagStyles.Relative)))
|
||||||
.SendAsync();
|
.SendAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[UserPerm(GuildPerm.ManageRoles)]
|
||||||
|
[BotPerm(GuildPerm.ManageRoles)]
|
||||||
|
public Task RoleIcon(IRole role, Emote emote)
|
||||||
|
=> RoleIcon(role, emote.Url);
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[UserPerm(GuildPerm.ManageRoles)]
|
||||||
|
[BotPerm(GuildPerm.ManageRoles)]
|
||||||
|
public async Task RoleIcon(IRole role, [Leftover] string iconUrl)
|
||||||
|
{
|
||||||
|
if (!await CheckRoleHierarchy(role))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(iconUrl))
|
||||||
|
{
|
||||||
|
await Response().Error(strs.userrole_icon_invalid).SendAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the URL format
|
||||||
|
if (!Uri.TryCreate(iconUrl, UriKind.Absolute, out var uri))
|
||||||
|
{
|
||||||
|
await Response().Error(strs.userrole_icon_invalid).SendAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Download the image
|
||||||
|
using var httpClient = new HttpClient();
|
||||||
|
using var response = await httpClient.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);
|
||||||
|
|
||||||
|
// Check if the response is successful
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
await Response().Error(strs.userrole_icon_fail).SendAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check content type - must be image/png or image/jpeg
|
||||||
|
var contentType = response.Content.Headers.ContentType?.MediaType?.ToLower();
|
||||||
|
if (contentType != "image/png"
|
||||||
|
&& contentType != "image/jpeg"
|
||||||
|
&& contentType != "image/webp")
|
||||||
|
{
|
||||||
|
await Response().Error(strs.userrole_icon_fail).SendAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check file size - Discord limit is 256KB
|
||||||
|
var contentLength = response.Content.Headers.ContentLength;
|
||||||
|
if (contentLength is > 256 * 1024)
|
||||||
|
{
|
||||||
|
await Response().Error(strs.userrole_icon_fail).SendAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the image to a memory stream
|
||||||
|
await using var stream = await response.Content.ReadAsStreamAsync();
|
||||||
|
await using var memoryStream = new MemoryStream();
|
||||||
|
await stream.CopyToAsync(memoryStream);
|
||||||
|
memoryStream.Position = 0;
|
||||||
|
|
||||||
|
// Create Discord image from stream
|
||||||
|
using var discordImage = new Image(memoryStream);
|
||||||
|
|
||||||
|
// Upload the image to Discord
|
||||||
|
await role.ModifyAsync(r => r.Icon = discordImage);
|
||||||
|
|
||||||
|
await Response().Confirm(strs.userrole_icon_success(Format.Bold(role.Name))).SendAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -154,7 +154,7 @@ public sealed class UserRoleService : IUserRoleService, IEService
|
||||||
memoryStream.Position = 0;
|
memoryStream.Position = 0;
|
||||||
|
|
||||||
// Create Discord image from stream
|
// Create Discord image from stream
|
||||||
var discordImage = new Image(memoryStream);
|
using var discordImage = new Image(memoryStream);
|
||||||
|
|
||||||
// Upload the image to Discord
|
// Upload the image to Discord
|
||||||
var discordSuccess = await _discordRoleManager.ModifyRoleAsync(
|
var discordSuccess = await _discordRoleManager.ModifyRoleAsync(
|
||||||
|
|
|
@ -1606,6 +1606,21 @@
|
||||||
"Administrator Server Permission"
|
"Administrator Server Permission"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Aliases": [
|
||||||
|
".roleicon"
|
||||||
|
],
|
||||||
|
"Description": "Changes the icon of a role.",
|
||||||
|
"Usage": [
|
||||||
|
".roleicon @Role :server_emoji_here:"
|
||||||
|
],
|
||||||
|
"Submodule": "RoleCommands",
|
||||||
|
"Module": "Administration",
|
||||||
|
"Options": null,
|
||||||
|
"Requirements": [
|
||||||
|
"ManageRoles Server Permission"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Aliases": [
|
"Aliases": [
|
||||||
".iam"
|
".iam"
|
||||||
|
@ -7384,6 +7399,37 @@
|
||||||
"ManageChannels Channel Permission"
|
"ManageChannels Channel Permission"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Aliases": [
|
||||||
|
".linkfix",
|
||||||
|
".lfix"
|
||||||
|
],
|
||||||
|
"Description": "Configures automatic link fixing from one site to another.\nWhen a user posts a link containing the old domain, the bot will automatically fix it to use the new domain.\nProvide no second domain to disable link fixing.",
|
||||||
|
"Usage": [
|
||||||
|
".linkfix twitter.com vxtwitter.com",
|
||||||
|
".linkfix x.com"
|
||||||
|
],
|
||||||
|
"Submodule": "LinkFixerCommands",
|
||||||
|
"Module": "Utility",
|
||||||
|
"Options": null,
|
||||||
|
"Requirements": [
|
||||||
|
"ManageMessages Server Permission"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Aliases": [
|
||||||
|
".linkfixlist",
|
||||||
|
".lfixlist"
|
||||||
|
],
|
||||||
|
"Description": "Lists all configured link fixes for the server.",
|
||||||
|
"Usage": [
|
||||||
|
".linkfixlist"
|
||||||
|
],
|
||||||
|
"Submodule": "LinkFixerCommands",
|
||||||
|
"Module": "Utility",
|
||||||
|
"Options": null,
|
||||||
|
"Requirements": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Aliases": [
|
"Aliases": [
|
||||||
".livechadd",
|
".livechadd",
|
||||||
|
@ -8218,7 +8264,7 @@
|
||||||
],
|
],
|
||||||
"Description": "Changes the icon of your assigned role.",
|
"Description": "Changes the icon of your assigned role.",
|
||||||
"Usage": [
|
"Usage": [
|
||||||
".userroleicon @Role :thumbsup:"
|
".userroleicon @Role :server_emoji_here:"
|
||||||
],
|
],
|
||||||
"Submodule": "UserRoleCommands",
|
"Submodule": "UserRoleCommands",
|
||||||
"Module": "Utility",
|
"Module": "Utility",
|
||||||
|
|
|
@ -165,6 +165,8 @@ deleterole:
|
||||||
rolecolor:
|
rolecolor:
|
||||||
- rolecolor
|
- rolecolor
|
||||||
- roleclr
|
- roleclr
|
||||||
|
roleicon:
|
||||||
|
- roleicon
|
||||||
ban:
|
ban:
|
||||||
- ban
|
- ban
|
||||||
- b
|
- b
|
||||||
|
|
|
@ -599,6 +599,20 @@ rolehoist:
|
||||||
params:
|
params:
|
||||||
- role:
|
- role:
|
||||||
desc: "The role that determines the visibility of the sidebar."
|
desc: "The role that determines the visibility of the sidebar."
|
||||||
|
roleicon:
|
||||||
|
desc: |-
|
||||||
|
Changes the icon of a role.
|
||||||
|
ex:
|
||||||
|
- '@Role :server_emoji_here:'
|
||||||
|
params:
|
||||||
|
- role:
|
||||||
|
desc: 'The role to change the icon of.'
|
||||||
|
imageUrl:
|
||||||
|
desc: 'The image url to be used as a new icon for the role.'
|
||||||
|
- role:
|
||||||
|
desc: 'The role to change the icon of.'
|
||||||
|
serverEmoji:
|
||||||
|
desc: 'The server emoji to be used as a new icon for the role.'
|
||||||
createrole:
|
createrole:
|
||||||
desc: Creates a role with a given name.
|
desc: Creates a role with a given name.
|
||||||
ex:
|
ex:
|
||||||
|
@ -5054,7 +5068,7 @@ userroleicon:
|
||||||
desc: |-
|
desc: |-
|
||||||
Changes the icon of your assigned role.
|
Changes the icon of your assigned role.
|
||||||
ex:
|
ex:
|
||||||
- '@Role :thumbsup:'
|
- '@Role :server_emoji_here:'
|
||||||
params:
|
params:
|
||||||
- role:
|
- role:
|
||||||
desc: 'The assigned role to change the icon of.'
|
desc: 'The assigned role to change the icon of.'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue