thieved
thieved
Explore posts from servers
CC#
Created by thieved on 2/24/2023 in #help
✅ command methods not throwing any errors
my methods for my commands, even when awaited at every reference point, aren't throwing errors that can be seen or kill my program? and no there is no try-catch
12 replies
CC#
Created by thieved on 2/23/2023 in #help
`System.String` doesn't have the `Substring` method or something is weird about this string??
i've even tried this
description.Length > 2043 ? description[0 .. 2043] : description;
description.Length > 2043 ? description[0 .. 2043] : description;
but here's my substring operation:
description.Substring(0, 2043);
description.Substring(0, 2043);
it works for some returned strings but not all????
152 replies
CC#
Created by thieved on 2/22/2023 in #help
random item from a record
how can I get a random item from a record?
314 replies
CC#
Created by thieved on 2/21/2023 in #help
substringing and slicing not working..
i've tried everything on planet earth it feels like
character.description.ToString()[new Range(0, 2043)]
character.description.ToString()[new Range(0, 2043)]
character.description.ToString().Substring(0, 2043)
character.description.ToString().Substring(0, 2043)
character.description.Value.Substring(0, 2043)
character.description.Value.Substring(0, 2043)
character.description.Value.ToString(0, 2043)
character.description.Value.ToString(0, 2043)
((string)character.description).Substring(0, 2043)
((string)character.description).Substring(0, 2043)
etc... i'm converting a NewtonSoft.JValue to a string and none of these have worked, and the .Substring method exists on some of the description strings but not all of them??
41 replies
CC#
Created by thieved on 2/19/2023 in #help
automated event handler
7 replies
CC#
Created by thieved on 2/18/2023 in #help
duplicate methods from .GetMethods()
public ElfinCommand[] ReadCommands()
{
List<ElfinCommand> commands = new List<ElfinCommand>();

var progGroupClasses = GetTypesWithAttribute<ElfinGroupAttribute>();

foreach (Type type in progGroupClasses)
{
MethodInfo[] methods = type.GetMethods().Skip(4).ToArray();
public ElfinCommand[] ReadCommands()
{
List<ElfinCommand> commands = new List<ElfinCommand>();

var progGroupClasses = GetTypesWithAttribute<ElfinGroupAttribute>();

foreach (Type type in progGroupClasses)
{
MethodInfo[] methods = type.GetMethods().Skip(4).ToArray();
so above is my code for getting all classes with the group attribute, and then getting their methods (these methods represent commands). as you can see, though, i have to do .Skip(4) because one of the commands is getting duplicated 4 more times. what could be the cause of this? none of the other methods do this.
public IEnumerable<Type> GetTypesWithAttribute<T>() where T : Attribute
{
foreach (Type type in typeof(Program).Assembly.GetTypes())
{
if (type.GetCustomAttributes(typeof(T), true).Length > 0)
{
yield return type;
}
}
}
public IEnumerable<Type> GetTypesWithAttribute<T>() where T : Attribute
{
foreach (Type type in typeof(Program).Assembly.GetTypes())
{
if (type.GetCustomAttributes(typeof(T), true).Length > 0)
{
yield return type;
}
}
}
here's the method i use to grab groups classes.
135 replies
CC#
Created by thieved on 2/18/2023 in #help
method reference/callback
what's the best way to get the reference/callback from a MethodInfo instance?
1 replies
CC#
Created by thieved on 2/18/2023 in #help
trying to figure out attributes for a discord bot's command system
how can i use attributes to develop command groups and such? any small examples of attributes for something like this?
3 replies
CC#
Created by thieved on 2/18/2023 in #help
how can i add a function/method to a class that can be changed upon construction?
namespace Elfin
{
public class ElfinCommand
{
public string Name;

public ElfinCommand(ElfinCommand data)
{
this.Name = data.Name;
this.Respond = data.Respond;
}
}
}
namespace Elfin
{
public class ElfinCommand
{
public string Name;

public ElfinCommand(ElfinCommand data)
{
this.Name = data.Name;
this.Respond = data.Respond;
}
}
}
i'm trying to make a command class but how can i make it so i can provide a response function to the command when i construct a new one? (this.Respond)
66 replies
CC#
Created by thieved on 2/18/2023 in #help
what is this operation?
50 replies
CC#
Created by thieved on 2/17/2023 in #help
discord libraries
which is better: Discord.Net or DShardPlus in your opinion?
3 replies
CC#
Created by thieved on 2/17/2023 in #help
new to C#, looking for a compiler?
i'm coming from javascript and lua what's a good compiler for C#? i'm looking to write C# with Visual Studio Code if possible
203 replies